Skip to content

Commit

Permalink
more compact code
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Aug 16, 2024
1 parent 7b9e8ee commit c0dab87
Showing 1 changed file with 54 additions and 48 deletions.
102 changes: 54 additions & 48 deletions cdci_data_analysis/flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,11 @@ def get(self, path):

@app.route('/resolve_name', methods=['GET'])
def resolve_name():
logger.info("request.args: %s ", request.args)
token = request.args.get('token', None)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 606 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L604-L606

Added lines #L604 - L606 were not covered by tests

token = par_dic.pop('token', None)

Check warning on line 608 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L608

Added line #L608 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -613,7 +616,7 @@ def resolve_name():
if output_code is not None:
return make_response(output, output_code)

name = request.args.get('name', None)
name = par_dic.get('name', None)

Check warning on line 619 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L619

Added line #L619 was not covered by tests

name_resolver_url = app_config.name_resolver_url
entities_portal_url = app_config.entities_portal_url
Expand All @@ -627,8 +630,11 @@ def resolve_name():

@app.route('/get_revnum', methods=['GET'])
def get_revnum():
logger.info("request.args: %s ", request.args)
token = request.args.get('token', None)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 635 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L633-L635

Added lines #L633 - L635 were not covered by tests

token = par_dic.pop('token', None)

Check warning on line 637 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L637

Added line #L637 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -639,7 +645,7 @@ def get_revnum():
if output_code is not None:
return make_response(output, output_code)

time_to_convert = request.args.get('time_to_convert', None)
time_to_convert = par_dic.get('time_to_convert', None)

Check warning on line 648 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L648

Added line #L648 was not covered by tests

converttime_revnum_service_url = app_config.converttime_revnum_service_url

Expand All @@ -650,8 +656,11 @@ def get_revnum():

@app.route('/get_list_terms', methods=['GET'])
def get_list_terms():
logger.info("request.args: %s ", request.args)
token = request.args.get('token', None)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 661 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L659-L661

Added lines #L659 - L661 were not covered by tests

token = par_dic.pop('token', None)

Check warning on line 663 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L663

Added line #L663 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -665,8 +674,8 @@ def get_list_terms():

sentry_dsn = sentry.sentry_url

group = request.args.get('group', None)
parent = request.args.get('parent', None)
group = par_dic.get('group', None)
parent = par_dic.get('parent', None)

Check warning on line 678 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L677-L678

Added lines #L677 - L678 were not covered by tests

