def __init__(self, record: lbsn.Post = None, hashtag: str = None): super().__init__() self.key['year'] = None self.key['month'] = None self.key['latitude'] = None self.key['longitude'] = None self.attrs['latlng_geom'] = None if record is None: # init empty return if isinstance(record, lbsn.Post): post_date_time = HLF.merge_dates_post(record) if post_date_time is None: return date = post_date_time.date() self.key['year'] = date.year self.key['month'] = date.month coordinates_geom = record.post_latlng coordinates = HF.get_coordinates_from_ewkt(coordinates_geom) self.key['latitude'] = coordinates.lat self.key['longitude'] = coordinates.lng # additional (optional) attributes # formatted ready for sql upsert self.attrs['latlng_geom'] = HF.return_ewkb_from_geotext( coordinates_geom) else: raise ValueError("Parsing of MonthLatLngBase only supported " "from lbsn.Post")
def __init__(self, record: lbsn.Post = None): super().__init__() self.key["timestamp"] = None if record is None: # init empty return post_date_time = HLF.merge_dates_post(record) self.key["timestamp"] = post_date_time
def __init__(self, record: lbsn.Post = None): super().__init__() self.key['timeofday'] = None if record is None: # init empty return post_date_time = HLF.merge_dates_post(record) # remove microseconds from datetime self.key['timeofday'] = post_date_time.time.replace(microsecond=0)
def __init__(self, record: lbsn.Post = None): super().__init__() self.key['month'] = None self.key['day'] = None if record is None: # init empty return post_date_time = HLF.merge_dates_post(record) self.key['month'] = post_date_time.month self.key['day'] = post_date_time.day
def __init__(self, record: lbsn.Post = None): super().__init__() self.key['year'] = None if record is None: # init empty return post_date_time = HLF.merge_dates_post(record) if post_date_time is None: return date = post_date_time.date() self.key['year'] = date.year
def __init__(self, record: lbsn.Post = None): super().__init__() self.key['date'] = None self.attrs['name'] = None if record is None: # init empty return post_date_time = HLF.merge_dates_post(record) if post_date_time is None: return # optional: add name of date (e.g. "New Year's Day") self.key['date'] = post_date_time.date()
def __init__(self, record: lbsn.Post = None, hashtag: str = None): super().__init__() self.key['year'] = None self.key['month'] = None self.key['hashtag'] = None if hashtag is None: # init empty return self.key['hashtag'] = hashtag.lower() if record is None: # init empty return if isinstance(record, lbsn.Post): post_date_time = HLF.merge_dates_post(record) if post_date_time is None: return date = post_date_time.date() self.key['year'] = date.year self.key['month'] = date.month else: raise ValueError("Parsing of MonthHashtagBase only supported " "from lbsn.Post")