1+ """
2+ Provides a command-line interface to the package
3+ """
4+
15import argparse
26import json
37import sys
@@ -12,6 +16,16 @@ def _parse_file(
1216 encoding : str = "utf-8" ,
1317 errors : str = "backslashreplace" ,
1418) -> None :
19+ """
20+ Parses `file` and prints output to standard output.
21+
22+ :param file: File to parse.
23+ :param force_headers: Iterable of header names to use as a heuristic.
24+ :param encoding: Encoding to use for decoding.
25+ :param errors: Error resolution strategy for decoding.
26+ :return: None.
27+ """
28+
1529 header_line : bytes = file .readline ()
1630 while not header_line .strip ():
1731 header_line = file .readline ()
@@ -40,6 +54,16 @@ def _process_file(
4054 encoding : str = "utf-8" ,
4155 errors : str = "backslashreplace" ,
4256) -> None :
57+ """
58+ Opens the appropriate stream and performs parsing.
59+
60+ :param file_path: Path to file to parse.
61+ :param force_headers: Iterable of header names to use as a heuristic.
62+ :param encoding: Encoding to use for decoding.
63+ :param errors: Error resolution strategy for decoding.
64+ :return: None.
65+ """
66+
4367 if file_path == "-" :
4468 if sys .stdin .isatty ():
4569 raise RuntimeError ("Terminal is attached - cannot process standard input" )
@@ -58,6 +82,12 @@ def _process_file(
5882
5983
6084def main () -> None :
85+ """
86+ Parses inputs from the command-line and prints output to standard output.
87+
88+ :return: None.
89+ """
90+
6191 parser = argparse .ArgumentParser ()
6292 parser .add_argument (
6393 "--header" ,
@@ -84,6 +114,8 @@ def main() -> None:
84114
85115 headers : tuple [bytes , ...] = tuple (header .encode () for header in args .header )
86116 for file_path in args .files :
117+ # noinspection PyBroadException
118+ # pylint: disable=broad-exception-caught
87119 try :
88120 _process_file (
89121 file_path ,
0 commit comments