list_terms = drupal_helper.get_list_terms(disp_conf=app_config,
group=group,
Expand All @@ -681,8 +690,11 @@ def get_list_terms():

@app.route('/get_parents_term', methods=['GET'])
def get_parents_term():
logger.info("request.args: %s ", request.args)
token = request.args.get('token', None)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 695 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L693-L695

Added lines #L693 - L695 were not covered by tests

token = par_dic.pop('token', None)

Check warning on line 697 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L697

Added line #L697 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -696,8 +708,8 @@ def get_parents_term():

sentry_dsn = sentry.sentry_url

group = request.args.get('group', None)
term = request.args.get('term', None)
group = par_dic.get('group', None)
term = par_dic.get('term', None)

Check warning on line 712 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L711-L712

Added lines #L711 - L712 were not covered by tests

list_parents = drupal_helper.get_parents_term(disp_conf=app_config,
term=term,
Expand All @@ -712,9 +724,12 @@ def get_parents_term():

@app.route('/get_observation_attachments', methods=['GET'])
def get_observation_attachments():
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 729 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L727-L729

Added lines #L727 - L729 were not covered by tests
logger.info("request.args: %s ", request.args)

token = request.args.get('token', None)
token = par_dic.pop('token', None)

Check warning on line 732 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L732

Added line #L732 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -726,9 +741,6 @@ def get_observation_attachments():
return make_response(output, output_code)
decoded_token = output

par_dic = request.values.to_dict()
par_dic.pop('token')

sentry_dsn = sentry.sentry_url

gallery_secret_key = app_config.product_gallery_secret_key
Expand All @@ -752,10 +764,12 @@ def get_observation_attachments():

@app.route('/get_all_revs', methods=['GET'])
def get_all_revs():
logger.info("request.args: %s ", request.args)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 769 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L767-L769

Added lines #L767 - L769 were not covered by tests
logger.info("request.files: %s ", request.files)

token = request.args.get('token', None)
token = par_dic.pop('token', None)

Check warning on line 772 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L772

Added line #L772 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -767,9 +781,6 @@ def get_all_revs():
return make_response(output, output_code)
decoded_token = output

par_dic = request.values.to_dict()
par_dic.pop('token')

sentry_dsn = sentry.sentry_url

gallery_secret_key = app_config.product_gallery_secret_key
Expand All @@ -792,10 +803,12 @@ def get_all_revs():

@app.route('/get_all_astro_entities', methods=['GET'])
def get_all_astro_entities():
logger.info("request.args: %s ", request.args)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 808 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L806-L808

Added lines #L806 - L808 were not covered by tests
logger.info("request.files: %s ", request.files)

token = request.args.get('token', None)
token = par_dic.pop('token', None)

Check warning on line 811 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L811

Added line #L811 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -807,9 +820,6 @@ def get_all_astro_entities():
return make_response(output, output_code)
decoded_token = output

par_dic = request.values.to_dict()
par_dic.pop('token')

sentry_dsn = sentry.sentry_url

gallery_secret_key = app_config.product_gallery_secret_key
Expand All @@ -831,15 +841,17 @@ def get_all_astro_entities():

@app.route('/get_astro_entity_info_by_source_name', methods=['GET'])
def get_astro_entity_info_by_source_name():
logger.info("request.args: %s ", request.args)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 846 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L844-L846

Added lines #L844 - L846 were not covered by tests
logger.info("request.files: %s ", request.files)

app_config = app.config.get('conf')

sentry_dsn = sentry.sentry_url

product_gallery_url = app_config.product_gallery_url
src_name = request.args.get('src_name', None)
src_name = par_dic.get('src_name', None)

Check warning on line 854 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L854

Added line #L854 was not covered by tests

source_entity_info = drupal_helper.get_source_astrophysical_entity_info_by_source_and_alternative_name(product_gallery_url,
gallery_jwt_token=None,
Expand All @@ -866,10 +878,11 @@ def get_astro_entity_info_by_source_name():

@app.route('/get_data_product_list_with_conditions', methods=['GET'])
def get_data_product_list_with_conditions():
logger.info("request.args: %s ", request.args)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 883 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L881-L883

Added lines #L881 - L883 were not covered by tests
logger.info("request.files: %s ", request.files)

par_dic = request.values.to_dict()
token = par_dic.pop('token', None)
app_config = app.config.get('conf')
secret_key = app_config.secret_key
Expand All @@ -893,8 +906,6 @@ def get_data_product_list_with_conditions():
# update the token
gallery_jwt_token = drupal_helper.generate_gallery_jwt_token(gallery_secret_key, user_id=user_id_product_creator)

# src_name = par_dic.pop('src_name', None)

output_get = drupal_helper.get_data_product_list_by_source_name_with_conditions(product_gallery_url=product_gallery_url,
gallery_jwt_token=gallery_jwt_token,
sentry_dsn=sentry_dsn,
Expand All @@ -907,10 +918,12 @@ def get_data_product_list_with_conditions():
# TODO to refactor using get_data_product_list_with_conditions
@app.route('/get_data_product_list_by_source_name', methods=['GET'])
def get_data_product_list_by_source_name():
logger.info("request.args: %s ", request.args)
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)
logger.info("request.args: %s ", sanitized_par_dic)

Check warning on line 923 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L921-L923

Added lines #L921 - L923 were not covered by tests
logger.info("request.files: %s ", request.files)

token = request.args.get('token', None)
token = par_dic.pop('token', None)

Check warning on line 926 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L926

Added line #L926 was not covered by tests
app_config = app.config.get('conf')
secret_key = app_config.secret_key

Expand All @@ -922,8 +935,6 @@ def get_data_product_list_by_source_name():
return make_response(output, output_code)
decoded_token = output

par_dic = request.values.to_dict()
par_dic.pop('token')

sentry_dsn = sentry.sentry_url

Expand Down Expand Up @@ -955,8 +966,7 @@ def post_astro_entity_to_gallery():
logger.info("request.values: %s ", sanitized_par_dic)

Check warning on line 966 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L966

Added line #L966 was not covered by tests
logger.info("request.files: %s ", request.files)

token = par_dic.get('token', None)
par_dic.pop('token')
token = par_dic.pop('token', None)

Check warning on line 969 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L969

Added line #L969 was not covered by tests

app_config = app.config.get('conf')
secret_key = app_config.secret_key
Expand All @@ -983,8 +993,7 @@ def post_observation_to_gallery():
par_dic = request.values.to_dict()
sanitized_par_dic = sanitize_dict_before_log(par_dic)

Check warning on line 994 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L993-L994

Added lines #L993 - L994 were not covered by tests

token = par_dic.get('token', None)
par_dic.pop('token')
token = par_dic.pop('token', None)

Check warning on line 996 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L996

Added line #L996 was not covered by tests

logger.info("request.values: %s ", sanitized_par_dic)

Check warning on line 998 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L998

Added line #L998 was not covered by tests
logger.info("request.files: %s ", request.files)
Expand Down Expand Up @@ -1017,8 +1026,7 @@ def post_product_to_gallery():
logger.info("request.values: %s ", sanitized_par_dic)

Check warning on line 1026 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1026

Added line #L1026 was not covered by tests
logger.info("request.files: %s ", request.files)

token = par_dic.get('token', None)
par_dic.pop('token')
token = par_dic.pop('token', None)

Check warning on line 1029 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1029

Added line #L1029 was not covered by tests

app_config = app.config.get('conf')
secret_key = app_config.secret_key
Expand Down Expand Up @@ -1047,8 +1055,7 @@ def delete_product_to_gallery():
logger.info("request.values: %s ", sanitized_par_dic)

Check warning on line 1055 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1055

Added line #L1055 was not covered by tests
logger.info("request.files: %s ", request.files)

token = par_dic.get('token', None)
par_dic.pop('token')
token = par_dic.pop('token', None)

Check warning on line 1058 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1058

Added line #L1058 was not covered by tests

app_config = app.config.get('conf')
secret_key = app_config.secret_key
Expand Down Expand Up @@ -1077,8 +1084,7 @@ def post_revolution_processing_log_to_gallery():
logger.info("request.values: %s ", sanitized_par_dic)

Check warning on line 1084 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1084

Added line #L1084 was not covered by tests
logger.info("request.files: %s ", request.files)

token = par_dic.get('token', None)
par_dic.pop('token')
token = par_dic.pop('token', None)

Check warning on line 1087 in cdci_data_analysis/flask_app/app.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/flask_app/app.py#L1087

Added line #L1087 was not covered by tests

app_config = app.config.get('conf')
secret_key = app_config.secret_key
Expand Down

0 comments on commit c0dab87

Please sign in to comment.