def update(self):
currencies = self.get_currencies()<EOL>currency_objects = {}<EOL>for code, name in currencies:<EOL><INDENT>currency_objects[code], created = Currency.objects.get_or_create(<EOL>code=code, defaults={'<STR_LIT:name>': name})<EOL>if created:<EOL><INDENT>logger.info('<STR_LIT>', code)<EOL><DEDENT><DEDENT>existing = ExchangeRate.objects.values('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT:id>')<EOL>existing = {(d['<STR_LIT>'], d['<STR_LIT>']): d['<STR_LIT:id>']<EOL>for d in existing}<EOL>usd_exchange_rates = dict(self.get_exchangerates('<STR_LIT>'))<EOL>updates = []<EOL>inserts = []<EOL>for source in currencies:<EOL><INDENT>for target in currencies:<EOL><INDENT>rate = self._get_rate_through_usd(source.code,<EOL>target.code,<EOL>usd_exchange_rates)<EOL>exchange_rate = ExchangeRate(source=currency_objects[source.code],<EOL>target=currency_objects[target.code],<EOL>rate=rate)<EOL>if (source.code, target.code) in existing:<EOL><INDENT>exchange_rate.id = existing[(source.code, target.code)]<EOL>updates.append(exchange_rate)<EOL>logger.debug('<STR_LIT>'<EOL>% (source, target, rate))<EOL><DEDENT>else:<EOL><INDENT>inserts.append(exchange_rate)<EOL>logger.debug('<STR_LIT>'<EOL>% (source, target, rate))<EOL><DEDENT><DEDENT>logger.info('<STR_LIT>' % source.code)<EOL><DEDENT>logger.info("<STR_LIT>" % len(updates))<EOL>update_many(updates)<EOL>logger.info("<STR_LIT>" % len(inserts))<EOL>insert_many(inserts)<EOL>logger.info('<STR_LIT>')<EOL>
Actual update process goes here using auxialary ``get_currencies``
        and ``get_exchangerates`` methods. This method creates or updates
        corresponding ``Currency`` and ``ExchangeRate`` models