text
stringlengths
0
828
if os.path.exists(yaml_path):
return yaml_path
directory = os.path.dirname(directory)
return"
1152,"def _load_yaml_config(path=None):
""""""Open and return the yaml contents.""""""
countour_yaml_path = path or find_contour_yaml()
if countour_yaml_path is None:
logging.debug(""countour.yaml not found."")
return None
with open(countour_yaml_path) as yaml_file:
return yaml_file.read()"
1153,"def build_parser():
""""""
_build_parser_
Set up CLI parser options, parse the
CLI options an return the parsed results
""""""
parser = argparse.ArgumentParser(
description='dockerstache templating util'
)
parser.add_argument(
'--output', '-o',
help='Working directory to render dockerfile and templates',
dest='output',
default=None
)
parser.add_argument(
'--input', '-i',
help='Working directory containing dockerfile and script mustache templates',
dest='input',
default=os.getcwd()
)
parser.add_argument(
'--context', '-c',
help='JSON file containing context dictionary to render templates',
dest='context',
default=None
)
parser.add_argument(
'--defaults', '-d',
help='JSON file containing default context dictionary to render templates',
dest='defaults',
default=None
)
parser.add_argument(
'--inclusive',
help='include non .mustache files from template',
default=False,
action='store_true'
)
parser.add_argument(
'--exclude', '-e',
help='exclude files from template in this list',
default=[],
nargs='+'
)
opts = parser.parse_args()
return vars(opts)"
1154,"def main():
""""""
_main_
Create a CLI parser and use that to run
the template rendering process
""""""
options = build_parser()
try:
run(**options)
except RuntimeError as ex:
msg = (
""An error occurred running dockerstache: {} ""
""please see logging info above for details""
).format(ex)
LOGGER.error(msg)
sys.exit(1)"
1155,"def _guess_type_from_validator(validator):
""""""
Utility method to return the declared type of an attribute or None. It handles _OptionalValidator and _AndValidator
in order to unpack the validators.
:param validator:
:return: the type of attribute declared in an inner 'instance_of' validator (if any is found, the first one is used)
or None if no inner 'instance_of' validator is found
""""""
if isinstance(validator, _OptionalValidator):
# Optional : look inside
return _guess_type_from_validator(validator.validator)
elif isinstance(validator, _AndValidator):
# Sequence : try each of them
for v in validator.validators: