• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python config.config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mercurial.config.config函数的典型用法代码示例。如果您正苦于以下问题:Python config函数的具体用法?Python config怎么用?Python config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了config函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _ui

    def _ui(self):
        """
        Creates an db based ui object for this repository
        """
        from mercurial import ui
        from mercurial import config
        baseui = ui.ui()

        #clean the baseui object
        baseui._ocfg = config.config()
        baseui._ucfg = config.config()
        baseui._tcfg = config.config()


        ret = RhodeCodeUi.query()\
            .options(FromCache("sql_cache_short", "repository_repo_ui")).all()

        hg_ui = ret
        for ui_ in hg_ui:
            if ui_.ui_active:
                log.debug('settings ui from db[%s]%s:%s', ui_.ui_section,
                          ui_.ui_key, ui_.ui_value)
                baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value)

        return baseui
开发者ID:lmamsen,项目名称:rhodecode,代码行数:25,代码来源:db.py


示例2: make_ui

def make_ui(read_from='file', path=None, checkpaths=True, clear_session=True):
    """
    A function that will read python rc files or database
    and make an mercurial ui object from read options

    :param path: path to mercurial config file
    :param checkpaths: check the path
    :param read_from: read from 'file' or 'db'
    """

    baseui = ui.ui()

    # clean the baseui object
    baseui._ocfg = config.config()
    baseui._ucfg = config.config()
    baseui._tcfg = config.config()

    if read_from == 'file':
        if not os.path.isfile(path):
            log.debug('hgrc file is not present at %s, skipping...' % path)
            return False
        log.debug('reading hgrc from %s' % path)
        cfg = config.config()
        cfg.read(path)
        for section in ui_sections:
            for k, v in cfg.items(section):
                log.debug('settings ui from file[%s]%s:%s' % (section, k, v))
                baseui.setconfig(safe_str(section), safe_str(k), safe_str(v))

    elif read_from == 'db':
        sa = meta.Session()
        ret = sa.query(RhodeCodeUi)\
            .options(FromCache("sql_cache_short", "get_hg_ui_settings"))\
            .all()

        hg_ui = ret
        for ui_ in hg_ui:
            if ui_.ui_active:
                log.debug('settings ui from db[%s]%s:%s', ui_.ui_section,
                          ui_.ui_key, ui_.ui_value)
                baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key),
                                 safe_str(ui_.ui_value))
            if ui_.ui_key == 'push_ssl':
                # force set push_ssl requirement to False, rhodecode
                # handles that
                baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key),
                                 False)
        if clear_session:
            meta.Session.remove()
    return baseui
开发者ID:break123,项目名称:rhodecode,代码行数:50,代码来源:utils.py


示例3: __init__

    def __init__(self, ui, root, data):
        self._decode = {"LF": "to-lf", "CRLF": "to-crlf", "BIN": "is-binary"}
        self._encode = {"LF": "to-lf", "CRLF": "to-crlf", "BIN": "is-binary"}

        self.cfg = config.config()
        # Our files should not be touched. The pattern must be
        # inserted first override a '** = native' pattern.
        self.cfg.set("patterns", ".hg*", "BIN", "eol")
        # We can then parse the user's patterns.
        self.cfg.parse(".hgeol", data)

        isrepolf = self.cfg.get("repository", "native") != "CRLF"
        self._encode["NATIVE"] = isrepolf and "to-lf" or "to-crlf"
        iswdlf = ui.config("eol", "native", os.linesep) in ("LF", "\n")
        self._decode["NATIVE"] = iswdlf and "to-lf" or "to-crlf"

        include = []
        exclude = []
        for pattern, style in self.cfg.items("patterns"):
            key = style.upper()
            if key == "BIN":
                exclude.append(pattern)
            else:
                include.append(pattern)
        # This will match the files for which we need to care
        # about inconsistent newlines.
        self.match = match.match(root, "", [], include, exclude)
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:27,代码来源:eol.py


