def read(): config = configparser.ConfigParser() config.read("config.ini") generalsection = config['General'] migrationsection = config['Migration'] user = generalsection['User'] password = generalsection['Password'] repositoryurl = generalsection['Repo'] scmcommand = generalsection['ScmCommand'] shell.logcommands = config['Miscellaneous']['LogShellCommands'] == "True" shell.setencoding(generalsection['encoding']) workspace = generalsection['WorkspaceName'] gitreponame = generalsection['GIT-Reponame'] useexistingworkspace = generalsection['useExistingWorkspace'] useprovidedhistory = migrationsection['UseProvidedHistory'] useautomaticconflictresolution = migrationsection['UseAutomaticConflictResolution'] workdirectory = getworkdirectory(generalsection['Directory']) streamname = migrationsection['StreamToMigrate'].strip() baselines = getinitialcomponentbaselines(migrationsection['InitialBaseLines']) configbuilder = Builder().setuser(user).setpassword(password).setrepourl(repositoryurl).setscmcommand(scmcommand) configbuilder.setworkspace(workspace).setgitreponame(gitreponame).setrootfolder(os.getcwd()) configbuilder.setuseexistingworkspace(useexistingworkspace).setuseprovidedhistory(useprovidedhistory) configbuilder.setuseautomaticconflictresolution(useautomaticconflictresolution) configbuilder.setworkdirectory(workdirectory).setstreamname(streamname).setinitialcomponentbaselines(baselines) return configbuilder.build()
def read(configname=None): if not configname: global configfile configname = configfile parsedconfig = configparser.ConfigParser() if len(parsedconfig.read(configname)) < 1: raise IOError('unable to read %s' % configname) generalsection = parsedconfig['General'] migrationsectionname = 'Migration' migrationsection = parsedconfig[migrationsectionname] miscsectionname = 'Miscellaneous' global user if not user: user = generalsection['User'] global password if not password: password = generalsection['Password'] repositoryurl = generalsection['Repo'] scmcommand = generalsection.get('ScmCommand', "lscm") shell.logcommands = parsedconfig.get(miscsectionname, 'LogShellCommands', fallback="False") == "True" shell.setencoding(generalsection.get('encoding')) workspace = shlex.quote(generalsection['WorkspaceName']) gitreponame = generalsection['GIT-Reponame'] useexistingworkspace = generalsection.get('useExistingWorkspace', "False") useprovidedhistory = migrationsection.get('UseProvidedHistory', "False") useautomaticconflictresolution = migrationsection.get('UseAutomaticConflictResolution', "False") maxchangesetstoaccepttogether = migrationsection.get('MaxChangeSetsToAcceptTogether', "10") workdirectory = generalsection.get('Directory', os.getcwd()) streamname = shlex.quote(migrationsection['StreamToMigrate'].strip()) previousstreamname = migrationsection.get('PreviousStream', '').strip() baselines = getinitialcomponentbaselines(migrationsection.get('InitialBaseLines')) ignorefileextensionsproperty = parsedconfig.get(miscsectionname, 'IgnoreFileExtensions', fallback='') ignorefileextensions = parsesplittedproperty(ignorefileextensionsproperty) ignoredirectoriessproperty = parsedconfig.get(miscsectionname, 'IgnoreDirectories', fallback='') ignoredirectories = parsesplittedproperty(ignoredirectoriessproperty) includecomponentroots = parsedconfig.get(miscsectionname, 'IncludeComponentRoots', fallback="False") commitmessageprefix = migrationsection.get('CommitMessageWorkItemPrefix', "") gitattributesproperty = parsedconfig.get(migrationsectionname, 'Gitattributes', fallback='') gitattributes = parsesplittedproperty(gitattributesproperty) configbuilder = Builder().setuser(user).setpassword(password).setrepourl(repositoryurl).setscmcommand(scmcommand) configbuilder.setworkspace(workspace).setgitreponame(gitreponame).setrootfolder(os.getcwd()) configbuilder.setuseexistingworkspace(useexistingworkspace).setuseprovidedhistory(useprovidedhistory) configbuilder.setuseautomaticconflictresolution(useautomaticconflictresolution) configbuilder.setmaxchangesetstoaccepttogether(maxchangesetstoaccepttogether) configbuilder.setworkdirectory(workdirectory).setstreamname(streamname).setinitialcomponentbaselines(baselines) configbuilder.setpreviousstreamname(previousstreamname) configbuilder.setignorefileextensions(ignorefileextensions) configbuilder.setignoredirectories(ignoredirectories) configbuilder.setincludecomponentroots(includecomponentroots).setcommitmessageprefix(commitmessageprefix) configbuilder.setgitattributes(gitattributes) global config config = configbuilder.build() return config
def test_ReadChangesetInformationFromFile_InUtf8_ShouldBeSuccesful(self): shell.setencoding("UTF-8") sample_file_path = self.get_Sample_File_Path( "SampleCompareOutputInUtf8.txt") changeentries = ImportHandler.getchangeentriesfromfile( sample_file_path) self.assertEqual(1, len(changeentries)) author = "John ÆØÅ" mail = "*****@*****.**" self.assert_Change_Entry(changeentries[0], author, mail, "Comment", "2015-05-26 10:40:00")
def read(): config = configparser.ConfigParser() config.read("config.ini") generalsection = config['General'] migrationsection = config['Migration'] user = generalsection['User'] password = generalsection['Password'] repositoryurl = generalsection['Repo'] scmcommand = generalsection['ScmCommand'] shell.logcommands = config['Miscellaneous']['LogShellCommands'] == "True" shell.setencoding(generalsection['encoding']) workspace = generalsection['WorkspaceName'] gitreponame = generalsection['GIT-Reponame'] useexistingworkspace = generalsection['useExistingWorkspace'] useprovidedhistory = migrationsection['UseProvidedHistory'] useautomaticconflictresolution = migrationsection[ 'UseAutomaticConflictResolution'] workdirectory = getworkdirectory(generalsection['Directory']) streamname = migrationsection['StreamToMigrate'].strip() baselines = getinitialcomponentbaselines( migrationsection['InitialBaseLines']) configbuilder = Builder().setuser(user).setpassword(password).setrepourl( repositoryurl).setscmcommand(scmcommand) configbuilder.setworkspace(workspace).setgitreponame( gitreponame).setrootfolder(os.getcwd()) configbuilder.setuseexistingworkspace( useexistingworkspace).setuseprovidedhistory(useprovidedhistory) configbuilder.setuseautomaticconflictresolution( useautomaticconflictresolution) configbuilder.setworkdirectory(workdirectory).setstreamname( streamname).setinitialcomponentbaselines(baselines) return configbuilder.build()
def testSetNoEncoding_ShouldBeNone(self): shell.setencoding("") self.assertIsNone(shell.encoding)
def testSetEncodingUTF8_ShouldBeUTF8(self): encoding = "UTF-8" shell.setencoding(encoding) self.assertEqual(encoding, shell.encoding)
def read(configname=None): if not configname: global configfile configname = configfile parsedconfig = configparser.ConfigParser() if len(parsedconfig.read(configname)) < 1: raise IOError('unable to read %s' % configname) generalsection = parsedconfig['General'] migrationsectionname = 'Migration' migrationsection = parsedconfig[migrationsectionname] miscsectionname = 'Miscellaneous' global user if not user and not stored: user = generalsection['User'] global password if not password and not stored: password = generalsection['Password'] repositoryurl = generalsection['Repo'] scmcommand = generalsection.get('ScmCommand', "lscm") shell.logcommands = parsedconfig.get(miscsectionname, 'LogShellCommands', fallback="False") == "True" shell.setencoding(generalsection.get('encoding')) rtcversion = generalsection.get('RTCVersion', "5") workspace = shlex.quote(generalsection['WorkspaceName']) gitreponame = generalsection['GIT-Reponame'] useexistingworkspace = generalsection.get('useExistingWorkspace', "False") useprovidedhistory = migrationsection.get('UseProvidedHistory', "False") useautomaticconflictresolution = migrationsection.get( 'UseAutomaticConflictResolution', "False") maxchangesetstoaccepttogether = migrationsection.get( 'MaxChangeSetsToAcceptTogether', "10") workdirectory = generalsection.get('Directory', os.getcwd()) streamname = shlex.quote(migrationsection['StreamToMigrate'].strip()) previousstreamname = migrationsection.get('PreviousStream', '').strip() baselines = getinitialcomponentbaselines( migrationsection.get('InitialBaseLines')) ignorefileextensionsproperty = parsedconfig.get(miscsectionname, 'IgnoreFileExtensions', fallback='') ignorefileextensions = parsesplittedproperty(ignorefileextensionsproperty) ignoredirectoriessproperty = parsedconfig.get(miscsectionname, 'IgnoreDirectories', fallback='') ignoredirectories = parsesplittedproperty(ignoredirectoriessproperty) includecomponentroots = parsedconfig.get(miscsectionname, 'IncludeComponentRoots', fallback="False") commitmessageprefix = migrationsection.get('CommitMessageWorkItemPrefix', "") gitattributesproperty = parsedconfig.get(migrationsectionname, 'Gitattributes', fallback='') gitattributes = parsesplittedproperty(gitattributesproperty) configbuilder = Builder().setuser(user).setpassword(password).setstored( stored).setrepourl(repositoryurl) configbuilder.setscmcommand(scmcommand).setrtcversion(rtcversion) configbuilder.setworkspace(workspace).setgitreponame( gitreponame).setrootfolder(os.getcwd()) configbuilder.setuseexistingworkspace( useexistingworkspace).setuseprovidedhistory(useprovidedhistory) configbuilder.setuseautomaticconflictresolution( useautomaticconflictresolution) configbuilder.setmaxchangesetstoaccepttogether( maxchangesetstoaccepttogether) configbuilder.setworkdirectory(workdirectory).setstreamname( streamname).setinitialcomponentbaselines(baselines) configbuilder.setpreviousstreamname(previousstreamname) configbuilder.setignorefileextensions(ignorefileextensions) configbuilder.setignoredirectories(ignoredirectories) configbuilder.setincludecomponentroots( includecomponentroots).setcommitmessageprefix(commitmessageprefix) configbuilder.setgitattributes(gitattributes) global config config = configbuilder.build() return config