aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--update.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/update.py b/update.py
index 64a7768..7f84193 100644
--- a/update.py
+++ b/update.py
@@ -1,3 +1,4 @@
+from collections import defaultdict
import csv
from dataclasses import dataclass
import datetime
@@ -83,7 +84,7 @@ if not dump_tarball.exists():
csv.field_size_limit(69696969)
dump = tarfile.open(dump_tarball)
-crates = dict()
+crates = defaultdict(lambda: Crate('', -1))
metadata = None
for item in dump:
if item.name.endswith('metadata.json'):
@@ -91,9 +92,9 @@ for item in dump:
elif item.name.endswith('crates.csv'):
reader = csv.DictReader(io.TextIOWrapper(dump.extractfile(item), 'UTF-8'))
for crate in reader:
- crates[crate['id']] = Crate(crate['name'], int(crate['downloads']))
+ crates[crate['id']].name = crate['name']
+ crates[crate['id']].downloads = int(crate['downloads'])
elif item.name.endswith('versions.csv'):
- assert len(crates) > 0, "versions read before crates!"
reader = csv.DictReader(io.TextIOWrapper(dump.extractfile(item), 'UTF-8'))
for version in reader:
if version['yanked'] == 't':