Example #1
0
def add_category_mapping(file, account):
    f = open(file)
    for line in f.readlines():
        line = line.strip()
        if line and not line.startswith('#'):
            theirs, ours, store = line.split('","')
            theirs = theirs.replace('"','')
            ours = ours.replace('"','')
            store = store.replace('"','')
            if ours == 'Blacklisted':
                continue
            feedutils.get_or_create_category_mapping(account, theirs, ours, store)
    f.close()
Example #2
0
File: feed.py Project: daasara/riba
 def get_category_mapping(self, category):
     log.info('Finding category mapping for %s' % category)
     try:
         self._category_cache.setdefault(category, CategoryMapping.objects.using('default').get(
             category=category,
             account=self.config['ACCOUNT']))
         return self._category_cache[category]
     except CategoryMapping.DoesNotExist:
         mapping = feedutils.get_or_create_category_mapping(
                 account=self.config['ACCOUNT'],
                 ours = category,
                 theirs = category)
         self._category_cache[category] = mapping
         return mapping