bitdruid / python-wayback-machine-downloader

Query and download archive.org as simple as possible.
MIT License
30 stars 1 forks source link

[BUG] SyntaxError: f-string: expecting '}' #24

Open Tiptop4792 opened 6 days ago

Tiptop4792 commented 6 days ago

Just made a fresh install on Ubuntu 22.04. - Any idea what causes this?

Describe Constant syntax error, even when running waybackup -h

Terminal output


waybackup -h
Traceback (most recent call last):
  File "/home/user/python-wayback-machine-downloader-TEST/python-wayback-machine-downloader/waybackdownloaderEnvironment/bin/waybackup", line 33, in <module>
    sys.exit(load_entry_point('pywaybackup==2.0.0', 'console_scripts', 'waybackup')())
  File "/home/user/python-wayback-machine-downloader-TEST/python-wayback-machine-downloader/waybackdownloaderEnvironment/bin/waybackup", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/user/python-wayback-machine-downloader-TEST/python-wayback-machine-downloader/waybackdownloaderEnvironment/lib/python3.10/site-packages/pywaybackup/main.py", line 5, in <module>
    import pywaybackup.archive as archive
  File "/home/user/python-wayback-machine-downloader-TEST/python-wayback-machine-downloader/waybackdownloaderEnvironment/lib/python3.10/site-packages/pywaybackup/archive.py", line 177
    vb.write(message=f"-----> {"in CDX file".ljust(18)}: {sc.CDX_TOTAL:,}")
                                ^^
SyntaxError: f-string: expecting '}'

Any idea what causes this? Many thanks!

bitdruid commented 6 days ago

i think it is because of the double-quote inside the double-quote. which python version do you have? i do not get this bug.

Tiptop4792 commented 5 days ago

I'm on Python 3.10.12

Thanks for looking into this!

bitdruid commented 5 days ago

you can try if 2.0.1 resolves this. just install via pip and let me know :)

dw5 commented 2 days ago
lab@lab-Virtual-Machine:~/lab$ pip install pywaybackup --upgrade
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pywaybackup in /home/lab/.local/lib/python3.10/site-packages (2.0.1)
Requirement already satisfied: requests==2.31.0 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup) (2.31.0)
Requirement already satisfied: python-magic==0.4.27 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup) (0.4.27)
Requirement already satisfied: tqdm==4.66.2 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup) (4.66.2)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup) (2020.6.20)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/lab/.local/lib/python3.10/site-packages (from requests==2.31.0->pywaybackup) (3.4.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup) (3.3)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup) (1.26.5)
lab@lab-Virtual-Machine:~/lab$ waybackup -h
Traceback (most recent call last):
  File "/home/lab/.local/bin/waybackup", line 5, in <module>
    from pywaybackup.main import main
  File "/home/lab/.local/lib/python3.10/site-packages/pywaybackup/main.py", line 5, in <module>
    import pywaybackup.archive as archive
  File "/home/lab/.local/lib/python3.10/site-packages/pywaybackup/archive.py", line 184
    vb.write(message=f"\n-----> {"to utilize".ljust(18)}: {sc.SNAPSHOT_UNHANDLED:,}")
                                  ^^
SyntaxError: f-string: expecting '}'

---

lab@lab-Virtual-Machine:~/lab$ git clone https://github.com/bitdruid/python-wayback-machine-downloader.git
Cloning into 'python-wayback-machine-downloader'...
remote: Enumerating objects: 251, done.
remote: Counting objects: 100% (150/150), done.
remote: Compressing objects: 100% (92/92), done.
remote: Total 251 (delta 115), reused 66 (delta 57), pack-reused 101 (from 1)
Receiving objects: 100% (251/251), 311.65 KiB | 2.73 MiB/s, done.
Resolving deltas: 100% (130/130), done.
lab@lab-Virtual-Machine:~/lab$ cd python-wayback-machine-downloader/
lab@lab-Virtual-Machine:~/lab/python-wayback-machine-downloader$ pip install .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/lab/lab/python-wayback-machine-downloader
  Preparing metadata (setup.py) ... done
Requirement already satisfied: requests==2.31.0 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup==2.0.0) (2.31.0)
Requirement already satisfied: tqdm==4.66.2 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup==2.0.0) (4.66.2)
Requirement already satisfied: python-magic==0.4.27 in /home/lab/.local/lib/python3.10/site-packages (from pywaybackup==2.0.0) (0.4.27)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup==2.0.0) (1.26.5)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup==2.0.0) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests==2.31.0->pywaybackup==2.0.0) (2020.6.20)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/lab/.local/lib/python3.10/site-packages (from requests==2.31.0->pywaybackup==2.0.0) (3.4.0)
Building wheels for collected packages: pywaybackup
  Building wheel for pywaybackup (setup.py) ... done
  Created wheel for pywaybackup: filename=pywaybackup-2.0.0-py3-none-any.whl size=24096 sha256=eee02b340825146d5d5bb7f5ea4010b40e975d8e89ef9e68e7666896a6b25f1d
  Stored in directory: /home/lab/.cache/pip/wheels/4d/7d/e6/632672ae4126060b04a2047798a81503a70e268d5eb2cc6191
Successfully built pywaybackup
Installing collected packages: pywaybackup
  Attempting uninstall: pywaybackup
    Found existing installation: pywaybackup 2.0.1
    Uninstalling pywaybackup-2.0.1:
      Successfully uninstalled pywaybackup-2.0.1
  WARNING: The script waybackup is installed in '/home/lab/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

lab@lab-Virtual-Machine:~/lab/python-wayback-machine-downloader$ waybackup -h
Traceback (most recent call last):
  File "/usr/local/bin/waybackup", line 5, in <module>
    from pywaybackup.main import main
  File "/home/lab/.local/lib/python3.10/site-packages/pywaybackup/main.py", line 5, in <module>
    import pywaybackup.archive as archive
  File "/home/lab/.local/lib/python3.10/site-packages/pywaybackup/archive.py", line 177
    vb.write(message=f"-----> {"in CDX file".ljust(18)}: {sc.CDX_TOTAL:,}")
                                ^^
SyntaxError: f-string: expecting '}'
lab@lab-Virtual-Machine:~/lab/python-wayback-machine-downloader$ 
bitdruid commented 2 days ago

you sure you are on 2.0.1 ? 2.0.1 is not on main - only dev

vb.write(message=f"-----> {"in CDX file".ljust(18)}: {sc.CDX_TOTAL:,}")

changed to

vb.write(message=f"-----> {'in CDX file'.ljust(18)}: {sc.CDX_TOTAL:,}")

in 2.0.1

update:

so i tested (now 2.0.2) on ubuntu 24.04 and manjaro 24.1.1 without these errors raising. should be fixed

dw5 commented 1 day ago

For me, That solved the bug in those two past versions.