コード例 #1
0
ファイル: config.py プロジェクト: balagopalraj/clearlinux
 def _apply_installroot(yumconf, option):
     path = getattr(yumconf, option)
     ir_path = yumconf.installroot + path
     ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
                                          # it annoys me
     ir_path = varReplace(ir_path, yumvars)
     setattr(yumconf, option, ir_path)
コード例 #2
0
 def _apply_installroot(yumconf, option):
     path = getattr(yumconf, option)
     ir_path = yumconf.installroot + path
     ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
                                          # it annoys me
     ir_path = varReplace(ir_path, yumvars)
     setattr(yumconf, option, ir_path)
コード例 #3
0
ファイル: config.py プロジェクト: 274914765/python
def writeRawRepoFile(repo,only=None):
    """
    Writes changes in a repo object back to a .repo file.
    @param repo: Repo Object
    @param only: List of attributes to work on (None = All)
    It work by reading the repo file, changes the values there shall be changed and write it back to disk.
    """

    if not _use_iniparse:
        return

    ini = INIConfig(open(repo.repofile))
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect
    
    # Updated the ConfigParser with the changed values    
    cfgOptions = repo.cfg.options(repo.id)
    for name,value in repo.iteritems():
        option = repo.optionobj(name)
        if option.default != value or name in cfgOptions :
            if only == None or name in only:
                ini[section_id][name] = option.tostring(value)
    fp =file(repo.repofile,"w")               
    fp.write(str(ini))
    fp.close()
コード例 #4
0
def writeRawRepoFile(repo,only=None):
    """
    Writes changes in a repo object back to a .repo file.
    @param repo: Repo Object
    @param only: List of attributes to work on (None = All)
    It work by reading the repo file, changes the values there shall be changed and write it back to disk.
    """

    if not _use_iniparse:
        return

    ini = INIConfig(open(repo.repofile))
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect
    
    # Updated the ConfigParser with the changed values    
    cfgOptions = repo.cfg.options(repo.id)
    for name,value in repo.iteritems():
        option = repo.optionobj(name)
        if option.default != value or name in cfgOptions :
            if only == None or name in only:
                ini[section_id][name] = option.tostring(value)
    fp =file(repo.repofile,"w")               
    fp.write(str(ini))
    fp.close()
コード例 #5
0
ファイル: config.py プロジェクト: dmnks/yum
def writeRawRepoFile(repo, only=None):
    """Write changes in a repo object back to a .repo file.

    :param repo: the Repo Object to write back out
    :param only: list of attributes to work on. If *only* is None, all
       options will be written out   
    """
    if not _use_iniparse:
        return

    ini, section_id = _readRawRepoFile(repo)

    # Updated the ConfigParser with the changed values
    cfgOptions = repo.cfg.options(repo.id)
    for name, value in repo.iteritems():
        if value is None:  # Proxy
            continue

        if only is not None and name not in only:
            continue

        option = repo.optionobj(name)
        ovalue = option.tostring(value)
        #  If the value is the same, but just interpreted ... when we don't want
        # to keep the interpreted values.
        if name in ini[section_id] and ovalue == varReplace(ini[section_id][name], repo.yumvar):
            ovalue = ini[section_id][name]

        if name not in cfgOptions and option.default == value:
            continue

        ini[section_id][name] = ovalue
    fp = file(repo.repofile, "w")
    fp.write(str(ini))
    fp.close()
コード例 #6
0
ファイル: config.py プロジェクト: zhunzhun1988/mydocker
def _writeRawConfigFile(filename,
                        section_id,
                        yumvar,
                        cfgoptions,
                        items,
                        optionobj,
                        only=None):
    """
    From writeRawRepoFile, but so we can alter [main] too.
    """
    ini = INIConfig(open(filename))

    osection_id = section_id
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    if section_id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, yumvar) == section_id:
                section_id = sect

    # Updated the ConfigParser with the changed values
    cfgOptions = cfgoptions(osection_id)
    for name, value in items():
        if value is None:  # Proxy
            continue

        if only is not None and name not in only:
            continue

        option = optionobj(name)
        ovalue = option.tostring(value)
        #  If the value is the same, but just interpreted ... when we don't want
        # to keep the interpreted values.
        if (name in ini[section_id]
                and ovalue == varReplace(ini[section_id][name], yumvar)):
            ovalue = ini[section_id][name]

        if name not in cfgOptions and option.default == value:
            continue

        ini[section_id][name] = ovalue
    fp = file(filename, "w")
    fp.write(str(ini))
    fp.close()
