def cat_convert(cat):
 if (cat and (cat.lower() != 'none')):
  cats = config.get_ordered_categories()
  raw_cats = config.get_categories()
  for ucat in cats:
   try:
    indexer = raw_cats[ucat['name']].newzbin()
    if (not isinstance(indexer, list)):
     indexer = [indexer]
   except:
    indexer = []
   for name in indexer:
    if re.search(('^%s$' % wildcard_to_re(name)), cat, re.I):
     if ('.' in name):
      logging.debug('Convert group "%s" to user-cat "%s"', cat, ucat['name'])
     else:
      logging.debug('Convert index site category "%s" to user-cat "%s"', cat, ucat['name'])
     return ucat['name']
  for ucat in cats:
   if (cat.lower() == ucat['name'].lower()):
    logging.debug('Convert index site category "%s" to user-cat "%s"', cat, ucat['name'])
    return ucat['name']
  for ucat in cats:
   if cat.lower().startswith(ucat['name'].lower()):
    logging.debug('Convert index site category "%s" to user-cat "%s"', cat, ucat['name'])
    return ucat['name']
 return None

def cat_convert ( cat ) : if ( cat and ( cat . lower ( ) != 'none' ) ) : cats = config . get_ordered_categories ( ) raw_cats = config . get_categories ( ) for ucat in cats : try : indexer = raw_cats [ ucat [ 'name' ] ] . newzbin ( ) if ( not isinstance ( indexer , list ) ) : indexer = [ indexer ] except : indexer = [ ] for name in indexer : if re . search ( ( '^%s$' % wildcard_to_re ( name ) ) , cat , re . I ) : if ( '.' in name ) : logging . debug ( 'Convert group "%s" to user-cat "%s"' , cat , ucat [ 'name' ] ) else : logging . debug ( 'Convert index site category "%s" to user-cat "%s"' , cat , ucat [ 'name' ] ) return ucat [ 'name' ] for ucat in cats : if ( cat . lower ( ) == ucat [ 'name' ] . lower ( ) ) : logging . debug ( 'Convert index site category "%s" to user-cat "%s"' , cat , ucat [ 'name' ] ) return ucat [ 'name' ] for ucat in cats : if cat . lower ( ) . startswith ( ucat [ 'name' ] . lower ( ) ) : logging . debug ( 'Convert index site category "%s" to user-cat "%s"' , cat , ucat [ 'name' ] ) return ucat [ 'name' ] return None
convert indexers category/group-name to user categories .