コード例 #1
0
    def __getattribute__(self, name):
        # attempt to use any attributes first
        value = object.__getattribute__(self, name)
        if value:
            LOG.debug("Retrieved '{}' setting from cache".format(name))
            return value

        # fallback to reading from git config otherwise
        value = utils.git_config('pw.{}'.format(name))
        if value:
            LOG.debug("Retrieved '{}' setting from git-config".format(name))

        setattr(self, name, value)

        return value
コード例 #2
0
ファイル: config.py プロジェクト: matttbe/git-pw
    def __getattribute__(self, name):
        # attempt to use any attributes first
        try:
            value = super(Config, self).__getattribute__(name)
        except AttributeError:
            value = None
        if value:
            LOG.debug("Retrieved '{}' setting from cache".format(name))
            return value

        # fallback to reading from git config otherwise
        value = utils.git_config('pw.{}'.format(name))
        if value:
            LOG.debug("Retrieved '{}' setting from git-config".format(name))

        setattr(self, name, value)

        return value
コード例 #3
0
ファイル: test_utils.py プロジェクト: ajdlinux/git-pw
def test_git_config_error(mock_subprocess):
    value = utils.git_config('foo')

    assert value == ''
コード例 #4
0
ファイル: test_utils.py プロジェクト: ajdlinux/git-pw
def test_git_config_unicode(mock_subprocess):
    value = utils.git_config('foo')

    assert value == u'\U0001f937'
    mock_subprocess.assert_called_once_with(['git', 'config', 'foo'])
コード例 #5
0
ファイル: test_utils.py プロジェクト: ajdlinux/git-pw
def test_git_config(mock_subprocess):
    value = utils.git_config('foo')

    assert value == 'bar'
    mock_subprocess.assert_called_once_with(['git', 'config', 'foo'])