コード例 #1
0
def all_committers_set() -> List[CommittersSet]:
    lines = read_lines(Path(join(CONFIGURATION_DIRECTORY, constants.COMMITTERS_SET)))
    committers_sets = []
    for line in lines:
        *initials, set_time, path_as_str = line.split(',')
        committers_sets.append(CommittersSet(initials, set_time, Path(path_as_str)))
    return committers_sets
コード例 #2
0
ファイル: hook.py プロジェクト: chiptopher/guet
 def _get_file_content(path_to_hook, create: bool):
     try:
         _content = read_lines(path_to_hook)
     except FileNotFoundError:
         if create:
             if not which('python3'):
                 _content = PYTHON_GUET_HOOK
             else:
                 _content = PYTHON3_GUET_HOOK
         else:
             raise
     return _content
コード例 #3
0
ファイル: git.py プロジェクト: chiptopher/guet
 def __init__(self, repository_path: Path):
     super().__init__()
     if not repository_path.is_dir():
         raise NoGitPresentError()
     default = _load_hooks(
         HookLoader(repository_path.joinpath('hooks'),
                    BaseFileNameStrategy(), DontCreateStrategy()))
     alongside = _load_hooks(
         HookLoader(repository_path.joinpath('hooks'),
                    AlongsideFileNameStrategy(), DontCreateStrategy()))
     self.hooks = default + alongside
     self.path_to_git_folder = repository_path
     self._commit_msg = _load_commit_msg(repository_path)
     self._config_lines = read_lines(repository_path.joinpath('config'))
     self._author: Author = load_author(self._config_lines)
     self._hooks_destination = None
コード例 #4
0
ファイル: test_read_lines.py プロジェクト: chiptopher/guet
 def test_returns_lines_from_file(self, mock_Path):
     path: Path = Mock()
     expected = ['Line1', 'Line2']
     path.read_text.return_value = 'Line1\nLine2'
     result = read_lines(path)
     self.assertEqual(expected, result)
コード例 #5
0
ファイル: test_read_lines.py プロジェクト: chiptopher/guet
 def test_removes_last_empty_line(self, mock_Path):
     path: Path = Mock()
     path.read_text.return_value = 'Line1\nLine2\n'
     result = read_lines(path)
     self.assertEqual(['Line1', 'Line2'], result)
コード例 #6
0
ファイル: test_read_lines.py プロジェクト: chiptopher/guet
 def test_strips_newlines_from_the_end_of_lines(self, mock_Path):
     path: Path = Mock()
     path.read_text.return_value = 'Line1\nLine2\n'
     result = read_lines(path)
     self.assertEqual(['Line1', 'Line2'], result)
コード例 #7
0
ファイル: git.py プロジェクト: chiptopher/guet
def _load_commit_msg(path_to_repository: Path) -> List[str]:
    try:
        return read_lines(path_to_repository.joinpath('COMMIT_EDITMSG'))
    except FileNotFoundError:
        return []
コード例 #8
0
def get_settings() -> Settings:
    lines = read_lines(Path(join(CONFIGURATION_DIRECTORY, constants.CONFIG)))
    settings = Settings()
    settings.load(lines)
    return settings
コード例 #9
0
ファイル: _add_committer.py プロジェクト: chiptopher/guet
def _read_all_committers_from_file(path: Path) -> List[str]:
    try:
        return read_lines(path)
    except FileNotFoundError:
        return []
コード例 #10
0
 def read(self) -> List[str]:
     try:
         self._content = read_lines(self._absolute_path)
     except FileNotFoundError:
         self._content = []
     return self._content