Skip to content

Commit

Permalink
refactor: assign FOCA config to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jvkersch committed Jun 18, 2024
1 parent adff084 commit fabd702
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions drs_filer/ga4gh/drs/endpoints/register_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,26 @@ def register_object(
A unique identifier for the object.
"""
# Set parameters
foca_config = current_app.config.foca
db_collection = (
current_app.config.foca.db.dbs['drsStore'].
foca_config.db.dbs['drsStore'].
collections['objects'].client
)
url_prefix = current_app.config.foca.endpoints['url_prefix']
external_host = current_app.config.foca.endpoints['external_host']
external_port = current_app.config.foca.endpoints['external_port']
api_path = current_app.config.foca.endpoints['api_path']
url_prefix = foca_config.endpoints['url_prefix']
external_host = foca_config.endpoints['external_host']
external_port = foca_config.endpoints['external_port']
api_path = foca_config.endpoints['api_path']

# Set flags and parameters for POST/PUT routes
replace = True
was_replaced = False
if object_id is None:
replace = False
id_length = (
current_app.config.foca.endpoints['objects']['id_length']
foca_config.endpoints['objects']['id_length']
)
id_charset: str = (
current_app.config.foca.endpoints['objects']['id_charset']
foca_config.endpoints['objects']['id_charset']
)
# evaluate character set expression or interpret literal string as set
try:
Expand Down Expand Up @@ -120,11 +121,12 @@ def __add_access_ids(data: List) -> List:
Returns:
Access methods metadata complete with unique access identifiers.
"""
foca_config = current_app.config.foca
id_charset = eval(
current_app.config.foca.endpoints['access_methods']['id_charset']
foca_config.endpoints['access_methods']['id_charset']
)
id_length = (
current_app.config.foca.endpoints['access_methods']['id_length']
foca_config.endpoints['access_methods']['id_length']
)
access_ids = []
for method in data:
Expand Down

0 comments on commit fabd702

Please sign in to comment.