示例4: __init__

    def __init__(self, ui, root, data):
        self._decode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}
        self._encode = {'LF': 'to-lf', 'CRLF': 'to-crlf', 'BIN': 'is-binary'}

        self.cfg = config.config()
        # Our files should not be touched. The pattern must be
        # inserted first override a '** = native' pattern.
        self.cfg.set('patterns', '.hg*', 'BIN')
        # We can then parse the user's patterns.
        self.cfg.parse('.hgeol', data)

        isrepolf = self.cfg.get('repository', 'native') != 'CRLF'
        self._encode['NATIVE'] = isrepolf and 'to-lf' or 'to-crlf'
        iswdlf = ui.config('eol', 'native', os.linesep) in ('LF', '\n')
        self._decode['NATIVE'] = iswdlf and 'to-lf' or 'to-crlf'

        include = []
        exclude = []
        for pattern, style in self.cfg.items('patterns'):
            key = style.upper()
            if key == 'BIN':
                exclude.append(pattern)
            else:
                include.append(pattern)
        # This will match the files for which we need to care
        # about inconsistent newlines.
        self.match = match.match(root, '', [], include, exclude)
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:27,代码来源:eol.py


示例5: _activepath

 def _activepath(self, remote):
     conf = config.config()
     try:
         rc = self.vfs.join('hgrc')
     except AttributeError:
         # old hg
         rc = self.join('hgrc')
     if os.path.exists(rc):
         with open(rc) as fp:
             conf.parse('.hgrc', fp.read(), include=conf.read)
     realpath = ''
     if 'paths' in conf:
         for path, uri in conf['paths'].items():
             for s in schemes.schemes.iterkeys():
                 if uri.startswith('%s://' % s):
                     # TODO: refactor schemes so we don't
                     # duplicate this logic
                     ui.note('performing schemes expansion with '
                             'scheme %s\n' % s)
                     scheme = hg.schemes[s]
                     parts = uri.split('://', 1)[1].split('/',
                                                          scheme.parts)
                     if len(parts) > scheme.parts:
                         tail = parts[-1]
                         parts = parts[:-1]
                     else:
                         tail = ''
                     context = dict((str(i+1), v) for i, v in
                                    enumerate(parts))
                     uri = ''.join(scheme.templater.process(
                         scheme.url, context)) + tail
             uri = self.ui.expandpath(uri)
             if remote.local():
                 uri = os.path.realpath(uri)
                 rpath = getattr(remote, 'root', None)
                 if rpath is None:
                     # Maybe a localpeer? ([email protected], 2.3)
                     rpath = getattr(getattr(remote, '_repo', None),
                                     'root', None)
             else:
                 rpath = getattr(remote, 'url', lambda : remote._url)()
                 if uri.startswith('http'):
                     try:
                         uri = url.url(uri).authinfo()[0]
                     except AttributeError:
                         try:
                             uri = util.url(uri).authinfo()[0]
                         except AttributeError:
                             uri = url.getauthinfo(uri)[0]
             uri = uri.rstrip('/')
             rpath = rpath.rstrip('/')
             if uri == rpath:
                 realpath = path
                 # prefer a non-default name to default
                 if path != 'default':
                     break
     return realpath
开发者ID:jakesgordon,项目名称:dotfiles,代码行数:57,代码来源:hg_remotebranches.py


示例6: make_ui

def make_ui(read_from='file', path=None, checkpaths=True):
    """A function that will read python rc files or database
    and make an mercurial ui object from read options

    :param path: path to mercurial config file
    :param checkpaths: check the path
    :param read_from: read from 'file' or 'db'
    """

    baseui = ui.ui()

    #clean the baseui object
    baseui._ocfg = config.config()
    baseui._ucfg = config.config()
    baseui._tcfg = config.config()

    if read_from == 'file':
        if not os.path.isfile(path):
            log.warning('Unable to read config file %s' % path)
            return False
        log.debug('reading hgrc from %s', path)
        cfg = config.config()
        cfg.read(path)
        for section in ui_sections:
            for k, v in cfg.items(section):
                log.debug('settings ui from file[%s]%s:%s', section, k, v)
                baseui.setconfig(section, k, v)

    elif read_from == 'db':
        sa = meta.Session()
        ret = sa.query(RhodeCodeUi)\
            .options(FromCache("sql_cache_short",
                               "get_hg_ui_settings")).all()

        hg_ui = ret
        for ui_ in hg_ui:
            if ui_.ui_active:
                log.debug('settings ui from db[%s]%s:%s', ui_.ui_section,
                          ui_.ui_key, ui_.ui_value)
                baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value)

        meta.Session.remove()
    return baseui
开发者ID:pombredanne,项目名称:rhodecode,代码行数:43,代码来源:utils.py


示例7: config

def config(data=None):
    """Create writable config if iniparse available; otherwise readonly obj

    You can test whether the returned obj is writable or not by
    `hasattr(obj, 'write')`.
    """
    if _hasiniparse:
        return _wconfig(data)
    else:
        return config_mod.config(data)
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:10,代码来源:wconfig.py


