mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-30 23:29:30 +03:00
Refactor __main__ logic
Most of this is just de-pyramiding the code, removing else clauses that are unneeded (or making the if such that the else is not needed). Rationale is simple, every level of indentation adds more that the reader needs to keep track of.
This commit is contained in:
parent
fe3a6c11f4
commit
3a2e159b1e
16
collate.py
16
collate.py
@ -185,20 +185,24 @@ def addships(data):
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) <= 1:
|
||||
print('Usage: collate.py [dump.json]')
|
||||
else:
|
||||
sys.exit()
|
||||
|
||||
# read from dumped json file(s)
|
||||
session = companion.Session()
|
||||
for f in sys.argv[1:]:
|
||||
with open(f) as h:
|
||||
print(f)
|
||||
data = json.load(h)
|
||||
for file_name in sys.argv[1:]:
|
||||
data = None
|
||||
with open(file_name) as f:
|
||||
print(file_name)
|
||||
data = json.load(f)
|
||||
|
||||
if not data['commander'].get('docked'):
|
||||
print('Not docked!')
|
||||
continue
|
||||
|
||||
elif not data.get('lastStarport'):
|
||||
print('No starport!')
|
||||
continue
|
||||
|
||||
else:
|
||||
if data['lastStarport'].get('commodities'):
|
||||
addcommodities(data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user