Exemplo n.º 1
0
 def asdict(self):
     path = self.path()
     if core.exists(path):
         return read_json(path)
     # We couldn't find ~/.config/git-cola, try ~/.cola
     values = {}
     path = os.path.join(core.expanduser('~'), '.cola')
     if core.exists(path):
         json_values = read_json(path)
         # Keep only the entries we care about
         for key in self.values:
             try:
                 values[key] = json_values[key]
             except KeyError:
                 pass
     return values
Exemplo n.º 2
0
 def asdict(self):
     path = self.path()
     if core.exists(path):
         return read_json(path)
     # We couldn't find ~/.config/git-cola, try ~/.cola
     values = {}
     path = os.path.join(core.expanduser('~'), '.cola')
     if core.exists(path):
         json_values = read_json(path)
         # Keep only the entries we care about
         for key in self.values:
             try:
                 values[key] = json_values[key]
             except KeyError:
                 pass
     return values
Exemplo n.º 3
0
    def _load_dot_cola(self):
        values = {}
        path = os.path.join(core.expanduser('~'), '.cola')
        if not core.exists(path):
            return {}
        try:
            with core.xopen(path, 'r') as fp:
                json_values = json.load(fp)
        except: # bad json
            return {}

        # Keep only the entries we care about
        for key in self.values:
            try:
                values[key] = json_values[key]
            except KeyError:
                pass

        return values
Exemplo n.º 4
0
    def _load_dot_cola(self):
        values = {}
        path = os.path.join(core.expanduser('~'), '.cola')
        if not core.exists(path):
            return {}
        try:
            with core.xopen(path, 'r') as fp:
                json_values = json.load(fp)
        except:  # bad json
            return {}

        # Keep only the entries we care about
        for key in self.values:
            try:
                values[key] = json_values[key]
            except KeyError:
                pass

        return values
Exemplo n.º 5
0
from cola import core
from cola import git
from cola import observable
from cola.decorators import memoize
from cola.git import STDOUT
from cola.compat import ustr

BUILTIN_READER = os.environ.get('GIT_COLA_BUILTIN_CONFIG_READER', False)

@memoize
def instance():
    """Return a static GitConfig instance."""
    return GitConfig()

_USER_CONFIG = core.expanduser(join('~', '.gitconfig'))
_USER_XDG_CONFIG = core.expanduser(
        join(core.getenv('XDG_CONFIG_HOME', join('~', '.config')),
             'git', 'config'))

def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (('system', '/etc/gitconfig'),
             ('user', _USER_XDG_CONFIG),
             ('user', _USER_CONFIG),
             ('repo', git.instance().git_path('config')))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
        except OSError:
Exemplo n.º 6
0
def config_home(*args):
    config = core.getenv('XDG_CONFIG_HOME',
                         os.path.join(core.expanduser('~'), '.config'))
    return os.path.join(config, 'git-cola', *args)
Exemplo n.º 7
0
def config_home(*args):
    config = core.getenv('XDG_CONFIG_HOME',
                         os.path.join(core.expanduser('~'), '.config'))
    return os.path.join(config, 'git-cola', *args)
Exemplo n.º 8
0
from cola import core
from cola import git
from cola import observable
from cola.decorators import memoize
from cola.git import STDOUT
from cola.compat import ustr


@memoize
def instance():
    """Return a static GitConfig instance."""
    return GitConfig()


_USER_CONFIG = core.expanduser(join('~', '.gitconfig'))
_USER_XDG_CONFIG = core.expanduser(
    join(core.getenv('XDG_CONFIG_HOME', join('~', '.config')), 'git',
         'config'))


def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (('system', '/etc/gitconfig'), ('user', _USER_XDG_CONFIG),
             ('user', _USER_CONFIG), ('repo',
                                      git.instance().git_path('config')))
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
        except OSError:
Exemplo n.º 9
0
from os.path import join

from cola import core
from cola import git
from cola import observable
from cola.decorators import memoize
from cola.git import STDOUT


@memoize
def instance():
    """Return a static GitConfig instance."""
    return GitConfig()


_USER_CONFIG = core.expanduser(join("~", ".gitconfig"))
_USER_XDG_CONFIG = core.expanduser(join(core.getenv("XDG_CONFIG_HOME", join("~", ".config")), "git", "config"))


def _stat_info():
    # Try /etc/gitconfig as a fallback for the system config
    paths = (
        ("system", "/etc/gitconfig"),
        ("user", _USER_XDG_CONFIG),
        ("user", _USER_CONFIG),
        ("repo", git.instance().git_path("config")),
    )
    statinfo = []
    for category, path in paths:
        try:
            statinfo.append((category, path, core.stat(path).st_mtime))
Exemplo n.º 10
0
def config_home(*args):
    config = core.getenv("XDG_CONFIG_HOME", os.path.join(core.expanduser("~"), ".config"))
    return os.path.join(config, "git-cola", *args)