Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean_commonscat.py #13

Open
JAnDud opened this issue Sep 11, 2023 · 3 comments
Open

clean_commonscat.py #13

JAnDud opened this issue Sep 11, 2023 · 3 comments

Comments

@JAnDud
Copy link

JAnDud commented Sep 11, 2023

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

@matejsuchanek
Copy link
Owner

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...

@JAnDud
Copy link
Author

JAnDud commented Sep 12, 2023

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

@matejsuchanek matejsuchanek reopened this Sep 15, 2023
matejsuchanek added a commit that referenced this issue Nov 13, 2023
@JAnDud
Copy link
Author

JAnDud commented Jan 16, 2024

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

@JAnDud JAnDud closed this as completed Jan 16, 2024
@JAnDud JAnDud reopened this Jan 16, 2024
matejsuchanek added a commit that referenced this issue Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants