<commit_before>import datetime
import os
import sys

import django

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "museum.settings")
django.setup()

from museum_site.models import *  # noqa: E402
from museum_site.constants import SITE_ROOT

now = datetime.datetime.now()
HEADER = """
{% with "articles/2021/publish-<date>/" as path %}
<p></p>

""".replace("<date>", now.strftime("%b-%d").lower())

QUERY = """{% with "<ids_string>"|get_files_by_id as files %}

"""

ENTRY = """{% with files.<f_id> as file %}
<h2>"{{file.title}}" {% if file.author != "Unknown" %} by {{file.author}}{% endif %}{% if file.release_date %} ({{file.release_date.year}}){% endif %}</h2>
{% include "museum_site/blocks/file_detailed_block.html" %}
<p></p>
<div class="image-set">
    <img src='{% static path|add:"<thumb>-1.png" %}' class="screenshot-thumb">
    <img src='{% static path|add:"<thumb>-2.png" %}' class="screenshot-thumb">
    <img src='{% static path|add:"<thumb>-3.png" %}' class="screenshot-thumb">
</div>
{% endwith %}

"""

FOOTER = """{% endwith %}
{% patreon_plug %}
{% endwith %}

"""

def main():
    count = 0
    ids_string = ""
    ids = []
    thumbs = []

    while True:
        print("Count", count)
        f_id = input("File ID (blank to stop): ")

        if not f_id:
            break

        f = File.objects.filter(pk=int(f_id))
        if f:
            print(f[0])
        else:
            print("No File object found.")

        while True:<commit_msg>Fix crash on non-integer IDs<commit_after>import datetime
import os
import sys

import django

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "museum.settings")
django.setup()

from museum_site.models import *  # noqa: E402
from museum_site.constants import SITE_ROOT

now = datetime.datetime.now()
HEADER = """{% with "articles/2021/publish-<date>/" as path %}
<p></p>

""".replace("<date>", now.strftime("%b-%d").lower())

QUERY = """{% with "<ids_string>"|get_files_by_id as files %}

"""

ENTRY = """{% with files.<f_id> as file %}
<h2>"{{file.title}}" {% if file.author != "Unknown" %} by {{file.author}}{% endif %}{% if file.release_date %} ({{file.release_date.year}}){% endif %}</h2>
{% include "museum_site/blocks/file_detailed_block.html" %}
<p></p>
<div class="image-set">
    <img src='{% static path|add:"<thumb>-1.png" %}' class="screenshot-thumb">
    <img src='{% static path|add:"<thumb>-2.png" %}' class="screenshot-thumb">
    <img src='{% static path|add:"<thumb>-3.png" %}' class="screenshot-thumb">
</div>
{% endwith %}

"""

FOOTER = """{% endwith %}
{% patreon_plug %}
{% endwith %}
"""

def main():
    count = 0
    ids_string = ""
    ids = []
    thumbs = []

    while True:
        print("Count", count)
        f_id = input("File ID (blank to stop): ")

        if not f_id:
            break

        try:
            f_id_int = int(f_id)
        except ValueError:
            print("Invalid ID!")
            continue

        f = File.objects.filter(pk=f_id_int)
        if f:
            print(f[0])
        else:
            print("No File object found.")

        while True:
{'fraction_non_alphanumeric': 0.19956816779765577, 'fraction_numerical': 0.00863664404688464, 'mean_word_length': 3.2559055118110236, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2189784', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1131, 'n_words': 235}