Exemplo n.º 1
0
    def get_package_ids(self, set_ids, config, last_time, client):
        ''' Get package identifiers from given set identifiers.
        '''
        def filter_map_args(list_tuple):
            for key, value in list_tuple:
                if key in ['until', 'from']:
                    if key == 'from':
                        key = 'from_'
                    yield (key, dp(value).replace(tzinfo=None))

        kwargs = dict(filter_map_args(config.items()))
        kwargs['metadataPrefix'] = self.md_format
        if last_time and 'from_' not in kwargs:
            kwargs['from_'] = dp(last_time).replace(tzinfo=None)
        if set_ids:
            for set_id in set_ids:
                try:
                    for header in client.listIdentifiers(set=set_id, **kwargs):
                        yield header.identifier()
                except oaipmh.error.NoRecordsMatchError:
                    pass
        else:
            try:
                for header in client.listIdentifiers(**kwargs):
                    yield header.identifier()
            except oaipmh.error.NoRecordsMatchError:
                pass
Exemplo n.º 2
0
    def get_package_ids(self, set_ids, config, last_time, client):
        ''' Get package identifiers from given set identifiers.
        '''
        def filter_map_args(list_tuple):
            for key, value in list_tuple:
                if key in ['until', 'from']:
                    if key == 'from':
                        key = 'from_'
                    yield (key, dp(value).replace(tzinfo=None))

        kwargs = dict(filter_map_args(config.items()))
        kwargs['metadataPrefix'] = self.md_format
        if last_time and 'from_' not in kwargs:
            kwargs['from_'] = dp(last_time).replace(tzinfo=None)
        if set_ids:
            for set_id in set_ids:
                try:
                    for header in client.listIdentifiers(set=set_id, **kwargs):
                        yield header.identifier()
                except oaipmh.error.NoRecordsMatchError:
                    pass
        else:
            try:
                for header in client.listIdentifiers(**kwargs):
                    yield header.identifier()
            except oaipmh.error.NoRecordsMatchError:
                pass
Exemplo n.º 3
0
 def test_confirm_event__fourth(self):
     uuids = self.test_confirm_event__fourth__no_avail()
     self.cal.confirm_invite(uuids[3], dt(2016, 6, 24, 12, 0))
     assert uuids[3] not in self.cal._pending
     assert len(self.cal._calendar_invites.events) == 4
     tl = list(self.cal._calendar_invites.timeline)
     assert tl[3].begin.datetime == dp('2016-06-24T12:00:00+00:00') ; assert tl[3].duration == td(minutes=90) ; assert tl[3].all_day == False
Exemplo n.º 4
0
 def test_confirm_event__third(self):
     uuids = self.test_confirm_event__second()
     self.cal.confirm_invite(uuids[2], dt(2016, 6, 21, 12, 0))
     assert uuids[2] not in self.cal._pending
     assert len(self.cal._calendar_invites.events) == 3
     tl = list(self.cal._calendar_invites.timeline)
     assert tl[2].begin.datetime == dp('2016-06-21T12:00:00+00:00') ; assert tl[2].duration == td(days=2)     ; assert tl[2].all_day == False
     return uuids
Exemplo n.º 5
0
 def test_confirm_event__second(self):
     uuids = self.test_confirm_event__first()
     self.cal.confirm_invite(uuids[1], dt(2016, 6, 18, 10, 40))
     assert uuids[1] not in self.cal._pending
     assert len(self.cal._calendar_invites.events) == 2
     tl = list(self.cal._calendar_invites.timeline)
     assert tl[1].begin.datetime == dp('2016-06-18T20:40:00+00:00') ; assert tl[1].duration == td(minutes=20) ; assert tl[1].all_day == False
     return uuids
Exemplo n.º 6
0
    def string_to_date(self):
        df = self.session.read.format("com.mongodb.spark.sql").load()
        # df.registerTempTable("mycollection")
        # result_data = spark.sql("SELECT * from mycollection limit 10")

        func = udf(lambda x: dp(x), DateType())

        dfr = df.withColumn('postedT', func(col('object.postedTime')))

        dfr.registerTempTable("dfr")
        rf = self.session.sql("SELECT * from dfr limit 10")
        rf.show()
Exemplo n.º 7
0
    def parse(feed):
        _rss_configurations = (
            {'body': 'channel',
             'news': 'item',
             'pub_date': 'pubDate',
             'url': 'link',
             },
            {'body': 'feed',
             'news': 'entry',
             'pub_date': 'updated',
             'url': 'link',
             },
        )

        soup = BeautifulSoup(feed.raw_data, 'lxml-xml')

        for configuration in _rss_configurations:
            if body := soup.find(configuration['body']):
                for item in body.findChildren(configuration['news']):
                    if url := (item.find(configuration['url']).text or item.find(configuration['url'])['href']):
                        url = url.strip()

                    title = item.title.text.strip() if item.title else url

                    publication_date = dp(
                        item.find(configuration['pub_date']).text, fuzzy=True
                    )

                    if item.description:
                        description_soap = BeautifulSoup(
                            item.description.text, 'lxml'
                        )
                        description = description_soap.text
                    else:
                        description = ''

                    if block_ad(description):
                        continue

                    yield NewsItemEntity(
                        title=title,
                        description=description,
                        url=url,
                        feed=feed.title,
                        publication_date=publication_date,
                        collection_date=feed.collection_date,
                    )

                break
