diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-25 16:59:15 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-25 16:59:15 -0700 |
commit | 3b05473d57f5aaadf4cd0b57b7138d9ff2141808 (patch) | |
tree | 34656f396bca9e5420c4ab3f4df5885e24ef49fb /tools | |
parent | 67c82c0b7edc1e7012a5e2c6959b468abc69b7df (diff) | |
download | vyos-cloud-init-3b05473d57f5aaadf4cd0b57b7138d9ff2141808.tar.gz vyos-cloud-init-3b05473d57f5aaadf4cd0b57b7138d9ff2141808.zip |
Add a simple tool that will parse the requires file
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/read-dependencies | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/read-dependencies b/tools/read-dependencies new file mode 100755 index 00000000..72e1e095 --- /dev/null +++ b/tools/read-dependencies @@ -0,0 +1,45 @@ +#!/usr/bin/python +# vi: ts=4 expandtab + +import os +import sys +import re + + +def parse_requires(fn): + requires = [] + with open(fn, 'r') as fh: + lines = fh.read().splitlines() + for line in lines: + line = line.strip() + if not line or line[0] == '#': + continue + else: + requires.append(line) + return requires + + +def find_requires(args): + p_files = [] + if args: + p_files.append(args[0]) + p_files.append(os.path.join(os.pardir, "Requires")) + p_files.append(os.path.join(os.getcwd(), 'Requires')) + found = None + for fn in p_files: + if os.path.isfile(fn): + found = fn + break + return found + + +if __name__ == '__main__': + run_args = sys.argv[1:] + fn = find_requires(run_args) + if not fn: + sys.stderr.write("'Requires' file not found!\n") + sys.exit(1) + else: + deps = parse_requires(fn) + for entry in deps: + print entry |