<commit_before># -*- coding: utf-8 -*-
from collections import OrderedDict
from importlib import import_module
from django.conf import settings
from django.core.management.base import BaseCommand
from ...models import Currency


# The list of available backend currency sources
sources = OrderedDict([
    # oxr must remain first for backward compatibility
    ('oxr',     '._openexchangerates'),
    ('yahoo',   '._yahoofinance'),
    ('iso',     '._currencyiso'),
    #TODO:
    #('google', '._googlecalculator.py'),
    #('ecb', '._europeancentralbank.py'),
])


class Command(BaseCommand):
    help = "Create all missing db currencies available from the chosen source"

    _package_name = __loader__.name.rsplit('.', 1)[0]
    _source_param = 'source'
    _source_default = next(iter(sources))
    _source_kwargs = {'action': 'store', 'nargs': '?', 'default': _source_default,
                        'choices': sources.keys(),
                        'help': 'Select the desired currency source, default is ' + _source_default}

    def add_arguments(self, parser):
        """Add command arguments"""
        parser.add_argument(self._source_param, **self._source_kwargs)
        parser.add_argument('--force', '-f', action='store_true', default=False,
            help='Update database even if currency already exists')
        parser.add_argument('--import', '-i', action='append', default=[],
            help=   'Selectively import currencies by supplying the currency codes (e.g. USD) one per switch, '
                    'or supply an uppercase settings variable name with an iterable (once only), '
                    'or looks for settings CURRENCIES or SHOP_CURRENCIES.')

    def get_imports(self, option):
        """
        See if we have been passed a set of currencies or a setting variable
        or look for settings CURRENCIES or SHOP_CURRENCIES.<commit_msg>get pkgname via __name__ instead of __loader__<commit_after># -*- coding: utf-8 -*-
from collections import OrderedDict
from importlib import import_module
from django.conf import settings
from django.core.management.base import BaseCommand
from ...models import Currency


# The list of available backend currency sources
sources = OrderedDict([
    # oxr must remain first for backward compatibility
    ('oxr',     '._openexchangerates'),
    ('yahoo',   '._yahoofinance'),
    ('iso',     '._currencyiso'),
    #TODO:
    #('google', '._googlecalculator.py'),
    #('ecb', '._europeancentralbank.py'),
])


class Command(BaseCommand):
    help = "Create all missing db currencies available from the chosen source"

    _package_name = __name__.rsplit('.', 1)[0]
    _source_param = 'source'
    _source_default = next(iter(sources))
    _source_kwargs = {'action': 'store', 'nargs': '?', 'default': _source_default,
                        'choices': sources.keys(),
                        'help': 'Select the desired currency source, default is ' + _source_default}

    def add_arguments(self, parser):
        """Add command arguments"""
        parser.add_argument(self._source_param, **self._source_kwargs)
        parser.add_argument('--force', '-f', action='store_true', default=False,
            help='Update database even if currency already exists')
        parser.add_argument('--import', '-i', action='append', default=[],
            help=   'Selectively import currencies by supplying the currency codes (e.g. USD) one per switch, '
                    'or supply an uppercase settings variable name with an iterable (once only), '
                    'or looks for settings CURRENCIES or SHOP_CURRENCIES.')

    def get_imports(self, option):
        """
        See if we have been passed a set of currencies or a setting variable
        or look for settings CURRENCIES or SHOP_CURRENCIES.
{'fraction_non_alphanumeric': 0.11506055818852028, 'fraction_numerical': 0.001579778830963665, 'mean_word_length': 3.0674518201284795, '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': '1779084', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1024, 'n_words': 339}