[LNT] r307337 - lnt/test/__init__: Fix pep8 warnings

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 17:03:14 PDT 2017


Author: matze
Date: Thu Jul  6 17:03:14 2017
New Revision: 307337

URL: http://llvm.org/viewvc/llvm-project?rev=307337&view=rev
Log:
lnt/test/__init__: Fix pep8 warnings

Modified:
    lnt/trunk/lnt/testing/__init__.py

Modified: lnt/trunk/lnt/testing/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/__init__.py?rev=307337&r1=307336&r2=307337&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/__init__.py (original)
+++ lnt/trunk/lnt/testing/__init__.py Thu Jul  6 17:03:14 2017
@@ -20,13 +20,15 @@ PASS = 0
 FAIL = 1
 XFAIL = 2
 
+
 def normalize_time(t):
-    if isinstance(t,float):
+    if isinstance(t, float):
         t = datetime.datetime.utcfromtimestamp(t)
     elif not isinstance(t, datetime.datetime):
         t = datetime.datetime.strptime(t, '%Y-%m-%d %H:%M:%S')
     return t.strftime('%Y-%m-%d %H:%M:%S')
 
+
 class Report:
     """Information on a single testing run.
 
@@ -59,28 +61,31 @@ class Report:
         # Note that we specifically override the encoding to avoid the
         # possibility of encoding errors. Clients which care about the text
         # encoding should supply unicode string objects.
-        return json.dumps({ 'Machine' : self.machine.render(),
-                            'Run' : self.run.render(),
-                            'Tests' : [t.render() for t in self.tests] },
+        return json.dumps({'Machine': self.machine.render(),
+                           'Run': self.run.render(),
+                           'Tests': [t.render() for t in self.tests]},
                           sort_keys=True, indent=indent, encoding='latin-1')
 
+
 class Machine:
     """Information on the machine the test was run on.
 
-    The info dictionary can be used to describe additional information about the
-    machine, for example the hardware resources or the operating environment.
+    The info dictionary can be used to describe additional information about
+    the machine, for example the hardware resources or the operating
+    environment.
 
     Machines entries in the database are uniqued by their name and the entire
     contents of the info dictionary.
     """
     def __init__(self, name, info={}):
         self.name = str(name)
-        self.info = dict((str(key),str(value))
-                         for key,value in info.items())
+        self.info = dict((str(key), str(value))
+                         for key, value in info.items())
 
     def render(self):
-        return { 'Name' : self.name,
-                 'Info' : self.info }
+        return {'Name': self.name,
+                'Info': self.info}
+
 
 class Run:
     """Information on the particular test run.
@@ -91,8 +96,8 @@ class Run:
 
     As with Machine, the info dictionary can be used to describe additional
     information on the run. This dictionary should be used to describe
-    information on the software-under-test that is constant across the test run,
-    for example the revision number being tested. It can also be used to
+    information on the software-under-test that is constant across the test
+    run, for example the revision number being tested. It can also be used to
     describe information about the current state which could be useful in
     analysis, for example the current machine load.
     """
@@ -104,8 +109,8 @@ class Run:
 
         self.start_time = normalize_time(start_time)
         self.end_time = normalize_time(end_time)
-        self.info = dict((str(key),str(value))
-                         for key,value in info.items())
+        self.info = dict((str(key), str(value))
+                         for key, value in info.items())
         if '__report_version__' in self.info:
             raise ValueError("'__report_version__' key is reserved")
         # TODO: Convert to version 2
@@ -117,9 +122,10 @@ class Run:
         self.end_time = normalize_time(end_time)
 
     def render(self):
-        return { 'Start Time' : self.start_time,
-                 'End Time' : self.end_time,
-                 'Info' : self.info }
+        return {'Start Time': self.start_time,
+                'End Time': self.end_time,
+                'Info': self.info}
+
 
 class TestSamples:
     """Test sample data.
@@ -128,10 +134,10 @@ class TestSamples:
     values. The server automatically creates test database objects whenever a
     new test name is seen.
 
-    Test names are intended to be a persistent, recognizable identifier for what
-    is being executed. Currently, most formats use some form of dotted notation
-    for the test name, and this may become enshrined in the format in the
-    future. In general, the test names should be independent of the
+    Test names are intended to be a persistent, recognizable identifier for
+    what is being executed. Currently, most formats use some form of dotted
+    notation for the test name, and this may become enshrined in the format in
+    the future. In general, the test names should be independent of the
     software-under-test and refer to some known quantity, for example the
     software under test. For example, 'CINT2006.403_gcc' is a meaningful test
     name.