Exemplo n.º 8
0
def main():
    spark = (SparkSession.builder
             .appName('etl')
             .master("spark://star:7077")
             .config("spark.mongodb.input.uri", "mongodb://localhost:27017/star_raw.raw_staging")
             .getOrCreate())
    # spark.conf.set("spark.mongodb.input.uri", "mongodb://localhost:27017/star_raw.raw_staging")

    df = spark.read.format("com.mongodb.spark.sql").load()
    # df.registerTempTable("mycollection")
    # result_data = spark.sql("SELECT * from mycollection limit 10")

    func = udf(lambda x: dp(x), DateType())

    dfr = df.withColumn('postedT', func(col('object.postedTime')))

    dfr.registerTempTable("dfr")
    rf = spark.sql("SELECT * from dfr limit 10")
    rf.show()

    print(1)
Exemplo n.º 9
0
    def parse(self, response):
        item = GetCoinPriceHistoryItem()
        for coin_price in response.xpath(
                '//*[@id="historical-data"]/div/div[3]/table/tbody/tr'):
            item['CoinName'] = self.coin_name
            item['Date'] = dp(
                coin_price.xpath('td/text()')[0].extract()).strftime('%Y%m%d')
            item['Open'] = coin_price.xpath('td/text()')[1].extract().replace(
                ',', '')
            item['High'] = coin_price.xpath('td/text()')[2].extract().replace(
                ',', '')
            item['Low'] = coin_price.xpath('td/text()')[3].extract().replace(
                ',', '')
            item['Close'] = coin_price.xpath('td/text()')[4].extract().replace(
                ',', '')
            item['Volume'] = coin_price.xpath(
                'td/text()')[5].extract().replace(',', '')
            item['MarketCap'] = coin_price.xpath(
                'td/text()')[6].extract().replace(',', '')

            yield item
Exemplo n.º 10
0
orgs = json.load(open('../../conf/organizations.json'))

# Get account information.
twAccounts = json.load(open(filePath_users % 'twitter'))
fbAccounts = json.load(open(filePath_users % 'facebook'))

# Tokens to skip for word count.
# This is an inherently difficult task, but this should help us get to where we need to go.
skipTokens = {'\'s','.','?',',','(',')','#','\\',':',';','@','-','\''}

# Facebook status type mapping.
fbStatusTypeToMedium = {'added_photos': 'photo', 'added_video': 'video'}

# Information about proper dates.
dates = json.load(open(filePath_dates))
twStartDate = dp(dates['twitter']['start'])
twEndDate   = dp(dates['twitter']['end'])
fbStartDate  = dp(dates['facebook']['start'])
fbEndDate    = dp(dates['facebook']['end'])

# Get local timezone.
localTz = pytz.timezone('America/New_York')

# URL counts. Allows us to adjust URL traffic.
urlCounts = dict()		# Click counts by URL.
urlNetworks = dict()	# Distinct networks by URL.
retweetedUrls = set()	# Set of all retweets.

# Containers for statistics that will become DFs.
tweetInfo = []
postInfo  = []
Exemplo n.º 11
0
    def _date_parser(self, date, config):
        """
        Attempt to parse a date from a given string.
        :param date str: date to parse
        :rtype: str
        """
        if not isinstance(date, str):
            raise TypeError('date argument is expected to be a string')
        month = {
            'january': '01',
            'february': '02',
            'march': '03',
            'april': '04',
            'may': '05',
            'june': '06',
            'july': '07',
            'august': '08',
            'september': '09',
            'october': '10',
            'november': '11',
            'december': '12'
        }
        shortMonth = {
            'jan': '01',
            'feb': '02',
            'mar': '03',
            'apr': '04',
            'jun': '06',
            'jul': '07',
            'aug': '08',
            'ags': '08',
            'agu': '08',
            'sep': '09',
            'oct': '10',
            'okt': '10',
            'nov': '11',
            'dec': '12',
            'des': '12'
        }
        bulan = {
            'januari': '01',
            'februari': '02',
            'maret': '03',
            'april': '04',
            'mei': '05',
            'juni': '06',
            'juli': '07',
            'agustus': '08',
            'september': '09',
            'oktober': '10',
            'nopember': '11',
            'desember': '12'
        }
        if 'normalize_date' not in config or config["normalize_date"]:
            repl = {}
            repl.update(month)
            repl.update(shortMonth)
            repl.update(bulan)
            date = self._multireplace(date.lower(), repl)
        if "date_regex" in config and len(config["date_regex"]) > 0:
            reg = re.compile(config["date_regex"])
            try:
                matches = reg.search(date).groupdict()
                date = '{d}/{m}/{y} {h}:{i}'.format_map(matches)
            except Exception as e:
                date = re.sub(r'[^0-9:\s\/\-]', '', date)
        else:
            date = re.sub(r'[^0-9:\s\/\-]', '', date)

        try:
            parser = dp()
            df = True if 'day_first' not in config or config[
                'day_first'] else False
            dateObj = parser.parse(date, dayfirst=df)
            return dateObj.strftime("%Y-%m-%d %H:%M:%S")
        except Exception as e:
            return None
