From 7a1a85d64088a9eaefaf30d6aa50711cb4ed8245 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 18 Jul 2022 19:03:57 -0600 Subject: gh-94673: [c-analyzer] Add a Script to Identify Static Types (#94989) issue: https://github.com/python/cpython/issues/94673 --- Tools/c-analyzer/c_common/tables.py | 285 +++++++++++++++++++++--------------- 1 file changed, 163 insertions(+), 122 deletions(-) (limited to 'Tools/c-analyzer/c_common/tables.py') diff --git a/Tools/c-analyzer/c_common/tables.py b/Tools/c-analyzer/c_common/tables.py index 130be6beba5..fe8e8cf473d 100644 --- a/Tools/c-analyzer/c_common/tables.py +++ b/Tools/c-analyzer/c_common/tables.py @@ -1,3 +1,4 @@ +from collections import namedtuple import csv import re import textwrap @@ -225,7 +226,11 @@ WIDTH = 20 def resolve_columns(specs): if isinstance(specs, str): specs = specs.replace(',', ' ').strip().split() - return _resolve_colspecs(specs) + resolved = [] + for raw in specs: + column = ColumnSpec.from_raw(raw) + resolved.append(column) + return resolved def build_table(specs, *, sep=' ', defaultwidth=None): @@ -233,37 +238,145 @@ def build_table(specs, *, sep=' ', defaultwidth=None): return _build_table(columns, sep=sep, defaultwidth=defaultwidth) -_COLSPEC_RE = re.compile(textwrap.dedent(r''' - ^ - (?: - \[ - ( - (?: [^\s\]] [^\]]* )? - [^\s\]] - ) #