lervag / apy

CLI script for interacting with local Anki collection
MIT License
228 stars 17 forks source link

Remove the dependency on aqt #57

Closed lervag closed 1 year ago

lervag commented 1 year ago

As suggested by @ckp95, we can access the database directly and avoid the dependency on aqt. I've made a first version of this here and would be happy to get a review or comments from someone!

@denismaciel @ckp95

ckp95 commented 1 year ago

Cool, I'll test this out tomorrow.

denismaciel commented 1 year ago

I have installed this branch version with pipx.

pipx install --force git+https://github.com/lervag/apy.git@feat/avoid-aqt

The installation went through! But I got the following error when running the command:

$ /home/denis/.local/bin/apy
Config file:             Not found
Traceback (most recent call last):
  File "/home/denis/.local/bin/apy", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/apy/cli.py", line 54, in main
    ctx.invoke(info)
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/apy/cli.py", line 181, in info
    with Anki(**cfg) as a:
         ^^^^^^^^^^^
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/apy/anki.py", line 31, in __init__
    self._init_load_profile(base_path, collection_db_path)
  File "/home/denis/.local/pipx/venvs/apy/lib/python3.11/site-packages/apy/anki.py", line 49, in _init_load_profile
    Path(collection_db_path).absolute())
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 871, in __new__
    self = cls._from_parts(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 509, in _from_parts
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 493, in _parse_args
    a = os.fspath(a)
        ^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

I haven't looked into it, but I figured I would just dump it here, since I pair of trained eyes might be able to quickly find out what's going on.

lervag commented 1 year ago

Thanks for testing! It would be nice if you could test once more; I believe I fixed the problem you found.

lervag commented 1 year ago

Sorry, there are some errors. I'm working on fixing them now.

lervag commented 1 year ago

Now it should be fixed. The new GitHub actions pipeline is already very useful; thanks!

lervag commented 1 year ago

The present PR will introduce a breaking change: the config option base is now called base_path.

lervag commented 1 year ago

I've reworked the commits and I believe this is ready to merge now.

denismaciel commented 1 year ago

@lervag Problem solved, the pipx installation just works ™ Amazing!

lervag commented 1 year ago

Cool, I'm glad to hear it!