Skip to content

Commit

Permalink
refactor: add data to a dictionary
Browse files Browse the repository at this point in the history
Signed-off-by: lucasvmx <[email protected]>
  • Loading branch information
lucasvmx committed Sep 11, 2022
1 parent 02757d4 commit 0052684
Showing 1 changed file with 12 additions and 36 deletions.
48 changes: 12 additions & 36 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

# Type constants
wt_data_types = {
"GAMECHAT": 1,
"HUDMSG": 2,
"INDICATORS": 3,
"MAPOBJECTS": 4,
"MAPINFO": 5,
"MISSION": 6,
"STATE": 7
"GAMECHAT": { "URL": gamechat_url, "FILE": gamechat_file},
"HUDMSG": { "URL": hudmsg_url, "FILE": hudmsg_file},
"INDICATORS": { "URL": indicators_url, "FILE": indicators_file },
"MAPOBJECTS": { "URL": mapobjects_url, "FILE": mapobjects_file },
"MAPINFO": { "URL": mapinfo_url, "FILE": mapinfo_file },
"MISSION": { "URL": mission_url, "FILE": mission_file },
"STATE": { "url": state_url, "FILE": state_file }
}

def get_correct_typename(typename: str):
Expand All @@ -50,35 +50,11 @@ def get_correct_typename(typename: str):

return typename

def get_url_and_filename(data_type: int):
url = ''
filename = ''

if data_type == wt_data_types['GAMECHAT']:
url = gamechat_url
filename = gamechat_file
elif data_type == wt_data_types['HUDMSG']:
url = hudmsg_url
filename = hudmsg_file
elif data_type == wt_data_types['INDICATORS']:
url = indicators_url
filename = indicators_file
elif data_type == wt_data_types['MAPOBJECTS']:
url = mapobjects_url
filename = mapobjects_file
elif data_type == wt_data_types['MAPINFO']:
url = mapinfo_url
filename = mapinfo_file
elif data_type == wt_data_types['MISSION']:
url = mission_url
filename = mission_file
elif data_type == wt_data_types['STATE']:
url = state_url
filename = state_file
else:
raise('Invalid parameter')

return [url, filename]
def get_url_and_filename(data_type: str):
if not data_type in wt_data_types.keys():
raise("invalid key")

return [wt_data_types[data_type]["URL"], wt_data_types[data_type]["URL"]]

def get_wt_data(data_type: int):

Expand Down

0 comments on commit 0052684

Please sign in to comment.