aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-09-04 10:40:29 +0200
committerSimo Fält <simo.falt@qt.io>2017-09-14 11:00:29 +0000
commit6678fc1a6353e596965f0daff74afec9d1605c57 (patch)
tree936665d9e8c829c342930ba56e73a4a303ee9c55
parentc700aba0f9904289dc14089cd697342e723f3d01 (diff)
Update missing bindings script to include report generation time
Also changed logging strings to use .format() substitution. Change-Id: I437080169f94da487cb541c72efb0fe41ac90105 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--missing_bindings.py67
1 files changed, 37 insertions, 30 deletions
diff --git a/missing_bindings.py b/missing_bindings.py
index 00202dcc..1b7b4244 100644
--- a/missing_bindings.py
+++ b/missing_bindings.py
@@ -61,6 +61,7 @@ except ImportError:
import argparse
from bs4 import BeautifulSoup
from collections import OrderedDict
+from time import gmtime, strftime
import sys
import os.path
@@ -287,38 +288,45 @@ def log(*pargs, **kw):
print(computed_str, file=wiki_file)
-log('PySide2 bindings for Qt ' + str(args.version), style='heading1')
+log('PySide2 bindings for Qt {}'.format(args.version), style='heading1')
-log('\nUsing Qt version ' + str(args.version) + ' documentation to find public API Qt types, to test '
- 'if they are present in PySide2.')
+log("""
+Using Qt version {} documentation to find public API Qt types and test if the types are present \
+in the PySide2 package.""".format(args.version))
-log('\nResults are usually stored at https://wiki.qt.io/PySide2_Missing_Bindings so consider '
- 'taking the contents of the generated missing_bindings_for_wiki_qt_io.txt file and updating '
- 'the linked wiki page.', style='end')
+log("""
+Results are usually stored at https://wiki.qt.io/PySide2_Missing_Bindings so consider \
+taking the contents of the generated missing_bindings_for_wiki_qt_io.txt file and updating \
+the linked wiki page.""", style='end')
-log('\nSimilar report: https://gist.github.com/ethanhs/6c626ca4e291f3682589699296377d3a',
- style='text_with_link')
+log("""
+Similar report: https://gist.github.com/ethanhs/6c626ca4e291f3682589699296377d3a \
+""", style='text_with_link')
python_executable = os.path.basename(sys.executable or '')
command_line_arguments = ' '.join(sys.argv)
-log('\nThis report was generated by running the following command: '
- + python_executable + ' ' + command_line_arguments + '\n')
+report_date = strftime("%Y-%m-%d %H:%M:%S %Z", gmtime())
+
+log("""
+This report was generated by running the following command:
+ {} {}
+on the following date:
+ {}
+""".format(python_executable, command_line_arguments, report_date))
for module_name in modules_to_test.keys():
log(module_name, style='heading5')
url = create_doc_url(modules_to_test[module_name], args.version)
- log('Documentation link: ' + url + '\n', style='text_with_link')
+ log('Documentation link: {}\n'.format(url), style='text_with_link')
# Import the tested module
try:
pyside_tested_module = getattr(__import__(pyside_package_name, fromlist=[module_name]),
module_name)
except Exception as e:
- log('\nCould not load ' + pyside_package_name + '.' + module_name + '. Received error: '
- + str(e).replace("'", '')
- + '. Skipping.\n',
- style='error')
+ log('\nCould not load {}.{}. Received error: {}. Skipping.\n'
+ .format(pyside_package_name, module_name, str(e).replace("'", '')), style='error')
total_missing_modules_count += 1
continue
@@ -326,12 +334,10 @@ for module_name in modules_to_test.keys():
pyqt_tested_module = getattr(__import__(pyqt_package_name, fromlist=[module_name]),
module_name)
except Exception as e:
- log('\nCould not load ' + pyqt_package_name + '.' + module_name + ' for comparison.'
- + ' Received error: ' + str(e).replace("'", '') + ' \n',
- style='error')
-
- # Get C++ class list from documentation page
+ log('\nCould not load {}.{} for comparison. Received error: {}.\n'
+ .format(pyqt_package_name, module_name, str(e).replace("'", '')), style='error')
+ # Get C++ class list from documentation page.
page = urllib2.urlopen(url)
soup = BeautifulSoup(page, 'html.parser')
@@ -345,7 +351,7 @@ for module_name in modules_to_test.keys():
if link_text not in types_to_ignore:
types_on_html_page.append(link_text)
- log('Number of types in ' + module_name + ": " + str(len(types_on_html_page)),
+ log('Number of types in {}: {}'.format(module_name, len(types_on_html_page)),
style='bold_colon')
missing_types_count = 0
@@ -379,23 +385,24 @@ for module_name in modules_to_test.keys():
missing_types.append(missing_type)
if len(missing_types) > 0:
- log('Missing types in ' + module_name + ":", style='with_newline')
+ log('Missing types in {}:'.format(module_name), style='with_newline')
missing_types.sort()
for missing_type in missing_types:
log(missing_type, style='code')
log('')
- log('Number of missing types: ' + str(missing_types_count), style='bold_colon')
+ log('Number of missing types: {}'.format(missing_types_count), style='bold_colon')
if len(missing_types) > 0:
- log('Number of missing types that are present in PyQt5: '
- + str(missing_types_compared_to_pyqt), style='bold_colon')
- log('End of missing types for ' + module_name + '\n', style='end')
+ log('Number of missing types that are present in PyQt5: {}'
+ .format(missing_types_compared_to_pyqt), style='bold_colon')
+ log('End of missing types for {}\n'.format(module_name), style='end')
else:
log('', style='end')
log('Summary', style='heading5')
-log('Total number of missing types: ' + str(total_missing_types_count), style='bold_colon')
-log('Total number of missing types that are present in PyQt5: '
- + str(total_missing_types_count_compared_to_pyqt), style='bold_colon')
-log('Total number of missing modules: ' + str(total_missing_modules_count), style='bold_colon')
+log('Total number of missing types: {}'.format(total_missing_types_count), style='bold_colon')
+log('Total number of missing types that are present in PyQt5: {}'
+ .format(total_missing_types_count_compared_to_pyqt), style='bold_colon')
+log('Total number of missing modules: {}'
+ .format(total_missing_modules_count), style='bold_colon')
wiki_file.close()