コード例 #7
0
ファイル: config.py プロジェクト: balagopalraj/clearlinux
def writeRawRepoFile(repo,only=None):
    """
    Writes changes in a repo object back to a .repo file.
    @param repo: Repo Object
    @param only: List of attributes to work on (None = All)
    It work by reading the repo file, changes the values there shall be changed and write it back to disk.
    """

    if not _use_iniparse:
        return

    ini = INIConfig(open(repo.repofile))
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect
    
    # Updated the ConfigParser with the changed values    
    cfgOptions = repo.cfg.options(repo.id)
    for name,value in repo.iteritems():
        if value is None: # Proxy
            continue

        if only is not None and name not in only:
            continue

        option = repo.optionobj(name)
        ovalue = option.tostring(value)
        #  If the value is the same, but just interpreted ... when we don't want
        # to keep the interpreted values.
        if (name in ini[section_id] and
            ovalue == varReplace(ini[section_id][name], yumvar)):
            ovalue = ini[section_id][name]

        if name not in cfgOptions and option.default == value:
            continue

        ini[section_id][name] = ovalue
    fp =file(repo.repofile,"w")               
    fp.write(str(ini))
    fp.close()
コード例 #8
0
def writeRawRepoFile(repo, only=None):
    """Write changes in a repo object back to a .repo file.

    :param repo: the Repo Object to write back out
    :param only: list of attributes to work on. If *only* is None, all
       options will be written out
    """
    if not _use_iniparse:
        return

    ini = INIConfig(open(repo.repofile))
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect

    # Updated the ConfigParser with the changed values
    cfgOptions = repo.cfg.options(repo.id)
    for name, value in repo.iteritems():
        if value is None:  # Proxy
            continue

        if only is not None and name not in only:
            continue

        option = repo.optionobj(name)
        ovalue = option.tostring(value)
        #  If the value is the same, but just interpreted ... when we don't want
        # to keep the interpreted values.
        if (name in ini[section_id]
                and ovalue == varReplace(ini[section_id][name], repo.yumvar)):
            ovalue = ini[section_id][name]

        if name not in cfgOptions and option.default == value:
            continue

        ini[section_id][name] = ovalue
    fp = file(repo.repofile, "w")
    fp.write(str(ini))
    fp.close()
コード例 #9
0
ファイル: config.py プロジェクト: harshithanaik/yum
def _writeRawConfigFile(filename, section_id, yumvar,
                        cfgoptions, items, optionobj,
                        only=None):
    """
    From writeRawRepoFile, but so we can alter [main] too.
    """
    ini = INIConfig(open(filename))

    osection_id = section_id
    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    if section_id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, yumvar) == section_id:
                section_id = sect

    # Updated the ConfigParser with the changed values
    cfgOptions = cfgoptions(osection_id)
    for name,value in items():
        if value is None: # Proxy
            continue

        if only is not None and name not in only:
            continue

        option = optionobj(name)
        ovalue = option.tostring(value)
        #  If the value is the same, but just interpreted ... when we don't want
        # to keep the interpreted values.
        if (name in ini[section_id] and
            ovalue == varReplace(ini[section_id][name], yumvar)):
            ovalue = ini[section_id][name]

        if name not in cfgOptions and option.default == value:
            continue

        ini[section_id][name] = ovalue
    fp =file(filename, "w")
    fp.write(str(ini))
    fp.close()
コード例 #10
0
ファイル: config.py プロジェクト: akozumpl/yum
def _readRawRepoFile(repo):
    if not _use_iniparse:
        return None

    if not hasattr(repo, 'repofile') or not repo.repofile:
        return None

    try:
        ini = INIConfig(open(repo.repofile))
    except:
        return None

    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect
    return ini, section_id
コード例 #11
0
def _readRawRepoFile(repo):
    if not _use_iniparse:
        return None

    if not hasattr(repo, 'repofile') or not repo.repofile:
        return None

    try:
        ini = INIConfig(open(repo.repofile))
    except:
        return None

    # b/c repoids can have $values in them we need to map both ways to figure
    # out which one is which
    section_id = repo.id
    if repo.id not in ini._sections:
        for sect in ini._sections.keys():
            if varReplace(sect, repo.yumvar) == repo.id:
                section_id = sect
    return ini, section_id