Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0210e39

Browse files
committed
src: import os.path as osp
1 parenta2d248b commit0210e39

24 files changed

+361
-332
lines changed

‎git/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
# flake8: noqa
77
#@PydevCodeAnalysisIgnore
8+
importinspect
89
importos
910
importsys
10-
importinspect
11+
12+
importos.pathasosp
13+
1114

1215
__version__='git'
1316

@@ -16,7 +19,7 @@
1619
def_init_externals():
1720
"""Initialize external projects by putting them into the path"""
1821
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'))
2023

2124
try:
2225
importgitdb

‎git/config.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@
66
"""Module containing module parser implementation able to properly read and write
77
configuration files"""
88

9-
importre
10-
try:
11-
importConfigParserascp
12-
exceptImportError:
13-
# PY3
14-
importconfigparserascp
9+
importabc
10+
fromfunctoolsimportwraps
1511
importinspect
1612
importlogging
17-
importabc
1813
importos
14+
importre
1915

20-
fromfunctoolsimportwraps
21-
22-
fromgit.odictimportOrderedDict
23-
fromgit.utilimportLockFile
2416
fromgit.compatimport (
2517
string_types,
2618
FileType,
@@ -29,6 +21,18 @@
2921
with_metaclass,
3022
PY3
3123
)
24+
fromgit.odictimportOrderedDict
25+
fromgit.utilimportLockFile
26+
27+
importos.pathasosp
28+
29+
30+
try:
31+
importConfigParserascp
32+
exceptImportError:
33+
# PY3
34+
importconfigparserascp
35+
3236

3337
__all__= ('GitConfigParser','SectionConstraint')
3438

@@ -408,15 +412,15 @@ def read(self):
408412
ifself._has_includes():
409413
for_,include_pathinself.items('include'):
410414
ifinclude_path.startswith('~'):
411-
include_path=os.path.expanduser(include_path)
412-
ifnotos.path.isabs(include_path):
415+
include_path=osp.expanduser(include_path)
416+
ifnotosp.isabs(include_path):
413417
ifnotfile_ok:
414418
continue
415419
# end ignore relative paths if we don't know the configuration file path
416-
assertos.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+
assertosp.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)
418422
# end make include path absolute
419-
include_path=os.path.normpath(include_path)
423+
include_path=osp.normpath(include_path)
420424
ifinclude_pathinseenornotos.access(include_path,os.R_OK):
421425
continue
422426
seen.add(include_path)

‎git/index/base.py

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,36 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
6-
importtempfile
7-
importos
8-
importsys
9-
importsubprocess
106
importglob
117
fromioimportBytesIO
12-
8+
importos
139
fromstatimportS_ISLNK
10+
importsubprocess
11+
importsys
12+
importtempfile
1413

15-
from .typimport (
16-
BaseIndexEntry,
17-
IndexEntry,
18-
)
19-
20-
from .utilimport (
21-
TemporaryFileSwap,
22-
post_clear_cache,
23-
default_index,
24-
git_working_dir
14+
fromgit.compatimport (
15+
izip,
16+
xrange,
17+
string_types,
18+
force_bytes,
19+
defenc,
20+
mviter,
21+
is_win
2522
)
26-
27-
importgit.diffasdiff
2823
fromgit.excimport (
2924
GitCommandError,
3025
CheckoutError,
3126
InvalidGitRepositoryError
3227
)
33-
3428
fromgit.objectsimport (
3529
Blob,
3630
Submodule,
3731
Tree,
3832
Object,
3933
Commit,
4034
)
41-
4235
fromgit.objects.utilimportSerializable
43-
fromgit.compatimport (
44-
izip,
45-
xrange,
46-
string_types,
47-
force_bytes,
48-
defenc,
49-
mviter,
50-
is_win
51-
)
52-
5336
fromgit.utilimport (
5437
LazyMixin,
5538
LockedFD,
@@ -58,6 +41,12 @@
5841
to_native_path_linux,
5942
unbare_repo
6043
)
44+
fromgitdb.baseimportIStream
45+
fromgitdb.dbimportMemoryDB
46+
fromgitdb.utilimportto_bin_sha
47+
48+
importgit.diffasdiff
49+
importos.pathasosp
6150

6251
from .funimport (
6352
entry_key,
@@ -69,10 +58,17 @@
6958
S_IFGITLINK,
7059
run_commit_hook
7160
)
61+
from .typimport (
62+
BaseIndexEntry,
63+
IndexEntry,
64+
)
65+
from .utilimport (
66+
TemporaryFileSwap,
67+
post_clear_cache,
68+
default_index,
69+
git_working_dir
70+
)
7271

73-
fromgitdb.baseimportIStream
74-
fromgitdb.dbimportMemoryDB
75-
fromgitdb.utilimportto_bin_sha
7672

7773
__all__= ('IndexFile','CheckoutError')
7874

@@ -354,7 +350,7 @@ def from_tree(cls, repo, *treeish, **kwargs):
354350
index.entries# force it to read the file as we will delete the temp-file
355351
del(index_handler)# release as soon as possible
356352
finally:
357-
ifos.path.exists(tmp_index):
353+
ifosp.exists(tmp_index):
358354
os.remove(tmp_index)
359355
# END index merge handling
360356

@@ -374,8 +370,8 @@ def raise_exc(e):
374370
rs=r+os.sep
375371
forpathinpaths:
376372
abs_path=path
377-
ifnotos.path.isabs(abs_path):
378-
abs_path=os.path.join(r,path)
373+
ifnotosp.isabs(abs_path):
374+
abs_path=osp.join(r,path)
379375
# END make absolute path
380376

381377
try:
@@ -407,7 +403,7 @@ def raise_exc(e):
407403
forroot,dirs,filesinos.walk(abs_path,onerror=raise_exc):# @UnusedVariable
408404
forrela_fileinfiles:
409405
# add relative paths only
410-
yieldos.path.join(root.replace(rs,''),rela_file)
406+
yieldosp.join(root.replace(rs,''),rela_file)
411407
# END for each file in subdir
412408
# END for each subdirectory
413409
exceptOSError:
@@ -569,7 +565,7 @@ def _process_diff_args(self, args):
569565
def_to_relative_path(self,path):
570566
""":return: Version of path relative to our git directory or raise ValueError
571567
if it is not within our git direcotory"""
572-
ifnotos.path.isabs(path):
568+
ifnotosp.isabs(path):
573569
returnpath
574570
ifself.repo.bare:
575571
raiseInvalidGitRepositoryError("require non-bare repository")
@@ -617,12 +613,12 @@ def _entries_for_paths(self, paths, path_rewriter, fprogress, entries):
617613
entries_added=list()
618614
ifpath_rewriter:
619615
forpathinpaths:
620-
ifos.path.isabs(path):
616+
ifosp.isabs(path):
621617
abspath=path
622618
gitrelative_path=path[len(self.repo.working_tree_dir)+1:]
623619
else:
624620
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)
626622
# end obtain relative and absolute paths
627623