Exemplo n.º 12
0
 def validate_date_param(d, p, t):
     '''
     Validate a date parameter by trying to parse it
     '''
     if validate_param(d, p, t):
         dp(d[p]).replace(tzinfo=None)
Exemplo n.º 13
0
 def filter_map_args(list_tuple):
     for key, value in list_tuple:
         if key in ['until', 'from']:
             if key == 'from':
                 key = 'from_'
             yield (key, dp(value).replace(tzinfo=None))
Exemplo n.º 14
0
 def filter_map_args(list_tuple):
     for key, value in list_tuple:
         if key in ['until', 'from']:
             if key == 'from':
                 key = 'from_'
             yield (key, dp(value).replace(tzinfo=None))
Exemplo n.º 15
0
 def validate_date_param(d, p, t):
     '''
     Validate a date parameter by trying to parse it
     '''
     if validate_param(d, p, t):
         dp(d[p]).replace(tzinfo=None)
Exemplo n.º 16
0
 def test_get_calendar(self, datadir):
     self.test_subscribe_calendar__file_merge_three(datadir)
     self.test_confirm_event__fourth()
     cal = self.cal.calendar
     tl = list(cal.timeline)
     assert tl[ 0].begin.datetime == dp('2015-01-01T00:00:00+00:00') ; assert tl[ 0].end.datetime == dp('2015-01-03T00:00:00+00:00') ; assert tl[ 0].all_day == False
     assert tl[ 1].begin.datetime == dp('2015-01-19T00:00:00+00:00') ; assert tl[ 1].end.datetime == dp('2015-01-21T00:00:00+00:00') ; assert tl[ 1].all_day == True
     assert tl[ 2].begin.datetime == dp('2015-02-14T00:00:00+00:00') ; assert tl[ 2].end.datetime == dp('2015-02-18T00:00:00+00:00') ; assert tl[ 2].all_day == False
     assert tl[ 3].begin.datetime == dp('2015-04-03T00:00:00+00:00') ; assert tl[ 3].end.datetime == dp('2015-04-08T00:00:00+00:00') ; assert tl[ 3].all_day == False
     assert tl[ 4].begin.datetime == dp('2015-05-01T00:00:00+00:00') ; assert tl[ 4].end.datetime == dp('2015-05-03T00:00:00+00:00') ; assert tl[ 4].all_day == True
     assert tl[ 5].begin.datetime == dp('2015-05-04T00:00:00+00:00') ; assert tl[ 5].end.datetime == dp('2015-05-06T00:00:00+00:00') ; assert tl[ 5].all_day == True
     assert tl[ 6].begin.datetime == dp('2015-05-08T00:00:00+00:00') ; assert tl[ 6].end.datetime == dp('2015-05-12T00:00:00+00:00') ; assert tl[ 6].all_day == False
     assert tl[ 7].begin.datetime == dp('2015-05-14T00:00:00+00:00') ; assert tl[ 7].end.datetime == dp('2015-05-16T00:00:00+00:00') ; assert tl[ 7].all_day == True
     assert tl[ 8].begin.datetime == dp('2015-05-24T00:00:00+00:00') ; assert tl[ 8].end.datetime == dp('2015-05-27T00:00:00+00:00') ; assert tl[ 8].all_day == False
     assert tl[ 9].begin.datetime == dp('2015-06-21T00:00:00+00:00') ; assert tl[ 9].end.datetime == dp('2015-06-23T00:00:00+00:00') ; assert tl[ 9].all_day == True
     assert tl[10].begin.datetime == dp('2015-07-04T00:00:00+00:00') ; assert tl[10].end.datetime == dp('2015-07-06T00:00:00+00:00') ; assert tl[10].all_day == True
     assert tl[11].begin.datetime == dp('2015-07-14T00:00:00+00:00') ; assert tl[11].end.datetime == dp('2015-07-16T00:00:00+00:00') ; assert tl[11].all_day == True
     assert tl[12].begin.datetime == dp('2015-08-03T00:00:00+00:00') ; assert tl[12].end.datetime == dp('2015-08-05T00:00:00+00:00') ; assert tl[12].all_day == True
     assert tl[13].begin.datetime == dp('2015-08-15T00:00:00+00:00') ; assert tl[13].end.datetime == dp('2015-08-17T00:00:00+00:00') ; assert tl[13].all_day == True
     assert tl[14].begin.datetime == dp('2015-08-31T00:00:00+00:00') ; assert tl[14].end.datetime == dp('2015-09-02T00:00:00+00:00') ; assert tl[14].all_day == True
     assert tl[15].begin.datetime == dp('2015-09-07T00:00:00+00:00') ; assert tl[15].end.datetime == dp('2015-09-09T00:00:00+00:00') ; assert tl[15].all_day == True
     assert tl[16].begin.datetime == dp('2015-10-12T00:00:00+00:00') ; assert tl[16].end.datetime == dp('2015-10-14T00:00:00+00:00') ; assert tl[16].all_day == True
     assert tl[17].begin.datetime == dp('2015-10-31T00:00:00+00:00') ; assert tl[17].end.datetime == dp('2015-11-03T00:00:00+00:00') ; assert tl[17].all_day == False
     assert tl[18].begin.datetime == dp('2015-11-05T00:00:00+00:00') ; assert tl[18].end.datetime == dp('2015-11-07T00:00:00+00:00') ; assert tl[18].all_day == True
     assert tl[19].begin.datetime == dp('2015-11-11T00:00:00+00:00') ; assert tl[19].end.datetime == dp('2015-11-13T00:00:00+00:00') ; assert tl[19].all_day == False
     assert tl[20].begin.datetime == dp('2015-11-26T00:00:00+00:00') ; assert tl[20].end.datetime == dp('2015-11-28T00:00:00+00:00') ; assert tl[20].all_day == True
     assert tl[21].begin.datetime == dp('2015-12-25T00:00:00+00:00') ; assert tl[21].end.datetime == dp('2015-12-28T00:00:00+00:00') ; assert tl[21].all_day == False
     assert tl[22].begin.datetime == dp('2015-12-31T00:00:00+00:00') ; assert tl[22].end.datetime == dp('2016-01-03T00:00:00+00:00') ; assert tl[22].all_day == False
     assert tl[23].begin.datetime == dp('2016-01-18T00:00:00+00:00') ; assert tl[23].end.datetime == dp('2016-01-20T00:00:00+00:00') ; assert tl[23].all_day == True
     assert tl[24].begin.datetime == dp('2016-02-14T00:00:00+00:00') ; assert tl[24].end.datetime == dp('2016-02-17T00:00:00+00:00') ; assert tl[24].all_day == False
     assert tl[25].begin.datetime == dp('2016-03-25T00:00:00+00:00') ; assert tl[25].end.datetime == dp('2016-03-30T00:00:00+00:00') ; assert tl[25].all_day == False
     assert tl[26].begin.datetime == dp('2016-05-01T00:00:00+00:00') ; assert tl[26].end.datetime == dp('2016-05-04T00:00:00+00:00') ; assert tl[26].all_day == False
     assert tl[27].begin.datetime == dp('2016-05-05T00:00:00+00:00') ; assert tl[27].end.datetime == dp('2016-05-07T00:00:00+00:00') ; assert tl[27].all_day == True
     assert tl[28].begin.datetime == dp('2016-05-08T00:00:00+00:00') ; assert tl[28].end.datetime == dp('2016-05-10T00:00:00+00:00') ; assert tl[28].all_day == False
     assert tl[29].begin.datetime == dp('2016-05-15T00:00:00+00:00') ; assert tl[29].end.datetime == dp('2016-05-18T00:00:00+00:00') ; assert tl[29].all_day == False
     assert tl[30].begin.datetime == dp('2016-05-30T00:00:00+00:00') ; assert tl[30].end.datetime == dp('2016-06-01T00:00:00+00:00') ; assert tl[30].all_day == False
     assert tl[31].begin.datetime == dp('2016-06-18T10:40:00+00:00') ; assert tl[31].end.datetime == dp('2016-06-18T14:40:00+00:00') ; assert tl[31].all_day == False
     assert tl[32].begin.datetime == dp('2016-06-18T20:40:00+00:00') ; assert tl[32].end.datetime == dp('2016-06-18T21:00:00+00:00') ; assert tl[32].all_day == False
     assert tl[33].begin.datetime == dp('2016-06-19T00:00:00+00:00') ; assert tl[33].end.datetime == dp('2016-06-21T00:00:00+00:00') ; assert tl[33].all_day == True
     assert tl[34].begin.datetime == dp('2016-06-21T12:00:00+00:00') ; assert tl[34].end.datetime == dp('2016-06-23T12:00:00+00:00') ; assert tl[34].all_day == False
     assert tl[35].begin.datetime == dp('2016-06-24T12:00:00+00:00') ; assert tl[35].end.datetime == dp('2016-06-24T13:30:00+00:00') ; assert tl[35].all_day == False
     assert tl[36].begin.datetime == dp('2016-07-04T00:00:00+00:00') ; assert tl[36].end.datetime == dp('2016-07-06T00:00:00+00:00') ; assert tl[36].all_day == True
     assert tl[37].begin.datetime == dp('2016-07-14T00:00:00+00:00') ; assert tl[37].end.datetime == dp('2016-07-16T00:00:00+00:00') ; assert tl[37].all_day == True
     assert tl[38].begin.datetime == dp('2016-08-01T00:00:00+00:00') ; assert tl[38].end.datetime == dp('2016-08-03T00:00:00+00:00') ; assert tl[38].all_day == True
     assert tl[39].begin.datetime == dp('2016-08-15T00:00:00+00:00') ; assert tl[39].end.datetime == dp('2016-08-17T00:00:00+00:00') ; assert tl[39].all_day == True
     assert tl[40].begin.datetime == dp('2016-08-29T00:00:00+00:00') ; assert tl[40].end.datetime == dp('2016-08-31T00:00:00+00:00') ; assert tl[40].all_day == True
     assert tl[41].begin.datetime == dp('2016-09-05T00:00:00+00:00') ; assert tl[41].end.datetime == dp('2016-09-07T00:00:00+00:00') ; assert tl[41].all_day == True
     assert tl[42].begin.datetime == dp('2016-10-10T00:00:00+00:00') ; assert tl[42].end.datetime == dp('2016-10-12T00:00:00+00:00') ; assert tl[42].all_day == True
     assert tl[43].begin.datetime == dp('2016-10-31T00:00:00+00:00') ; assert tl[43].end.datetime == dp('2016-11-03T00:00:00+00:00') ; assert tl[43].all_day == False
     assert tl[44].begin.datetime == dp('2016-11-05T00:00:00+00:00') ; assert tl[44].end.datetime == dp('2016-11-07T00:00:00+00:00') ; assert tl[44].all_day == True
     assert tl[45].begin.datetime == dp('2016-11-11T00:00:00+00:00') ; assert tl[45].end.datetime == dp('2016-11-13T00:00:00+00:00') ; assert tl[45].all_day == False
     assert tl[46].begin.datetime == dp('2016-11-24T00:00:00+00:00') ; assert tl[46].end.datetime == dp('2016-11-26T00:00:00+00:00') ; assert tl[46].all_day == True
     assert tl[47].begin.datetime == dp('2016-12-25T00:00:00+00:00') ; assert tl[47].end.datetime == dp('2016-12-29T00:00:00+00:00') ; assert tl[47].all_day == False
     assert tl[48].begin.datetime == dp('2016-12-31T00:00:00+00:00') ; assert tl[48].end.datetime == dp('2017-01-02T00:00:00+00:00') ; assert tl[48].all_day == True
