Ejemplo n.º 1
0
    def create_conf(self, repo_name=None):
        text = dedent("""
            [main]
            verbose=1
            fallback=1

            [foo]
            verbose=foo

            [bar]
            verbose=bar

            [repo:main]
            verbose=main
            """)
        tmpfile = NamedTemporaryFile()
        with open(tmpfile.name, 'w') as f:
            f.write(text)
            f.flush()
            f.close()

        if repo_name is not None:
            conf = Config(repo_name)
        else:
            conf = Config()

        conf.load(tmpfile.name)
        return conf
Ejemplo n.º 2
0
Archivo: cli.py Proyecto: tpn/enversion
    def __init__(self, program_name):
        self.__program_name = program_name
        pattern = re.compile('[A-Z][^A-Z]*')
        self.classname = self.__class__.__name__
        tokens = [ t for t in pattern.findall(self.classname) ]
        assert tokens[-2:] == [ 'Command', 'Line' ]
        if self._command_ is not None:
            self.command_class = self._command_
            self.command_classname = self._command_.__name__
        else:
            ccn = ''.join(tokens[:-1])
            ccl = getattr(self.commands_module, ccn)
            self.command_classname = ccn
            self.command_class = ccl

        self.command = self.command_class(sys.stdin, sys.stdout, sys.stderr)

        tokens = [ t.lower() for t in tokens[:-2] ]
        self.name = '-'.join(t for t in tokens)
        self.shortname = None
        if self._shortname_ is not None:
            self.shortname = self._shortname_
        elif len(tokens) > 1:
            self.shortname = ''.join(t[0] for t in tokens)

        self.aliases = None
        if self._aliases_:
            self.aliases = self._aliases_

        self.conf = Config()
        self.repo_path = None
        self.parser = None
Ejemplo n.º 3
0
    def get_changeset(cls, path, rev_or_txn, **kwds):
        k = DecayDict(**kwds)
        estream = k.get('estream', sys.stderr)
        ostream = k.get('ostream', sys.stdout)
        istream = k.get('istream', sys.stdout)

        c = ChangeSetCommand(ostream, estream)

        c.path    = path
        c.conf    = k.get('conf', Config())
        c.options = k.get('options', Options())
        c.rev_or_txn = rev_or_txn

        k.assert_empty(cls)

        with c:
            c.run()
            return c.result
Ejemplo n.º 4
0
    def find_merges(cls, path, revision, **kwds):
        k = DecayDict(**kwds)
        estream = kwds.get('estream', sys.stderr)
        ostream = kwds.get('ostream', sys.stdout)
        istream = kwds.get('istream', sys.stdout)

        c = FindMergesCommand(istream, ostream, estream)

        c.revision = revision

        c.path    = path
        c.conf    = kwds.get('conf', Config())
        c.options = kwds.get('options', Options())

        k.assert_empty(cls)

        c.yield_values = True
        with c:
            c.run()
            return c
Ejemplo n.º 5
0
 def run(self):
     cf = Config()
     cf.write(self.ostream)
Ejemplo n.º 6
0
 def reload_conf(self):
     conf = Config()
     conf.load()
     conf.load_repo(self.path)
     self.conf = conf
     return conf