@@ -71,30 +71,14 @@ def onerror(function, path, excinfo):
71
71
else :
72
72
raise
73
73
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 ()
98
82
99
83
def get_special_folder_path (path_name ):
100
84
"""Return special folder path."""