CallReports 0.1.0__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.
@@ -0,0 +1,17 @@
1
+ """Date-aware Call Report definitions and local FFIEC bulk preparation."""
2
+
3
+ from .definitions import (
4
+ CallReport_031, CallReport_051, DEFAULT_HISTORY, Global_uc,
5
+ LagSupport, QuarterCache, safe_divide,
6
+ )
7
+ from .preparation import (
8
+ clean_report, convert_txt_to_csv, extract_archive,
9
+ merge_schedule_files, merge_schedules, prepare_archive,
10
+ )
11
+
12
+ __all__ = [
13
+ "CallReport_031", "CallReport_051", "DEFAULT_HISTORY", "Global_uc",
14
+ "LagSupport", "QuarterCache", "safe_divide", "clean_report",
15
+ "convert_txt_to_csv", "extract_archive", "merge_schedule_files",
16
+ "merge_schedules", "prepare_archive",
17
+ ]
@@ -0,0 +1,5 @@
1
+ """Run the same interface as the installed callreports command."""
2
+
3
+ from .cli import main
4
+
5
+ raise SystemExit(main())
callreports/cli.py ADDED
@@ -0,0 +1,39 @@
1
+ """Convert and merge local Call Report data from explicit input/output paths."""
2
+
3
+ import argparse
4
+ import csv
5
+ from pathlib import Path
6
+ import sys
7
+ import zipfile
8
+
9
+ from .preparation import convert_txt_to_csv, merge_schedules, prepare_archive
10
+
11
+
12
+ def main(argv=None):
13
+ parser = argparse.ArgumentParser(description=__doc__)
14
+ commands = parser.add_subparsers(dest="command", required=True)
15
+ prepare = commands.add_parser("prepare", help="Extract a local quarterly ZIP and produce a merged CSV")
16
+ prepare.add_argument("archive", type=Path)
17
+ prepare.add_argument("--output-dir", type=Path, required=True)
18
+ prepare.add_argument("--date", help="Reporting quarter end, YYYYMMDD; otherwise inferred from filenames")
19
+ convert = commands.add_parser("convert", help="Convert one quarter's extracted TXT schedules to CSV")
20
+ convert.add_argument("input_dir", type=Path)
21
+ convert.add_argument("--output-dir", type=Path, required=True)
22
+ merge = commands.add_parser("merge", help="Merge one quarter's schedule CSVs by IDRSSD")
23
+ merge.add_argument("input_dir", type=Path)
24
+ merge.add_argument("--output", type=Path, required=True)
25
+ merge.add_argument("--date", help="Reporting quarter end, YYYYMMDD; otherwise inferred from filenames")
26
+ args = parser.parse_args(argv)
27
+ try:
28
+ if args.command == "prepare":
29
+ print(prepare_archive(args.archive, args.output_dir, args.date))
30
+ elif args.command == "convert":
31
+ for path in convert_txt_to_csv(args.input_dir, args.output_dir):
32
+ print(path)
33
+ else:
34
+ merge_schedules(args.input_dir, args.output, args.date)
35
+ print(args.output)
36
+ except (OSError, ValueError, zipfile.BadZipFile, csv.Error) as error:
37
+ print("CallReports: " + str(error), file=sys.stderr)
38
+ return 1
39
+ return 0