当前位置: 首页>>代码示例>>Python>>正文


Python config.config函数代码示例

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


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


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