| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c946906 commit 4e9a2f2
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,15 +3,17 @@ | |||
| 3 | 3 | # This module is part of GitPython and is released under the | |
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | 5 | ||
| 6 | - import gitdb.typ as dbtyp | ||
| 6 | + __all__ = ("Object", "IndexObject") | ||
| 7 | + | ||
| 7 | 8 | import os.path as osp | |
| 8 | 9 | ||
| 10 | + import gitdb.typ as dbtyp | ||
| 11 | + | ||
| 9 | 12 | from git.exc import WorkTreeRepositoryUnsupported | |
| 10 | - from git.util import LazyMixin, join_path_native, stream_copy, bin_to_hex | ||
| 13 | + from git.util import LazyMixin, bin_to_hex, join_path_native, stream_copy | ||
| 11 | 14 | ||
| 12 | 15 | from .util import get_object_type_by_name | |
| 13 | 16 | ||
| 14 | - | ||
| 15 | 17 | # typing ------------------------------------------------------------------ | |
| 16 | 18 | ||
| 17 | 19 | from typing import Any, TYPE_CHECKING, Union | |
@@ -24,16 +26,14 @@ | |||
| 24 | 26 | from git.refs.reference import Reference | |
| 25 | 27 | from git.repo import Repo | |
| 26 | 28 | ||
| 27 | - from .tree import Tree | ||
| 28 | 29 | from .blob import Blob | |
| 29 | 30 | from .submodule.base import Submodule | |
| 31 | + from .tree import Tree | ||
| 30 | 32 | ||
| 31 | 33 | IndexObjUnion = Union["Tree", "Blob", "Submodule"] | |
| 32 | 34 | ||
| 33 | 35 | # -------------------------------------------------------------------------- | |
| 34 | 36 | ||
| 35 | - __all__ = ("Object", "IndexObject") | ||
| 36 | - | ||
| 37 | 37 | ||
| 38 | 38 | class Object(LazyMixin): | |
| 39 | 39 | """Base class for classes representing git object types. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,17 +3,17 @@ | |||
| 3 | 3 | # This module is part of GitPython and is released under the | |
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | 5 | ||
| 6 | + __all__ = ("Blob",) | ||
| 7 | + | ||
| 6 | 8 | from mimetypes import guess_type | |
| 7 | 9 | import sys | |
| 8 | 10 | ||
| 9 | - from . import base | ||
| 10 | - | ||
| 11 | 11 | if sys.version_info >= (3, 8): | |
| 12 | 12 | from typing import Literal | |
| 13 | 13 | else: | |
| 14 | 14 | from typing_extensions import Literal | |
| 15 | 15 | ||
| 16 | - __all__ = ("Blob",) | ||
| 16 | + from . import base | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | class Blob(base.IndexObject): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,8 @@ | |||
| 3 | 3 | # This module is part of GitPython and is released under the | |
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | 5 | ||
| 6 | + __all__ = ("Commit",) | ||
| 7 | + | ||
| 6 | 8 | from collections import defaultdict | |
| 7 | 9 | import datetime | |
| 8 | 10 | from io import BytesIO | |
@@ -14,10 +16,12 @@ | |||
| 14 | 16 | from time import altzone, daylight, localtime, time, timezone | |
| 15 | 17 | ||
| 16 | 18 | from gitdb import IStream | |
| 19 | + | ||
| 17 | 20 | from git.cmd import Git | |
| 18 | 21 | from git.diff import Diffable | |
| 19 | - from git.util import hex_to_bin, Actor, Stats, finalize_process | ||
| 22 | + from git.util import Actor, Stats, finalize_process, hex_to_bin | ||
| 20 | 23 | ||
| 24 | + from . import base | ||
| 21 | 25 | from .tree import Tree | |
| 22 | 26 | from .util import ( | |
| 23 | 27 | Serializable, | |
@@ -27,7 +31,6 @@ | |||
| 27 | 31 | parse_actor_and_date, | |
| 28 | 32 | parse_date, | |
| 29 | 33 | ) | |
| 30 | - from . import base | ||
| 31 | 34 | ||
| 32 | 35 | # typing ------------------------------------------------------------------ | |
| 33 | 36 | ||
@@ -59,8 +62,6 @@ | |||
| 59 | 62 | ||
| 60 | 63 | _logger = logging.getLogger(__name__) | |
| 61 | 64 | ||
| 62 | - __all__ = ("Commit",) | ||
| 63 | - | ||
| 64 | 65 | ||
| 65 | 66 | class Commit(base.Object, TraversableIterableObj, Diffable, Serializable): | |
| 66 | 67 | """Wraps a git commit object. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | 4 | """Functions that are supposed to be as fast as possible.""" | |
| 5 | 5 | ||
| 6 | - from stat import S_ISDIR | ||
| 6 | + __all__ = ( | ||
| 7 | + "tree_to_stream", | ||
| 8 | + "tree_entries_from_data", | ||
| 9 | + "traverse_trees_recursive", | ||
| 10 | + "traverse_tree_recursive", | ||
| 11 | + ) | ||
| 7 | 12 | ||
| 13 | + from stat import S_ISDIR | ||
| 8 | 14 | ||
| 9 | 15 | from git.compat import safe_decode, defenc | |
| 10 | 16 | ||
@@ -23,22 +29,15 @@ | |||
| 23 | 29 | ||
| 24 | 30 | if TYPE_CHECKING: | |
| 25 | 31 | from _typeshed import ReadableBuffer | |
| 32 | + | ||
| 26 | 33 | from git import GitCmdObjectDB | |
| 27 | 34 | ||
| 28 | - EntryTup = Tuple[bytes, int, str] # same as TreeCacheTup in tree.py | ||
| 35 | + EntryTup = Tuple[bytes, int, str] # Same as TreeCacheTup in tree.py. | ||
| 29 | 36 | EntryTupOrNone = Union[EntryTup, None] | |
| 30 | 37 | ||
| 31 | 38 | # --------------------------------------------------- | |
| 32 | 39 | ||
| 33 | 40 | ||
| 34 | - __all__ = ( | ||
| 35 | - "tree_to_stream", | ||
| 36 | - "tree_entries_from_data", | ||
| 37 | - "traverse_trees_recursive", | ||
| 38 | - "traverse_tree_recursive", | ||
| 39 | - ) | ||
| 40 | - | ||
| 41 | - | ||
| 42 | 41 | def tree_to_stream(entries: Sequence[EntryTup], write: Callable[["ReadableBuffer"], Union[int, None]]) -> None: | |
| 43 | 42 | """Write the given list of entries into a stream using its ``write`` method. | |
| 44 | 43 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,12 +23,13 @@ | |||
| 23 | 23 | from git.types import PathLike | |
| 24 | 24 | ||
| 25 | 25 | if TYPE_CHECKING: | |
| 26 | - from .base import Submodule | ||
| 27 | 26 | from weakref import ReferenceType | |
| 27 | + | ||
| 28 | + from git.refs import Head, RemoteReference | ||
| 29 | + from git.remote import Remote | ||
| 28 | 30 | from git.repo import Repo | |
| 29 | - from git.refs import Head | ||
| 30 | - from git import Remote | ||
| 31 | - from git.refs import RemoteReference | ||
| 31 | + | ||
| 32 | + from .base import Submodule | ||
| 32 | 33 | ||
| 33 | 34 | # { Utilities | |
| 34 | 35 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,12 +9,17 @@ | |||
| 9 | 9 | For lightweight tags, see the :mod:`git.refs.tag` module. | |
| 10 | 10 | """ | |
| 11 | 11 | ||
| 12 | + __all__ = ("TagObject",) | ||
| 13 | + | ||
| 12 | 14 | import sys | |
| 13 | 15 | ||
| 16 | + from git.compat import defenc | ||
| 17 | + from git.util import hex_to_bin | ||
| 18 | + | ||
| 14 | 19 | from . import base | |
| 15 | 20 | from .util import get_object_type_by_name, parse_actor_and_date | |
| 16 | - from ..util import hex_to_bin | ||
| 17 | - from ..compat import defenc | ||
| 21 | + | ||
| 22 | + # typing ---------------------------------------------- | ||
| 18 | 23 | ||
| 19 | 24 | from typing import List, TYPE_CHECKING, Union | |
| 20 | 25 | ||
@@ -26,11 +31,12 @@ | |||
| 26 | 31 | if TYPE_CHECKING: | |
| 27 | 32 | from git.repo import Repo | |
| 28 | 33 | from git.util import Actor | |
| 29 | - from .commit import Commit | ||
| 34 | + | ||
| 30 | 35 | from .blob import Blob | |
| 36 | + from .commit import Commit | ||
| 31 | 37 | from .tree import Tree | |
| 32 | 38 | ||
| 33 | - __all__ = ("TagObject",) | ||
| 39 | + # --------------------------------------------------- | ||
| 34 | 40 | ||
| 35 | 41 | ||
| 36 | 42 | class TagObject(base.Object): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,16 +3,18 @@ | |||
| 3 | 3 | # This module is part of GitPython and is released under the | |
| 4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ | |
| 5 | 5 | ||
| 6 | + __all__ = ("TreeModifier", "Tree") | ||
| 7 | + | ||
| 6 | 8 | import sys | |
| 7 | 9 | ||
| 8 | 10 | import git.diff as git_diff | |
| 9 | 11 | from git.util import IterableList, join_path, to_bin_sha | |
| 10 | 12 | ||
| 13 | + from . import util | ||
| 11 | 14 | from .base import IndexObjUnion, IndexObject | |
| 12 | 15 | from .blob import Blob | |
| 13 | 16 | from .fun import tree_entries_from_data, tree_to_stream | |
| 14 | 17 | from .submodule.base import Submodule | |
| 15 | - from . import util | ||
| 16 | 18 | ||
| 17 | 19 | # typing ------------------------------------------------- | |
| 18 | 20 | ||
@@ -39,23 +41,20 @@ | |||
| 39 | 41 | ||
| 40 | 42 | if TYPE_CHECKING: | |
| 41 | 43 | from io import BytesIO | |
| 44 | + | ||
| 42 | 45 | from git.repo import Repo | |
| 43 | 46 | ||
| 44 | 47 | TreeCacheTup = Tuple[bytes, int, str] | |
| 45 | 48 | ||
| 46 | 49 | TraversedTreeTup = Union[Tuple[Union["Tree", None], IndexObjUnion, Tuple["Submodule", "Submodule"]]] | |
| 47 | 50 | ||
| 48 | - | ||
| 49 | 51 | # def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]: | |
| 50 | 52 | # return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str) | |
| 51 | 53 | ||
| 52 | 54 | # -------------------------------------------------------- | |
| 53 | 55 | ||
| 54 | - | ||
| 55 | 56 | cmp: Callable[[str, str], int] = lambda a, b: (a > b) - (a < b) | |
| 56 | 57 | ||
| 57 | - __all__ = ("TreeModifier", "Tree") | ||
| 58 | - | ||
| 59 | 58 | ||
| 60 | 59 | class TreeModifier: | |
| 61 | 60 | """A utility class providing methods to alter the underlying cache in a list-like | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,46 +5,63 @@ | |||
| 5 | 5 | ||
| 6 | 6 | """General utility functions.""" | |
| 7 | 7 | ||
| 8 | + __all__ = ( | ||
| 9 | + "get_object_type_by_name", | ||
| 10 | + "parse_date", | ||
| 11 | + "parse_actor_and_date", | ||
| 12 | + "ProcessStreamAdapter", | ||
| 13 | + "Traversable", | ||
| 14 | + "altz_to_utctz_str", | ||
| 15 | + "utctz_to_altz", | ||
| 16 | + "verify_utctz", | ||
| 17 | + "Actor", | ||
| 18 | + "tzoffset", | ||
| 19 | + "utc", | ||
| 20 | + ) | ||
| 21 | + | ||
| 8 | 22 | from abc import ABC, abstractmethod | |
| 9 | 23 | import calendar | |
| 10 | 24 | from collections import deque | |
| 11 | 25 | from datetime import datetime, timedelta, tzinfo | |
| 12 | - from string import digits | ||
| 13 | 26 | import re | |
| 27 | + from string import digits | ||
| 14 | 28 | import time | |
| 15 | 29 | import warnings | |
| 16 | 30 | ||
| 17 | - from git.util import IterableList, IterableObj, Actor | ||
| 31 | + from git.util import Actor, IterableList, IterableObj | ||
| 18 | 32 | ||
| 19 | 33 | # typing ------------------------------------------------------------ | |
| 34 | + | ||
| 20 | 35 | from typing import ( | |
| 21 | 36 | Any, | |
| 22 | 37 | Callable, | |
| 23 | 38 | Deque, | |
| 24 | - Iterator, | ||
| 25 | 39 | # Generic, | |
| 40 | + Iterator, | ||
| 26 | 41 | NamedTuple, | |
| 27 | - overload, | ||
| 28 | 42 | Sequence, | |
| 29 | 43 | TYPE_CHECKING, | |
| 30 | 44 | Tuple, | |
| 31 | 45 | Type, | |
| 32 | 46 | TypeVar, | |
| 33 | 47 | Union, | |
| 34 | 48 | cast, | |
| 49 | + overload, | ||
| 35 | 50 | ) | |
| 36 | 51 | ||
| 37 | 52 | from git.types import Has_id_attribute, Literal # , _T | |
| 38 | 53 | ||
| 39 | 54 | if TYPE_CHECKING: | |
| 40 | 55 | from io import BytesIO, StringIO | |
| 41 | - from .commit import Commit | ||
| 42 | - from .blob import Blob | ||
| 43 | - from .tag import TagObject | ||
| 44 | - from .tree import Tree, TraversedTreeTup | ||
| 45 | 56 | from subprocess import Popen | |
| 46 | - from .submodule.base import Submodule | ||
| 57 | + | ||
| 47 | 58 | from git.types import Protocol, runtime_checkable | |
| 59 | + | ||
| 60 | + from .blob import Blob | ||
| 61 | + from .commit import Commit | ||
| 62 | + from .submodule.base import Submodule | ||
| 63 | + from .tag import TagObject | ||
| 64 | + from .tree import TraversedTreeTup, Tree | ||
| 48 | 65 | else: | |
| 49 | 66 | # Protocol = Generic[_T] # Needed for typing bug #572? | |
| 50 | 67 | Protocol = ABC | |
@@ -68,20 +85,6 @@ class TraverseNT(NamedTuple): | |||
| 68 | 85 | ||
| 69 | 86 | # -------------------------------------------------------------------- | |
| 70 | 87 | ||
| 71 | - __all__ = ( | ||
| 72 | - "get_object_type_by_name", | ||
| 73 | - "parse_date", | ||
| 74 | - "parse_actor_and_date", | ||
| 75 | - "ProcessStreamAdapter", | ||
| 76 | - "Traversable", | ||
| 77 | - "altz_to_utctz_str", | ||
| 78 | - "utctz_to_altz", | ||
| 79 | - "verify_utctz", | ||
| 80 | - "Actor", | ||
| 81 | - "tzoffset", | ||
| 82 | - "utc", | ||
| 83 | - ) | ||
| 84 | - | ||
| 85 | 88 | ZERO = timedelta(0) | |
| 86 | 89 | ||
| 87 | 90 | # { Functions | |
| Back | FazBrowse Home | New Git URL |
0 commit comments