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
dataset/ETHPy150Open rtcTo/rtc2git/configuration.py/read/original