| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,9 +5,12 @@ | |||
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | # flake8: noqa | |
| 7 | 7 | #@PydevCodeAnalysisIgnore | |
| 8 | + import inspect | ||
| 8 | 9 | import os | |
| 9 | 10 | import sys | |
| 10 | - import inspect | ||
| 11 | + | ||
| 12 | + import os.path as osp | ||
| 13 | + | ||
| 11 | 14 | ||
| 12 | 15 | __version__ = 'git' | |
| 13 | 16 | ||
@@ -16,7 +19,7 @@ | |||
| 16 | 19 | def _init_externals(): | |
| 17 | 20 | """Initialize external projects by putting them into the path""" | |
| 18 | 21 | if __version__ == 'git': | |
| 19 | - sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'ext', 'gitdb')) | ||
| 22 | + sys.path.insert(0, osp.join(osp.dirname(__file__), 'ext', 'gitdb')) | ||
| 20 | 23 | ||
| 21 | 24 | try: | |
| 22 | 25 | import gitdb | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,21 +6,13 @@ | |||
| 6 | 6 | """Module containing module parser implementation able to properly read and write | |
| 7 | 7 | configuration files""" | |
| 8 | 8 | ||
| 9 | - import re | ||
| 10 | - try: | ||
| 11 | - import ConfigParser as cp | ||
| 12 | - except ImportError: | ||
| 13 | - # PY3 | ||
| 14 | - import configparser as cp | ||
| 9 | + import abc | ||
| 10 | + from functools import wraps | ||
| 15 | 11 | import inspect | |
| 16 | 12 | import logging | |
| 17 | - import abc | ||
| 18 | 13 | import os | |
| 14 | + import re | ||
| 19 | 15 | ||
| 20 | - from functools import wraps | ||
| 21 | - | ||
| 22 | - from git.odict import OrderedDict | ||
| 23 | - from git.util import LockFile | ||
| 24 | 16 | from git.compat import ( | |
| 25 | 17 | string_types, | |
| 26 | 18 | FileType, | |
@@ -29,6 +21,18 @@ | |||
| 29 | 21 | with_metaclass, | |
| 30 | 22 | PY3 | |
| 31 | 23 | ) | |
| 24 | + from git.odict import OrderedDict | ||
| 25 | + from git.util import LockFile | ||
| 26 | + | ||
| 27 | + import os.path as osp | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + try: | ||
| 31 | + import ConfigParser as cp | ||
| 32 | + except ImportError: | ||
| 33 | + # PY3 | ||
| 34 | + import configparser as cp | ||
| 35 | + | ||
| 32 | 36 | ||
| 33 | 37 | __all__ = ('GitConfigParser', 'SectionConstraint') | |
| 34 | 38 | ||
@@ -408,15 +412,15 @@ def read(self): | |||
| 408 | 412 | if self._has_includes(): | |
| 409 | 413 | for _, include_path in self.items('include'): | |
| 410 | 414 | if include_path.startswith('~'): | |
| 411 | - include_path = os.path.expanduser(include_path) | ||
| 412 | - if not os.path.isabs(include_path): | ||
| 415 | + include_path = osp.expanduser(include_path) | ||
| 416 | + if not osp.isabs(include_path): | ||
| 413 | 417 | if not file_ok: | |
| 414 | 418 | continue | |
| 415 | 419 | # end ignore relative paths if we don't know the configuration file path | |
| 416 | - assert os.path.isabs(file_path), "Need absolute paths to be sure our cycle checks will work" | ||
| 417 | - include_path = os.path.join(os.path.dirname(file_path), include_path) | ||
| 420 | + assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work" | ||
| 421 | + include_path = osp.join(osp.dirname(file_path), include_path) | ||
| 418 | 422 | # end make include path absolute | |
| 419 | - include_path = os.path.normpath(include_path) | ||
| 423 | + include_path = osp.normpath(include_path) | ||
| 420 | 424 | if include_path in seen or not os.access(include_path, os.R_OK): | |
| 421 | 425 | continue | |
| 422 | 426 | seen.add(include_path) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,53 +3,36 @@ | |||
| 3 | 3 | # | |
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | - import tempfile | ||
| 7 | - import os | ||
| 8 | - import sys | ||
| 9 | - import subprocess | ||
| 10 | 6 | import glob | |
| 11 | 7 | from io import BytesIO | |
| 12 | - | ||
| 8 | + import os | ||
| 13 | 9 | from stat import S_ISLNK | |
| 10 | + import subprocess | ||
| 11 | + import sys | ||
| 12 | + import tempfile | ||
| 14 | 13 | ||
| 15 | - from .typ import ( | ||
| 16 | - BaseIndexEntry, | ||
| 17 | - IndexEntry, | ||
| 18 | - ) | ||
| 19 | - | ||
| 20 | - from .util import ( | ||
| 21 | - TemporaryFileSwap, | ||
| 22 | - post_clear_cache, | ||
| 23 | - default_index, | ||
| 24 | - git_working_dir | ||
| 14 | + from git.compat import ( | ||
| 15 | + izip, | ||
| 16 | + xrange, | ||
| 17 | + string_types, | ||
| 18 | + force_bytes, | ||
| 19 | + defenc, | ||
| 20 | + mviter, | ||
| 21 | + is_win | ||
| 25 | 22 | ) | |
| 26 | - | ||
| 27 | - import git.diff as diff | ||
| 28 | 23 | from git.exc import ( | |
| 29 | 24 | GitCommandError, | |
| 30 | 25 | CheckoutError, | |
| 31 | 26 | InvalidGitRepositoryError | |
| 32 | 27 | ) | |
| 33 | - | ||
| 34 | 28 | from git.objects import ( | |
| 35 | 29 | Blob, | |
| 36 | 30 | Submodule, | |
| 37 | 31 | Tree, | |
| 38 | 32 | Object, | |
| 39 | 33 | Commit, | |
| 40 | 34 | ) | |
| 41 | - | ||
| 42 | 35 | from git.objects.util import Serializable | |
| 43 | - from git.compat import ( | ||
| 44 | - izip, | ||
| 45 | - xrange, | ||
| 46 | - string_types, | ||
| 47 | - force_bytes, | ||
| 48 | - defenc, | ||
| 49 | - mviter, | ||
| 50 | - is_win | ||
| 51 | - ) | ||
| 52 | - | ||
| 53 | 36 | from git.util import ( | |
| 54 | 37 | LazyMixin, | |
| 55 | 38 | LockedFD, | |
@@ -58,6 +41,12 @@ | |||
| 58 | 41 | to_native_path_linux, | |
| 59 | 42 | unbare_repo | |
| 60 | 43 | ) | |
| 44 | + from gitdb.base import IStream | ||
| 45 | + from gitdb.db import MemoryDB | ||
| 46 | + from gitdb.util import to_bin_sha | ||
| 47 | + | ||
| 48 | + import git.diff as diff | ||
| 49 | + import os.path as osp | ||
| 61 | 50 | ||
| 62 | 51 | from .fun import ( | |
| 63 | 52 | entry_key, | |
@@ -69,10 +58,17 @@ | |||
| 69 | 58 | S_IFGITLINK, | |
| 70 | 59 | run_commit_hook | |
| 71 | 60 | ) | |
| 61 | + from .typ import ( | ||
| 62 | + BaseIndexEntry, | ||
| 63 | + IndexEntry, | ||
| 64 | + ) | ||
| 65 | + from .util import ( | ||
| 66 | + TemporaryFileSwap, | ||
| 67 | + post_clear_cache, | ||
| 68 | + default_index, | ||
| 69 | + git_working_dir | ||
| 70 | + ) | ||
| 72 | 71 | ||
| 73 | - from gitdb.base import IStream | ||
| 74 | - from gitdb.db import MemoryDB | ||
| 75 | - from gitdb.util import to_bin_sha | ||
| 76 | 72 | ||
| 77 | 73 | __all__ = ('IndexFile', 'CheckoutError') | |
| 78 | 74 | ||
@@ -354,7 +350,7 @@ def from_tree(cls, repo, *treeish, **kwargs): | |||
| 354 | 350 | index.entries # force it to read the file as we will delete the temp-file | |
| 355 | 351 | del(index_handler) # release as soon as possible | |
| 356 | 352 | finally: | |
| 357 | - if os.path.exists(tmp_index): | ||
| 353 | + if osp.exists(tmp_index): | ||
| 358 | 354 | os.remove(tmp_index) | |
| 359 | 355 | # END index merge handling | |
| 360 | 356 | ||
@@ -374,8 +370,8 @@ def raise_exc(e): | |||
| 374 | 370 | rs = r + os.sep | |
| 375 | 371 | for path in paths: | |
| 376 | 372 | abs_path = path | |
| 377 | - if not os.path.isabs(abs_path): | ||
| 378 | - abs_path = os.path.join(r, path) | ||
| 373 | + if not osp.isabs(abs_path): | ||
| 374 | + abs_path = osp.join(r, path) | ||
| 379 | 375 | # END make absolute path | |
| 380 | 376 | ||
| 381 | 377 | try: | |
@@ -407,7 +403,7 @@ def raise_exc(e): | |||
| 407 | 403 | for root, dirs, files in os.walk(abs_path, onerror=raise_exc): # @UnusedVariable | |
| 408 | 404 | for rela_file in files: | |
| 409 | 405 | # add relative paths only | |
| 410 | - yield os.path.join(root.replace(rs, ''), rela_file) | ||
| 406 | + yield osp.join(root.replace(rs, ''), rela_file) | ||
| 411 | 407 | # END for each file in subdir | |
| 412 | 408 | # END for each subdirectory | |
| 413 | 409 | except OSError: | |
@@ -569,7 +565,7 @@ def _process_diff_args(self, args): | |||
| 569 | 565 | def _to_relative_path(self, path): | |
| 570 | 566 | """:return: Version of path relative to our git directory or raise ValueError | |
| 571 | 567 | if it is not within our git direcotory""" | |
| 572 | - if not os.path.isabs(path): | ||
| 568 | + if not osp.isabs(path): | ||
| 573 | 569 | return path | |
| 574 | 570 | if self.repo.bare: | |
| 575 | 571 | raise InvalidGitRepositoryError("require non-bare repository") | |
@@ -617,12 +613,12 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries): | |||
| 617 | 613 | entries_added = list() | |
| 618 | 614 | if path_rewriter: | |
| 619 | 615 | for path in paths: | |
| 620 | - if os.path.isabs(path): | ||
| 616 | + if osp.isabs(path): | ||
| 621 | 617 | abspath = path | |
| 622 | 618 | gitrelative_path = path[len(self.repo.working_tree_dir) + 1:] | |
| 623 | 619 | else: | |
| 624 | 620 | gitrelative_path = path | |
| 625 | - abspath = os.path.join(self.repo.working_tree_dir, gitrelative_path) | ||
| 621 | + abspath = osp.join(self.repo.working_tree_dir, gitrelative_path) | ||
| 626 | 622 | # end obtain relative and absolute paths | |
| 627 | 623 | ||
| 628 | 624 | blob = Blob(self.repo, Blob.NULL_BIN_SHA, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,8 @@ | |||
| 1 | 1 | # Contains standalone functions to accompany the index implementation and make it | |
| 2 | 2 | # more versatile | |
| 3 | 3 | # NOTE: Autodoc hates it if this is a docstring | |
| 4 | + from io import BytesIO | ||
| 5 | + import os | ||
| 4 | 6 | from stat import ( | |
| 5 | 7 | S_IFDIR, | |
| 6 | 8 | S_IFLNK, | |
@@ -9,13 +11,18 @@ | |||
| 9 | 11 | S_IFMT, | |
| 10 | 12 | S_IFREG, | |
| 11 | 13 | ) | |
| 12 | - | ||
| 13 | - from io import BytesIO | ||
| 14 | - import os | ||
| 15 | 14 | import subprocess | |
| 16 | 15 | ||
| 17 | - from git.util import IndexFileSHA1Writer, finalize_process | ||
| 18 | 16 | from git.cmd import PROC_CREATIONFLAGS, handle_process_output | |
| 17 | + from git.compat import ( | ||
| 18 | + PY3, | ||
| 19 | + defenc, | ||
| 20 | + force_text, | ||
| 21 | + force_bytes, | ||
| 22 | + is_posix, | ||
| 23 | + safe_encode, | ||
| 24 | + safe_decode, | ||
| 25 | + ) | ||
| 19 | 26 | from git.exc import ( | |
| 20 | 27 | UnmergedEntriesError, | |
| 21 | 28 | HookExecutionError | |
@@ -25,30 +32,23 @@ | |||
| 25 | 32 | traverse_tree_recursive, | |
| 26 | 33 | traverse_trees_recursive | |
| 27 | 34 | ) | |
| 35 | + from git.util import IndexFileSHA1Writer, finalize_process | ||
| 36 | + from gitdb.base import IStream | ||
| 37 | + from gitdb.typ import str_tree_type | ||
| 38 | + | ||
| 39 | + import os.path as osp | ||
| 28 | 40 | ||
| 29 | 41 | from .typ import ( | |
| 30 | 42 | BaseIndexEntry, | |
| 31 | 43 | IndexEntry, | |
| 32 | 44 | CE_NAMEMASK, | |
| 33 | 45 | CE_STAGESHIFT | |
| 34 | 46 | ) | |
| 35 | - | ||
| 36 | 47 | from .util import ( | |
| 37 | 48 | pack, | |
| 38 | 49 | unpack | |
| 39 | 50 | ) | |
| 40 | 51 | ||
| 41 | - from gitdb.base import IStream | ||
| 42 | - from gitdb.typ import str_tree_type | ||
| 43 | - from git.compat import ( | ||
| 44 | - PY3, | ||
| 45 | - defenc, | ||
| 46 | - force_text, | ||
| 47 | - force_bytes, | ||
| 48 | - is_posix, | ||
| 49 | - safe_encode, | ||
| 50 | - safe_decode, | ||
| 51 | - ) | ||
| 52 | 52 | ||
| 53 | 53 | S_IFGITLINK = S_IFLNK | S_IFDIR # a submodule | |
| 54 | 54 | CE_NAMEMASK_INV = ~CE_NAMEMASK | |
@@ -59,7 +59,7 @@ | |||
| 59 | 59 | ||
| 60 | 60 | def hook_path(name, git_dir): | |
| 61 | 61 | """:return: path to the given named hook in the given git repository directory""" | |
| 62 | - return os.path.join(git_dir, 'hooks', name) | ||
| 62 | + return osp.join(git_dir, 'hooks', name) | ||
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | 65 | def run_commit_hook(name, index): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,14 @@ | |||
| 1 | 1 | """Module containing index utilities""" | |
| 2 | + from functools import wraps | ||
| 3 | + import os | ||
| 2 | 4 | import struct | |
| 3 | 5 | import tempfile | |
| 4 | - import os | ||
| 5 | - | ||
| 6 | - from functools import wraps | ||
| 7 | 6 | ||
| 8 | 7 | from git.compat import is_win | |
| 9 | 8 | ||
| 9 | + import os.path as osp | ||
| 10 | + | ||
| 11 | + | ||
| 10 | 12 | __all__ = ('TemporaryFileSwap', 'post_clear_cache', 'default_index', 'git_working_dir') | |
| 11 | 13 | ||
| 12 | 14 | #{ Aliases | |
@@ -32,8 +34,8 @@ def __init__(self, file_path): | |||
| 32 | 34 | pass | |
| 33 | 35 | ||
| 34 | 36 | def __del__(self): | |
| 35 | - if os.path.isfile(self.tmp_file_path): | ||
| 36 | - if is_win and os.path.exists(self.file_path): | ||
| 37 | + if osp.isfile(self.tmp_file_path): | ||
| 38 | + if is_win and osp.exists(self.file_path): | ||
| 37 | 39 | os.remove(self.file_path) | |
| 38 | 40 | os.rename(self.tmp_file_path, self.file_path) | |
| 39 | 41 | # END temp file exists | |
| Back | FazBrowse Home | New Git URL |
0 commit comments