37 files changed
@@ -3,8 +3,10 @@ | |||
| 3 | 3 | # | |
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 6 | + | ||
| 6 | 7 | # flake8: noqa | |
| 7 | 8 | # @PydevCodeAnalysisIgnore | |
| 9 | + | ||
| 8 | 10 | from git.exc import * # @NoMove @IgnorePep8 | |
| 9 | 11 | from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING | |
| 10 | 12 | from git.types import PathLike | |
@@ -1,10 +1,12 @@ | |||
| 1 | 1 | # -*- coding: utf-8 -*- | |
| 2 | - # config.py | ||
| 2 | + # compat.py | ||
| 3 | 3 | # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors | |
| 4 | 4 | # | |
| 5 | 5 | # This module is part of GitPython and is released under | |
| 6 | 6 | # the BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 7 | - """utilities to help provide compatibility with python 3""" | ||
| 7 | + | ||
| 8 | + """Utilities to help provide compatibility with Python 3.""" | ||
| 9 | + | ||
| 8 | 10 | # flake8: noqa | |
| 9 | 11 | ||
| 10 | 12 | import locale | |
@@ -50,7 +52,7 @@ def safe_decode(s: AnyStr) -> str: | |||
| 50 | 52 | ||
| 51 | 53 | ||
| 52 | 54 | def safe_decode(s: Union[AnyStr, None]) -> Optional[str]: | |
| 53 | - """Safely decodes a binary string to unicode""" | ||
| 55 | + """Safely decode a binary string to Unicode.""" | ||
| 54 | 56 | if isinstance(s, str): | |
| 55 | 57 | return s | |
| 56 | 58 | elif isinstance(s, bytes): | |
@@ -72,7 +74,7 @@ def safe_encode(s: AnyStr) -> bytes: | |||
| 72 | 74 | ||
| 73 | 75 | ||
| 74 | 76 | def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]: | |
| 75 | - """Safely encodes a binary string to unicode""" | ||
| 77 | + """Safely encode a binary string to Unicode.""" | ||
| 76 | 78 | if isinstance(s, str): | |
| 77 | 79 | return s.encode(defenc) | |
| 78 | 80 | elif isinstance(s, bytes): | |
@@ -94,7 +96,7 @@ def win_encode(s: AnyStr) -> bytes: | |||
| 94 | 96 | ||
| 95 | 97 | ||
| 96 | 98 | def win_encode(s: Optional[AnyStr]) -> Optional[bytes]: | |
| 97 | - """Encode unicodes for process arguments on Windows.""" | ||
| 99 | + """Encode Unicode strings for process arguments on Windows.""" | ||
| 98 | 100 | if isinstance(s, str): | |
| 99 | 101 | return s.encode(locale.getpreferredencoding(False)) | |
| 100 | 102 | elif isinstance(s, bytes): | |
@@ -1,4 +1,5 @@ | |||
| 1 | - """Module with our own gitdb implementation - it uses the git command""" | ||
| 1 | + """Module with our own gitdb implementation - it uses the git command.""" | ||
| 2 | + | ||
| 2 | 3 | from git.util import bin_to_hex, hex_to_bin | |
| 3 | 4 | from gitdb.base import OInfo, OStream | |
| 4 | 5 | from gitdb.db import GitDB | |
@@ -22,17 +23,17 @@ | |||
| 22 | 23 | ||
| 23 | 24 | ||
| 24 | 25 | class GitCmdObjectDB(LooseObjectDB): | |
| 25 | - | ||
| 26 | 26 | """A database representing the default git object store, which includes loose | |
| 27 | - objects, pack files and an alternates file | ||
| 27 | + objects, pack files and an alternates file. | ||
| 28 | 28 | ||
| 29 | 29 | It will create objects only in the loose object database. | |
| 30 | - :note: for now, we use the git command to do all the lookup, just until he | ||
| 31 | - have packs and the other implementations | ||
| 30 | + | ||
| 31 | + :note: For now, we use the git command to do all the lookup, just until we | ||
| 32 | + have packs and the other implementations. | ||
| 32 | 33 | """ | |
| 33 | 34 | ||
| 34 | 35 | def __init__(self, root_path: PathLike, git: "Git") -> None: | |
| 35 | - """Initialize this instance with the root and a git command""" | ||
| 36 | + """Initialize this instance with the root and a git command.""" | ||
| 36 | 37 | super(GitCmdObjectDB, self).__init__(root_path) | |
| 37 | 38 | self._git = git | |
| 38 | 39 | ||
@@ -48,11 +49,15 @@ def stream(self, binsha: bytes) -> OStream: | |||
| 48 | 49 | # { Interface | |
| 49 | 50 | ||
| 50 | 51 | def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes: | |
| 51 | - """:return: Full binary 20 byte sha from the given partial hexsha | ||
| 52 | + """ | ||
| 53 | + :return: Full binary 20 byte sha from the given partial hexsha | ||
| 54 | + | ||
| 52 | 55 | :raise AmbiguousObjectName: | |
| 53 | 56 | :raise BadObject: | |
| 54 | - :note: currently we only raise BadObject as git does not communicate | ||
| 55 | - AmbiguousObjects separately""" | ||
| 57 | + | ||
| 58 | + :note: Currently we only raise :class:`BadObject` as git does not communicate | ||
| 59 | + AmbiguousObjects separately. | ||
| 60 | + """ | ||
| 56 | 61 | try: | |
| 57 | 62 | hexsha, _typename, _size = self._git.get_object_header(partial_hexsha) | |
| 58 | 63 | return hex_to_bin(hexsha) | |
0 commit comments