def parse(self): response = self._get_response(self.post.url) response.encoding = 'utf-8' if not response.status_code / 100 == 2: return self.post doc = BeautifulSoup.BeautifulSoup(response.text) episodes = [] for e in doc.findAll('p'): a = e.find('a') if not a: continue href = a.get('href', None) title = str(unicode(a.text.strip())) if not title: continue encoded = BeautifulSoup.BeautifulSoup( title, convertEntities=BeautifulSoup.BeautifulSoup.HTML_ENTITIES) title = encoded.contents[0] title = str(unicode(title)) ep = episode.Episode(url=href, post=self.post, title=title) episodes.append(ep) return episodes
def get_episodes_in_rss(): """ Grabs all the episodes that already exist in the podcast and returns a list of episode objects. If the xml file doesn't exist an empty list is returned instead. """ if os.path.exists(config.XML_LOCATION): feed = feedparser.parse(config.XML_LOCATION) episodes = [episode.Episode(i.summary, "", "") for i in feed.entries] print("\n".join(["{} already in podcast...".format(i.title) for i in episodes])) return episodes else: return []
def __init__(self, id): self.id = id self.episode = episode.Episode() self.role = "question" if self.agent_type == codraw_data.Agent.DRAWER else "answer" self.handlers = { 'paired': self.on_paired, 'receive message': self.on_receive_message, 'server error': self. on_server_error, #TODO(nikita): Not emitted after I modified the server code 'disconnected partner': self.on_disconnected_partner, } self.disconnected = False self.num_messages_sent = 0
def main(): print('Starting.') args = flag_parser.parse_arguments() # Seed sources of randomness. random.seed(args.seed) scene = 'FloorPlan{}_physics'.format(args.scenes) gpu_id = 0 # Start a new episode. total_reward = 0 ep = episode.Episode(args, gpu_id, 0) ep.new_episode(args, scene) total_reward = 0 while True: print("Reward so far: %s" % (total_reward)) for i, action in enumerate(ep.actions_list): print("%s: %s" % (i, action["action"])) print("Choice?") choice = misc_util.getch() print() try: selection = int(choice) if selection < len(ep.actions_list): reward, terminal, success = ep.step(selection) total_reward += reward if terminal: if ep.success: print("Episode was successful!") else: print("Episode failed.") print("Final reward: ", total_reward) break if not success: print("Action failed!") print() else: raise ValueError("Invalid choice") except ValueError as e: print("Invalid action: %s" % (selection)) print("Replaying...") ep.slow_replay() print("Done.")
def __init__(self, max_size, max_step, frame_shape, frame_dtype, rng=np.random.RandomState()): self.max_size = max_size self.max_step = max_step self.frame_shape = frame_shape self.frame_dtype = frame_dtype self.rng = rng self.current_episode = episode.Episode(max_step, frame_shape, frame_dtype) self.episodes = deque() self.total_size = 0
def clear_current_episode(self): self.current_episode = episode.Episode(self.max_step, self.frame_shape, self.frame_dtype)