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

Unified Diff: mojo/public/tools/dart_package_name.py

Issue 1132063007: Rationalize Dart mojo and sky package structure (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 | « mojo/public/tools/dart_package.py ('k') | mojo/public/tools/dart_pkg.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/dart_package_name.py
diff --git a/mojo/public/tools/dart_package_name.py b/mojo/public/tools/dart_package_name.py
new file mode 100755
index 0000000000000000000000000000000000000000..5817945e49cba2b316bd085ea2529366d2ce4eb7
--- /dev/null
+++ b/mojo/public/tools/dart_package_name.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""This script outputs the package name specified in the pubspec.yaml"""
+
+import argparse
+import os
+import sys
+
+# TODO(johnmccutchan): Use the yaml package to parse.
+def PackageName(line):
+ assert line.startswith("name:")
+ return line.split(":")[1].strip()
+
+def main(pubspec_file):
+ source_file = open(pubspec_file, "r")
+ for line in source_file:
+ if line.startswith("name:"):
+ print(PackageName(line))
+ return 0
+ source_file.close()
+ # Couldn't find it.
+ return -1
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(
+ description="This script outputs the package name specified in the"
+ "pubspec.yaml")
+ parser.add_argument("--pubspec",
+ dest="pubspec_file",
+ metavar="<pubspec-file>",
+ type=str,
+ required=True,
+ help="Path to pubspec file")
+ args = parser.parse_args()
+ sys.exit(main(args.pubspec_file))
« no previous file with comments | « mojo/public/tools/dart_package.py ('k') | mojo/public/tools/dart_pkg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698