diff options
author | Aki <please@ignore.pl> | 2022-05-25 00:20:53 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-05-25 00:21:06 +0200 |
commit | f0c5c468c75a780bed55fabd91e8b153e27bf804 (patch) | |
tree | 2fe32d0809c155980caed294dec4b769ffe218bb /scrap.py | |
parent | 9dfaa42565692b31a028ec92372fa675da4f3e21 (diff) | |
download | salvager-f0c5c468c75a780bed55fabd91e8b153e27bf804.zip salvager-f0c5c468c75a780bed55fabd91e8b153e27bf804.tar.gz salvager-f0c5c468c75a780bed55fabd91e8b153e27bf804.tar.bz2 |
Streamlined quote and blanks formatting
Diffstat (limited to 'scrap.py')
-rw-r--r-- | scrap.py | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -21,7 +21,7 @@ def get_hash(kill): data = response.json() if len(data) > 1: raise ValueError() - return data[0]["zkb"]["hash"] + return data[0]['zkb']['hash'] class RelatedParser(HTMLParser): @@ -36,15 +36,12 @@ class RelatedParser(HTMLParser): def handle_starttag(self, tag, attrs): attrs = dict(attrs) - if tag == "table" and attrs.get("id", "").lower() == "killlist": self._team += 1 - if tag == "tr" and attrs.get("class", "").lower() == "killlistrow" and self._team > 0: self._flush() killid = attrs.get("killid", "") self._current = (killid, self._team, None) - if tag == "a" and self._team > 0 and self._current: match = OWNER_HREF.match(attrs.get("href", "")) if match: @@ -77,19 +74,19 @@ def get_related_kills(url): killmails = [] teams = (set(), set()) for kill, team, victim in related.kills: - killmails.append({"id": int(kill)}) + killmails.append({'id': int(kill)}) destination = teams[team - 1] destination.add(int(victim)) - return {"killmails": killmails, "teams": list(map(list, teams))} + return {'killmails': killmails, 'teams': list(map(list, teams))} def expand_hashes(snapshot): """ Expands killmails in *snapshot* IN PLACE by adding their hash based on information from Zkillboard. """ - for killmail in snapshot["killmails"]: + for killmail in snapshot['killmails']: time.sleep(1.05) # Zkillboard is very sensitive. - killmail["hash"] = get_hash(killmail["id"]) + killmail['hash'] = get_hash(killmail['id']) return snapshot @@ -139,7 +136,7 @@ def main(): expand_hashes(snapshot) expand_details(snapshot) filename = output_name(args) - with open(filename, "w") as fd: + with open(filename, 'w') as fd: opts = {'indent': 4} if args.pretty else {} fd.write(json.dumps(snapshot, **opts)) fd.write("\n") |