示例8: __init__

    def __init__(self, data=None):
        self._config = config_mod.config(data)
        self._readfiles = []  # list of read (path, fp, sections, remap)
        self._sections = {}

        if isinstance(data, self.__class__):  # keep log
            self._readfiles.extend(data._readfiles)
            self._sections.update(data._sections)
        elif data:  # record as changes
            self._logupdates(data)
开发者ID:gilshwartz,项目名称:tortoisehg-caja,代码行数:10,代码来源:wconfig.py


示例9: load_user_cache

def load_user_cache(ui, api_server, filename):
    user_cache = get_global_path(filename)

    # Ensure that the cache exists before attempting to use it
    fp = open(user_cache, "a");
    fp.close()

    c = config.config()
    c.read(user_cache)
    return c
开发者ID:terrence2,项目名称:dotfiles,代码行数:10,代码来源:bzauth.py


示例10: parsegitmodules

 def parsegitmodules(self, content):
     """Parse the formatted .gitmodules file, example file format:
     [submodule "sub"]\n
     \tpath = sub\n
     \turl = git://giturl\n
     """
     self.submodules = []
     c = config.config()
     # Each item in .gitmodules starts with \t that cant be parsed
     c.parse('.gitmodules', content.replace('\t',''))
     for sec in c.sections():
         s = c[sec]
         if 'url' in s and 'path' in s:
             self.submodules.append(submodule(s['path'], '', s['url']))
开发者ID:RayFerr000,项目名称:PLTL,代码行数:14,代码来源:git.py


示例11: user_config

def user_config():
    """Read the Mercurial user configuration

    This is typically ~/.hgrc on POSIX.  This is returned
    as a Mercurial.config.config object.
    """
    hgrc = config()
    for cfg in userrcpath():
        if not os.path.exists(cfg):
            log("NOT reading missing cfg: " + cfg)
            continue
        log("Reading config: " + cfg)
        hgrc.read(cfg)
    return hgrc
开发者ID:RavenB,项目名称:gitifyhg,代码行数:14,代码来源:util.py


示例12: _activepath

 def _activepath(self, remote):
     conf = config.config()
     rc = self.join("hgrc")
     if os.path.exists(rc):
         fp = open(rc)
         conf.parse(".hgrc", fp.read())
         fp.close()
     realpath = ""
     if "paths" in conf:
         for path, uri in conf["paths"].items():
             for s in schemes.schemes.iterkeys():
                 if uri.startswith("%s://" % s):
                     # TODO: refactor schemes so we don't
                     # duplicate this logic
                     ui.note("performing schemes expansion with " "scheme %s\n" % s)
                     scheme = hg.schemes[s]
                     parts = uri.split("://", 1)[1].split("/", scheme.parts)
                     if len(parts) > scheme.parts:
                         tail = parts[-1]
                         parts = parts[:-1]
                     else:
                         tail = ""
                     context = dict((str(i + 1), v) for i, v in enumerate(parts))
                     uri = "".join(scheme.templater.process(scheme.url, context)) + tail
             uri = self.ui.expandpath(uri)
             if remote.local():
                 uri = os.path.realpath(uri)
                 rpath = getattr(remote, "root", None)
                 if rpath is None:
                     # Maybe a localpeer? ([email protected], 2.3)
                     rpath = getattr(getattr(remote, "_repo", None), "root", None)
             else:
                 rpath = remote._url
                 if uri.startswith("http"):
                     try:
                         uri = url.url(uri).authinfo()[0]
                     except AttributeError:
                         try:
                             uri = util.url(uri).authinfo()[0]
                         except AttributeError:
                             uri = url.getauthinfo(uri)[0]
             uri = uri.rstrip("/")
             rpath = rpath.rstrip("/")
             if uri == rpath:
                 realpath = path
                 # prefer a non-default name to default
                 if path != "default":
                     break
     return realpath
开发者ID:charleseff,项目名称:dotfiles,代码行数:49,代码来源:hg_remotebranches.py


示例13: __init__

    def __init__(self, path):
        self._c = config.config()
        with open(path, 'rb') as fh:
            self._c.read(path, fh)

        if 'GLOBAL' not in self._c:
            raise error.Abort('config file missing GLOBAL section')

        self.stagepath = self._c.get('GLOBAL', 'stagepath')
        if not self.stagepath:
            raise error.Abort('GLOBAL.stagepath not defined in config')

        self.destpath = self._c.get('GLOBAL', 'destpath')
        if not self.destpath:
            raise error.Abort('GLOBAL.destpath not defined in config')
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:15,代码来源:__init__.py


