8000 Merge pull request #1407 from stonebig/master · LeeXyan/winpython@f9a4077 · GitHub
[go: up one dir, main page]

Skip to content

Commit f9a4077

Browse files
authored
Merge pull request winpython#1407 from stonebig/master
modernise style
2 parents 87c30f0 + d2ed0d9 commit f9a4077

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

winpython/utils.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ def onerror(function, path, excinfo):
6363
raise
6464

6565

66-
#==============================================================================
67-
# https://stackoverflow.com/questions/580924/how-to-access-a-files-properties-on-windows
6866
def getFileProperties(fname):
69-
#==============================================================================
7067
"""
7168
Read all properties of the given file return them as a dictionary.
7269
"""
70+
# from https://stackoverflow.com/questions/580924/how-to-access-a-files-properties-on-windows
7371
import win32api
7472
propNames = ('Comments', 'InternalName', 'ProductName',
7573
'CompanyName', 'LegalCopyright', 'ProductVersion',
@@ -104,9 +102,6 @@ def getFileProperties(fname):
104102
pass
105103

106104
return props
107-
# =============================================================================
108-
# Shortcuts, start menu
109-
# =============================================================================
110105

111106

112107
def get_special_folder_path(path_name):
@@ -215,11 +210,6 @@ def create_shortcut(
215210
pass
216211

217212

218-
# =============================================================================
219-
# Misc.
220-
# =============================================================================
221-
222-
223213
def print_box(text):
224214
"""Print text in a box"""
225215
line0 = "+" + ("-" * (len(text) + 2)) + "+"
@@ -237,11 +227,6 @@ def is_python_distribution(path):
237227
return has_exec and has_site
238228

239229

240-
# =============================================================================
241-
# Shell, Python queries
242-
# =============================================================================
243-
244-
245230
def decode_fs_string(string):
246231
"""Convert string from file system charset to unicode"""
247232
charset = sys.getfilesystemencoding()
@@ -365,13 +350,10 @@ def get_python_long_version(path):
365350
return ver
366351

367352

368-
# =============================================================================
369-
# Patch chebang line (courtesy of Christoph Gohlke)
370-
# =============================================================================
371353
def patch_shebang_line(
372354
fname, pad=b' ', to_movable=True, targetdir=""
373355
):
374-
"""Remove absolute path to python.exe in shebang lines, or re-add it"""
356+
"""Remove absolute path to python.exe in shebang lines in binary files, or re-add it"""
375357

376358
import re
377359
import sys
@@ -425,9 +407,6 @@ def patch_shebang_line(
425407
print("failed to patch", fname)
426408

427409

428-
# =============================================================================
429-
# Patch shebang line in .py files
430-
# =============================================================================
431410
def patch_shebang_line_py(
432411
fname, to_movable=True, targetdir=""
433412
):
@@ -455,9 +434,6 @@ def patch_shebang_line_py(
455434
print(line, end='')
456435

457436

458-
# =============================================================================
459-
# Guess encoding (shall rather be utf-8 per default)
460-
# =============================================================================
461437
def guess_encoding(csv_file):
462438
"""guess the encoding of the given file"""
463439
# UTF_8_BOM = "\xEF\xBB\xBF"
@@ -474,9 +450,7 @@ def guess_encoding(csv_file):
474450
except:
475451
return [locale.getdefaultlocale()[1], "utf-8"]
476452

477-
# =============================================================================
478-
# Patch sourcefile (instead of forking packages)
479-
# =============================================================================
453+
480454
def patch_sourcefile(
481455
fname, in_text, out_text, silent_mode=False
482456
):
@@ -502,9 +476,6 @@ def patch_sourcefile(
502476
fh.write(new_content)
503477

504478

505-
# =============================================================================
506-
# Patch sourcelines (instead of forking packages)
507-
# =============================================================================
508479
def patch_sourcelines(
509480
fname,
510481
in_line_start,
@@ -563,9 +534,6 @@ def patch_sourcelines(
563534
)
564535

565536

566-
# =============================================================================
567-
# Extract functions
568-
# =============================================================================
569537
def _create_temp_dir():
570538
"""Create a temporary directory and remove it at exit"""
571539
tmpdir = tempfile.mkdtemp(prefix='wppm_')

0 commit comments

Comments
 (0)
0