def test_mem_storage(self): storage = MemStorage('foo') storage['ham'] = 'spam' self.assertEqual(storage['ham'], 'spam') self.assertTrue('ham' in storage) print(storage) # Test __str__ method del storage['ham'] self.assertFalse('ham' in storage) self.assertRaises(KeyError, storage.__getitem__, 'bar') self.assertRaises(KeyError, storage.__delitem__, 'bar') self.assertRaises(TypeError, storage.__getitem__, 5) self.assertRaises(TypeError, storage.__setitem__, 5, 5) self.assertRaises(TypeError, storage.__delitem__, 5) self.assertRaises(TypeError, storage.__contains__, 5)
import sys import gc import json import xbmc, xbmcgui, xbmcplugin import urllib from simpleplugin import RoutedPlugin from simpleplugin import MemStorage try: import urllib2 except: import urllib.request as urllib2 plugin = RoutedPlugin() storage = MemStorage('legends') @plugin.route('/') def root(): listing = get_releases_list() return plugin.create_listing(listing, content='movies', sort_methods=(xbmcplugin.SORT_METHOD_DATEADDED, xbmcplugin.SORT_METHOD_VIDEO_RATING), cache_to_disk=True) @plugin.route('/film') def film(): allmovies = storage['movies'] use_torrserver = plugin.get_setting('use_engine', True) id = int(plugin.params.id) major_version = int(xbmc.getInfoLabel('System.BuildVersion')[:2])
def __init__(self): ''' ''' self.storage = MemStorage('shiki.SearchAdv')
def __init__(self): self._id = get_info('id') self._storage = MemStorage(self._id)
class SearchAdv(object): def __init__(self): ''' ''' self.storage = MemStorage('shiki.SearchAdv') # -------------------------------------------------------------------------------------- years = property() @years.getter def years(self): return self.storage.get('years') @years.setter def years(self, value): self.storage['years'] = value @years.deleter def years(self): del self.storage['years'] @staticmethod def years_list(): import datetime now = datetime.datetime.now() return [ year for year in xrange(now.year, 1990, -1) ] # -------------------------------------------------------------------------------------- genres = property() @genres.getter def genres(self): return self.storage.get('genres', []) @genres.setter def genres(self, value): self.storage['genres'] = value @genres.deleter def genres(self): del self.storage['genres'] def genres_dict(self): import shikicore if 'genres_dict' not in self.storage: self.storage['genres_dict'] = [ genre for genre in shikicore.genres() if genre['kind'] == 'anime' ] return self.storage['genres_dict'] @property def genre_ids(self): l = self.genres return [ genre['id'] for genre in SearchAdv().genres_dict() if genre['russian'] in l ] @staticmethod def genres_list(): return sorted([ genre['russian'] for genre in SearchAdv().genres_dict() ]) # -------------------------------------------------------------------------------------- score = property() @score.getter def score(self): return self.storage.get('score') @score.setter def score(self, value): self.storage['score'] = value @score.deleter def score(self): del self.storage['score'] @staticmethod def scores_list(): #import shikicore from rates import score_statuses def line(n): result = u'{0}: {1}'.format(n, score_statuses.get(str(n))) return result return [ line(n) for n in range(1, 10) ] # -------------------------------------------------------------------------------------- rating = property() @rating.getter def rating(self): return self.storage.get('rating', []) @rating.setter def rating(self, value): self.storage['rating'] = value @rating.deleter def rating(self): del self.storage['rating'] @staticmethod def ratings_keys(): return ['g', 'pg', 'pg_13', 'r', 'r_plus', 'rx'] @staticmethod def ratings_dict(): return { 'g': u"G - Нет возрастных ограничений", 'pg': u"PG - Рекомендуется присутствие родителей", 'pg_13': u"PG-13 - Детям до 13 лет просмотр не желателен", 'r': u"R - Лицам до 17 лет обязательно присутствие взрослого", 'r_plus': u"R+ - Лицам до 17 лет просмотр запрещен", 'rx': u"Rx - Хентай" } @staticmethod def ratings_list(): rk = SearchAdv.ratings_keys() return [ SearchAdv.ratings_dict()[r] for r in rk ]