OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """This script outputs the package name specified in the pubspec.yaml""" |
| 7 |
| 8 import argparse |
| 9 import os |
| 10 import sys |
| 11 |
| 12 def PackageName(line): |
| 13 assert line.startswith("name:") |
| 14 return line.split(":")[1].strip() |
| 15 |
| 16 def main(pubspec_file): |
| 17 source_file = open(pubspec_file, "r") |
| 18 for line in source_file: |
| 19 if line.startswith("name:"): |
| 20 print(PackageName(line)) |
| 21 return 0 |
| 22 source_file.close() |
| 23 # Couldn't find it. |
| 24 return -1 |
| 25 |
| 26 if __name__ == '__main__': |
| 27 parser = argparse.ArgumentParser( |
| 28 description="This script outputs the package name specified in the" |
| 29 "pubspec.yaml") |
| 30 parser.add_argument("--pubspec", |
| 31 dest="pubspec_file", |
| 32 metavar="<pubspec-file>", |
| 33 type=str, |
| 34 required=True, |
| 35 help="Path to pubspec file") |
| 36 args = parser.parse_args() |
| 37 sys.exit(main(args.pubspec_file)) |
OLD | NEW |