@@ -165,6 +171,8 @@ class TestSamples:
         return "TestSample({}): {} - {}".format(self.name,
                                                 self.data,
                                                 self.info)
+
+
 ###
 # Format Versioning
 
@@ -219,7 +227,7 @@ def upgrade_0_to_1(data):
     run_info['run_order'] = run_info['inferred_run_order'] = run_order
 
     # If this was a production Clang build, try to recompute the src tag.
-    if 'clang' in run_info.get('cc_name','') and \
+    if 'clang' in run_info.get('cc_name', '') and \
             run_info.get('cc_build') == 'PROD' and \
             run_info.get('cc_src_tag') and \
             run_order == run_info['cc_src_tag'].strip():
@@ -239,7 +247,7 @@ def upgrade_0_to_1(data):
         if not m:
             return data
 
-        cc_name,cc_version_num,cc_build_string,cc_extra = m.groups()
+        cc_name, cc_version_num, cc_build_string, cc_extra = m.groups()
         m = re.search('clang-([0-9.]*)', cc_build_string)
         if m:
             run_info['run_order'] = run_info['inferred_run_order'] = \
@@ -266,9 +274,9 @@ _nts_upgrade = _UpgradeSchema(
         '.hash.status': 'hash_status',
         '.mem': 'mem_bytes',
         '.score': 'score',
-    }, machine_param_rename = {
-        'name': 'hostname', # Avoid name clash with actual machine name.
-    }, run_param_rename = {
+    }, machine_param_rename={
+        'name': 'hostname',  # Avoid name clash with actual machine name.
+    }, run_param_rename={
         'run_order': 'llvm_project_revision',
     }
 )
@@ -284,18 +292,18 @@ _compile_upgrade = _UpgradeSchema(
         '.user.status': 'user_status',
         '.wall': 'wall_time',
         '.wall.status': 'wall_status',
-    }, machine_param_rename = {
+    }, machine_param_rename={
         'hw.model': 'hardware',
         'kern.version': 'os_version',
         'name': 'hostname',
-    }, run_param_rename = {
+    }, run_param_rename={
         'run_order': 'llvm_project_revision',
     }
 )
 _default_upgrade = _UpgradeSchema(
     metric_rename={},
     machine_param_rename={},
-    run_param_rename = {
+    run_param_rename={
         'run_order': 'llvm_project_revision',
     }
 )
@@ -304,6 +312,7 @@ _upgrades = {
     'compile': _compile_upgrade
 }
 
+
 def upgrade_1_to_2(data, ts_name):
     result = dict()
 
@@ -375,7 +384,7 @@ def upgrade_1_to_2(data, ts_name):
             # Fallback logic for unknown metrics: Assume they are '.xxxx'
             name, dot, metric = name_metric.rpartition('.')
             if dot != '.':
-                raise ValueError("Tests/%s: test name does not end in .metric" %
+                raise ValueError("Tests/%s: name does not end in .metric" %
                                  test_Name)
             logging.warning("Found unknown metric '%s'" % metric)
             upgrade.metric_rename['.'+metric] = metric
@@ -396,12 +405,13 @@ def upgrade_1_to_2(data, ts_name):
         elif len(data) > 0:
             # Transform the test data into a list
             if not isinstance(result_test[metric], list):
-                result_test[metric] = [ result_test[metric] ]
+                result_test[metric] = [result_test[metric]]
             result_test[metric] += data
 
     result['tests'] = result_tests
     return result
 
+
 def upgrade_report(data, ts_name):
     # Get the report version. V2 has it at the top level, older version
     # in Run.Info.
@@ -409,13 +419,13 @@ def upgrade_report(data, ts_name):
     if format_version is None:
         format_version = 2
 
-    if format_version==0:
+    if format_version == 0:
         data = upgrade_0_to_1(data)
-        format_version=1
-    if format_version==1:
+        format_version = 1
+    if format_version == 1:
         data = upgrade_1_to_2(data, ts_name)
-        format_version=2
-    assert(format_version==2)
+        format_version = 2
+    assert(format_version == 2)
     return data
 
 __all__ = ['Report', 'Machine', 'Run', 'TestSamples']




More information about the llvm-commits mailing list