Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(979)

Unified Diff: mojo/public/tools/bindings/mojom_list_dart_outputs.py

Issue 1740323002: Fix mojom_list_dart_outputs.py to not use the old Mojom parser. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/mojom_list_dart_outputs.py
diff --git a/mojo/public/tools/bindings/mojom_list_dart_outputs.py b/mojo/public/tools/bindings/mojom_list_dart_outputs.py
index 6962520f7c1840d92f4857797f220c196b5cd20a..18f9da64dd47774bf22f3b5b1646fae4e1e9f843 100755
--- a/mojo/public/tools/bindings/mojom_list_dart_outputs.py
+++ b/mojo/public/tools/bindings/mojom_list_dart_outputs.py
@@ -12,11 +12,12 @@ import shutil
import sys
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
+SDK_DIR = os.path.join(SCRIPT_DIR, os.path.pardir, os.path.pardir)
sys.path.insert(0, os.path.join(SCRIPT_DIR, 'pylib'))
from mojom.error import Error
-from mojom.parse.parser import Parse
-from mojom.parse.translate import Translate
+from mojom.parse import parser_runner
+from mojom.generate import mojom_translator
def mojom_path(name, namespace, attributes):
package_name = 'mojom'
@@ -30,27 +31,18 @@ def mojom_path(name, namespace, attributes):
def process_mojom(path_to_mojom):
filename = os.path.abspath(path_to_mojom)
- name = os.path.basename(filename)
-
- # Read in mojom file.
- try:
- with open(filename) as f:
- source = f.read()
- except IOError:
- print("Error reading %s" % filename)
- sys.exit(2)
# Parse
- try:
- tree = Parse(source, name)
- except Error:
+ mojom_file_graph = parser_runner.ParseToMojomFileGraph(SDK_DIR, [filename],
+ meta_data_only=True)
+ if mojom_file_graph is None:
print("Error parsing %s" % filename)
- sys.exit(2)
+ mojom_dict = mojom_translator.TranslateFileGraph(mojom_file_graph)
+ mojom = mojom_dict[filename]
- mojom = Translate(tree, name)
# Output path
- attributes = mojom.get('attributes')
- print(mojom_path(mojom['name'], mojom['namespace'], attributes))
+ attributes = mojom.attributes
+ print(mojom_path(mojom.name, mojom.namespace, attributes))
def main():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698