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

Python pywikibot.calledModuleName函数代码示例

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

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



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

示例1: load_page

 def load_page(self):
     """Load the page to be archived and break it up into threads."""
     self.header = ''
     self.threads = []
     self.archives = {}
     self.archived_threads = 0
     lines = self.get().split('\n')
     found = False  # Reading header
     cur_thread = None
     for line in lines:
         thread_header = re.search('^== *([^=].*?) *== *$', line)
         if thread_header:
             found = True  # Reading threads now
             if cur_thread:
                 self.threads.append(cur_thread)
             cur_thread = DiscussionThread(thread_header.group(1), self.now,
                                           self.timestripper)
         else:
             if found:
                 cur_thread.feed_line(line)
             else:
                 self.header += line + '\n'
     if cur_thread:
         self.threads.append(cur_thread)
     # This extra info is not desirable when run under the unittest
     # framework, which may be run either directly or via setup.py
     if pywikibot.calledModuleName() not in ['archivebot_tests', 'setup']:
         pywikibot.output(u'%d Threads found on %s'
                          % (len(self.threads), self))
开发者ID:metakgp,项目名称:batman,代码行数:29,代码来源:archivebot.py


示例2: fixSelfInterwiki

 def fixSelfInterwiki(self, text):
     """
     Interwiki links to the site itself are displayed like local links.
     Remove their language code prefix.
     """
     if not self.talkpage and pywikibot.calledModuleName() <> 'interwiki':
         interwikiR = re.compile(r'\[\[%s\s?:([^\[\]\n]*)\]\]' % self.site.lang)
         text = interwikiR.sub(r'[[\1]]', text)
     return text
开发者ID:azatoth,项目名称:pywikipedia,代码行数:9,代码来源:cosmetic_changes.py


示例3: test_default_user_agent

 def test_default_user_agent(self):
     """Config defined format string test."""
     self.assertTrue(http.user_agent().startswith(
         pywikibot.calledModuleName()))
     self.assertIn('Pywikibot/' + pywikibot.__release__, http.user_agent())
     self.assertNotIn('  ', http.user_agent())
     self.assertNotIn('()', http.user_agent())
     self.assertNotIn('(;', http.user_agent())
     self.assertNotIn(';)', http.user_agent())
     self.assertIn('requests/', http.user_agent())
     self.assertIn('Python/' + str(PYTHON_VERSION[0]), http.user_agent())
开发者ID:AbdealiJK,项目名称:pywikibot-core,代码行数:11,代码来源:http_tests.py


示例4: test_default_user_agent

 def test_default_user_agent(self):
     """Config defined format string test."""
     self.assertTrue(http.user_agent().startswith(
         pywikibot.calledModuleName()))
     self.assertIn('Pywikibot/' + pywikibot.__release__, http.user_agent())
     self.assertNotIn('  ', http.user_agent())
     self.assertNotIn('()', http.user_agent())
     self.assertNotIn('(;', http.user_agent())
     self.assertNotIn(';)', http.user_agent())
     self.assertIn('httplib2/', http.user_agent())
     self.assertIn('Python/' + str(sys.version_info[0]), http.user_agent())
开发者ID:skamithi,项目名称:pywikibot-core,代码行数:11,代码来源:http_tests.py


示例5: test_user_agent

    def test_user_agent(self):
        """Test different variants of user agents."""
        x = self.get_site()

        x._userinfo = {'name': 'foo'}
        x._username = ('foo', None)

        self.assertEqual('Pywikibot/' + pywikibot.__release__,
                         user_agent(x, format_string='{pwb}'))

        self.assertEqual(x.family.name,
                         user_agent(x, format_string='{family}'))
        self.assertEqual(x.code,
                         user_agent(x, format_string='{lang}'))
        self.assertEqual(x.family.name + ' ' + x.code,
                         user_agent(x, format_string='{family} {lang}'))

        self.assertEqual(x.username(),
                         user_agent(x, format_string='{username}'))

        x._userinfo = {'name': u'!'}
        x._username = (u'!', None)

        self.assertEqual('!', user_agent(x, format_string='{username}'))

        x._userinfo = {'name': u'foo bar'}
        x._username = (u'foo bar', None)

        self.assertEqual('foo_bar', user_agent(x, format_string='{username}'))

        old_config = '{script}/{version} Pywikibot/2.0 (User:{username})'

        pywikibot.version.getversiondict()
        script_value = pywikibot.calledModuleName() + '/' + pywikibot.version.cache['rev']

        self.assertEqual(script_value + ' Pywikibot/2.0 (User:foo_bar)',
                         user_agent(x, format_string=old_config))

        x._userinfo = {'name': u'⁂'}
        x._username = (u'⁂', None)

        self.assertEqual('%E2%81%82',
                         user_agent(x, format_string='{username}'))

        x._userinfo = {'name': u'127.0.0.1'}
        x._username = (None, None)

        self.assertEqual('Foo', user_agent(x, format_string='Foo {username}'))
        self.assertEqual('Foo (' + x.family.name + ':' + x.code + ')',
                         user_agent(x, format_string='Foo ({script_comments})'))
开发者ID:PersianWikipedia,项目名称:pywikibot-core,代码行数:50,代码来源:dry_site_tests.py


示例6: putSpacesInLists

    def putSpacesInLists(self, text):
        """
        For better readability of bullet list and enumeration wiki source code,
        puts a space between the * or # and the text.

        NOTE: This space is recommended in the syntax help on the English,
        German, and French Wikipedia. It might be that it is not wanted on other
        wikis. If there are any complaints, please file a bug report.
        """
        exceptions = ['comment', 'math', 'nowiki', 'pre', 'source', 'timeline']
        if not (self.redirect or self.template) and \
           pywikibot.calledModuleName() != 'capitalize_redirects':
            text = pywikibot.replaceExcept(
                text,
                r'(?m)^(?P<bullet>[:;]*(\*+|#+)[:;\*#]*)(?P<char>[^\s\*#:;].+?)', '\g<bullet> \g<char>',
                exceptions)
        return text
开发者ID:azatoth,项目名称:pywikipedia,代码行数:17,代码来源:cosmetic_changes.py


示例7:

from pywikibot.exceptions import Server504Error
import pywikibot
import cookielib
import threadedhttp
import pywikibot.version

_logger = "comm.http"


# global variables

# the User-agent: header. The default is 
# '<script>/<revision> Pywikipediabot/2.0', where '<script>' is the currently
# executing script and version is the SVN revision of Pywikipediabot.
USER_AGENT_FORMAT = '{script}/r{version[rev]} Pywikipediabot/2.0'
useragent = USER_AGENT_FORMAT.format(script=pywikibot.calledModuleName(),
                                     version=pywikibot.version.getversiondict())
numthreads = 1
threads = []

connection_pool = threadedhttp.ConnectionPool()
http_queue = Queue.Queue()

cookie_jar = threadedhttp.LockableCookieJar(
                 config.datafilepath("pywikibot.lwp"))
try:
    cookie_jar.load()
except (IOError, cookielib.LoadError):
    pywikibot.debug(u"Loading cookies failed.", _logger)
else:
    pywikibot.debug(u"Loaded cookies from file.", _logger)
开发者ID:edgarskos,项目名称:pywikipedia-rewrite,代码行数:31,代码来源:http.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pywikibot.debug函数代码示例发布时间:2022-05-26
下一篇:
Python webhdfs.PyWebHdfsClient类代码示例发布时间: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