cr-proc 0.1.12__py3-none-any.whl → 0.1.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- code_recorder_processor/cli.py +52 -30
- {cr_proc-0.1.12.dist-info → cr_proc-0.1.13.dist-info}/METADATA +1 -1
- {cr_proc-0.1.12.dist-info → cr_proc-0.1.13.dist-info}/RECORD +5 -5
- {cr_proc-0.1.12.dist-info → cr_proc-0.1.13.dist-info}/WHEEL +1 -1
- {cr_proc-0.1.12.dist-info → cr_proc-0.1.13.dist-info}/entry_points.txt +0 -0
code_recorder_processor/cli.py
CHANGED
|
@@ -229,6 +229,7 @@ def find_submitted_file(
|
|
|
229
229
|
|
|
230
230
|
def process_single_file(
|
|
231
231
|
jsonl_path: Path,
|
|
232
|
+
json_data: tuple[dict[str, Any], ...],
|
|
232
233
|
template_data: str,
|
|
233
234
|
target_document: str | None,
|
|
234
235
|
time_limit: int | None,
|
|
@@ -241,7 +242,9 @@ def process_single_file(
|
|
|
241
242
|
Parameters
|
|
242
243
|
----------
|
|
243
244
|
jsonl_path : Path
|
|
244
|
-
Path to the JSONL file
|
|
245
|
+
Path to the JSONL file (used for error reporting and file matching)
|
|
246
|
+
json_data : tuple[dict[str, Any], ...]
|
|
247
|
+
Pre-loaded JSON events from the recording file
|
|
245
248
|
template_data : str
|
|
246
249
|
Template file content
|
|
247
250
|
target_document : str | None
|
|
@@ -258,11 +261,6 @@ def process_single_file(
|
|
|
258
261
|
tuple
|
|
259
262
|
(verified, reconstructed_code, suspicious_events, time_info, template_diff_text, doc_events, submitted_comparison)
|
|
260
263
|
"""
|
|
261
|
-
try:
|
|
262
|
-
json_data = load_jsonl(jsonl_path)
|
|
263
|
-
except (FileNotFoundError, ValueError, IOError) as e:
|
|
264
|
-
print(f"Error loading {jsonl_path}: {e}", file=sys.stderr)
|
|
265
|
-
return False, "", [], None, "", (), None
|
|
266
264
|
|
|
267
265
|
# Filter events for target document
|
|
268
266
|
doc_events = filter_events_by_document(json_data, target_document)
|
|
@@ -380,7 +378,8 @@ def write_reconstructed_file(
|
|
|
380
378
|
|
|
381
379
|
def handle_playback_mode(
|
|
382
380
|
jsonl_file: Path,
|
|
383
|
-
|
|
381
|
+
json_data: tuple[dict[str, Any], ...],
|
|
382
|
+
template_base: Path | None,
|
|
384
383
|
template_data: str,
|
|
385
384
|
document_override: str | None,
|
|
386
385
|
speed: float,
|
|
@@ -391,9 +390,11 @@ def handle_playback_mode(
|
|
|
391
390
|
Parameters
|
|
392
391
|
----------
|
|
393
392
|
jsonl_file : Path
|
|
394
|
-
Path to the recording file
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
Path to the recording file (for error reporting)
|
|
394
|
+
json_data : tuple[dict[str, Any], ...]
|
|
395
|
+
Pre-loaded JSON events from the recording file
|
|
396
|
+
template_base : Path | None
|
|
397
|
+
Path to the template file or directory
|
|
397
398
|
template_data : str
|
|
398
399
|
Template file content
|
|
399
400
|
document_override : str | None
|
|
@@ -407,9 +408,8 @@ def handle_playback_mode(
|
|
|
407
408
|
Exit code (0 for success, 1 for error)
|
|
408
409
|
"""
|
|
409
410
|
try:
|
|
410
|
-
json_data = load_jsonl(jsonl_file)
|
|
411
411
|
recorded_docs = get_recorded_documents(json_data)
|
|
412
|
-
target_document = resolve_document(recorded_docs,
|
|
412
|
+
target_document = resolve_document(recorded_docs, template_base, document_override)
|
|
413
413
|
|
|
414
414
|
if target_document:
|
|
415
415
|
playback_recording(json_data, target_document, template_data, speed)
|
|
@@ -418,12 +418,13 @@ def handle_playback_mode(
|
|
|
418
418
|
print("Error: No documents found in recording", file=sys.stderr)
|
|
419
419
|
return 1
|
|
420
420
|
except Exception as e:
|
|
421
|
-
print(f"Error
|
|
421
|
+
print(f"Error in playback: {e}", file=sys.stderr)
|
|
422
422
|
return 1
|
|
423
423
|
|
|
424
424
|
|
|
425
425
|
def process_batch(
|
|
426
426
|
jsonl_files: list[Path],
|
|
427
|
+
json_data_map: dict[Path, tuple[dict[str, Any], ...]],
|
|
427
428
|
template_base: Path | None,
|
|
428
429
|
template_data: str,
|
|
429
430
|
args: argparse.Namespace,
|
|
@@ -435,6 +436,8 @@ def process_batch(
|
|
|
435
436
|
----------
|
|
436
437
|
jsonl_files : list[Path]
|
|
437
438
|
List of JSONL files to process
|
|
439
|
+
json_data_map : dict[Path, tuple[dict[str, Any], ...]]
|
|
440
|
+
Pre-loaded JSON data for each file
|
|
438
441
|
template_base : Path
|
|
439
442
|
Path to template file or directory
|
|
440
443
|
template_data : str
|
|
@@ -456,9 +459,16 @@ def process_batch(
|
|
|
456
459
|
for i, jsonl_file in enumerate(jsonl_files, 1):
|
|
457
460
|
print_batch_header(i, len(jsonl_files), jsonl_file.name)
|
|
458
461
|
|
|
462
|
+
# Get pre-loaded data for this file
|
|
463
|
+
if jsonl_file not in json_data_map:
|
|
464
|
+
print(f"Error: No pre-loaded data for {jsonl_file}", file=sys.stderr)
|
|
465
|
+
all_verified = False
|
|
466
|
+
continue
|
|
467
|
+
|
|
468
|
+
file_data = json_data_map[jsonl_file]
|
|
469
|
+
|
|
459
470
|
# Determine target document for this file
|
|
460
471
|
try:
|
|
461
|
-
file_data = load_jsonl(jsonl_file)
|
|
462
472
|
recorded_docs = get_recorded_documents(file_data)
|
|
463
473
|
target_document = resolve_document(recorded_docs, template_base, args.document)
|
|
464
474
|
except (FileNotFoundError, ValueError, IOError) as e:
|
|
@@ -482,9 +492,9 @@ def process_batch(
|
|
|
482
492
|
else:
|
|
483
493
|
file_template_data = template_data
|
|
484
494
|
|
|
485
|
-
# Process the file
|
|
495
|
+
# Process the file with pre-loaded data
|
|
486
496
|
verified, reconstructed, suspicious_events, time_info, diff_text, doc_events, submitted_comparison = process_single_file(
|
|
487
|
-
jsonl_file, file_template_data, target_document, args.time_limit, args.submitted_file, args.submitted_dir
|
|
497
|
+
jsonl_file, file_data, file_template_data, target_document, args.time_limit, args.submitted_file, args.submitted_dir
|
|
488
498
|
)
|
|
489
499
|
|
|
490
500
|
if not verified:
|
|
@@ -520,6 +530,7 @@ def process_batch(
|
|
|
520
530
|
|
|
521
531
|
def process_single(
|
|
522
532
|
jsonl_file: Path,
|
|
533
|
+
json_data: tuple[dict[str, Any], ...],
|
|
523
534
|
template_base: Path | None,
|
|
524
535
|
template_data: str,
|
|
525
536
|
args: argparse.Namespace,
|
|
@@ -531,6 +542,8 @@ def process_single(
|
|
|
531
542
|
----------
|
|
532
543
|
jsonl_file : Path
|
|
533
544
|
Path to JSONL file
|
|
545
|
+
json_data : tuple[dict[str, Any], ...]
|
|
546
|
+
Pre-loaded JSON data for the file
|
|
534
547
|
template_base : Path
|
|
535
548
|
Path to template file or directory
|
|
536
549
|
template_data : str
|
|
@@ -544,8 +557,7 @@ def process_single(
|
|
|
544
557
|
(results, verified)
|
|
545
558
|
"""
|
|
546
559
|
try:
|
|
547
|
-
|
|
548
|
-
recorded_docs = get_recorded_documents(file_data)
|
|
560
|
+
recorded_docs = get_recorded_documents(json_data)
|
|
549
561
|
target_document = resolve_document(recorded_docs, template_base, args.document)
|
|
550
562
|
except (FileNotFoundError, ValueError, IOError) as e:
|
|
551
563
|
print(f"Error determining document: {e}", file=sys.stderr)
|
|
@@ -570,7 +582,7 @@ def process_single(
|
|
|
570
582
|
print(f"Processing: {target_document or template_base}", file=sys.stderr)
|
|
571
583
|
|
|
572
584
|
verified, reconstructed, suspicious_events, time_info, diff_text, doc_events, submitted_comparison = process_single_file(
|
|
573
|
-
jsonl_file, file_template_data, target_document, args.time_limit, args.submitted_file, args.submitted_dir
|
|
585
|
+
jsonl_file, json_data, file_template_data, target_document, args.time_limit, args.submitted_file, args.submitted_dir
|
|
574
586
|
)
|
|
575
587
|
|
|
576
588
|
# Display results
|
|
@@ -647,10 +659,23 @@ def main() -> int:
|
|
|
647
659
|
# Determine template source (use template_dir if provided, otherwise template_file)
|
|
648
660
|
template_path = args.template_dir if args.template_dir else template_file
|
|
649
661
|
|
|
662
|
+
# Load all files once - fail fast if any fail
|
|
663
|
+
json_data_map: dict[Path, tuple[dict[str, Any], ...]] = {}
|
|
664
|
+
for jsonl_file in jsonl_files:
|
|
665
|
+
try:
|
|
666
|
+
json_data_map[jsonl_file] = load_jsonl(jsonl_file)
|
|
667
|
+
except ValueError as e:
|
|
668
|
+
print(f"Error parsing {jsonl_file}: {e}", file=sys.stderr)
|
|
669
|
+
print("Tampering is likey - aborting processing.", file=sys.stderr)
|
|
670
|
+
return 1
|
|
671
|
+
except (FileNotFoundError, ValueError, IOError) as e:
|
|
672
|
+
print(f"Error loading {jsonl_file}: {e}", file=sys.stderr)
|
|
673
|
+
return 1
|
|
674
|
+
|
|
650
675
|
# Handle playback mode (single file only)
|
|
651
676
|
if not batch_mode and args.playback:
|
|
652
677
|
try:
|
|
653
|
-
json_data =
|
|
678
|
+
json_data = json_data_map[jsonl_files[0]]
|
|
654
679
|
recorded_docs = get_recorded_documents(json_data)
|
|
655
680
|
target_document = resolve_document(recorded_docs, template_path, args.document)
|
|
656
681
|
|
|
@@ -661,14 +686,11 @@ def main() -> int:
|
|
|
661
686
|
target_document
|
|
662
687
|
)
|
|
663
688
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
else:
|
|
668
|
-
print("Error: No documents found in recording", file=sys.stderr)
|
|
669
|
-
return 1
|
|
689
|
+
return handle_playback_mode(
|
|
690
|
+
jsonl_files[0], json_data, template_path, template_data, args.document, args.playback_speed
|
|
691
|
+
)
|
|
670
692
|
except Exception as e:
|
|
671
|
-
print(f"Error
|
|
693
|
+
print(f"Error in playback: {e}", file=sys.stderr)
|
|
672
694
|
return 1
|
|
673
695
|
|
|
674
696
|
# Get template data
|
|
@@ -687,14 +709,14 @@ def main() -> int:
|
|
|
687
709
|
print(f"Error: {e}", file=sys.stderr)
|
|
688
710
|
return 1
|
|
689
711
|
|
|
690
|
-
# Process files
|
|
712
|
+
# Process files with pre-loaded data
|
|
691
713
|
if batch_mode:
|
|
692
714
|
results, all_verified = process_batch(
|
|
693
|
-
jsonl_files, template_path, template_data, args
|
|
715
|
+
jsonl_files, json_data_map, template_path, template_data, args
|
|
694
716
|
)
|
|
695
717
|
else:
|
|
696
718
|
results, all_verified = process_single(
|
|
697
|
-
jsonl_files[0], template_path, template_data, args
|
|
719
|
+
jsonl_files[0], json_data_map[jsonl_files[0]], template_path, template_data, args
|
|
698
720
|
)
|
|
699
721
|
|
|
700
722
|
if not results:
|
|
@@ -4,10 +4,10 @@ code_recorder_processor/api/document.py,sha256=eIsGBCPq234cPiPN_ktBOoVrt0G1hHqbg
|
|
|
4
4
|
code_recorder_processor/api/load.py,sha256=Br-USpFQJ6W8c5hjmCnunM3V0_MURKZp5Yyl1IJdahc,5514
|
|
5
5
|
code_recorder_processor/api/output.py,sha256=HLa6DtN4i-wW0-vyE7SzqLeq35nhSoj2yHc9RjTPcBc,2441
|
|
6
6
|
code_recorder_processor/api/verify.py,sha256=6D8Zs8NBziG1kNc6HgH59yQp4u1wa4zyCuNE0qLTlpk,36040
|
|
7
|
-
code_recorder_processor/cli.py,sha256=
|
|
7
|
+
code_recorder_processor/cli.py,sha256=giFUu9KiB40k5Z2CwZK9CDL7dQOicBLCGBx0Uzki39o,26329
|
|
8
8
|
code_recorder_processor/display.py,sha256=He5loCMrm1S1186N2BgDy6bl0v__kiosJ_qDxpa4hbM,8657
|
|
9
9
|
code_recorder_processor/playback.py,sha256=6-OJtQOHKgfutxUNBMunWl-VVSIB0zUDENSl0EsPCh4,4008
|
|
10
|
-
cr_proc-0.1.
|
|
11
|
-
cr_proc-0.1.
|
|
12
|
-
cr_proc-0.1.
|
|
13
|
-
cr_proc-0.1.
|
|
10
|
+
cr_proc-0.1.13.dist-info/METADATA,sha256=-3ylZb1eSoxy2GY2egju_6WobzjoyLnGfEQikM7wMzA,9812
|
|
11
|
+
cr_proc-0.1.13.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
|
|
12
|
+
cr_proc-0.1.13.dist-info/entry_points.txt,sha256=xb5dPAAWN1Z9NUHpvZgNakaslR1MVOERf_IfpG_M04M,77
|
|
13
|
+
cr_proc-0.1.13.dist-info/RECORD,,
|
|
File without changes
|