def get_date(self, chat_id, i): try: return util.extract_date(self.plans[str(chat_id)][i]) except IndexError: return None except KeyError: return None
def _scrape_panel_hist(g, el): g['panel_history'] = [] for e in (PyQuery(x) for x in el.find('#dgPanelHistory tr.DetailValue')): ph = map(lambda x: PyQuery(x).text(), e.find('td')) ph[0] = util.extract_date(ph[0], "%d %b %Y") g['panel_history'].append(ph)
def set_time(self, chat_id, i, time): try: plan = self.plans[str(chat_id)][i] dt_str = plan["dt"] if is_datetime(dt_str): dt_str = util.extract_date(plan) + ", " + time plan["dt"] = datetime2str(get_datetime(dt_str)) else: return "_Set a date first!_" self.plans[chat_id] = sort_plans(self.plans[chat_id]) iomgr.save(PLANS_JSON, self.plans) return "*Time is updated!* 😎" except IndexError: return False except KeyError: return False
def _scrape_dates_value(g, el): g['start_date'] = util.extract_date(el.find('#lblStarts').eq(0).text()) g['end_date'] = util.extract_date(el.find('#lblEnds').eq(0).text()) value = el.find('#lblValue').eq(0).attr.title g['value'] = util.extract_monetary_value(value)
def _scrape_dates_value(g, el): g["start_date"] = util.extract_date(el.find("#lblStarts").eq(0).text()) g["end_date"] = util.extract_date(el.find("#lblEnds").eq(0).text()) value = el.find("#lblValue").eq(0).attr.title g["value"] = util.extract_monetary_value(value)