628624
blob=Blob(self.repo,Blob.NULL_BIN_SHA,

‎git/index/fun.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Contains standalone functions to accompany the index implementation and make it
22
# more versatile
33
# NOTE: Autodoc hates it if this is a docstring
4+
fromioimportBytesIO
5+
importos
46
fromstatimport (
57
S_IFDIR,
68
S_IFLNK,
@@ -9,13 +11,18 @@
911
S_IFMT,
1012
S_IFREG,
1113
)
12-
13-
fromioimportBytesIO
14-
importos
1514
importsubprocess
1615

17-
fromgit.utilimportIndexFileSHA1Writer,finalize_process
1816
fromgit.cmdimportPROC_CREATIONFLAGS,handle_process_output
17+
fromgit.compatimport (
18+
PY3,
19+
defenc,
20+
force_text,
21+
force_bytes,
22+
is_posix,
23+
safe_encode,
24+
safe_decode,
25+
)
1926
fromgit.excimport (
2027
UnmergedEntriesError,
2128
HookExecutionError
@@ -25,30 +32,23 @@
2532
traverse_tree_recursive,
2633
traverse_trees_recursive
2734
)
35+
fromgit.utilimportIndexFileSHA1Writer,finalize_process
36+
fromgitdb.baseimportIStream
37+
fromgitdb.typimportstr_tree_type
38+
39+
importos.pathasosp
2840

2941
from .typimport (
3042
BaseIndexEntry,
3143
IndexEntry,
3244
CE_NAMEMASK,
3345
CE_STAGESHIFT
3446
)
35-
3647
from .utilimport (
3748
pack,
3849
unpack
3950
)
4051

41-
fromgitdb.baseimportIStream
42-
fromgitdb.typimportstr_tree_type
43-
fromgit.compatimport (
44-
PY3,
45-
defenc,
46-
force_text,
47-
force_bytes,
48-
is_posix,
49-
safe_encode,
50-
safe_decode,
51-
)
5252

5353
S_IFGITLINK=S_IFLNK|S_IFDIR# a submodule
5454
CE_NAMEMASK_INV=~CE_NAMEMASK
@@ -59,7 +59,7 @@
5959

6060
defhook_path(name,git_dir):
6161
""":return: path to the given named hook in the given git repository directory"""
62-
returnos.path.join(git_dir,'hooks',name)
62+
returnosp.join(git_dir,'hooks',name)
6363

6464

6565
defrun_commit_hook(name,index):

‎git/index/util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""Module containing index utilities"""
2+
fromfunctoolsimportwraps
3+
importos
24
importstruct
35
importtempfile
4-
importos
5-
6-
fromfunctoolsimportwraps
76

87
fromgit.compatimportis_win
98

9+
importos.pathasosp
10+
11+
1012
__all__= ('TemporaryFileSwap','post_clear_cache','default_index','git_working_dir')
1113

1214
#{ Aliases
@@ -32,8 +34,8 @@ def __init__(self, file_path):
3234
pass
3335

3436
def__del__(self):
35-
ifos.path.isfile(self.tmp_file_path):
36-
ifis_winandos.path.exists(self.file_path):
37+
ifosp.isfile(self.tmp_file_path):
38+
ifis_winandosp.exists(self.file_path):
3739
os.remove(self.file_path)
3840
os.rename(self.tmp_file_path,self.file_path)
3941
# END temp file exists

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp