@@ -140,7 +140,7 @@ def ordering(game: str) -> tuple:
140140 header = row_temp .format ('Game' , 'Base' , 'Point' , 'Brush' )
141141 print ('Counted entities.' )
142142
143- with open (report_dir / 'counts.txt' , 'w' ) as f :
143+ with open (report_dir / 'counts.txt' , 'w' , encoding = 'utf8' ) as f :
144144 f .write (header )
145145 print ('-' * len (header ), file = f )
146146
@@ -153,12 +153,12 @@ def ordering(game: str) -> tuple:
153153 ))
154154
155155 f .write ('\n \n Bases:\n ' )
156- for base , count in sorted (base_uses .items (), key = lambda x : (len (x [1 ]), x [0 ])):
156+ for base , used in sorted (base_uses .items (), key = lambda x : (len (x [1 ]), x [0 ])):
157157 ent = fgd [base ]
158158 if ent .type is EntityTypes .BASE and (
159159 ent .keyvalues or ent .outputs or ent .inputs
160160 ):
161- f .write (f'{ base } { len (count )} { count if len (count ) == 1 else '...' } \n ' )
161+ f .write (f'{ base } { len (used )} { used if len (used ) == 1 else '...' } \n ' )
162162
163163 for kind_name , count_map in (
164164 ('keyvalues' , kv_counts ),
@@ -168,7 +168,7 @@ def ordering(game: str) -> tuple:
168168 ('desc' , desc_counts )
169169 ):
170170 count = 0
171- with open (report_dir / f'duplicate_{ kind_name } .txt' , 'w' ) as f :
171+ with open (report_dir / f'duplicate_{ kind_name } .txt' , 'w' , encoding = 'utf8' ) as f :
172172 for key , info in sorted (count_map .items (), key = lambda v : len (v [1 ]), reverse = True ):
173173 if len (info ) <= 2 :
174174 continue
@@ -215,14 +215,14 @@ def report_factories(
215215 missing = dump_classes - defined_classes
216216 all_classes |= defined_classes
217217 used_classes |= dump_classes
218- with open (report_dir / f'factories_{ game .lower ()} .txt' , 'w' ) as rep_f :
218+ with open (report_dir / f'factories_{ game .lower ()} .txt' , 'w' , encoding = 'utf8' ) as rep_f :
219219 rep_f .write ('Extraneous definitions: \n ' )
220220 pprint (sorted (extra ), rep_f , compact = True )
221221 rep_f .write ('\n \n Missing definitions: \n ' )
222222 pprint (sorted (missing ), rep_f , compact = True )
223223
224224 unused = all_classes - used_classes
225- with open (report_dir / f 'factories_unused.txt' , 'w' ) as rep_f :
225+ with open (report_dir / 'factories_unused.txt' , 'w' , encoding = 'utf8 ' ) as rep_f :
226226 pprint (sorted (unused ), rep_f , compact = True )
227227 print (f'Checked entity factories. { len (unused )} totally unused.' )
228228
@@ -248,7 +248,7 @@ def report_undefined_resources(fgd: FGD, report_dir: Path) -> None:
248248 class_res [frozenset (appliesto )].append (ent .classname )
249249 missing_count += 1
250250
251- with open (report_dir / 'undefined_resources.txt' , 'w' ) as f :
251+ with open (report_dir / 'undefined_resources.txt' , 'w' , encoding = 'utf8' ) as f :
252252 for tags_list , classnames in class_res .items ():
253253 classnames .sort ()
254254 f .write (f'{ ', ' .join (tags_list )} = { pformat (classnames , compact = True )} \n ' )
@@ -271,7 +271,7 @@ def report(msg: str) -> None:
271271 f .write (f'Ent { ent .classname } res error: { msg } \n ' )
272272 res_ctx = ResourceCtx (fgd = fgd )
273273
274- with open (report_dir / 'missing_resources.txt' , 'w' ) as f :
274+ with open (report_dir / 'missing_resources.txt' , 'w' , encoding = 'utf8' ) as f :
275275 for ent in fgd .entities .values ():
276276 # Get them all, checking validity in the process.
277277 for _ in ent .get_resources (res_ctx , ent = None , on_error = report ):
@@ -313,7 +313,7 @@ def check_ent_sprites(used: dict[str, list[str]], f: TextIO, ent: EntityDef) ->
313313def report_helper_reuse (fgd : FGD , report_dir : Path ) -> None :
314314 """Report missing or reused helpers."""
315315 mdl_or_sprites : dict [str , list [str ]] = defaultdict (list )
316- with open (report_dir / 'helper_reuse.txt' , 'w' ) as f :
316+ with open (report_dir / 'helper_reuse.txt' , 'w' , encoding = 'utf8' ) as f :
317317 for ent in fgd :
318318 if ent .type is not EntityTypes .BASE and ent .type is not EntityTypes .BRUSH and not ent .is_alias :
319319 check_ent_sprites (mdl_or_sprites , f , ent )
@@ -337,13 +337,13 @@ def check_parents(done: set[EntityDef], repeat: set[EntityDef], ent: EntityDef)
337337 assert isinstance (base , EntityDef ), (ent , ent .bases )
338338 check_parents (done , repeat , base )
339339
340- with open (report_dir / 'repeated_bases.txt' , 'w' ) as f :
340+ with open (report_dir / 'repeated_bases.txt' , 'w' , encoding = 'utf8' ) as f :
341341 for ent in fgd :
342342 done : set [EntityDef ] = set ()
343343 repeat : set [EntityDef ] = set ()
344344 check_parents (done , repeat , ent )
345345 if repeat :
346- print (
346+ f . write (
347347 f'Repeated bases: { ent .classname } = '
348348 f'{ [ent .classname for ent in repeat ]} , '
349349 f'all={ [ent .classname for ent in done ]} '
0 commit comments