示例14: find_profile

def find_profile(ui, profileName):
    """
    Find the default Firefox profile location. Returns None
    if no profile could be located.

    """
    path = None
    if platform.system() == "Darwin":
        # Use FSFindFolder
        from Carbon import Folder, Folders
        pathref = Folder.FSFindFolder(Folders.kUserDomain,
                                      Folders.kApplicationSupportFolderType,
                                      Folders.kDontCreateFolder)
        basepath = pathref.FSRefMakePath()
        path = os.path.join(basepath, "Firefox")
    elif platform.system() == "Windows":
        # From http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494%28v=vs.85%29.aspx
        CSIDL_APPDATA = 26
        path = win_get_folder_path(CSIDL_APPDATA)
        if path:
            path = os.path.join(path, "Mozilla", "Firefox")
    else:
        # Assume POSIX
        # Pretty simple in comparison, eh?
        path = os.path.expanduser("~/.mozilla/firefox")
    if path is None:
        raise util.Abort(_("Could not find a Firefox profile"))

    profileini = os.path.join(path, "profiles.ini")
    c = config.config()
    c.read(profileini)

    if profileName:
        sections = [s for s in c.sections() if profileName in [s, c.get(s, "Name", None)]]
    else:
        sections = [s for s in c.sections() if c.get(s, "Default", None)]
        if len(sections) == 0:
            sections = c.sections()

    sections = [s for s in sections if c.get(s, "Path", None) is not None]
    if len(sections) == 0:
        raise util.Abort(_("Could not find a Firefox profile"))

    section = sections.pop(0)
    profile = c[section].get("Path")
    if c.get(section, "IsRelative", "0") == "1":
        profile = os.path.join(path, profile)
    return profile
开发者ID:simar7,项目名称:git-version-control-tools-clone,代码行数:48,代码来源:bzauth.py


示例15: readhgeol

        def readhgeol(self, node=None, data=None):
            if data is None:
                try:
                    if node is None:
                        data = self.wfile('.hgeol').read()
                    else:
                        data = self[node]['.hgeol'].data()
                except (IOError, LookupError):
                    return None

            if self.ui.config('eol', 'native', os.linesep) in ('LF', '\n'):
                self._decode['NATIVE'] = 'to-lf'
            else:
                self._decode['NATIVE'] = 'to-crlf'

            eol = config.config()
            # Our files should not be touched. The pattern must be
            # inserted first override a '** = native' pattern.
            eol.set('patterns', '.hg*', 'BIN')
            # We can then parse the user's patterns.
            eol.parse('.hgeol', data)

            if eol.get('repository', 'native') == 'CRLF':
                self._encode['NATIVE'] = 'to-crlf'
            else:
                self._encode['NATIVE'] = 'to-lf'

            for pattern, style in eol.items('patterns'):
                key = style.upper()
                try:
                    self.ui.setconfig('decode', pattern, self._decode[key])
                    self.ui.setconfig('encode', pattern, self._encode[key])
                except KeyError:
                    self.ui.warn(_("ignoring unknown EOL style '%s' from %s\n")
                                 % (style, eol.source('patterns', pattern)))

            include = []
            exclude = []
            for pattern, style in eol.items('patterns'):
                key = style.upper()
                if key == 'BIN':
                    exclude.append(pattern)
                else:
                    include.append(pattern)

            # This will match the files for which we need to care
            # about inconsistent newlines.
            return match.match(self.root, '', [], include, exclude)
开发者ID:helloandre,项目名称:cr48,代码行数:48,代码来源:eol.py


示例16: make_ui

def make_ui(self, path='hgwebdir.config'):
    """
    A funcion that will read python rc files and make an ui from read options

    :param path: path to mercurial config file
    """
    #propagated from mercurial documentation
    sections = [
                'alias',
                'auth',
                'decode/encode',
                'defaults',
                'diff',
                'email',
                'extensions',
                'format',
                'merge-patterns',
                'merge-tools',
                'hooks',
                'http_proxy',
                'smtp',
                'patch',
                'paths',
                'profiling',
                'server',
                'trusted',
                'ui',
                'web',
                ]

    repos = path
    baseui = ui.ui()
    cfg = config.config()
    cfg.read(repos)
    self.paths = cfg.items('paths')
    self.base_path = self.paths[0][1].replace('*', '')
    self.check_repo_dir(self.paths)
    self.set_statics(cfg)

    for section in sections:
        for k, v in cfg.items(section):
            baseui.setconfig(section, k, v)

    return baseui