Exemplo n.º 17
0
async def crawl_government_exam(pool):
    logger.debug('enter crawl_government_exam')
    with await pool.acquire() as conn:
        conn.row_factory = __dict_factory
        # 获取事业单位招聘
        async with aiohttp.ClientSession(
            headers={'User-Agent': random.choice(ua_list)}) as session:
            resp_text = await fetch_teacher_exam_first_page(
                session, 'http://m.sc.huatu.com/list/sydw/kaoshi/')
            tree = etree.HTML(resp_text)
            tids = tree.xpath('//input[@name="tids"]/@value')[0]
            i_lst = []
            u_lst = []
            for _tree_elem in tree.xpath('//ul[@class="list"]/li'):
                _url = _tree_elem.xpath('./a/@href')[0]
                _id = _url[_url.rindex('/') + 1:_url.rindex('.html')]
                title = str(
                    _tree_elem.xpath('.//p[@class="item-tit"]/text()')[0])
                c_flag = False
                for key in key_word_list:
                    if key in title:
                        c_flag = True
                        break
                if not c_flag:
                    continue
                time = _tree_elem.xpath('.//p[@class="item-time"]/text()')[0]
                result = await data_exist(conn, _id)
                if not result:
                    i_lst.append((_id, title, f'{host}{_url}', dp(time),
                                  'pre_notice', 'gov'))
                else:
                    if title != result.get('exam_title'):
                        u_lst.append((title, f'{host}{_url}', dp(time), _id,
                                      'update_notice'))
            for index in range(2, 4):
                resp = await fetch(session,
                                   f'{base_url}?page={index}&tids={tids}')
                for item in (resp.get('data') or []):
                    if item and 'id' in item and 'title' in item and 'date' in item and 'url' in item:
                        c_flag = False
                        for key in key_word_list:
                            if key in item.get('title'):
                                c_flag = True
                                break
                        if not c_flag:
                            continue
                        result = await data_exist(conn, item.get('id'))
                        if not result:
                            i_lst.append(
                                (item.get('id'), item.get('title'),
                                 f"{host}{item.get('url')}",
                                 dp(item.get('date')), 'pre_notice', 'gov'))
                        else:
                            if item.get('title') != result.get('exam_title'):
                                u_lst.append((item.get('title'),
                                              f'{host}{_url}', dp(time),
                                              item.get('id'), 'update_notice'))
            logger.debug('crawl government exam finish')
            logger.info(f"add teacher data {encoder.encode(i_lst)}")
            logger.info(f"update teacher data {encoder.encode(u_lst)}")
            if i_lst:
                await conn.executemany(insert_sql, tuple(i_lst))
            if u_lst:
                await conn.executemany(update_sql, tuple(u_lst))
            await conn.commit()
