Permalink
Browse files

the result of running `black .`

	modified:   bf.py
	modified:   botoform/__main__.py
	modified:   botoform/builders.py
	modified:   botoform/config.py
	modified:   botoform/enriched/__init__.py
	modified:   botoform/enriched/autoscaling.py
	modified:   botoform/enriched/elasticache.py
	modified:   botoform/enriched/elb.py
	modified:   botoform/enriched/enriched.py
	modified:   botoform/enriched/instance.py
	modified:   botoform/enriched/key_pair.py
	modified:   botoform/enriched/rds.py
	modified:   botoform/enriched/route53.py
	modified:   botoform/enriched/vpc.py
	modified:   botoform/enriched/vpc_endpoint.py
	modified:   botoform/plugins/__init__.py
	modified:   botoform/plugins/atmosphere.py
	modified:   botoform/plugins/create.py
	modified:   botoform/plugins/destroy.py
	modified:   botoform/plugins/dump.py
	modified:   botoform/plugins/exec.py
	modified:   botoform/plugins/list.py
	modified:   botoform/plugins/lock.py
	modified:   botoform/plugins/refresh.py
	modified:   botoform/plugins/repl.py
	modified:   botoform/plugins/unlock.py
	modified:   botoform/subnetallocator.py
	modified:   docs/source/conf.py
	modified:   hbf.py
	modified:   setup.py
	modified:   tests/unit/helpers.py
	modified:   tests/unit/test_config_loader.py
	modified:   tests/unit/test_enriched_evpc.py
	modified:   tests/unit/test_enriched_instance.py
	modified:   tests/unit/test_subnetallocator.py
	modified:   tests/unit/test_utils.py
  • Loading branch information...
russellballestrini committed May 25, 2018
1 parent 4145351 commit 9b0cbb1cb21ddab4be4492e9e99ab2afb20a0c3f
1 bf.py
@@ -1,3 +1,4 @@
#!/usr/bin/env python
from botoform.__main__ import main
main()
@@ -6,10 +6,13 @@
from os import environ
def get_profile_names():
"""Return a list of profile names in ~/.aws/config"""
import botocore.session
return botocore.session.get_session().full_config.get('profiles', {}).keys()
return botocore.session.get_session().full_config.get("profiles", {}).keys()
def load_entry_points(group_name):
"""Return a dictionary of entry_points related to given group_name"""
@@ -18,68 +21,77 @@ def load_entry_points(group_name):
entry_points[entry_point.name] = entry_point.load()
return entry_points
def load_parsers_from_plugins(subparser, plugins):
"""iterate over all plugins and load their parser."""
for plugin_name, plugin_class in plugins.items():
# create a parser object for the plugin.
plugin_parser = subparser.add_parser(
plugin_name,
description = plugin_class.__doc__,
)
plugin_name, description=plugin_class.__doc__
)
plugin_parser.add_argument('vpc_name', help='The VPC\'s Name tag.')
plugin_parser.add_argument("vpc_name", help="The VPC's Name tag.")
try:
# Assume class plugin with 'setup_parser' and 'main' staticmethods.
plugin_class.setup_parser(plugin_parser)
plugin_parser.set_defaults(func = plugin_class.main)
plugin_parser.set_defaults(func=plugin_class.main)
except AttributeError:
# Assume function plugin w/o 'setup_parser' or 'main' staticmethods.
plugin_parser.set_defaults(func = plugin_class)
plugin_parser.set_defaults(func=plugin_class)
def build_parser(description, load_subparser_plugins=False):
"""build argparser and attach each plugin's parser to subparser."""
parser = argparse.ArgumentParser(description = description)
#requiredNamed = parser.add_argument_group('required named arguments')
parser.add_argument('-p', '--profile', choices=get_profile_names(),
default=environ.get('AWS_DEFAULT_PROFILE', None),
help='botocore profile name for AWS creds and other vars.')
parser.add_argument('-r', '--region',
default=environ.get('AWS_DEFAULT_REGION', None),
help='AWS region to use')
#parser.add_argument('--search-regions', action='store_true', default=False,
parser = argparse.ArgumentParser(description=description)
# requiredNamed = parser.add_argument_group('required named arguments')
parser.add_argument(
"-p",
"--profile",
choices=get_profile_names(),
default=environ.get("AWS_DEFAULT_PROFILE", None),
help="botocore profile name for AWS creds and other vars.",
)
parser.add_argument(
"-r",
"--region",
default=environ.get("AWS_DEFAULT_REGION", None),
help="AWS region to use",
)
# parser.add_argument('--search-regions', action='store_true', default=False,
# help='search regions for VPC with given vpc_name')
#parser.add_argument('--quiet', action='store_true', default=False,
# parser.add_argument('--quiet', action='store_true', default=False,
# help='prevent status messages to STDOUT')
if load_subparser_plugins:
# create a subparser for our plugins to attach to.
subparser = parser.add_subparsers(
title = 'subcommands',
description = 'valid subcommands',
help = '--help for additional subcommand help'
)
plugins = load_entry_points('botoform.plugins')
title="subcommands",
description="valid subcommands",
help="--help for additional subcommand help",
)
plugins = load_entry_points("botoform.plugins")
load_parsers_from_plugins(subparser, plugins)
else:
parser.add_argument('vpc_name', help='The VPC\'s Name tag.')
parser.add_argument("vpc_name", help="The VPC's Name tag.")
return parser
def get_evpc_from_args(args):
if 'skip_evpc' not in args.__dict__:
if "skip_evpc" not in args.__dict__:
return EnrichedVPC(
vpc_name = args.vpc_name,
region_name = args.region,
profile_name = args.profile,
)
vpc_name=args.vpc_name, region_name=args.region, profile_name=args.profile
)
def main():
parser = build_parser('Manage infrastructure on AWS using YAML', True)
parser = build_parser("Manage infrastructure on AWS using YAML", True)
args = parser.parse_args()
evpc = get_evpc_from_args(args)
# call the plugin main method.
args.func(args, evpc)
if __name__ == '__main__':
if __name__ == "__main__":
main()
Oops, something went wrong.

0 comments on commit 9b0cbb1

Please sign in to comment.