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

Commit82b6794

Browse files
committed
fix further
1 parent88ceb63 commit82b6794

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-
defgetFileProperties(fname):
75-
"""Read all properties of the given file return them as a dictionary."""
76-
importwin32api
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-
forprop_nameinprop_names
93-
}
94-
except:
95-
pass
96-
97-
returnprops
74+
defsum_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+
iflen(summary)<=max_length:
78+
returnsummary
79+
ifstop_atandstop_atinsummary[:max_length]:
80+
returnsummary[:summary.rfind(stop_at,0,max_length)]+stop_at.strip()
81+
returnsummary[:max_length].strip()
9882

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp