• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pywikibot.Timestamp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pywikibot.Timestamp的典型用法代码示例。如果您正苦于以下问题:Python Timestamp类的具体用法?Python Timestamp怎么用?Python Timestamp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Timestamp类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_iso_format

 def test_iso_format(self):
     """Test conversion from and to ISO format."""
     t1 = Timestamp.utcnow()
     ts1 = t1.isoformat()
     t2 = Timestamp.fromISOformat(ts1)
     ts2 = t2.isoformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:11,代码来源:timestamp_tests.py


示例2: test_iso_format_with_sep

 def test_iso_format_with_sep(self):
     """Test conversion from and to ISO format with separator."""
     SEP = '*'
     t1 = Timestamp.utcnow().replace(microsecond=0)
     ts1 = t1.isoformat(sep=SEP)
     t2 = Timestamp.fromISOformat(ts1, sep=SEP)
     ts2 = t2.isoformat(sep=SEP)
     self.assertEqual(t1, t2)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
     date, sep, time = ts1.partition(SEP)
     time = time.rstrip('Z')
     self.assertEqual(date, str(t1.date()))
     self.assertEqual(time, str(t1.time()))
开发者ID:magul,项目名称:pywikibot-core,代码行数:14,代码来源:timestamp_tests.py


示例3: test_iso_format

 def test_iso_format(self):
     """Test conversion from and to ISO format."""
     SEP = 'T'
     t1 = Timestamp.utcnow()
     ts1 = t1.isoformat()
     t2 = Timestamp.fromISOformat(ts1)
     ts2 = t2.isoformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
     date, sep, time = ts1.partition(SEP)
     time = time.rstrip('Z')
     self.assertEqual(date, str(t1.date()))
     self.assertEqual(time, str(t1.time()))
开发者ID:magul,项目名称:pywikibot-core,代码行数:16,代码来源:timestamp_tests.py


示例4: test_build_table_with_check

 def test_build_table_with_check(self):
     """Test buildt table with check option."""
     bot = imagereview.CheckImageBot(check=True, total=0)
     bot.cat = 'Nonexisting page for imagereview'
     table = bot.build_table(save=False, unittest=True)
     if not table:
         self.skipTest('Table of files to review is empty')
     key = list(table.keys())[0]  # py3 comp
     data = table[key]
     item = data[0]
     self.assertIsInstance(key, StringTypes)
     self.assertIsInstance(data, list)
     self.assertIsInstance(item, list)
     self.assertEqual(len(item), 4)
     linkedtitle, uploader, filepage, reason = item
     user, time = uploader
     self.assertIsInstance(linkedtitle, StringTypes)
     self.assertIsInstance(uploader, list)
     self.assertIsInstance(filepage, imagereview.DUP_Image)
     self.assertIsInstance(reason, StringTypes)
     self.assertIsInstance(user, StringTypes)
     self.assertIsInstance(time, StringTypes)
     self.assertEqual(reason, '')
     self.assertEqual(filepage.title(asLink=True, textlink=True),
                      linkedtitle)
     self.assertEqual(user, key)
     self.assertIsInstance(Timestamp.fromISOformat(time), Timestamp)
开发者ID:edgarskos,项目名称:pywikibot-bots-xqbot,代码行数:27,代码来源:imagereview_tests.py


示例5: test_sub_timedate

 def test_sub_timedate(self):
     """Test subtracting two timestamps."""
     t1 = Timestamp.utcnow()
     t2 = t1 - datetime.timedelta(days=1)
     td = t1 - t2
     self.assertIsInstance(td, datetime.timedelta)
     self.assertEqual(t2 + td, t1)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:7,代码来源:timestamp_tests.py


示例6: test_sub_timedelta

 def test_sub_timedelta(self):
     """Test substracting a timedelta from a Timestamp."""
     t1 = Timestamp.utcnow()
     t2 = t1 - datetime.timedelta(days=1)
     if t1.month != t2.month:
         self.assertEqual(calendar.monthrange(t2.year, t2.month)[1], t2.day)
     else:
         self.assertEqual(t1.day - 1, t2.day)
     self.assertIsInstance(t2, Timestamp)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:9,代码来源:timestamp_tests.py


示例7: test_add_timedelta

 def test_add_timedelta(self):
     """Test addin a timedelta to a Timestamp."""
     t1 = Timestamp.utcnow()
     t2 = t1 + datetime.timedelta(days=1)
     if t1.month != t2.month:
         self.assertEqual(1, t2.day)
     else:
         self.assertEqual(t1.day + 1, t2.day)
     self.assertIsInstance(t2, Timestamp)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:9,代码来源:timestamp_tests.py


示例8: test_instantiate_from_instance

 def test_instantiate_from_instance(self):
     """Test passing instance to factory methods works."""
     t1 = Timestamp.utcnow()
     self.assertIsNot(t1, Timestamp.fromISOformat(t1))
     self.assertEqual(t1, Timestamp.fromISOformat(t1))
     self.assertIsInstance(Timestamp.fromISOformat(t1), Timestamp)
     self.assertIsNot(t1, Timestamp.fromtimestampformat(t1))
     self.assertEqual(t1, Timestamp.fromtimestampformat(t1))
     self.assertIsInstance(Timestamp.fromtimestampformat(t1), Timestamp)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:9,代码来源:timestamp_tests.py


示例9: test_add_timedate

    def test_add_timedate(self):
        """Test unsupported additions raise NotImplemented."""
        t1 = datetime.datetime.utcnow()
        t2 = t1 + datetime.timedelta(days=1)
        t3 = t1.__add__(t2)
        self.assertIs(t3, NotImplemented)

        # Now check that the pywikibot sub-class behaves the same way
        t1 = Timestamp.utcnow()
        t2 = t1 + datetime.timedelta(days=1)
        t3 = t1.__add__(t2)
        self.assertIs(t3, NotImplemented)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:12,代码来源:timestamp_tests.py


