diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-01-18 14:49:15 -0500 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2017-01-18 14:49:15 -0500 |
commit | b6576d28ec21411f8da58cedab7a6c6c57dc172b (patch) | |
tree | 982ac027c6ff335828b1a5bbb3b5e4523cbb3413 /roles/lib_utils/src | |
parent | 11a6465965af445f2cc2b8eaf91caaa2860b935c (diff) | |
download | openshift-b6576d28ec21411f8da58cedab7a6c6c57dc172b.tar.gz openshift-b6576d28ec21411f8da58cedab7a6c6c57dc172b.tar.bz2 openshift-b6576d28ec21411f8da58cedab7a6c6c57dc172b.tar.xz openshift-b6576d28ec21411f8da58cedab7a6c6c57dc172b.zip |
Updated the generate.py scripts for tox and virtualenv.
Diffstat (limited to 'roles/lib_utils/src')
-rwxr-xr-x | roles/lib_utils/src/generate.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/roles/lib_utils/src/generate.py b/roles/lib_utils/src/generate.py index cece68fb4..6daade108 100755 --- a/roles/lib_utils/src/generate.py +++ b/roles/lib_utils/src/generate.py @@ -5,11 +5,12 @@ import argparse import os -import six import yaml +import six OPENSHIFT_ANSIBLE_PATH = os.path.dirname(os.path.realpath(__file__)) OPENSHIFT_ANSIBLE_SOURCES_PATH = os.path.join(OPENSHIFT_ANSIBLE_PATH, 'sources.yml') # noqa: E501 +LIBRARY = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/') class GenerateAnsibleException(Exception): @@ -42,22 +43,29 @@ def generate(parts): return data -def main(): - ''' combine the necessary files to create the ansible module ''' - args = parse_args() +def get_sources(): + '''return the path to the generate sources''' + return yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read()) - library = os.path.join(OPENSHIFT_ANSIBLE_PATH, '..', 'library/') - sources = yaml.load(open(OPENSHIFT_ANSIBLE_SOURCES_PATH).read()) - for fname, parts in sources.items(): +def verify(): + '''verify if the generated code matches the library code''' + for fname, parts in get_sources().items(): data = generate(parts) - fname = os.path.join(library, fname) - if args.verify: - if not open(fname).read() == data.getvalue(): - raise GenerateAnsibleException('Generated content does not match for %s' % fname) + fname = os.path.join(LIBRARY, fname) + if not open(fname).read() == data.getvalue(): + raise GenerateAnsibleException('Generated content does not match for %s' % fname) - continue +def main(): + ''' combine the necessary files to create the ansible module ''' + args = parse_args() + if args.verify: + verify() + + for fname, parts in get_sources().items(): + data = generate(parts) + fname = os.path.join(LIBRARY, fname) with open(fname, 'w') as afd: afd.seek(0) afd.write(data.getvalue()) |