Skip to content

Commit 5c3fbcc

Browse files
committed
Cosmetic fixes
1 parent afb1450 commit 5c3fbcc

File tree

5 files changed

+25
-32
lines changed

5 files changed

+25
-32
lines changed

hierarchical_yaml/config_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
import json
1717
from .interpolation import InterpolationResolver, InterpolationValidator
1818
from .remote_state import S3TerraformRemoteStateRetriever
19-
from .python_compat import iteritems, primitive_types
19+
from .python_compat import iteritems, primitive_types, PY3
20+
2021

2122
class ConfigProcessor(object):
2223

@@ -103,11 +104,10 @@ def dict_constructor(loader, node):
103104
Dumper.add_representer(OrderedDict, dict_representer)
104105
Loader.add_constructor(_mapping_tag, dict_constructor)
105106

106-
Dumper.add_representer(str,
107-
SafeRepresenter.represent_str)
107+
Dumper.add_representer(str, SafeRepresenter.represent_str)
108108

109-
Dumper.add_representer(unicode,
110-
SafeRepresenter.represent_unicode)
109+
if not PY3:
110+
Dumper.add_representer(unicode, SafeRepresenter.represent_unicode)
111111
return Dumper
112112

113113
@staticmethod

hierarchical_yaml/inject_secrets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
except ImportError:
1515
from backports.functools_lru_cache import lru_cache
1616

17+
1718
class SecretInjector(object):
1819
"""
1920
Resolve secrets in the form:

hierarchical_yaml/interpolation.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def is_full_interpolation(value):
2424
def remove_white_spaces(value):
2525
return re.sub(r"\s+", "", value)
2626

27+
2728
class InterpolationResolver(object):
2829

2930
def resolve_interpolations(self, data):
@@ -56,10 +57,7 @@ def get_secret_injector(self, data):
5657
return SecretInjector(default_aws_profile)
5758

5859

59-
class DictIterator:
60-
61-
def __init__(self):
62-
pass
60+
class DictIterator(object):
6361

6462
def loop_all_items(self, data, process_func):
6563
if isinstance(data, string_types):
@@ -78,8 +76,6 @@ def loop_all_items(self, data, process_func):
7876

7977

8078
class AbstractInterpolationResolver(DictIterator):
81-
def __init__(self):
82-
pass
8379

8480
def resolve_interpolations(self, data):
8581
return self.loop_all_items(data, self.resolve_interpolation)
@@ -118,9 +114,6 @@ def do_resolve_interpolation(self, line):
118114

119115
class InterpolationValidator(DictIterator):
120116

121-
def __init__(self):
122-
pass
123-
124117
def check_all_interpolations_resolved(self, data):
125118
return self.loop_all_items(data, self.validate_value)
126119

@@ -130,7 +123,7 @@ def validate_value(self, value):
130123
return value
131124

132125

133-
class FromDictInjector:
126+
class FromDictInjector(object):
134127

135128
def __init__(self):
136129
self.results = {}
@@ -167,10 +160,7 @@ def parse_leaves(self, data, partial_key):
167160
self.parse_leaves(value, new_key)
168161

169162

170-
class FullBlobInjector:
171-
172-
def __init__(self):
173-
pass
163+
class FullBlobInjector(object):
174164

175165
def resolve(self, line, data):
176166
if not is_full_interpolation(line):

hierarchical_yaml/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
from .config_generator import ConfigProcessor
1414

15+
1516
def run(args=None):
1617
""" App entry point """
1718

@@ -32,7 +33,7 @@ def run(args=None):
3233
parser.add_argument('--enclosing-key', dest='enclosing_key', type=str,
3334
help='enclose the generated data under a common key')
3435
parser.add_argument('--cwd', dest='cwd', type=str, default="",
35-
help='the working directory')
36+
help='the working directory')
3637

3738
opts = parser.parse_args(args)
3839
cwd = opts.cwd if opts.cwd else os.getcwd()
@@ -42,5 +43,5 @@ def run(args=None):
4243

4344
config_processor = ConfigProcessor()
4445
config_processor.process(cwd, opts.path, filters, excluded_keys, opts.enclosing_key, opts.output_format,
45-
print_data, opts.output_file, opts.skip_interpolation_resolving,
46-
opts.skip_interpolation_validation)
46+
print_data, opts.output_file, opts.skip_interpolation_resolving,
47+
opts.skip_interpolation_validation)

hierarchical_yaml/simplessm.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#Copyright 2019 Adobe. All rights reserved.
2-
#This file is licensed to you under the Apache License, Version 2.0 (the "License");
3-
#you may not use this file except in compliance with the License. You may obtain a copy
4-
#of the License at http://www.apache.org/licenses/LICENSE-2.0
1+
# Copyright 2019 Adobe. All rights reserved.
2+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License. You may obtain a copy
4+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
55

6-
#Unless required by applicable law or agreed to in writing, software distributed under
7-
#the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8-
#OF ANY KIND, either express or implied. See the License for the specific language
9-
#governing permissions and limitations under the License.
6+
# Unless required by applicable law or agreed to in writing, software distributed under
7+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
8+
# OF ANY KIND, either express or implied. See the License for the specific language
9+
# governing permissions and limitations under the License.
1010

1111
from botocore.exceptions import ClientError
1212
import boto3
@@ -24,10 +24,11 @@ def get(self, key):
2424
try:
2525
return client.get_parameter(Name=key, WithDecryption=True).get("Parameter").get("Value")
2626
except ClientError as e:
27-
raise Exception('Error while trying to read SSM value for key: %s - %s' % (key, e.response['Error']['Code']))
27+
raise Exception(
28+
'Error while trying to read SSM value for key: %s - %s' % (key, e.response['Error']['Code']))
2829
finally:
2930
self.release_ssm_client()
30-
31+
3132
def get_ssm_client(self):
3233
os.environ['AWS_PROFILE'] = self.aws_profile
3334
return boto3.client('ssm', region_name=self.region_name)

0 commit comments

Comments
 (0)