Giter VIP home page Giter VIP logo

pywikibot-scripts's Introduction

pywikibot-scripts

Own pywikibot scripts (for Wikimedia projects)

Requirements

Python 3.6.1 or newer. Pywikibot version 4d6e674.

Usage

Checkout or download to "myscripts" directory inside "core/scripts/userscripts". Then add to your user-config.py:

user_script_paths = ['scripts.userscripts.myscripts']

pywikibot-scripts's People

Contributors

matejsuchanek avatar mykhal avatar urbanecm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pywikibot-scripts's Issues

[typos.py] Návrh nové funkce - ukládání s potvrzením

Rád bych navrhl novou funkci, kdy bude k dispozici nějaký podobný přepínač jako u PWB -always, bez kterého se bude skript typos.py na každou editaci ptát, aby pak nedocházelo k situacím jako je https://cs.wikipedia.org/w/index.php?diff=14026013, anebo předtím https://cs.wikipedia.org/w/index.php?title=%C4%8Cesk%C3%BD_pravopis&diff=13263784&oldid=12999425 (v čemž je ale typos.py nevinně, protože to byl můj jednorázový skriptík na překlepy; každopádně princip je stejný).

Předem díky za doprogramování.

[typos.py] pywikibot.data.api.APIError: gsrsearch-error

Ahoj Matěji,
zkusil jsem ten skript typos.py spustit (pomocí python typos.py v naklonovaném repozitáři). Evidentně jsem ho buď spouštěl blbě, anebo je něco s tím skriptem.

== Výstup skriptu ==
Expression matched title: Žlutý pes
No results from query insource:/himal[aá]j/i
Doing insource:/him[aá]l[aá]jemi/i
Expression matched title: Alois Musil
Expression matched title: Berlínské krize
Expression matched title: Brahmaputra
Expression matched title: Hulevník vysoký
Expression matched title: Petr Sirotek
Expression matched title: Puncak Jaya
Expression matched title: Sandó Kaisen
No results from query insource:/him[aá]l[aá]jemi/i
Doing insource:/honorál/i
No results from query insource:/honorál/i
Doing insource:/hardvardská univer/i
No results from query insource:/hardvardská univer/i
Doing insource:/hardvardské [^ ]+ity/i
No results from query insource:/hardvardské [^ ]+ity/i
Doing insource:/hardvardské [^ ]+itě/i
No results from query insource:/hardvardské [^ ]+itě/i
Doing insource:/hardvardskou [^ ]+itu/i
No results from query insource:/hardvardskou [^ ]+itu/i
Doing insource:/hardvardskou [^ ]+itou"/i
WARNING: API error gsrsearch-error: Regular expression syntax error at 23: expected '"'
Traceback (most recent call last):
File "typos.py", line 91, in
for page in pagegenerators.SearchPageGenerator(rule[0], namespaces=[0], site=site):
File "/home/martin/bin/pywikibot/pywikibot/pagegenerators.py", line 2278, in SearchPageGenerator
for page in site.search(query, total=total, namespaces=namespaces):
File "/home/martin/bin/pywikibot/pywikibot/data/api.py", line 2744, in iter
self.data = self.request.submit()
File "/home/martin/bin/pywikibot/pywikibot/data/api.py", line 2188, in submit
raise APIError(**result['error'])
pywikibot.data.api.APIError: gsrsearch-error: Regular expression syntax error at 23: expected '"' [help:See https://cs.wikipedia.org/w/api.php for API usage]
<class 'pywikibot.data.api.APIError'>
CRITICAL: Closing network session.

Commonscat není totéž co Commonscat v tabulce

i18n of checkwiki_errors.py

Maybe we could add some dict of localized edit summaries? Of course, I can go and translate them in my copy of this script, but if there are some major changes in script and I would like to follow them, I would need to do that again. That wouldn't be too cool :)

clean_commonscat padá

PO uvedení nové verze dostávám tuto chybu:
(číslo řádku je několik posunuté, mám přidaná shrnutí)

4 pages read
0 pages written
Execution time: 18 seconds
Read operation time: 4 seconds
Script terminated by exception:

ERROR: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "C:\pwb\pwb.py", line 263, in <module>
    if not main():
  File "C:\pwb\pwb.py", line 257, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "C:\pwb\pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File ".\scripts\clean_commonscat3.py", line 151, in <module>
    main()
  File ".\scripts\clean_commonscat3.py", line 148, in main
    bot.run()
  File "C:\pwb\pywikibot\bot.py", line 1435, in run
    self.treat(page)
  File "C:\pwb\pywikibot\bot.py", line 1722, in treat
    super(ExistingPageBot, self).treat(page)
  File "C:\pwb\pywikibot\bot.py", line 1786, in treat
    super(NoRedirectPageBot, self).treat(page)
  File "C:\pwb\pywikibot\bot.py", line 1649, in treat
    self.treat_page()
  File ".\scripts\clean_commonscat3.py", line 106, in treat_page
    pywikibot.output('Importing P373 to %s' % (page.title(), item.getID()))
TypeError: not all arguments converted during string formatting
<type 'exceptions.TypeError'>
CRITICAL: Closing network session.

přepínače clean_commonscat.py

Chtělo by to přidat přepínače, aby skript mohl dělat třeba jen část práce
už existuje -createnew, který vytvoří prázdnou kategorii na commons (nepoužívat)
chtělo by to další alespoň dva

  • noclean (nebude mazat z článků)
  • noimport (neprovede import na Wikidata)

clean_commonscat.py

C:\pwb>pwb.py userscripts/clean_commonscat.py Traceback (most recent call last): File "C:\pwb\pwb.py", line 39, in <module> sys.exit(main()) File "C:\pwb\pwb.py", line 35, in main runpy.run_path(str(path), run_name='__main__') File "C:\Python310\lib\runpy.py", line 289, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Python310\lib\runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\pwb\pywikibot\scripts\wrapper.py", line 513, in <module> main() File "C:\pwb\pywikibot\scripts\wrapper.py", line 497, in main if not execute(): File "C:\pwb\pywikibot\scripts\wrapper.py", line 484, in execute run_python_file(filename, script_args, module) File "C:\pwb\pywikibot\scripts\wrapper.py", line 147, in run_python_file exec(compile(source, filename, 'exec', dont_inherit=True), File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 43 fr'(?:^==|^\{\{(?:{templates})|^\[\[(?:{ns}):)', flags=re.M) ^ SyntaxError: f-string expression part cannot include a backslash CRITICAL: Exiting due to uncaught exception SyntaxError: f-string expression part cannot include a backslash (clean_commonscat.py, line 43)

pokud odsraním f na začátku řádku, dostanu

C:\pwb>pwb.py userscripts/clean_commonscat.py Traceback (most recent call last): File "C:\pwb\pwb.py", line 39, in <module> sys.exit(main()) File "C:\pwb\pwb.py", line 35, in main runpy.run_path(str(path), run_name='__main__') File "C:\Python310\lib\runpy.py", line 289, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Python310\lib\runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\pwb\pywikibot\scripts\wrapper.py", line 513, in <module> main() File "C:\pwb\pywikibot\scripts\wrapper.py", line 497, in main if not execute(): File "C:\pwb\pywikibot\scripts\wrapper.py", line 484, in execute run_python_file(filename, script_args, module) File "C:\pwb\pywikibot\scripts\wrapper.py", line 147, in run_python_file exec(compile(source, filename, 'exec', dont_inherit=True), File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 10, in <module> from .deferred import DeferredCallbacksBot ImportError: attempted relative import with no known parent package CRITICAL: Exiting due to uncaught exception ImportError: attempted relative import with no known parent package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.