2016-10-17 06:50:25 +00:00
|
|
|
#!/usr/bin/env python3
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2017-09-15 16:55:23 +00:00
|
|
|
import os
|
2016-04-22 15:32:15 +00:00
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
import math
|
|
|
|
import platform
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Config #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
flags = {
|
2016-10-30 17:57:40 +00:00
|
|
|
'c': platform.platform() != 'Windows', # Disable by default on windows, since we use ANSI escape codes
|
2016-10-30 17:44:57 +00:00
|
|
|
'b': False,
|
|
|
|
'g': False,
|
|
|
|
's': False,
|
|
|
|
'u': False,
|
|
|
|
'h': False,
|
|
|
|
'p': False,
|
|
|
|
'o': True,
|
|
|
|
'i': False,
|
2017-03-29 19:27:59 +00:00
|
|
|
'a': True,
|
2016-04-22 15:32:15 +00:00
|
|
|
}
|
|
|
|
flag_descriptions = {
|
2016-10-30 17:44:57 +00:00
|
|
|
'c': 'Toggle colors when outputting.',
|
|
|
|
'b': 'Toggle showing only not fully described classes.',
|
|
|
|
'g': 'Toggle showing only completed classes.',
|
|
|
|
's': 'Toggle showing comments about the status.',
|
|
|
|
'u': 'Toggle URLs to docs.',
|
|
|
|
'h': 'Show help and exit.',
|
|
|
|
'p': 'Toggle showing percentage as well as counts.',
|
|
|
|
'o': 'Toggle overall column.',
|
|
|
|
'i': 'Toggle collapse of class items columns.',
|
2017-03-29 19:27:59 +00:00
|
|
|
'a': 'Toggle showing all items.',
|
2016-04-22 15:32:15 +00:00
|
|
|
}
|
|
|
|
long_flags = {
|
2016-10-30 17:44:57 +00:00
|
|
|
'colors': 'c',
|
|
|
|
'use-colors': 'c',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'bad': 'b',
|
|
|
|
'only-bad': 'b',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'good': 'g',
|
|
|
|
'only-good': 'g',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'comments': 's',
|
|
|
|
'status': 's',
|
2016-04-26 19:35:06 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'urls': 'u',
|
|
|
|
'gen-url': 'u',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'help': 'h',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'percent': 'p',
|
|
|
|
'use-percentages': 'p',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'overall': 'o',
|
|
|
|
'use-overall': 'o',
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
'items': 'i',
|
|
|
|
'collapse': 'i',
|
2017-03-29 19:27:59 +00:00
|
|
|
|
|
|
|
'all': 'a',
|
2016-04-22 15:32:15 +00:00
|
|
|
}
|
|
|
|
table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals']
|
2016-04-26 19:35:06 +00:00
|
|
|
table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals']
|
2016-04-22 15:32:15 +00:00
|
|
|
colors = {
|
2016-10-30 17:57:40 +00:00
|
|
|
'name': [36], # cyan
|
|
|
|
'part_big_problem': [4, 31], # underline, red
|
|
|
|
'part_problem': [31], # red
|
|
|
|
'part_mostly_good': [33], # yellow
|
|
|
|
'part_good': [32], # green
|
|
|
|
'url': [4, 34], # underline, blue
|
|
|
|
'section': [1, 4], # bold, underline
|
|
|
|
'state_off': [36], # cyan
|
|
|
|
'state_on': [1, 35], # bold, magenta/plum
|
2016-04-22 15:32:15 +00:00
|
|
|
}
|
|
|
|
overall_progress_description_weigth = 10
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Utils #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
def validate_tag(elem, tag):
|
2016-10-30 17:44:57 +00:00
|
|
|
if elem.tag != tag:
|
|
|
|
print('Tag mismatch, expected "' + tag + '", got ' + elem.tag)
|
|
|
|
sys.exit(255)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2016-04-22 15:32:15 +00:00
|
|
|
def color(color, string):
|
2016-10-30 17:44:57 +00:00
|
|
|
if flags['c']:
|
|
|
|
color_format = ''
|
|
|
|
for code in colors[color]:
|
|
|
|
color_format += '\033[' + str(code) + 'm'
|
|
|
|
return color_format + string + '\033[0m'
|
|
|
|
else:
|
|
|
|
return string
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
ansi_escape = re.compile(r'\x1b[^m]*m')
|
2016-10-30 18:05:14 +00:00
|
|
|
|
|
|
|
|
2016-04-22 15:32:15 +00:00
|
|
|
def nonescape_len(s):
|
2016-10-30 17:44:57 +00:00
|
|
|
return len(ansi_escape.sub('', s))
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Classes #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
class ClassStatusProgress:
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
def __init__(self, described=0, total=0):
|
2016-10-30 17:44:57 +00:00
|
|
|
self.described = described
|
|
|
|
self.total = total
|
|
|
|
|
|
|
|
def __add__(self, other):
|
|
|
|
return ClassStatusProgress(self.described + other.described, self.total + other.total)
|
|
|
|
|
|
|
|
def increment(self, described):
|
|
|
|
if described:
|
|
|
|
self.described += 1
|
|
|
|
self.total += 1
|
|
|
|
|
|
|
|
def is_ok(self):
|
|
|
|
return self.described >= self.total
|
|
|
|
|
|
|
|
def to_configured_colored_string(self):
|
|
|
|
if flags['p']:
|
|
|
|
return self.to_colored_string('{percent}% ({has}/{total})', '{pad_percent}{pad_described}{s}{pad_total}')
|
|
|
|
else:
|
|
|
|
return self.to_colored_string()
|
|
|
|
|
|
|
|
def to_colored_string(self, format='{has}/{total}', pad_format='{pad_described}{s}{pad_total}'):
|
2016-10-30 17:57:40 +00:00
|
|
|
ratio = self.described / self.total if self.total != 0 else 1
|
|
|
|
percent = round(100 * ratio)
|
|
|
|
s = format.format(has=str(self.described), total=str(self.total), percent=str(percent))
|
2016-10-30 17:44:57 +00:00
|
|
|
if self.described >= self.total:
|
|
|
|
s = color('part_good', s)
|
2016-10-30 17:57:40 +00:00
|
|
|
elif self.described >= self.total / 4 * 3:
|
2016-10-30 17:44:57 +00:00
|
|
|
s = color('part_mostly_good', s)
|
|
|
|
elif self.described > 0:
|
|
|
|
s = color('part_problem', s)
|
|
|
|
else:
|
|
|
|
s = color('part_big_problem', s)
|
|
|
|
pad_size = max(len(str(self.described)), len(str(self.total)))
|
|
|
|
pad_described = ''.ljust(pad_size - len(str(self.described)))
|
|
|
|
pad_percent = ''.ljust(3 - len(str(percent)))
|
|
|
|
pad_total = ''.ljust(pad_size - len(str(self.total)))
|
2016-10-30 17:57:40 +00:00
|
|
|
return pad_format.format(pad_described=pad_described, pad_total=pad_total, pad_percent=pad_percent, s=s)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClassStatus:
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
def __init__(self, name=''):
|
|
|
|
self.name = name
|
|
|
|
self.has_brief_description = True
|
|
|
|
self.has_description = True
|
|
|
|
self.progresses = {
|
|
|
|
'methods': ClassStatusProgress(),
|
|
|
|
'constants': ClassStatusProgress(),
|
|
|
|
'members': ClassStatusProgress(),
|
|
|
|
'signals': ClassStatusProgress()
|
|
|
|
}
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
def __add__(self, other):
|
|
|
|
new_status = ClassStatus()
|
|
|
|
new_status.name = self.name
|
|
|
|
new_status.has_brief_description = self.has_brief_description and other.has_brief_description
|
|
|
|
new_status.has_description = self.has_description and other.has_description
|
|
|
|
for k in self.progresses:
|
|
|
|
new_status.progresses[k] = self.progresses[k] + other.progresses[k]
|
|
|
|
return new_status
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
def is_ok(self):
|
|
|
|
ok = True
|
|
|
|
ok = ok and self.has_brief_description
|
|
|
|
ok = ok and self.has_description
|
|
|
|
for k in self.progresses:
|
|
|
|
ok = ok and self.progresses[k].is_ok()
|
|
|
|
return ok
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
def make_output(self):
|
|
|
|
output = {}
|
|
|
|
output['name'] = color('name', self.name)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
ok_string = color('part_good', 'OK')
|
|
|
|
missing_string = color('part_big_problem', 'MISSING')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
output['brief_description'] = ok_string if self.has_brief_description else missing_string
|
|
|
|
output['description'] = ok_string if self.has_description else missing_string
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
description_progress = ClassStatusProgress(
|
|
|
|
(self.has_brief_description + self.has_description) * overall_progress_description_weigth,
|
|
|
|
2 * overall_progress_description_weigth
|
|
|
|
)
|
|
|
|
items_progress = ClassStatusProgress()
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
for k in ['methods', 'constants', 'members', 'signals']:
|
|
|
|
items_progress += self.progresses[k]
|
|
|
|
output[k] = self.progresses[k].to_configured_colored_string()
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
output['items'] = items_progress.to_configured_colored_string()
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if self.name.startswith('Total'):
|
2017-04-05 05:34:27 +00:00
|
|
|
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/')
|
2016-10-30 17:44:57 +00:00
|
|
|
if flags['s']:
|
|
|
|
output['comment'] = color('part_good', 'ALL OK')
|
|
|
|
else:
|
|
|
|
output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/class_{name}.html'.format(name=self.name.lower()))
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if flags['s'] and not flags['g'] and self.is_ok():
|
|
|
|
output['comment'] = color('part_good', 'ALL OK')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
return output
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
def generate_for_class(c):
|
|
|
|
status = ClassStatus()
|
|
|
|
status.name = c.attrib['name']
|
2017-09-15 16:55:23 +00:00
|
|
|
|
|
|
|
# setgets do not count
|
|
|
|
methods = []
|
|
|
|
for tag in list(c):
|
|
|
|
if tag.tag in ['methods']:
|
|
|
|
for sub_tag in list(tag):
|
|
|
|
methods.append(sub_tag.find('name'))
|
|
|
|
if tag.tag in ['members']:
|
|
|
|
for sub_tag in list(tag):
|
|
|
|
try:
|
|
|
|
methods.remove(sub_tag.find('setter'))
|
|
|
|
methods.remove(sub_tag.find('getter'))
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
for tag in list(c):
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if tag.tag == 'brief_description':
|
|
|
|
status.has_brief_description = len(tag.text.strip()) > 0
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
elif tag.tag == 'description':
|
|
|
|
status.has_description = len(tag.text.strip()) > 0
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
elif tag.tag in ['methods', 'signals']:
|
|
|
|
for sub_tag in list(tag):
|
2017-09-15 16:55:23 +00:00
|
|
|
if sub_tag.find('name') in methods or tag.tag == 'signals':
|
|
|
|
descr = sub_tag.find('description')
|
|
|
|
status.progresses[tag.tag].increment(len(descr.text.strip()) > 0)
|
2016-10-30 17:44:57 +00:00
|
|
|
elif tag.tag in ['constants', 'members']:
|
|
|
|
for sub_tag in list(tag):
|
|
|
|
status.progresses[tag.tag].increment(len(sub_tag.text.strip()) > 0)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2017-09-16 10:47:44 +00:00
|
|
|
elif tag.tag in ['tutorials', 'demos']:
|
|
|
|
pass # Ignore those tags for now
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
elif tag.tag in ['theme_items']:
|
2016-10-30 17:57:40 +00:00
|
|
|
pass # Ignore those tags, since they seem to lack description at all
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
|
|
|
print(tag.tag, tag.attrib)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
return status
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Arguments #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
input_file_list = []
|
|
|
|
input_class_list = []
|
2017-09-15 16:55:23 +00:00
|
|
|
merged_file = ""
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
for arg in sys.argv[1:]:
|
2016-10-30 17:44:57 +00:00
|
|
|
if arg.startswith('--'):
|
|
|
|
flags[long_flags[arg[2:]]] = not flags[long_flags[arg[2:]]]
|
|
|
|
elif arg.startswith('-'):
|
|
|
|
for f in arg[1:]:
|
|
|
|
flags[f] = not flags[f]
|
2017-09-15 16:55:23 +00:00
|
|
|
elif os.path.isdir(arg):
|
|
|
|
for f in os.listdir(arg):
|
|
|
|
if f.endswith('.xml'):
|
|
|
|
input_file_list.append(os.path.join(arg, f));
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
|
|
|
input_class_list.append(arg)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
if flags['i']:
|
2016-10-30 17:44:57 +00:00
|
|
|
for r in ['methods', 'constants', 'members', 'signals']:
|
|
|
|
index = table_columns.index(r)
|
|
|
|
del table_column_names[index]
|
|
|
|
del table_columns[index]
|
|
|
|
table_column_names.append('Items')
|
|
|
|
table_columns.append('items')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
if flags['o'] == (not flags['i']):
|
2016-10-30 17:44:57 +00:00
|
|
|
table_column_names.append('Overall')
|
|
|
|
table_columns.append('overall')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
if flags['u']:
|
2016-10-30 17:44:57 +00:00
|
|
|
table_column_names.append('Docs URL')
|
|
|
|
table_columns.append('url')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Help #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
if len(input_file_list) < 1 or flags['h']:
|
2016-10-30 17:44:57 +00:00
|
|
|
if not flags['h']:
|
2017-09-15 16:55:23 +00:00
|
|
|
print(color('section', 'Invalid usage') + ': Please specify a classes directory')
|
|
|
|
print(color('section', 'Usage') + ': doc_status.py [flags] <classes_dir> [class names]')
|
2016-10-30 17:44:57 +00:00
|
|
|
print('\t< and > signify required parameters, while [ and ] signify optional parameters.')
|
|
|
|
print(color('section', 'Available flags') + ':')
|
|
|
|
possible_synonym_list = list(long_flags)
|
|
|
|
possible_synonym_list.sort()
|
|
|
|
flag_list = list(flags)
|
|
|
|
flag_list.sort()
|
|
|
|
for flag in flag_list:
|
|
|
|
synonyms = [color('name', '-' + flag)]
|
|
|
|
for synonym in possible_synonym_list:
|
|
|
|
if long_flags[synonym] == flag:
|
|
|
|
synonyms.append(color('name', '--' + synonym))
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
print(('{synonyms} (Currently ' + color('state_' + ('on' if flags[flag] else 'off'), '{value}') + ')\n\t{description}').format(
|
|
|
|
synonyms=', '.join(synonyms),
|
|
|
|
value=('on' if flags[flag] else 'off'),
|
|
|
|
description=flag_descriptions[flag]
|
2016-10-30 17:44:57 +00:00
|
|
|
))
|
|
|
|
sys.exit(0)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Parse class list #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
class_names = []
|
|
|
|
classes = {}
|
|
|
|
|
|
|
|
for file in input_file_list:
|
2016-10-30 17:44:57 +00:00
|
|
|
tree = ET.parse(file)
|
|
|
|
doc = tree.getroot()
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if 'version' not in doc.attrib:
|
|
|
|
print('Version missing from "doc"')
|
|
|
|
sys.exit(255)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
version = doc.attrib['version']
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2017-09-15 16:55:23 +00:00
|
|
|
if doc.attrib['name'] in class_names:
|
|
|
|
continue
|
|
|
|
class_names.append(doc.attrib['name'])
|
|
|
|
classes[doc.attrib['name']] = doc
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
class_names.sort()
|
|
|
|
|
|
|
|
if len(input_class_list) < 1:
|
2016-10-30 17:44:57 +00:00
|
|
|
input_class_list = class_names
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Make output table #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
table = [table_column_names]
|
2017-09-16 10:47:44 +00:00
|
|
|
table_row_chars = '| - '
|
2016-04-22 15:32:15 +00:00
|
|
|
table_column_chars = '|'
|
|
|
|
|
|
|
|
total_status = ClassStatus('Total')
|
|
|
|
|
|
|
|
for cn in input_class_list:
|
2016-10-30 17:44:57 +00:00
|
|
|
if not cn in classes:
|
|
|
|
print('Cannot find class ' + cn + '!')
|
|
|
|
sys.exit(255)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
c = classes[cn]
|
|
|
|
validate_tag(c, 'class')
|
|
|
|
status = ClassStatus.generate_for_class(c)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2017-03-29 19:27:59 +00:00
|
|
|
total_status = total_status + status
|
|
|
|
|
|
|
|
if (flags['b'] and status.is_ok()) or (flags['g'] and not status.is_ok()) or (not flags['a']):
|
2016-10-30 17:44:57 +00:00
|
|
|
continue
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
out = status.make_output()
|
|
|
|
row = []
|
|
|
|
for column in table_columns:
|
|
|
|
if column in out:
|
|
|
|
row.append(out[column])
|
|
|
|
else:
|
|
|
|
row.append('')
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if 'comment' in out and out['comment'] != '':
|
|
|
|
row.append(out['comment'])
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
table.append(row)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Print output table #
|
|
|
|
################################################################################
|
|
|
|
|
2017-03-29 19:27:59 +00:00
|
|
|
if len(table) == 1 and flags['a']:
|
2016-10-30 17:44:57 +00:00
|
|
|
print(color('part_big_problem', 'No classes suitable for printing!'))
|
|
|
|
sys.exit(0)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2017-03-29 19:27:59 +00:00
|
|
|
if len(table) > 2 or not flags['a']:
|
2016-10-30 17:44:57 +00:00
|
|
|
total_status.name = 'Total = {0}'.format(len(table) - 1)
|
|
|
|
out = total_status.make_output()
|
|
|
|
row = []
|
|
|
|
for column in table_columns:
|
|
|
|
if column in out:
|
|
|
|
row.append(out[column])
|
|
|
|
else:
|
|
|
|
row.append('')
|
|
|
|
table.append(row)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
table_column_sizes = []
|
|
|
|
for row in table:
|
2016-10-30 17:44:57 +00:00
|
|
|
for cell_i, cell in enumerate(row):
|
|
|
|
if cell_i >= len(table_column_sizes):
|
|
|
|
table_column_sizes.append(0)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
table_column_sizes[cell_i] = max(nonescape_len(cell), table_column_sizes[cell_i])
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
divider_string = table_row_chars[0]
|
|
|
|
for cell_i in range(len(table[0])):
|
2017-09-16 10:47:44 +00:00
|
|
|
divider_string += table_row_chars[1] + table_row_chars[2] * (table_column_sizes[cell_i]) + table_row_chars[1] + table_row_chars[0]
|
2016-04-22 15:32:15 +00:00
|
|
|
print(divider_string)
|
|
|
|
|
|
|
|
for row_i, row in enumerate(table):
|
2016-10-30 17:44:57 +00:00
|
|
|
row_string = table_column_chars
|
|
|
|
for cell_i, cell in enumerate(row):
|
|
|
|
padding_needed = table_column_sizes[cell_i] - nonescape_len(cell) + 2
|
|
|
|
if cell_i == 0:
|
2017-09-16 10:47:44 +00:00
|
|
|
row_string += table_row_chars[3] + cell + table_row_chars[3] * (padding_needed - 1)
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2017-09-16 10:47:44 +00:00
|
|
|
row_string += table_row_chars[3] * math.floor(padding_needed / 2) + cell + table_row_chars[3] * math.ceil((padding_needed / 2))
|
2016-10-30 17:44:57 +00:00
|
|
|
row_string += table_column_chars
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
print(row_string)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
if row_i == 0 or row_i == len(table) - 2:
|
|
|
|
print(divider_string)
|
2016-04-22 15:32:15 +00:00
|
|
|
|
|
|
|
print(divider_string)
|
|
|
|
|
|
|
|
if total_status.is_ok() and not flags['g']:
|
2016-10-30 17:44:57 +00:00
|
|
|
print('All listed classes are ' + color('part_good', 'OK') + '!')
|