Added argument parsing.
This commit is contained in:
parent
3bb290cd0e
commit
097ea23731
|
@ -1,4 +1,4 @@
|
||||||
import sys
|
import sys, argparse
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def characters(soup):
|
def characters(soup):
|
||||||
|
@ -46,15 +46,21 @@ def inventory(soup):
|
||||||
|
|
||||||
item_tracking = {}
|
item_tracking = {}
|
||||||
|
|
||||||
|
print('-----')
|
||||||
|
|
||||||
|
storage_space_counter = 1
|
||||||
|
|
||||||
for inv_tag in soup.find_all('inv'):
|
for inv_tag in soup.find_all('inv'):
|
||||||
if inv_tag.parent.name != 'feat':
|
if inv_tag.parent.name != 'feat':
|
||||||
continue
|
continue
|
||||||
|
print('Storage space {}'.format(storage_space_counter))
|
||||||
|
print()
|
||||||
quantity_total = 0
|
quantity_total = 0
|
||||||
for s_tag in inv_tag.find_all('s'):
|
for s_tag in inv_tag.find_all('s'):
|
||||||
item_code = int(s_tag['elementaryId'])
|
item_code = int(s_tag['elementaryId'])
|
||||||
item_quantity = int(s_tag['inStorage'])
|
item_quantity = int(s_tag['inStorage'])
|
||||||
item_name = id_dict[item_code]
|
item_name = id_dict[item_code]
|
||||||
print("{}: {}, quantity: {}".format(item_code, item_name, item_quantity))
|
print("{:4}: {} - {}".format(item_code, item_name, item_quantity))
|
||||||
quantity_total += item_quantity
|
quantity_total += item_quantity
|
||||||
|
|
||||||
if item_code not in item_tracking:
|
if item_code not in item_tracking:
|
||||||
|
@ -62,11 +68,14 @@ def inventory(soup):
|
||||||
else:
|
else:
|
||||||
item_tracking[item_code] = item_tracking[item_code] + item_quantity
|
item_tracking[item_code] = item_tracking[item_code] + item_quantity
|
||||||
|
|
||||||
print('Total use of this storage space: {}'.format(quantity_total))
|
print()
|
||||||
|
print('Total use of storage space {}: {}'.format(storage_space_counter, quantity_total))
|
||||||
|
storage_space_counter += 1
|
||||||
print('-----')
|
print('-----')
|
||||||
|
|
||||||
|
|
||||||
print('Item total summary:')
|
print('Item total summary:')
|
||||||
|
print()
|
||||||
for item in item_tracking.items():
|
for item in item_tracking.items():
|
||||||
item_code = item[0]
|
item_code = item[0]
|
||||||
item_name = id_dict[item_code]
|
item_name = id_dict[item_code]
|
||||||
|
@ -76,7 +85,15 @@ def inventory(soup):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
filename = sys.argv[1]
|
parser = argparse.ArgumentParser(prog="Space Haven Saved Game Inspector", description="As above.")
|
||||||
|
|
||||||
|
parser.add_argument('filename')
|
||||||
|
parser.add_argument('--add_item', required=False, metavar='N', type=int, nargs=2, help="Add more of an item to storage by CODE - refer to accompanying data file reference")
|
||||||
|
parser.add_argument('--buff_chars', required=False, action='store_true')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
filename = args.filename
|
||||||
print(filename)
|
print(filename)
|
||||||
|
|
||||||
full_text = ""
|
full_text = ""
|
||||||
|
|
Loading…
Reference in New Issue