Exemplo n.º 18
0
 def check_first(self):
     tl = list(self.cal._calendar_soup.timeline)
     assert tl[ 0].begin.datetime == dp('2015-01-01T00:00:00+00:00') ; assert tl[ 0].end.datetime == dp('2015-01-03T00:00:00+00:00') ; assert tl[ 0].all_day == True
     assert tl[ 1].begin.datetime == dp('2015-04-03T00:00:00+00:00') ; assert tl[ 1].end.datetime == dp('2015-04-08T00:00:00+00:00') ; assert tl[ 1].all_day == False
     assert tl[ 2].begin.datetime == dp('2015-05-01T00:00:00+00:00') ; assert tl[ 2].end.datetime == dp('2015-05-03T00:00:00+00:00') ; assert tl[ 2].all_day == True
     assert tl[ 3].begin.datetime == dp('2015-05-08T00:00:00+00:00') ; assert tl[ 3].end.datetime == dp('2015-05-10T00:00:00+00:00') ; assert tl[ 3].all_day == True
     assert tl[ 4].begin.datetime == dp('2015-05-14T00:00:00+00:00') ; assert tl[ 4].end.datetime == dp('2015-05-16T00:00:00+00:00') ; assert tl[ 4].all_day == True
     assert tl[ 5].begin.datetime == dp('2015-05-24T00:00:00+00:00') ; assert tl[ 5].end.datetime == dp('2015-05-27T00:00:00+00:00') ; assert tl[ 5].all_day == False
     assert tl[ 6].begin.datetime == dp('2015-07-14T00:00:00+00:00') ; assert tl[ 6].end.datetime == dp('2015-07-16T00:00:00+00:00') ; assert tl[ 6].all_day == True
     assert tl[ 7].begin.datetime == dp('2015-08-15T00:00:00+00:00') ; assert tl[ 7].end.datetime == dp('2015-08-17T00:00:00+00:00') ; assert tl[ 7].all_day == True
     assert tl[ 8].begin.datetime == dp('2015-11-01T00:00:00+00:00') ; assert tl[ 8].end.datetime == dp('2015-11-03T00:00:00+00:00') ; assert tl[ 8].all_day == True
     assert tl[ 9].begin.datetime == dp('2015-11-11T00:00:00+00:00') ; assert tl[ 9].end.datetime == dp('2015-11-13T00:00:00+00:00') ; assert tl[ 9].all_day == True
     assert tl[10].begin.datetime == dp('2015-12-25T00:00:00+00:00') ; assert tl[10].end.datetime == dp('2015-12-27T00:00:00+00:00') ; assert tl[10].all_day == True
     assert tl[11].begin.datetime == dp('2015-12-31T00:00:00+00:00') ; assert tl[11].end.datetime == dp('2016-01-03T00:00:00+00:00') ; assert tl[11].all_day == False
     assert tl[12].begin.datetime == dp('2016-03-25T00:00:00+00:00') ; assert tl[12].end.datetime == dp('2016-03-30T00:00:00+00:00') ; assert tl[12].all_day == False
     assert tl[13].begin.datetime == dp('2016-05-01T00:00:00+00:00') ; assert tl[13].end.datetime == dp('2016-05-03T00:00:00+00:00') ; assert tl[13].all_day == True
     assert tl[14].begin.datetime == dp('2016-05-05T00:00:00+00:00') ; assert tl[14].end.datetime == dp('2016-05-07T00:00:00+00:00') ; assert tl[14].all_day == True
     assert tl[15].begin.datetime == dp('2016-05-08T00:00:00+00:00') ; assert tl[15].end.datetime == dp('2016-05-10T00:00:00+00:00') ; assert tl[15].all_day == True
     assert tl[16].begin.datetime == dp('2016-05-15T00:00:00+00:00') ; assert tl[16].end.datetime == dp('2016-05-18T00:00:00+00:00') ; assert tl[16].all_day == False
     assert tl[17].begin.datetime == dp('2016-07-14T00:00:00+00:00') ; assert tl[17].end.datetime == dp('2016-07-16T00:00:00+00:00') ; assert tl[17].all_day == True
     assert tl[18].begin.datetime == dp('2016-08-15T00:00:00+00:00') ; assert tl[18].end.datetime == dp('2016-08-17T00:00:00+00:00') ; assert tl[18].all_day == True
     assert tl[19].begin.datetime == dp('2016-11-01T00:00:00+00:00') ; assert tl[19].end.datetime == dp('2016-11-03T00:00:00+00:00') ; assert tl[19].all_day == True
     assert tl[20].begin.datetime == dp('2016-11-11T00:00:00+00:00') ; assert tl[20].end.datetime == dp('2016-11-13T00:00:00+00:00') ; assert tl[20].all_day == True
     assert tl[21].begin.datetime == dp('2016-12-25T00:00:00+00:00') ; assert tl[21].end.datetime == dp('2016-12-27T00:00:00+00:00') ; assert tl[21].all_day == True
     assert tl[22].begin.datetime == dp('2016-12-31T00:00:00+00:00') ; assert tl[22].end.datetime == dp('2017-01-02T00:00:00+00:00') ; assert tl[22].all_day == True
