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

Side by Side Diff: mojo/dart/tools/presubmit/check_mojom_dart.py

Issue 1834893002: Treat empty string DartPackage as no DartPackage specified (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/mojom_dart_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Checks that released mojom.dart files in the source tree are up to date""" 6 """Checks that released mojom.dart files in the source tree are up to date"""
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import subprocess 10 import subprocess
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 namespace = mojom.namespace 49 namespace = mojom.namespace
50 elements = ['lib'] 50 elements = ['lib']
51 elements.extend(namespace.split('.')) 51 elements.extend(namespace.split('.'))
52 elements.append("%s.dart" % name) 52 elements.append("%s.dart" % name)
53 return os.path.join(*elements) 53 return os.path.join(*elements)
54 54
55 55
56 # Given a mojom.Module, return the package or None. 56 # Given a mojom.Module, return the package or None.
57 def _mojom_package(mojom): 57 def _mojom_package(mojom):
58 if mojom.attributes: 58 if mojom.attributes:
59 return mojom.attributes.get('DartPackage') 59 package = mojom.attributes.get('DartPackage')
60 if package == None:
61 return package
62 package = package.strip()
63 if package == '':
64 return None
65 return package
60 66
61 # Load and parse a .mojom file. Returns the mojom.Module or raises an Exception 67 # Load and parse a .mojom file. Returns the mojom.Module or raises an Exception
62 # if there was an error. 68 # if there was an error.
63 def _load_mojom(path_to_mojom): 69 def _load_mojom(path_to_mojom):
64 filename = os.path.abspath(path_to_mojom) 70 filename = os.path.abspath(path_to_mojom)
65 71
66 # Parse 72 # Parse
67 mojom_file_graph = parser_runner.ParseToMojomFileGraph(SDK_DIR, [filename], 73 mojom_file_graph = parser_runner.ParseToMojomFileGraph(SDK_DIR, [filename],
68 meta_data_only=True) 74 meta_data_only=True)
69 if mojom_file_graph is None: 75 if mojom_file_graph is None:
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 if args.affected_files: 431 if args.affected_files:
426 check_failure = presubmit_check(packages, args.affected_files) 432 check_failure = presubmit_check(packages, args.affected_files)
427 else: 433 else:
428 check_failure = global_check(packages) 434 check_failure = global_check(packages)
429 if check_failure: 435 if check_failure:
430 return 2 436 return 2
431 return 0 437 return 0
432 438
433 if __name__ == '__main__': 439 if __name__ == '__main__':
434 sys.exit(main()) 440 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/mojom_dart_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698