-
Notifications
You must be signed in to change notification settings - Fork 7
/
structure-audit.py
63 lines (58 loc) · 1.89 KB
/
structure-audit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
import logging
import argparse
from structurebot.citadels import Structure
from structurebot.config import CONFIG
import six
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--csv', help='Print CSV output',
action='store_true')
parser.add_argument('-d', '--debug', help='Print debug output',
action='store_true')
args = parser.parse_args()
level = logging.WARNING
if CONFIG['DEBUG'] or args.debug:
level = logging.INFO
logging.basicConfig(level=level)
pyswagger_logger = logging.getLogger('pyswagger')
pyswagger_logger.setLevel(logging.ERROR)
structures = Structure.from_corporation(CONFIG['CORPORATION_NAME'])
total_fuel = 0
if args.csv:
import csv
import sys
columns = [
'structure_id',
'type_name',
'name',
'state',
'state_timer_end',
'unanchoring',
'fuel_expires',
'fuel_rate',
'needs_fuel',
'jump_fuel',
'needs_core',
'profile_id',
'packaged_volume',
'system_name',
'constellation_name',
'region_name'
]
writer = csv.writer(sys.stdout)
writer.writerow(columns)
for structure in sorted(structures, key=lambda x: x.name):
if args.csv:
writer.writerow([getattr(structure, c)
for c in columns])
else:
print(structure)
print('Fuel/Cycle: {}'.format(structure.fuel_rate))
print(structure.fitting)
print('-----')
total_fuel += structure.fuel_rate
if not args.csv:
print('Total fuel/cycle: {}'.format(total_fuel))