Steve broke the regex, lame
parent
919333e70c
commit
7d95d6ff8e
|
@ -21,17 +21,15 @@ def init_pope(meta):
|
|||
return pope
|
||||
else:
|
||||
pope = Pope(meta["id"], meta["name"])
|
||||
pope.save()
|
||||
return pope
|
||||
|
||||
|
||||
def add_pope_entry(pope, path):
|
||||
if pope_or_death(PopeImage, path=path):
|
||||
print('-', end='')
|
||||
return False
|
||||
return None
|
||||
pope_image = parse_pope(path)
|
||||
pope_image.pope = pope
|
||||
pope_image.save()
|
||||
print('+', end='')
|
||||
return pope_image
|
||||
|
||||
|
@ -56,11 +54,15 @@ def main():
|
|||
existing_popes.append(meta["id"])
|
||||
|
||||
pope = init_pope(meta)
|
||||
with open(pl) as file:
|
||||
pope_images_batch = []
|
||||
with open(pl, 'rU') as file:
|
||||
for line in file:
|
||||
line = line.rstrip()
|
||||
line = line.rstrip('\n')
|
||||
line = path.join("popes", line)
|
||||
add_pope_entry(pope, line)
|
||||
pope_images_batch.append(
|
||||
add_pope_entry(pope, line)
|
||||
)
|
||||
PopeImage.objects.bulk_create((x for x in pope_images_batch if x is not None))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue