コード例 #1
0
ファイル: rules.py プロジェクト: Distrotech/bzr
    def __init__(self, inifile):
        """Construct a _RulesSearcher based on an ini file.

        The content will be decoded as utf-8.

        :param inifile: the name of the file or a sequence of lines.
        """
        self._cfg = configobj.ConfigObj(inifile, encoding='utf-8')
        sections = self._cfg.keys()
        patterns = []
        self.pattern_to_section = {}
        for s in sections:
            if s.startswith(FILE_PREFS_PREFIX):
                file_patterns = cmdline.split(s[FILE_PREFS_PREFIX_LEN:])
                patterns.extend(file_patterns)
                for fp in file_patterns:
                    self.pattern_to_section[fp] = s
        if len(patterns) < len(sections):
            unknowns = [s for s in sections
                if not s.startswith(FILE_PREFS_PREFIX)]
            raise errors.UnknownRules(unknowns)
        elif patterns:
            self._globster = globbing._OrderedGlobster(patterns)
        else:
            self._globster = None
コード例 #2
0
ファイル: bashcomp.py プロジェクト: pombreda/dist-packages
 def aliases(self):
     for alias, expansion in config.GlobalConfig().get_aliases().iteritems(
     ):
         for token in cmdline.split(expansion):
             if not token.startswith("-"):
                 self.user_aliases.setdefault(token, set()).add(alias)
                 break
コード例 #3
0
    def __init__(self, inifile):
        """Construct a _RulesSearcher based on an ini file.

        The content will be decoded as utf-8.

        :param inifile: the name of the file or a sequence of lines.
        """
        self._cfg = configobj.ConfigObj(inifile, encoding='utf-8')
        sections = self._cfg.keys()
        patterns = []
        self.pattern_to_section = {}
        for s in sections:
            if s.startswith(FILE_PREFS_PREFIX):
                file_patterns = cmdline.split(s[FILE_PREFS_PREFIX_LEN:])
                patterns.extend(file_patterns)
                for fp in file_patterns:
                    self.pattern_to_section[fp] = s
        if len(patterns) < len(sections):
            unknowns = [
                s for s in sections if not s.startswith(FILE_PREFS_PREFIX)
            ]
            raise errors.UnknownRules(unknowns)
        elif patterns:
            self._globster = globbing._OrderedGlobster(patterns)
        else:
            self._globster = None
コード例 #4
0
ファイル: msgeditor.py プロジェクト: pombreda/dist-packages
def _run_editor(filename):
    """Try to execute an editor to edit the commit message."""
    for candidate, candidate_source in _get_editor():
        edargs = cmdline.split(candidate)
        try:
            ## mutter("trying editor: %r", (edargs +[filename]))
            x = call(edargs + [filename])
        except OSError, e:
            if candidate_source is not None:
                # We tried this editor because some user configuration (an
                # environment variable or config file) said to try it.  Let
                # the user know their configuration is broken.
                trace.warning(
                    'Could not start editor "%s" (specified by %s): %s\n' %
                    (candidate, candidate_source, str(e)))
            continue
            raise
        if x == 0:
            return True
        elif x == 127:
            continue
        else:
            break
コード例 #5
0
ファイル: bashcomp.py プロジェクト: GymWenFLL/tpp_libs
 def aliases(self):
     for alias, expansion in config.GlobalConfig().get_aliases().iteritems():
         for token in cmdline.split(expansion):
             if not token.startswith("-"):
                 self.user_aliases.setdefault(token, set()).add(alias)
                 break