papis
papis copied to clipboard
Difficulty in manipulating format for add-folder-name and add-file-name
- papis version : 0.11.1
The documentation is lacking on the format for setting add-folder-name and add-file-name etc.
Some examples given are {doc[author]}, {doc[author_list][0][family]}, {doc[title]:.15}.
Which led me to believe that I am manipulating str objects in a dictionary of the .yaml file.
However, methods that work on str objects like {doc[title].split()[0]} or {doc[author_list][0][family].capitalize()} does not work and will result in the folder/file name becoming str-object-has-no-attribute-split or str-object-has-no-attribute-capitalize.
Are they not the standard python str objects?
I want to name the folders and files as {FirstAuthor}{FirstWordOfTitle}{Year}, for example GomezExperimental2022, with capitalization.
Is this possible to be done?
I've also run into this when migrating from ol-bibtex.el and zotero to papis very recently. I've implemented my own Formater for this: https://github.com/lennonhill/papis/commit/b9b9c6eaa3de159e1b210174ef49e90a89271eb8
this format is specifically the format specification mini language found here https://docs.python.org/3.8/library/string.html#formatspec
I agree that the documentation is lacking to this respect as far as I remember.
I'd leave this therefore as a documentation TODO.
In order to solve your problem you could either follow @lennonhill approach or use the jinja formatter for instance
https://papis.readthedocs.io/en/latest/default-settings.html?highlight=jinja#config-settings-formater
Further suggestions or doucmentation improvements are of course welcome!
by the way @lennonhill you could also define this formatter you defined in your fork as a separate package as long as you
define the papis.format entry point in your setup.py, then papis will find it, as you did in https://github.com/lennonhill/papis/commit/b9b9c6eaa3de159e1b210174ef49e90a89271eb8#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7
Thanks for the reply.
I tried using the jinja formatter but it breaks existing entries in the picktool.
Running papis open shows each entry as:
{doc.html_escape[title]}
{doc.html_escape[author]}
{{doc.html_escape[year]}} [{doc.html_escape[tags]}]
Regarding the python format specification, I wonder if the formatter can be rewritten to use f-strings to allow users to have more control on the file and folder names?