<commit_before>import datetime
import os

import requests

from django.conf import settings
from django.core.management import BaseCommand, CommandError

from openprescribing.utils import mkdir_p


class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument('dataset', choices=['addresses', 'chemicals'])

    def handle(self, *args, **kwargs):
        today = datetime.date.today()
        year = today.year
        month = today.month

        num_missing_months = 0
        filename_fragment = {
            'addresses': 'ADDR+NNFT',
            'chemicals': 'CHEM+SUBS',
        }[kwargs['dataset']]

        while True:
            date = datetime.date(year, month, 1)
            year_and_month = date.strftime('%Y_%m')  # eg 2017_01

            dir_path = os.path.join(
                settings.PIPELINE_DATA_BASEDIR,
                'prescribing_metadata',<commit_msg>Use correct filename in fetch_prescribing_metadata<commit_after>import datetime
import os

import requests

from django.conf import settings
from django.core.management import BaseCommand, CommandError

from openprescribing.utils import mkdir_p


class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument('dataset', choices=['addresses', 'chemicals'])

    def handle(self, *args, **kwargs):
        today = datetime.date.today()
        year = today.year
        month = today.month

        num_missing_months = 0
        filename_fragment = {
            'addresses': 'ADDR+BNFT',
            'chemicals': 'CHEM+SUBS',
        }[kwargs['dataset']]

        while True:
            date = datetime.date(year, month, 1)
            year_and_month = date.strftime('%Y_%m')  # eg 2017_01

            dir_path = os.path.join(
                settings.PIPELINE_DATA_BASEDIR,
                'prescribing_metadata',
{'fraction_non_alphanumeric': 0.10231556273559504, 'fraction_numerical': 0.008616047388260635, 'mean_word_length': 2.5938104448742747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2372597', 'n_tokens_mistral': 564, 'n_tokens_neox': 519, 'n_words': 121}