pywikibot-scripts
pywikibot-scripts copied to clipboard
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
S těmi importy vlastních nástrojů je to problém, občas funguje from .X
, občas tam ta tečka být nemá. Dřív tam byla potřeba, teď už možná ne...
odstranil jsem postupně všechny tečky a teď dostávám
C:\pwb>pwb.py clean_commonscat.py -cat:Údržba:Commonscat_není_na_Wikidatech WARNING: CommonscatCleaningBot.__init__ set the Bot.site property; this is only needed when the Bot accesses many sites. 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 147, in <module> main() File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 143, in main bot.run() File "C:\pwb\pywikibot\bot.py", line 1756, in run super().run() File "C:\pwb\pywikibot\bot.py", line 1644, in run self.setup() File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 42, in setup r'\s*\n==+ *Externí odkazy *==+ *\n\s*' ValueError: unexpected '{' in field name CRITICAL: Exiting due to uncaught exception ValueError: unexpected '{' in field name
Skript už se spustí, ale spadne
C:\pwb>pwb.py clean_commonscat.py -cat:Údržba:Commonscat_není_na_Wikidatech
WARNING: Http response status 404
WARNING: CommonscatCleaningBot.__init__ set the Bot.site property; this is only needed when the Bot accesses many sites.
Retrieving 50 pages from wikipedia:cs.
>>> .356 TSW <<<
Executing remaining deferred callbacks: 0 left
1 read operation
Execution time: 3 seconds
Read operation time: 3.0 seconds
Script terminated by exception:
ERROR: invalid group reference 1 at position 5 (error)
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 146, in <module>
main()
File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 142, in main
bot.run()
File "C:\pwb\pywikibot\bot.py", line 1749, in run
super().run()
File "C:\pwb\pywikibot\bot.py", line 1664, in run
self.treat(page)
File "C:\pwb\pywikibot\bot.py", line 1917, in treat
self.treat_page()
File "C:\pwb\scripts\userscripts\clean_commonscat.py", line 93, in treat_page
page_replaced_text = self.empty_sectionR.sub(
File "C:\Python310\lib\re.py", line 326, in _subx
template = _compile_repl(template, pattern)
File "C:\Python310\lib\re.py", line 317, in _compile_repl
return sre_parse.parse_template(repl, pattern)
File "C:\Python310\lib\sre_parse.py", line 1048, in parse_template
addgroup(int(this[1:]), len(this) - 1)
File "C:\Python310\lib\sre_parse.py", line 992, in addgroup
raise s.error("invalid group reference %d" % index, pos)
re.error: invalid group reference 1 at position 5
CRITICAL: Exiting due to uncaught exception error: invalid group reference 1 at position 5