示例10: run

    def run(self):
        """Run the bot."""
        starttime = time()
        rc_listener = site_rc_listener(self.site, timeout=60)
        while True:
            pywikibot.output(Timestamp.now().strftime(">> %H:%M:%S: "))
            self.read_lists()
            try:
                self.markBlockedusers(self.loadBlockedUsers())
                self.contactDefendants(bootmode=self.start)
            except pywikibot.EditConflict:
                pywikibot.output("Edit conflict found, try again.")
                continue  # try again and skip waittime
            except pywikibot.PageNotSaved:
                pywikibot.output("Page not saved, try again.")
                continue  # try again and skip waittime

            # wait for new block entry
            print()
            now = time()
            pywikibot.stopme()
            for i, entry in enumerate(rc_listener):
                if i % 25 == 0:
                    print('\r', ' ' * 50, '\rWaiting for events', end='')
                if entry['type'] == 'log' and \
                   entry['log_type'] == 'block' and \
                   entry['log_action'] in ('block', 'reblock'):
                    pywikibot.output('\nFound a new blocking event '
                                     'by user "%s" for user "%s"'
                                     % (entry['user'], entry['title']))
                    break
                if entry['type'] == 'edit' and \
                   not entry['bot'] and \
                   entry['title'] == self.vmPageName:
                    pywikibot.output('\nFound a new edit by user "%s"'
                                     % entry['user'])
                    break
                if not entry['bot']:
                    print('.', end='')
            print('\n')

            self.optOutListAge += time() - now

            # read older entries again after ~4 minutes
            if time() - starttime > 250:
                starttime = time()
                self.reset_timestamp()
            self.start = False
            self.total = 10
开发者ID:edgarskos,项目名称:pywikibot-bots-xqbot,代码行数:49,代码来源:vandalism.py


示例11: test_clone

 def test_clone(self):
     """Test cloning a Timestamp instance."""
     t1 = Timestamp.utcnow()
     t2 = t1.clone()
     self.assertEqual(t1, t2)
     self.assertIsInstance(t2, Timestamp)
开发者ID:Darkdadaah,项目名称:pywikibot-core,代码行数:6,代码来源:timestamp_tests.py


示例12: test_iso_format_property

 def test_iso_format_property(self):
     """Test iso format properties."""
     self.assertEqual(Timestamp.ISO8601Format, Timestamp._ISO8601Format())
     self.assertEqual(re.sub(r'[\-:TZ]', '', Timestamp.ISO8601Format),
                      Timestamp.mediawikiTSFormat)
开发者ID:magul,项目名称:pywikibot-core,代码行数:5,代码来源:timestamp_tests.py


示例13: test_mediawiki_format

 def test_mediawiki_format(self):
     t1 = T.utcnow()
     ts1 = t1.totimestampformat()
     t2 = T.fromtimestampformat(ts1)
     ts2 = t2.totimestampformat()
     # MediaWiki timestamp format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:10,代码来源:timestamp_tests.py


示例14: test_iso_format

 def test_iso_format(self):
     t1 = T.utcnow()
     ts1 = t1.toISOformat()
     t2 = T.fromISOformat(ts1)
     ts2 = t2.toISOformat()
     # MediaWiki ISO format doesn't include microseconds
     self.assertNotEqual(t1, t2)
     t1 = t1.replace(microsecond=0)
     self.assertEqual(t1, t2)
     self.assertEqual(ts1, ts2)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:10,代码来源:timestamp_tests.py


示例15: test_add_timedelta

 def test_add_timedelta(self):
     t1 = T.utcnow()
     t2 = t1 + datetime.timedelta(days=1)
     if t1.month != t2.month:
         self.assertEqual(1, t2.day)
     else:
         self.assertEqual(t1.day + 1, t2.day)
     self.assertIsInstance(t2, T)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:8,代码来源:timestamp_tests.py


示例16: test_sub_timedelta

 def test_sub_timedelta(self):
     t1 = T.utcnow()
     t2 = t1 - datetime.timedelta(days=1)
     if t1.month != t2.month:
         self.assertEqual(calendar.monthrange(t2.year, t2.month)[1], t2.day)
     else:
         self.assertEqual(t1.day - 1, t2.day)
     self.assertIsInstance(t2, T)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:8,代码来源:timestamp_tests.py


示例17: test_sub_timedelta

 def test_sub_timedelta(self):
     t1 = T.utcnow()
     t2 = t1 - datetime.timedelta(days=1)
     self.assertEqual(t1.day - 1, t2.day)
     self.assertIsInstance(t2, T)
开发者ID:leogregianin,项目名称:pywikibot-core,代码行数:5,代码来源:timestamp_tests.py


示例18: test_sub_timedate

 def test_sub_timedate(self):
     t1 = T.utcnow()
     t2 = t1 - datetime.timedelta(days=1)
     td = t1 - t2
     self.assertIsInstance(td, datetime.timedelta)
     self.assertEqual(t2 + td, t1)
开发者ID:rubin16,项目名称:pywikibot-core,代码行数:6,代码来源:timestamp_tests.py


示例19: test_clone

 def test_clone(self):
     t1 = T.utcnow()
     t2 = t1.clone()
     self.assertEqual(t1, t2)
     self.assertIsInstance(t2, T)
开发者ID:edgarskos,项目名称:pywikibot_scripts,代码行数:5,代码来源:timestamp_tests.py



注:本文中的pywikibot.Timestamp类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python bot.debug函数代码示例发布时间:2022-05-26
下一篇:
Python pywikibot.warning函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap