def handle(self, *args, **options):
		print("Querying database at %s" % (CURRENCY_API_URL))

		currencies = []
		if len(args):
			currencies = list(args)

		api = urlopen(CURRENCY_API_URL)
		d = json.loads(api.read())
		i = 0

		for currency in sorted(d.keys()):
			if (not currencies) or currency in currencies:
				if not Currency.objects.filter(code=currency):
					print("Creating %r (%s)" % (d[currency], currency))
					Currency(code=currency, name=d[currency], factor=1.0, is_active=False).save()
					i+=1

		if i == 1:
			print("%i new currency" % (i))
		else:
			print("%i new currencies" % (i))
dataset/ETHPy150Open panosl/django-currencies/currencies/management/commands/initcurrencies.py/Command.handle/original