Skip to content

Commit 82b6794

Browse files
committed
fix further
1 parent 88ceb63 commit 82b6794

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

winpython/utils.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,14 @@ def onerror(function, path, excinfo):
7171
else:
7272
raise
7373

74-
def getFileProperties(fname):
75-
"""Read all properties of the given file return them as a dictionary."""
76-
import win32api
77-
prop_names = ('ProductName', 'ProductVersion', 'FileDescription', 'FileVersion')
78-
props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None}
79-
80-
try:
81-
fixed_info = win32api.GetFileVersionInfo(fname, '\\')
82-
props['FixedFileInfo'] = fixed_info
83-
props['FileVersion'] = "{}.{}.{}.{}".format(
84-
fixed_info['FileVersionMS'] // 65536,
85-
fixed_info['FileVersionMS'] % 65536,
86-
fixed_info['FileVersionLS'] // 65536,
87-
fixed_info['FileVersionLS'] % 65536
88-
)
89-
lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]
90-
props['StringFileInfo'] = {
91-
prop_name: win32api.GetFileVersionInfo(fname, f'\\StringFileInfo\\{lang:04X}{codepage:04X}\\{prop_name}')
92-
for prop_name in prop_names
93-
}
94-
except:
95-
pass
96-
97-
return props
74+
def sum_up(text: str, max_length: int = 144, stop_at: str = ". ") -> str:
75+
"""Summarize text to fit within max_length, ending at last complete sentence."""
76+
summary = (text + os.linesep).splitlines()[0].strip()
77+
if len(summary) <= max_length:
78+
return summary
79+
if stop_at and stop_at in summary[:max_length]:
80+
return summary[:summary.rfind(stop_at, 0, max_length)] + stop_at.strip()
81+
return summary[:max_length].strip()
9882

9983
def get_special_folder_path(path_name):
10084
"""Return special folder path."""

0 commit comments

Comments
 (0)