From 619de68a61be0117e635032347dde417d77c748c Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 24 Mar 2022 09:39:53 -0700 Subject: [PATCH] formatting --- jc/parsers/asciitable.py | 7 ++++--- jc/parsers/asciitable_m.py | 10 ++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/jc/parsers/asciitable.py b/jc/parsers/asciitable.py index de4cb56c..7b6c848a 100644 --- a/jc/parsers/asciitable.py +++ b/jc/parsers/asciitable.py @@ -165,7 +165,7 @@ def _strip(string: str) -> str: def _is_separator(line: str) -> bool: - """Returns true if a table separator line is found""" + """returns true if a table separator line is found""" strip_line = line.strip() if any(( strip_line.startswith('╒') and strip_line.endswith('╕'), @@ -223,7 +223,7 @@ def _snake_case(line: str) -> str: def _normalize_rows(table: str) -> List[str]: """ - Return a List row strings. Header is snake-cased + returns a List of row strings. Header is snake-cased """ result = [] for line in table.splitlines(): @@ -257,7 +257,7 @@ def _fixup_headers(table: List[Dict]) -> List[Dict]: new_table = [] for row in table: new_row = row.copy() - for k, v in row.items(): + for k in row: k_new = k # remove consecutive underscores k_new = re.sub(r'__+', '_', k_new) @@ -268,6 +268,7 @@ def _fixup_headers(table: List[Dict]) -> List[Dict]: return new_table + def parse( data: str, raw: bool = False, diff --git a/jc/parsers/asciitable_m.py b/jc/parsers/asciitable_m.py index e5f1a914..b18e0688 100644 --- a/jc/parsers/asciitable_m.py +++ b/jc/parsers/asciitable_m.py @@ -155,7 +155,7 @@ def _strip(string: str) -> str: def _table_sniff(string: str) -> str: - """Find the table-type via heuristics""" + """find the table-type via heuristics""" # pretty tables for line in string.splitlines(): line = line.strip() @@ -186,7 +186,7 @@ def _table_sniff(string: str) -> str: def _is_separator(line: str) -> bool: - """Returns true if a table separator line is found""" + """returns true if a table separator line is found""" strip_line = line.strip() if any(( strip_line.startswith('╒') and strip_line.endswith('╕'), @@ -234,7 +234,7 @@ def _snake_case(line: str) -> str: def _fixup_separators(line: str) -> str: - """Normalize separators, and remove first and last separators""" + """normalize separators, and remove first and last separators""" # normalize separator line = line.replace('│', '|')\ .replace('┃', '|')\ @@ -258,9 +258,7 @@ def _fixup_separators(line: str) -> str: def _normalize_rows(table_lines: Iterable[str]) -> List[Tuple[int, List[str]]]: - """ - Return a List of tuples of row-counters and data lines. - """ + """return a List of tuples of row-counters and data lines.""" result = [] header_found = False data_found = False