home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / totem / plugins / bbc / genres.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  9.1 KB  |  227 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import gobject
  5. gobject.threads_init()
  6. import pygst
  7. pygst.require('0.10')
  8. import gst
  9. shortref_to_label_map = {
  10.     'childrens': _("Children's"),
  11.     'childrens/activities': _('Activities'),
  12.     'childrens/drama': _('Drama'),
  13.     'childrens/entertainmentandcomedy': _('Entertainment & Comedy'),
  14.     'childrens/factual': _('Factual'),
  15.     'childrens/music': _('Music'),
  16.     'childrens/news': _('News'),
  17.     'childrens/sport': _('Sport'),
  18.     'drama': _('Drama'),
  19.     'drama/actionandadventure': _('Action & Adventure'),
  20.     'drama/biographical': _('Biographical'),
  21.     'drama/classicandperiod': _('Classic & Period'),
  22.     'drama/crime': _('Crime'),
  23.     'drama/historical': _('Historical'),
  24.     'drama/horrorandsupernatural': _('Horror & Supernatural'),
  25.     'drama/legalandcourtroom': _('Legal & Courtroom'),
  26.     'drama/medical': _('Medical'),
  27.     'drama/musical': _('Musical'),
  28.     'drama/political': _('Political'),
  29.     'drama/psychological': _('Psychological'),
  30.     'drama/relationshipsandromance': _('Relationships & Romance'),
  31.     'drama/scifiandfantasy': _('SciFi & Fantasy'),
  32.     'drama/soaps': _('Soaps'),
  33.     'drama/spiritual': _('Spiritual'),
  34.     'drama/thriller': _('Thriller'),
  35.     'drama/waranddisaster': _('War & Disaster'),
  36.     'drama/western': _('Western'),
  37.     'entertainmentandcomedy': _('Entertainment & Comedy'),
  38.     'entertainmentandcomedy/impressionists': _('Impressionists'),
  39.     'entertainmentandcomedy/satire': _('Satire'),
  40.     'entertainmentandcomedy/sitcoms': _('Sitcoms'),
  41.     'entertainmentandcomedy/sketch': _('Sketch'),
  42.     'entertainmentandcomedy/spoof': _('Spoof'),
  43.     'entertainmentandcomedy/standup': _('Standup'),
  44.     'entertainmentandcomedy/varietyshows': _('Variety Shows'),
  45.     'factual': _('Factual'),
  46.     'factual/antiques': _('Antiques'),
  47.     'factual/artscultureandthemedia': _('Arts, Culture & the Media'),
  48.     'factual/beautyandstyle': _('Beauty & Style'),
  49.     'factual/carsandmotors': _('Cars & Motors'),
  50.     'factual/cinema': _('Cinema'),
  51.     'factual/consumer': _('Consumer'),
  52.     'factual/crimeandjustice': _('Crime & Justice'),
  53.     'factual/disability': _('Disability'),
  54.     'factual/familiesandrelationships': _('Families & Relationships'),
  55.     'factual/foodanddrink': _('Food & Drink'),
  56.     'factual/healthandwellbeing': _('Health & Wellbeing'),
  57.     'factual/history': _('History'),
  58.     'factual/homesandgardens': _('Homes & Gardens'),
  59.     'factual/lifestories': _('Life Stories'),
  60.     'factual/money': _('Money'),
  61.     'factual/petsandanimals': _('Pets & Animals'),
  62.     'factual/politics': _('Politics'),
  63.     'factual/sciencenatureandenvironment': _('Science, Nature & Environment'),
  64.     'factual/travel': _('Travel'),
  65.     'learning': _('Learning'),
  66.     'learning/1119': _('Age 11-19'),
  67.     'learning/511': _('Age 5-11'),
  68.     'learning/adults': _('Adults'),
  69.     'learning/preschool': _('Pre-School'),
  70.     'music': _('Music'),
  71.     'music/classicpopandrock': _('Classic Pop & Rock'),
  72.     'music/classical': _('Classical'),
  73.     'music/country': _('Country'),
  74.     'music/danceandelectronica': _('Dance & Electronica'),
  75.     'music/desi': _('Desi'),
  76.     'music/easylisteningsoundtracksandmusicals': _('Easy Listening, Soundtracks & Musicals'),
  77.     'music/folk': _('Folk'),
  78.     'music/hiphoprnbanddancehall': _('Hip Hop, RnB & Dancehall'),
  79.     'music/jazzandblues': _('Jazz & Blues'),
  80.     'music/popandchart': _('Pop & Chart'),
  81.     'music/rockandindie': _('Rock & Indie'),
  82.     'music/soulandreggae': _('Soul & Reggae'),
  83.     'music/world': _('World'),
  84.     'news': _('News'),
  85.     'religionandethics': _('Religion & Ethics'),
  86.     'sport': _('Sport'),
  87.     'sport/archery': _('Archery'),
  88.     'sport/athletics': _('Athletics'),
  89.     'sport/badminton': _('Badminton'),
  90.     'sport/baseball': _('Baseball'),
  91.     'sport/basketball': _('Basketball'),
  92.     'sport/bowls': _('Bowls'),
  93.     'sport/boxing': _('Boxing'),
  94.     'sport/canoeing': _('Canoeing'),
  95.     'sport/cricket': _('Cricket'),
  96.     'sport/cycling': _('Cycling'),
  97.     'sport/darts': _('Darts'),
  98.     'sport/disabilitysport': _('Disability Sport'),
  99.     'sport/diving': _('Diving'),
  100.     'sport/equestrian': _('Equestrian'),
  101.     'sport/fencing': _('Fencing'),
  102.     'sport/football': _('Football'),
  103.     'sport/gaelicgames': _('Gaelic Games'),
  104.     'sport/golf': _('Golf'),
  105.     'sport/gymnastics': _('Gymnastics'),
  106.     'sport/handball': _('Handball'),
  107.     'sport/hockey': _('Hockey'),
  108.     'sport/horseracing': _('Horse Racing'),
  109.     'sport/judo': _('Judo'),
  110.     'sport/modernpentathlon': _('Modern Pentathlon'),
  111.     'sport/motorsport': _('Motorsport'),
  112.     'sport/olympics': _('Olympics'),
  113.     'sport/rowing': _('Rowing'),
  114.     'sport/rugbyleague': _('Rugby League'),
  115.     'sport/rugbyunion': _('Rugby Union'),
  116.     'sport/sailing': _('Sailing'),
  117.     'sport/shinty': _('Shinty'),
  118.     'sport/shooting': _('Shooting'),
  119.     'sport/snooker': _('Snooker'),
  120.     'sport/softball': _('Softball'),
  121.     'sport/swimming': _('Swimming'),
  122.     'sport/tabletennis': _('Table Tennis'),
  123.     'sport/taekwondo': _('Taekwondo'),
  124.     'sport/tennis': _('Tennis'),
  125.     'sport/triathlon': _('Triathlon'),
  126.     'sport/volleyball': _('Volleyball'),
  127.     'sport/waterpolo': _('Water Polo'),
  128.     'sport/weightlifting': _('Weightlifting'),
  129.     'sport/wintersports': _('Winter Sports'),
  130.     'sport/wrestling': _('Wrestling'),
  131.     'weather': _('Weather') }
  132. shortref_to_sortrank_map = {
  133.     'news': 1,
  134.     'childrens': 2,
  135.     'drama': 3,
  136.     'entertainmentandcomedy': 4,
  137.     'factual': 5,
  138.     'learning': 6,
  139.     'music': 7,
  140.     'religionandethics': 8,
  141.     'sport': 9,
  142.     'weather': 10 }
  143.  
  144. class GenrePool(object):
  145.     __slots__ = [
  146.         'genres',
  147.         'toplevel_genres']
  148.     
  149.     def __init__(self):
  150.         self.clear()
  151.  
  152.     
  153.     def clear(self):
  154.         self.genres = { }
  155.  
  156.     
  157.     def get_genre(self, short_ref):
  158.         if short_ref in self.genres:
  159.             return self.genres[short_ref]
  160.         lastslash_pos = short_ref.rfind('/')
  161.         if lastslash_pos > 0:
  162.             parent_ref = short_ref[0:lastslash_pos]
  163.             gst.log('genre: ' + short_ref + ', parent_genre: ' + parent_ref)
  164.             parent = self.get_genre(parent_ref)
  165.         else:
  166.             parent = None
  167.         genre = Genre(short_ref, parent)
  168.         self.genres[short_ref] = genre
  169.         return genre
  170.  
  171.     
  172.     def get_toplevel_genres(self):
  173.         toplevel_genres = []
  174.         for genre in self.genres.values():
  175.             if not genre.parent:
  176.                 toplevel_genres.append(genre)
  177.                 continue
  178.         
  179.         return toplevel_genres
  180.  
  181.  
  182.  
  183. class Genre(object):
  184.     __slots__ = [
  185.         'short_ref',
  186.         'label',
  187.         'sort_rank',
  188.         'parent',
  189.         'children',
  190.         'brands']
  191.     
  192.     def __init__(self, short_ref, parent_genre):
  193.         self.short_ref = short_ref
  194.         if short_ref in shortref_to_label_map:
  195.             self.label = shortref_to_label_map[short_ref]
  196.         else:
  197.             self.label = _('Unknown: ') + short_ref
  198.         if short_ref in shortref_to_sortrank_map:
  199.             self.sort_rank = shortref_to_sortrank_map[short_ref]
  200.         else:
  201.             self.sort_rank = 99999
  202.         self.parent = parent_genre
  203.         self.children = []
  204.         self.brands = []
  205.         if parent_genre is not None:
  206.             parent_genre.add_child(self)
  207.         
  208.         gst.log('created genre ' + short_ref + ' = ' + self.label)
  209.  
  210.     
  211.     def add_child(self, child_genre):
  212.         if child_genre not in self.children:
  213.             self.children.append(child_genre)
  214.         
  215.  
  216.     
  217.     def add_brand(self, brand):
  218.         if brand not in self.brands:
  219.             self.brands.append(brand)
  220.             gst.log(self.short_ref + ': adding show ' + brand.title)
  221.         
  222.  
  223.  
  224. if __name__ == '__main__':
  225.     pass
  226.  
  227.