mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-19 00:17:51 +02:00
formatting
This commit is contained in:
@ -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,
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user