Exemplo n.º 1
0
    def create(self, title="tessera title goes here"):
        """ create a new tessera with title {title}.

            @returns Tessera object of the new Tessera
        """
        uuid = uuid1()
        tessera_path = os.path.join(Tessera._tesserae, str(uuid))
        tessera_file = "%s/tessera" % tessera_path
        os.mkdir(tessera_path)
        fin = open(os.path.join(Tessera._tesserae, "template"), "r")
        fout = open(tessera_file, "w")
        for line in fin.readlines():
            if line == "@title@\n":
                line = "# %s\n" % title
            fout.write(line)
        fin.close()
        fout.close()

        tessera_info = "%s/info" % tessera_path
        fout = open(tessera_info, "w")
        c = StackedConfig(StackedConfig.default_backends())
        fout.write("author: %s\n" % c.get("user", "name"))
        fout.write("email: %s\n" % c.get("user", "email"))
        fout.write("updated: %d\n" % int(time()))
        fout.close()

        return Tessera(tessera_path, self._config)
Exemplo n.º 2
0
 def get_config_stack(self):
     from dulwich.config import StackedConfig
     backends = []
     p = self.get_config()
     if p is not None:
         backends.append(p)
         writable = p
     else:
         writable = None
     backends.extend(StackedConfig.default_backends())
     return StackedConfig(backends, writable=writable)
Exemplo n.º 3
0
    def get_config_stack(self):
        """Return a config stack for this repository.

        This stack accesses the configuration for both this repository
        itself (.git/config) and the global configuration, which usually
        lives in ~/.gitconfig.

        :return: `Config` instance for this repository
        """
        from dulwich.config import StackedConfig
        backends = [self.get_config()] + StackedConfig.default_backends()
        return StackedConfig(backends, writable=backends[0])