mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-20 16:54:31 +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
5583486589
commit
c233fa5ff5
16
collate.py
16
collate.py
@ -185,20 +185,24 @@ def addships(data):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) <= 1:
|
if len(sys.argv) <= 1:
|
||||||
print('Usage: collate.py [dump.json]')
|
print('Usage: collate.py [dump.json]')
|
||||||
else:
|
sys.exit()
|
||||||
|
|
||||||
# read from dumped json file(s)
|
# read from dumped json file(s)
|
||||||
session = companion.Session()
|
session = companion.Session()
|
||||||
for f in sys.argv[1:]:
|
for file_name in sys.argv[1:]:
|
||||||
with open(f) as h:
|
data = None
|
||||||
print(f)
|
with open(file_name) as f:
|
||||||
data = json.load(h)
|
print(file_name)
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
if not data['commander'].get('docked'):
|
if not data['commander'].get('docked'):
|
||||||
print('Not docked!')
|
print('Not docked!')
|
||||||
|
continue
|
||||||
|
|
||||||
elif not data.get('lastStarport'):
|
elif not data.get('lastStarport'):
|
||||||
print('No starport!')
|
print('No starport!')
|
||||||
|
continue
|
||||||
|
|
||||||
else:
|
|
||||||
if data['lastStarport'].get('commodities'):
|
if data['lastStarport'].get('commodities'):
|
||||||
addcommodities(data)
|
addcommodities(data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user