Exemplo n.º 19
0
 def check_third(self):
     tl = list(self.cal._calendar_soup.timeline)
     assert tl[ 0].begin.datetime == dp('2015-01-01T00:00:00+00:00') ; assert tl[ 0].end.datetime == dp('2015-01-03T00:00:00+00:00') ; assert tl[ 0].all_day == False
     assert tl[ 1].begin.datetime == dp('2015-01-19T00:00:00+00:00') ; assert tl[ 1].end.datetime == dp('2015-01-21T00:00:00+00:00') ; assert tl[ 1].all_day == True
     assert tl[ 2].begin.datetime == dp('2015-02-14T00:00:00+00:00') ; assert tl[ 2].end.datetime == dp('2015-02-18T00:00:00+00:00') ; assert tl[ 2].all_day == False
     assert tl[ 3].begin.datetime == dp('2015-04-03T00:00:00+00:00') ; assert tl[ 3].end.datetime == dp('2015-04-08T00:00:00+00:00') ; assert tl[ 3].all_day == False
     assert tl[ 4].begin.datetime == dp('2015-05-01T00:00:00+00:00') ; assert tl[ 4].end.datetime == dp('2015-05-03T00:00:00+00:00') ; assert tl[ 4].all_day == True
     assert tl[ 5].begin.datetime == dp('2015-05-04T00:00:00+00:00') ; assert tl[ 5].end.datetime == dp('2015-05-06T00:00:00+00:00') ; assert tl[ 5].all_day == True
     assert tl[ 6].begin.datetime == dp('2015-05-08T00:00:00+00:00') ; assert tl[ 6].end.datetime == dp('2015-05-12T00:00:00+00:00') ; assert tl[ 6].all_day == False
     assert tl[ 7].begin.datetime == dp('2015-05-14T00:00:00+00:00') ; assert tl[ 7].end.datetime == dp('2015-05-16T00:00:00+00:00') ; assert tl[ 7].all_day == True
     assert tl[ 8].begin.datetime == dp('2015-05-24T00:00:00+00:00') ; assert tl[ 8].end.datetime == dp('2015-05-27T00:00:00+00:00') ; assert tl[ 8].all_day == False
     assert tl[ 9].begin.datetime == dp('2015-06-21T00:00:00+00:00') ; assert tl[ 9].end.datetime == dp('2015-06-23T00:00:00+00:00') ; assert tl[ 9].all_day == True
     assert tl[10].begin.datetime == dp('2015-07-04T00:00:00+00:00') ; assert tl[10].end.datetime == dp('2015-07-06T00:00:00+00:00') ; assert tl[10].all_day == True
     assert tl[11].begin.datetime == dp('2015-07-14T00:00:00+00:00') ; assert tl[11].end.datetime == dp('2015-07-16T00:00:00+00:00') ; assert tl[11].all_day == True
     assert tl[12].begin.datetime == dp('2015-08-03T00:00:00+00:00') ; assert tl[12].end.datetime == dp('2015-08-05T00:00:00+00:00') ; assert tl[12].all_day == True
     assert tl[13].begin.datetime == dp('2015-08-15T00:00:00+00:00') ; assert tl[13].end.datetime == dp('2015-08-17T00:00:00+00:00') ; assert tl[13].all_day == True
     assert tl[14].begin.datetime == dp('2015-08-31T00:00:00+00:00') ; assert tl[14].end.datetime == dp('2015-09-02T00:00:00+00:00') ; assert tl[14].all_day == True
     assert tl[15].begin.datetime == dp('2015-09-07T00:00:00+00:00') ; assert tl[15].end.datetime == dp('2015-09-09T00:00:00+00:00') ; assert tl[15].all_day == True
     assert tl[16].begin.datetime == dp('2015-10-12T00:00:00+00:00') ; assert tl[16].end.datetime == dp('2015-10-14T00:00:00+00:00') ; assert tl[16].all_day == True
     assert tl[17].begin.datetime == dp('2015-10-31T00:00:00+00:00') ; assert tl[17].end.datetime == dp('2015-11-03T00:00:00+00:00') ; assert tl[17].all_day == False
     assert tl[18].begin.datetime == dp('2015-11-05T00:00:00+00:00') ; assert tl[18].end.datetime == dp('2015-11-07T00:00:00+00:00') ; assert tl[18].all_day == True
     assert tl[19].begin.datetime == dp('2015-11-11T00:00:00+00:00') ; assert tl[19].end.datetime == dp('2015-11-13T00:00:00+00:00') ; assert tl[19].all_day == False
     assert tl[20].begin.datetime == dp('2015-11-26T00:00:00+00:00') ; assert tl[20].end.datetime == dp('2015-11-28T00:00:00+00:00') ; assert tl[20].all_day == True
     assert tl[21].begin.datetime == dp('2015-12-25T00:00:00+00:00') ; assert tl[21].end.datetime == dp('2015-12-28T00:00:00+00:00') ; assert tl[21].all_day == False
     assert tl[22].begin.datetime == dp('2015-12-31T00:00:00+00:00') ; assert tl[22].end.datetime == dp('2016-01-03T00:00:00+00:00') ; assert tl[22].all_day == False
     assert tl[23].begin.datetime == dp('2016-01-18T00:00:00+00:00') ; assert tl[23].end.datetime == dp('2016-01-20T00:00:00+00:00') ; assert tl[23].all_day == True
     assert tl[24].begin.datetime == dp('2016-02-14T00:00:00+00:00') ; assert tl[24].end.datetime == dp('2016-02-17T00:00:00+00:00') ; assert tl[24].all_day == False
     assert tl[25].begin.datetime == dp('2016-03-25T00:00:00+00:00') ; assert tl[25].end.datetime == dp('2016-03-30T00:00:00+00:00') ; assert tl[25].all_day == False
     assert tl[26].begin.datetime == dp('2016-05-01T00:00:00+00:00') ; assert tl[26].end.datetime == dp('2016-05-04T00:00:00+00:00') ; assert tl[26].all_day == False
     assert tl[27].begin.datetime == dp('2016-05-05T00:00:00+00:00') ; assert tl[27].end.datetime == dp('2016-05-07T00:00:00+00:00') ; assert tl[27].all_day == True
     assert tl[28].begin.datetime == dp('2016-05-08T00:00:00+00:00') ; assert tl[28].end.datetime == dp('2016-05-10T00:00:00+00:00') ; assert tl[28].all_day == False
     assert tl[29].begin.datetime == dp('2016-05-15T00:00:00+00:00') ; assert tl[29].end.datetime == dp('2016-05-18T00:00:00+00:00') ; assert tl[29].all_day == False
     assert tl[30].begin.datetime == dp('2016-05-30T00:00:00+00:00') ; assert tl[30].end.datetime == dp('2016-06-01T00:00:00+00:00') ; assert tl[30].all_day == False
     assert tl[31].begin.datetime == dp('2016-06-19T00:00:00+00:00') ; assert tl[31].end.datetime == dp('2016-06-21T00:00:00+00:00') ; assert tl[31].all_day == True
     assert tl[32].begin.datetime == dp('2016-07-04T00:00:00+00:00') ; assert tl[32].end.datetime == dp('2016-07-06T00:00:00+00:00') ; assert tl[32].all_day == True
     assert tl[33].begin.datetime == dp('2016-07-14T00:00:00+00:00') ; assert tl[33].end.datetime == dp('2016-07-16T00:00:00+00:00') ; assert tl[33].all_day == True
     assert tl[34].begin.datetime == dp('2016-08-01T00:00:00+00:00') ; assert tl[34].end.datetime == dp('2016-08-03T00:00:00+00:00') ; assert tl[34].all_day == True
     assert tl[35].begin.datetime == dp('2016-08-15T00:00:00+00:00') ; assert tl[35].end.datetime == dp('2016-08-17T00:00:00+00:00') ; assert tl[35].all_day == True
     assert tl[36].begin.datetime == dp('2016-08-29T00:00:00+00:00') ; assert tl[36].end.datetime == dp('2016-08-31T00:00:00+00:00') ; assert tl[36].all_day == True
     assert tl[37].begin.datetime == dp('2016-09-05T00:00:00+00:00') ; assert tl[37].end.datetime == dp('2016-09-07T00:00:00+00:00') ; assert tl[37].all_day == True
     assert tl[38].begin.datetime == dp('2016-10-10T00:00:00+00:00') ; assert tl[38].end.datetime == dp('2016-10-12T00:00:00+00:00') ; assert tl[38].all_day == True
     assert tl[39].begin.datetime == dp('2016-10-31T00:00:00+00:00') ; assert tl[39].end.datetime == dp('2016-11-03T00:00:00+00:00') ; assert tl[39].all_day == False
     assert tl[40].begin.datetime == dp('2016-11-05T00:00:00+00:00') ; assert tl[40].end.datetime == dp('2016-11-07T00:00:00+00:00') ; assert tl[40].all_day == True
     assert tl[41].begin.datetime == dp('2016-11-11T00:00:00+00:00') ; assert tl[41].end.datetime == dp('2016-11-13T00:00:00+00:00') ; assert tl[41].all_day == False
     assert tl[42].begin.datetime == dp('2016-11-24T00:00:00+00:00') ; assert tl[42].end.datetime == dp('2016-11-26T00:00:00+00:00') ; assert tl[42].all_day == True
     assert tl[43].begin.datetime == dp('2016-12-25T00:00:00+00:00') ; assert tl[43].end.datetime == dp('2016-12-29T00:00:00+00:00') ; assert tl[43].all_day == False
     assert tl[44].begin.datetime == dp('2016-12-31T00:00:00+00:00') ; assert tl[44].end.datetime == dp('2017-01-02T00:00:00+00:00') ; assert tl[44].all_day == True