MCPcopy Create free account
hub / github.com/dobin/SuperMega / get_logfiles

Function get_logfiles

app/views_project.py:345–407  ·  view source on GitHub ↗
(directory)

Source from the content-addressed store, hash-verified

343
344
345def get_logfiles(directory):
346 log_files = []
347 id = 0
348 asm_a = "" # for diff
349 asm_b = ""
350 for file in os.listdir(f"{directory}/"):
351 if file.startswith("."):
352 continue
353 if not file.startswith("log-"):
354 continue
355 if file.endswith(".bin"):
356 continue
357
358 with open(os.path.join(f"{directory}/", file), "r") as f:
359 data = f.read()
360 if 'main_c' in file:
361 data = highlight(data, CLexer(), HtmlFormatter(full=False))
362 elif '_asm_' in file:
363 # handle special cases
364 if '_orig' in file:
365 asm_a = data
366 if '_updated' in file:
367 asm_b = data
368 data = highlight(data, NasmLexer(), HtmlFormatter(full=False))
369 elif '.ascii' in file:
370 data = conv.convert(data, full=False)
371 elif '.txt' in file:
372 continue # skip it
373 elif '.hex' in file:
374 continue # skip it
375 #data = escape(data)
376 #data = highlight(data, HexdumpLexer(), HtmlFormatter(full=False))
377 elif '.log' in file:
378 data = conv.convert(data, full=False)
379 else:
380 data = data
381
382 entry = {
383 "name": file,
384 "id": str(id),
385 "content": data,
386 }
387 log_files.append(entry)
388 id += 1
389
390 # more
391 if asm_a != "" and asm_b != "":
392 # do the diff from the content of the two files
393 a = asm_a.splitlines()
394 b = asm_b.splitlines()
395 diff_generator = difflib.unified_diff(a, b, lineterm='')
396 diff_string = '\n'.join(diff_generator)
397 diff_l = highlight(diff_string, DiffLexer(), HtmlFormatter(full=False))
398 entry = {
399 "name": "Summary: ASM Diff".format(),
400 "id": str(id),
401 "content": diff_l,
402 }

Callers 1

projectFunction · 0.85

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected