Skip to content

Commit 7d2b9aa

Browse files
committed
【完善】:增加代码易读性
1 parent 67e8dac commit 7d2b9aa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

archive.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
3535
pkg_ver = pkg['ver']
3636
flag = True
3737

38-
os_type = False
38+
iswindows = False
3939

4040
if platform.system() == "Windows":
41-
os_type = True
41+
iswindows = True
4242

4343
if ".tar.bz2" in archive_fn:
4444
arch = tarfile.open(archive_fn, "r:bz2")
4545
for tarinfo in arch:
4646
arch.extract(tarinfo, path)
4747
a = tarinfo.name
4848
if not os.path.isdir(os.path.join(path, a)):
49-
if os_type:
49+
if iswindows:
5050
right_path = a.replace('/', '\\')
5151
else:
5252
right_path = a
@@ -60,7 +60,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
6060
arch.extract(tarinfo, path)
6161
a = tarinfo.name
6262
if not os.path.isdir(os.path.join(path, a)):
63-
if os_type:
63+
if iswindows:
6464
right_path = a.replace('/', '\\')
6565
else:
6666
right_path = a
@@ -73,7 +73,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
7373
for item in arch.namelist():
7474
arch.extract(item, path)
7575
if not os.path.isdir(os.path.join(path, item)):
76-
if os_type:
76+
if iswindows:
7777
right_path = item.replace('/', '\\')
7878
else:
7979
right_path = item
@@ -92,7 +92,7 @@ def unpack(archive_fn, path, pkg, pkgs_name_in_json):
9292
change_dirname = pkgs_name_in_json + '-' + pkg_ver
9393

9494
if os.path.isdir(os.path.join(path, change_dirname)):
95-
if os_type:
95+
if iswindows:
9696
cmd = 'rd /s /q ' + os.path.join(path, change_dirname)
9797
os.system(cmd)
9898
else:

0 commit comments

Comments
 (0)