开发者ID:Lothiraldan,项目名称:vcs,代码行数:44,代码来源:baseui_config.py


示例17: cdm_reparent

def cdm_reparent(ui, repo, parent):
    '''reparent your workspace

    Update the 'default' path alias that is used as the default source
    for 'hg pull' and the default destination for 'hg push' (unless
    there is a 'default-push' alias).  This is also the path all
    Cadmium commands treat as your parent workspace.
    '''

    def append_new_parent(parent):
        fp = None
        try:
            fp = repo.opener('hgrc', 'a', atomictemp=True)
            if fp.tell() != 0:
                fp.write('\n')
            fp.write('[paths]\n'
                     'default = %s\n\n' % parent)
            fp.rename()
        finally:
            if fp and not fp.closed:
                fp.close()

    def update_parent(path, line, parent):
        line = line - 1 # The line number we're passed will be 1-based
        fp = None

        try:
            fp = open(path)
            data = fp.readlines()
        finally:
            if fp and not fp.closed:
                fp.close()

        #
        # line will be the last line of any continued block, go back
        # to the first removing the continuation as we go.
        #
        while data[line][0].isspace():
            data.pop(line)
            line -= 1

        assert data[line].startswith('default')

        data[line] = "default = %s\n" % parent
        if data[-1] != '\n':
            data.append('\n')

        try:
            fp = util.atomictempfile(path, 'w', 0644)
            fp.writelines(data)
            fp.rename()
        finally:
            if fp and not fp.closed:
                fp.close()

    from mercurial import config
    parent = ui.expandpath(parent)

    if not os.path.exists(repo.join('hgrc')):
        append_new_parent(parent)
        return

    cfg = config.config()
    cfg.read(repo.join('hgrc'))
    source = cfg.source('paths', 'default')

    if not source:
        append_new_parent(parent)
        return
    else:
        path, target = source.rsplit(':', 1)

        if path != repo.join('hgrc'):
            raise util.Abort("Cannot edit path specification not in repo hgrc\n"
                             "default path is from: %s" % source)

        update_parent(path, int(target), parent)
开发者ID:apprisi,项目名称:illumos-gate,代码行数:77,代码来源:cdm.py


示例18: get_profiles

def get_profiles(profilesdir):
    """Obtain information about available Firefox profiles.

    The Firefox profiles from the specified path will be loaded. A list of
    dicts describing each profile will be returned. The list is sorted
    according to profile preference. The default profile is always first.
    """
    profileini = os.path.join(profilesdir, 'profiles.ini')
    if not os.path.exists(profileini):
        return []

    c = config.config()
    c.read(profileini)

    profiles = []
    for s in c.sections():
        if not c.get(s, 'Path') or not c.get(s, 'Name'):
            continue

        name = c.get(s, 'Name')
        path = c.get(s, 'Path')

        if c.get(s, 'IsRelative') == '1':
            path = os.path.join(profilesdir, path)

        newest = -1
        if os.path.exists(path):
            mtimes = []
            for p in os.listdir(path):
                p = os.path.join(path, p)
                if os.path.isfile(p):
                    mtimes.append(os.path.getmtime(p))

            # If there are no files, ignore the profile completely.
            if not mtimes:
                continue

            newest = max(mtimes)

        p = {
            'name': name,
            'path': path,
            'default': c.get(s, 'Default', False) and True,
            'mtime': newest,
        }

        profiles.append(p)

    def compare(a, b):
        """Sort profile by default first, file mtime second."""
        if a['default']:
            return -1

        if a['mtime'] > b['mtime']:
            return -1
        elif a['mtime'] < b['mtime']:
            return 1

        return 0

    return sorted(profiles, cmp=compare)
开发者ID:pombredanne,项目名称:version-control-tools,代码行数:61,代码来源:auth.py


示例19: newrconfig

def newrconfig(vals={}):
    c = config.config()
    for k, v in isinstance(vals, dict) and vals.iteritems() or vals:
        sec, it = k.split('.', 1)
        c.set(sec, it, v)
    return c
开发者ID:velorientc,项目名称:git_test7,代码行数:6,代码来源:wconfig_test.py



注:本文中的mercurial.config.config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python context.memctx函数代码示例发布时间:2022-05-27
下一篇:
Python commands.update函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap