Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. [DIR]
  2. DirTo=D:AshishJab Tak hai Jaan
  3. DirBackup = D:ParserERICSSON_CSCORE_STANDARD_VMSBackup
  4. ErrorDir = D:ParserERICSSON_CSCORE_STANDARD_VMSError
  5.  
  6. CombinerDir = D:ParserERICSSON_CSCORE_STANDARD_VMSCombiner
  7. DirFrom=D:ParserERICSSON_CSCORE_STANDARD_VMSIn
  8. PidFileDIR = D:ParserERICSSON_CSCORE_STANDARD_VMSPid
  9. LogDir = D:ParserERICSSON_CSCORE_STANDARD_VMSLog
  10. TempDir = D:ParserERICSSON_CSCORE_STANDARD_VMSTemp
  11.  
  12. def changeINIfile():
  13. config=ConfigParser.RawConfigParser(allow_no_value=False)
  14. config.optionxform=lambda option: option
  15. cfgfile=open(r"D:ParserERICSSON_CSCORE_STANDARD_VMSWindowsopx_PAR_GEN_660_ERICSSON_CSCORE_STANDARD_PM_VMS_MALAYSIA.ini","w")
  16. config.set('DIR','DirTo','D:AshishJab Tak hai Jaan')
  17. config.optionxform=str
  18. config.write(cfgfile)
  19. cfgfile.close()
  20.  
  21. def write(self, fp):
  22. """Write an .ini-format representation of the configuration state."""
  23. if self._defaults:
  24. fp.write("[%s]n" % DEFAULTSECT)
  25. for (key, value) in self._defaults.items():
  26. fp.write("%s = %sn" % (key, str(value).replace('n', 'nt')))
  27. fp.write("n")
  28. for section in self._sections:
  29. fp.write("[%s]n" % section)
  30. for (key, value) in self._sections[section].items():
  31. if key != "__name__":
  32. fp.write("%s = %sn" %
  33. (key, str(value).replace('n', 'nt')))
  34. fp.write("n")
  35.  
  36. def remove_whitespace_from_assignments():
  37. separator = "="
  38. config_path = "config.ini"
  39. lines = file(config_path).readlines()
  40. fp = open(config_path, "w")
  41. for line in lines:
  42. line = line.strip()
  43. if not line.startswith("#") and separator in line:
  44. assignment = line.split(separator, 1)
  45. assignment = map(str.strip, assignment)
  46. fp.write("%s%s%sn" % (assignment[0], separator, assignment[1]))
  47. else:
  48. fp.write(line + "n")
  49.  
  50. class EqualsSpaceRemover:
  51. output_file = None
  52. def __init__( self, new_output_file ):
  53. self.output_file = new_output_file
  54.  
  55. def write( self, what ):
  56. self.output_file.write( what.replace( " = ", "=" ) )
  57.  
  58. config.write( EqualsSpaceRemover( cfgfile ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement