Title: [216181] trunk/Source/WebKit2
Revision
216181
Author
[email protected]
Date
2017-05-04 05:30:13 -0700 (Thu, 04 May 2017)

Log Message

check-webkit-style exits with an error while parsing Source/WebKit2/Scripts/webkit/ directory: KeyError: 'st'
<https://bugs.webkit.org/show_bug.cgi?id=171510>

Reviewed by Daniel Bates.

The problem was that 'import parser' was ambiguous since there
is a built-in parser module that comes with Python.  Changing
'import parser' to 'from webkit import parser' fixed the error
in check-webkit-style (and pylint) by forcing it to load the
local 'parser' module, but then running messages_unittest.py
directly would fail because .../Source/WebKit2/Scripts was not
in the module search path by default.  This is fixed by using
sys.path.append() to add .../Source/WebKit2/Scripts to the
module search path based on the path to messages_unittest.py.

As an added bonus, this patch also fixes all webkit-style issues
in Source/WebKit2/Scripts/webkit/*.py files.

* Scripts/webkit/messages.py:
- Separate local module imports from built-in modules for
  consistency.
- Fix whitespace issues for check-webkit-style, and remove stray
  semi-colon.
* Scripts/webkit/messages_unittest.py:
- Update sys.path to find the 'webkit' module based on the path
  to messages_unittest.py.  This makes 'from webkit import ...'
  statements work when running messages_unittest.py directly.
- Change 'messages' and 'parser' modules to use
  'from webkit import ...' format for consistency.
- Fix whitespace issues for check-webkit-style.
* Scripts/webkit/model.py:
- Fix whitespace issue for check-webkit-style.
* Scripts/webkit/parser.py:
- Fix whitespace issue for check-webkit-style.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (216180 => 216181)


--- trunk/Source/WebKit2/ChangeLog	2017-05-04 12:20:59 UTC (rev 216180)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-04 12:30:13 UTC (rev 216181)
@@ -1,3 +1,40 @@
+2017-05-04  David Kilzer  <[email protected]>
+
+        check-webkit-style exits with an error while parsing Source/WebKit2/Scripts/webkit/ directory: KeyError: 'st'
+        <https://bugs.webkit.org/show_bug.cgi?id=171510>
+
+        Reviewed by Daniel Bates.
+
+        The problem was that 'import parser' was ambiguous since there
+        is a built-in parser module that comes with Python.  Changing
+        'import parser' to 'from webkit import parser' fixed the error
+        in check-webkit-style (and pylint) by forcing it to load the
+        local 'parser' module, but then running messages_unittest.py
+        directly would fail because .../Source/WebKit2/Scripts was not
+        in the module search path by default.  This is fixed by using
+        sys.path.append() to add .../Source/WebKit2/Scripts to the
+        module search path based on the path to messages_unittest.py.
+
+        As an added bonus, this patch also fixes all webkit-style issues
+        in Source/WebKit2/Scripts/webkit/*.py files.
+
+        * Scripts/webkit/messages.py:
+        - Separate local module imports from built-in modules for
+          consistency.
+        - Fix whitespace issues for check-webkit-style, and remove stray
+          semi-colon.
+        * Scripts/webkit/messages_unittest.py:
+        - Update sys.path to find the 'webkit' module based on the path
+          to messages_unittest.py.  This makes 'from webkit import ...'
+          statements work when running messages_unittest.py directly.
+        - Change 'messages' and 'parser' modules to use
+          'from webkit import ...' format for consistency.
+        - Fix whitespace issues for check-webkit-style.
+        * Scripts/webkit/model.py:
+        - Fix whitespace issue for check-webkit-style.
+        * Scripts/webkit/parser.py:
+        - Fix whitespace issue for check-webkit-style.
+
 2017-05-03  Eric Carlson  <[email protected]>
 
         [MediaStream] Allow host application to enable/disable media capture

Modified: trunk/Source/WebKit2/Scripts/webkit/messages.py (216180 => 216181)


--- trunk/Source/WebKit2/Scripts/webkit/messages.py	2017-05-04 12:20:59 UTC (rev 216180)
+++ trunk/Source/WebKit2/Scripts/webkit/messages.py	2017-05-04 12:30:13 UTC (rev 216181)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -23,6 +23,7 @@
 import collections
 import re
 import sys
+
 from webkit import parser
 
 WANTS_CONNECTION_ATTRIBUTE = 'WantsConnection'
@@ -157,6 +158,7 @@
     else:
         return 'class %s' % type
 
+
 def forward_declarations_for_namespace(namespace, kind_and_types):
     result = []
     result.append('namespace %s {\n' % namespace)
@@ -210,6 +212,7 @@
 
     return (forward_declarations, headers)
 
+
 def generate_messages_header(file):
     receiver = parser.parse(file)
 
@@ -299,7 +302,7 @@
 
     match = re.match('(?P<template_name>.+?)<(?P<parameter_string>.+)>', template_string)
     if not match:
-        return {'header_infos':[], 'types':[template_string]}
+        return {'header_infos': [], 'types': [template_string]}
 
     template_name = match.groupdict()['template_name']
     if template_name not in class_template_types:
@@ -312,10 +315,10 @@
     for parameter in parser.split_parameters_string(match.groupdict()['parameter_string']):
         parameter_header_infos_and_types = class_template_headers(parameter)
 
-        header_infos += parameter_header_infos_and_types['header_infos'];
+        header_infos += parameter_header_infos_and_types['header_infos']
         types += parameter_header_infos_and_types['types']
 
-    return {'header_infos':header_infos, 'types':types}
+    return {'header_infos': header_infos, 'types': types}
 
 
 def argument_coder_headers_for_type(type):
@@ -343,6 +346,7 @@
 
     return headers
 
+
 def headers_for_type(type):
     header_infos_and_types = class_template_headers(type)
 
@@ -411,6 +415,7 @@
 
     return headers
 
+
 def generate_message_handler(file):
     receiver = parser.parse(file)
     header_conditions = {
@@ -461,7 +466,6 @@
                         header_conditions[header] = []
                     header_conditions[header].append(message.condition)
 
-
     result = []
 
     result.append(_license_header)

Modified: trunk/Source/WebKit2/Scripts/webkit/messages_unittest.py (216180 => 216181)


--- trunk/Source/WebKit2/Scripts/webkit/messages_unittest.py	2017-05-04 12:20:59 UTC (rev 216180)
+++ trunk/Source/WebKit2/Scripts/webkit/messages_unittest.py	2017-05-04 12:30:13 UTC (rev 216181)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -21,11 +21,13 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
+import sys
 import unittest
 from StringIO import StringIO
 
-import messages
-import parser
+sys.path.append(os.path.dirname(os.path.dirname(__file__)))
+from webkit import messages
+from webkit import parser
 
 print os.getcwd()
 
@@ -49,8 +51,8 @@
 
 with open(os.path.join(script_directory, 'MessagesSuperclass-expected.h')) as file:
     _expected_superclass_receiver_header = file.read()
-    
 
+
 with open(os.path.join(script_directory, 'MessageReceiver-expected.cpp')) as file:
     _expected_receiver_implementation = file.read()
 
@@ -243,7 +245,7 @@
 
 _expected_superclass_results = {
     'name': 'WebPage',
-    'superclass' : 'WebPageBase',
+    'superclass': 'WebPageBase',
     'conditions': None,
     'messages': (
         {
@@ -307,7 +309,6 @@
             self.check_message(message, _expected_superclass_results['messages'][index])
 
 
-
 class GeneratedFileContentsTest(unittest.TestCase):
     def assertGeneratedFileContentsEqual(self, first, second):
         first_list = first.split('\n')

Modified: trunk/Source/WebKit2/Scripts/webkit/model.py (216180 => 216181)


--- trunk/Source/WebKit2/Scripts/webkit/model.py	2017-05-04 12:20:59 UTC (rev 216180)
+++ trunk/Source/WebKit2/Scripts/webkit/model.py	2017-05-04 12:30:13 UTC (rev 216181)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -38,6 +38,7 @@
     def has_attribute(self, attribute):
         return attribute in self.attributes
 
+
 class Message(object):
     def __init__(self, name, parameters, reply_parameters, attributes, condition):
         self.name = name

Modified: trunk/Source/WebKit2/Scripts/webkit/parser.py (216180 => 216181)


--- trunk/Source/WebKit2/Scripts/webkit/parser.py	2017-05-04 12:20:59 UTC (rev 216180)
+++ trunk/Source/WebKit2/Scripts/webkit/parser.py	2017-05-04 12:30:13 UTC (rev 216181)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2017 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -121,6 +121,7 @@
     parameters.append(current_parameter_string)
     return parameters
 
+
 def parse_parameters_string(parameters_string):
     parameters = []
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to