|
@@ -48,10 +48,12 @@ def main() -> None:
|
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
|
|
|
for planet, bases in zip(args.planets, executor.map(get_bases, args.planets)):
|
|
for planet, bases in zip(args.planets, executor.map(get_bases, args.planets)):
|
|
|
print(planet)
|
|
print(planet)
|
|
|
- for base in bases:
|
|
|
|
|
- if base['OwnerCode'] is None:
|
|
|
|
|
- continue
|
|
|
|
|
- print(f'\t{base["OwnerCode"]}\t{base["OwnerName"]}')
|
|
|
|
|
|
|
+ companies = executor.map(get_company, (base['OwnerCode'] for base in bases if base['OwnerCode'] is not None))
|
|
|
|
|
+ for co in sorted(companies, key=lambda co: co['CorporationCode'] or '\uffff'):
|
|
|
|
|
+ print('\t', end='')
|
|
|
|
|
+ if co['CorporationCode'] is not None:
|
|
|
|
|
+ print(f'[{co["CorporationCode"]}]', end=' ')
|
|
|
|
|
+ print(f'{co["UserName"]}\t{co["CompanyCode"]}\t{co["CompanyName"]}')
|
|
|
|
|
|
|
|
def get_sectors() -> tuple[typing.Mapping[str, typing.Collection[str]], typing.Mapping[str, typing.Sequence[System]]]:
|
|
def get_sectors() -> tuple[typing.Mapping[str, typing.Collection[str]], typing.Mapping[str, typing.Sequence[System]]]:
|
|
|
systems: typing.Sequence[System] = cache.get('https://rest.fnar.net/systemstars')
|
|
systems: typing.Sequence[System] = cache.get('https://rest.fnar.net/systemstars')
|
|
@@ -66,6 +68,9 @@ def get_sectors() -> tuple[typing.Mapping[str, typing.Collection[str]], typing.M
|
|
|
def get_bases(planet: str) -> typing.Sequence[Site]:
|
|
def get_bases(planet: str) -> typing.Sequence[Site]:
|
|
|
return cache.get('https://rest.fnar.net/planet/sites/' + planet, expiry=cache.ONE_DAY)
|
|
return cache.get('https://rest.fnar.net/planet/sites/' + planet, expiry=cache.ONE_DAY)
|
|
|
|
|
|
|
|
|
|
+def get_company(code: str) -> typing.Mapping[str, typing.Any]:
|
|
|
|
|
+ return cache.get('https://rest.fnar.net/company/code/' + code, expiry=cache.ONE_DAY)
|
|
|
|
|
+
|
|
|
class System(typing.TypedDict):
|
|
class System(typing.TypedDict):
|
|
|
SystemId: str
|
|
SystemId: str
|
|
|
NaturalId: str
|
|
NaturalId: str
|
|
@@ -82,5 +87,11 @@ class Site(typing.TypedDict):
|
|
|
OwnerName: str
|
|
OwnerName: str
|
|
|
OwnerCode: str | None
|
|
OwnerCode: str | None
|
|
|
|
|
|
|
|
|
|
+class Company(typing.TypedDict):
|
|
|
|
|
+ UserName: str
|
|
|
|
|
+ CompanyCode: str
|
|
|
|
|
+ CompanyName: str
|
|
|
|
|
+ CorporationCode: str
|
|
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
main()
|
|
main()
|