def schedule_recipe(self, recipe, schedule_type, schedule, last_downloaded=None): with self.lock: for x in list(self.iter_recipes()): if x.get('id', False) == recipe.get('id'): ld = x.get('last_downloaded', None) if ld and last_downloaded is None: try: last_downloaded = parse_date(ld) except: pass self.root.remove(x) break if last_downloaded is None: last_downloaded = fromordinal(1) sr = E.scheduled_recipe( { 'id': recipe.get('id'), 'title': recipe.get('title'), 'last_downloaded': isoformat(last_downloaded), }, self.serialize_schedule(schedule_type, schedule)) self.root.append(sr) self.write_scheduler_file()
def sample_results(self): m1 = Metadata('The Great Gatsby', ['Francis Scott Fitzgerald']) m2 = Metadata('The Great Gatsby', ['F. Scott Fitzgerald']) m1.has_cached_cover_url = True m2.has_cached_cover_url = False m1.comments = 'Some comments '*10 m1.tags = ['tag%d'%i for i in range(20)] m1.rating = 4.4 m1.language = 'en' m2.language = 'fr' m1.pubdate = utcnow() m2.pubdate = fromordinal(1000000) m1.publisher = 'Publisher 1' m2.publisher = 'Publisher 2' return [m1, m2]
def sample_results(self): m1 = Metadata('The Great Gatsby', ['Francis Scott Fitzgerald']) m2 = Metadata('The Great Gatsby - An extra long title to test resizing', ['F. Scott Fitzgerald']) m1.has_cached_cover_url = True m2.has_cached_cover_url = False m1.comments = 'Some comments '*10 m1.tags = ['tag%d'%i for i in range(20)] m1.rating = 4.4 m1.language = 'en' m2.language = 'fr' m1.pubdate = utcnow() m2.pubdate = fromordinal(1000000) m1.publisher = 'Publisher 1' m2.publisher = 'Publisher 2' return [m1, m2]
def sample_results(self): m1 = Metadata("The Great Gatsby", ["Francis Scott Fitzgerald"]) m2 = Metadata("The Great Gatsby - An extra long title to test resizing", ["F. Scott Fitzgerald"]) m1.has_cached_cover_url = True m2.has_cached_cover_url = False m1.comments = "Some comments " * 10 m1.tags = ["tag%d" % i for i in range(20)] m1.rating = 4.4 m1.language = "en" m2.language = "fr" m1.pubdate = utcnow() m2.pubdate = fromordinal(1000000) m1.publisher = "Publisher 1" m2.publisher = "Publisher 2" return [m1, m2]
def schedule_recipe(self, recipe, schedule_type, schedule, last_downloaded=None): with self.lock: for x in list(self.iter_recipes()): if x.get('id', False) == recipe.get('id'): ld = x.get('last_downloaded', None) if ld and last_downloaded is None: try: last_downloaded = parse_date(ld) except: pass self.root.remove(x) break if last_downloaded is None: last_downloaded = fromordinal(1) sr = E.scheduled_recipe({ 'id' : recipe.get('id'), 'title': recipe.get('title'), 'last_downloaded':isoformat(last_downloaded), }, self.serialize_schedule(schedule_type, schedule)) self.root.append(sr) self.write_scheduler_file()