示例#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
 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
 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
 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
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