Skip to content

Commit a235361

Browse files
committed
fix: fixed flake8 issues
1 parent fd707e4 commit a235361

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

tools/proxy-endpoint-unifier/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def main():
3535
final_dict = {}
3636
processed_dict = {}
3737
if validation_enabled:
38-
utils.is_token_valid(os.getenv('APIGEE_ACCESS_TOKEN',''))
38+
utils.is_token_valid(os.getenv('APIGEE_ACCESS_TOKEN', ''))
3939

4040
for each_dir in proxies:
4141
each_proxy_dict = utils.read_proxy_artifacts(
4242
f"{proxy_dir}/{each_dir}/apiproxy",
43-
utils.parse_proxy_root(f"{proxy_dir}/{each_dir}/apiproxy")
43+
utils.parse_proxy_root(f"{proxy_dir}/{each_dir}/apiproxy") # noqa
4444
)
4545
if len(each_proxy_dict) > 0:
4646
each_proxy_rel = utils.get_proxy_objects_relationships(

tools/proxy-endpoint-unifier/utils.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import zipfile
2424
import requests
2525

26-
APIGEE_PROXY_ENDPOINT_LIMIT=10
26+
APIGEE_PROXY_ENDPOINT_LIMIT = 10
27+
2728

2829
def is_token_valid(token):
2930
"""Checks if an access token is valid.
@@ -43,19 +44,21 @@ def is_token_valid(token):
4344
response_json['email'] = ''
4445
print(f"Token Validated for user {response_json['email']}") # noqa pylint: disable=W1203
4546
return True
46-
print(f"Token expired or invalid. Please run export APIGEE_ACCESS_TOKEN=$(gcloud auth print-access-token)")
47+
print("Token expired or invalid. Please run export APIGEE_ACCESS_TOKEN=$(gcloud auth print-access-token)") # noqa
4748
sys.exit(1)
4849

50+
4951
def parse_config(config_file):
5052
config = configparser.ConfigParser()
5153
config.read(config_file)
5254
return config
5355

56+
5457
def get_proxy_endpoint_count(cfg):
5558
try:
5659
proxy_endpoint_count = cfg.getint('common', 'proxy_endpoint_count')
57-
if not (proxy_endpoint_count > 0 and proxy_endpoint_count <= APIGEE_PROXY_ENDPOINT_LIMIT):
58-
print(f'ERROR: Proxy Endpoints should be > Zero(0) & {APIGEE_PROXY_ENDPOINT_LIMIT}')
60+
if not (proxy_endpoint_count > 0 and proxy_endpoint_count <= APIGEE_PROXY_ENDPOINT_LIMIT): # noqa
61+
print(f'ERROR: Proxy Endpoints should be > Zero(0) & {APIGEE_PROXY_ENDPOINT_LIMIT}') # noqa
5962
sys.exit(1)
6063
except ValueError:
6164
print('proxy_endpoint_count should be a Number')
@@ -276,7 +279,6 @@ def get_all_policies_from_flow(flow, fault_rule=False): # noqa pylint: disable=
276279
return policies
277280

278281

279-
280282
def get_all_policies_from_endpoint(endpointData, endpointType):
281283
policies = []
282284
policies.extend(
@@ -453,19 +455,15 @@ def process_flow(flow, condition):
453455
dict: processed flow dictionary.
454456
"""
455457
processed_flow = flow.copy()
456-
457458
if flow.get('Request', None) is not None:
458459
Step = flow.get('Request', None).get('Step', None)
459-
if Step is not None:
460-
processed_flow['Request']['Step'] = process_steps(flow['Request'],
461-
condition)
460+
if Step is not None:
461+
processed_flow['Request']['Step'] = process_steps(flow['Request'], condition) # noqa
462462
if flow.get('Response', None) is not None:
463463
Step = flow.get('Response', None).get('Step', None)
464464
if Step is not None:
465-
processed_flow['Response']['Step'] = process_steps(flow['Response'],
466-
condition)
467-
processed_flow_with_condition = apply_condition(processed_flow,
468-
condition)
465+
processed_flow['Response']['Step'] = process_steps(flow['Response'], condition) # noqa
466+
processed_flow_with_condition = apply_condition(processed_flow, condition) # noqa
469467
return processed_flow_with_condition
470468

471469

@@ -531,7 +529,7 @@ def merge_proxy_endpoints(api_dict, basepath, pes):
531529
merged_pe['ProxyEndpoint']['Description'] = each_pe_info['ProxyEndpoint']['Description'] # noqa pylint: disable=C0301
532530
merged_pe['ProxyEndpoint']['FaultRules'] = each_pe_info['ProxyEndpoint']['FaultRules'] # noqa pylint: disable=C0301
533531
merged_pe['ProxyEndpoint']['HTTPProxyConnection']['BasePath'] = (basepath if basepath is None else f'/{basepath}') # noqa pylint: disable=C0301
534-
if len(merged_pe['ProxyEndpoint']['HTTPProxyConnection']['Properties']) != 0:
532+
if len(merged_pe['ProxyEndpoint']['HTTPProxyConnection']['Properties']) != 0: # noqa
535533
merged_pe['ProxyEndpoint']['HTTPProxyConnection']['Properties'] = each_pe_info['ProxyEndpoint']['HTTPProxyConnection']['Properties'] # noqa pylint: disable=C0301
536534
merged_pe['ProxyEndpoint']['HTTPProxyConnection']['VirtualHost'] = each_pe_info['ProxyEndpoint']['HTTPProxyConnection']['VirtualHost'] # noqa pylint: disable=C0301
537535

@@ -564,9 +562,10 @@ def merge_proxy_endpoints(api_dict, basepath, pes):
564562
merged_pe['ProxyEndpoint']['Flows']['Flow'].append(
565563
process_flow(each_flow, condition)
566564
)
567-
merged_pe['ProxyEndpoint']['@name'] = basepath.strip().replace('/','')
565+
merged_pe['ProxyEndpoint']['@name'] = basepath.strip().replace('/', '') # noqa
568566
return merged_pe
569567

568+
570569
def copy_folder(src, dst):
571570
try:
572571
shutil.copytree(src, dst)

0 commit comments

Comments
 (0)