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