papers icon indicating copy to clipboard operation
papers copied to clipboard

Implement nauthor, ntitle and nameformat user settings

Open malfatti opened this issue 4 years ago • 10 comments

Allows user to define number of authors, title words and file name fields. After this change, the user can run, for example:

$ papers add --rename --info --nameformat Author,year,-,Title --nauthor 1 --ntitle 1 esd-4-11-2013
INFO:papers:found doi:10.5194/esd-4-11-2013
INFO:papers:new entry: perrette2013scaling
INFO:papers:create directory: files/2013
INFO:papers:mv /home/perrette/playground/papers/esd-4-11-2013.pdf files/2013/PerretteEtAl2013-AScalingApproachToProjectRegionalSeaLevelRiseAndItsUncertainties.pdf
INFO:papers:renamed file(s): 1

I also made those arguments installable, so the user can run papers install --nameformat Author,year,-,Title --nauthor 1 --ntitle 1 to make them default.

This, if merged, closes #16.

malfatti avatar Apr 28 '20 00:04 malfatti

Thanks for all the work. I am slowly coming back to github and papers. Let me some more time to review the project and your changes, before merging.

perrette avatar Mar 10 '21 15:03 perrette

Hey @perrette !

Sorry for the slow feedback, I finally got some time to work on this.

I fixed the variable case and updated a bit the autoname functions to remove some set of characters that were getting my files into trouble.

I completely agree with your first comment, but I didn't get where should I apply such changes. Could you point me to the lines where I should improve string formatting?

By the way, in my local version I implemented a (still simple) tagging mechanism, so that you can:

$ papers add --info --rename --tags Auditory,Humans,Tinnitus,Etiology ~/Downloads/[email protected]

$ cat PapersBib.bib  # note the 'tags' line
[...]
@article{zagolski2014tinnitus,
 author = {Olaf Zag{\'{o}}lski and Pawe{\l} Strek},
 doi = {10.3109/14992027.2014.893377},
 file = {:/Documents/Papers/ZagOLskiAndStrKEK2014-TinnitusPitchAndMinimumMaskingLevelsInDifferentEtiologies.pdf:pdf},
 journal = {International Journal of Audiology},
 month = {mar},
 number = {7},
 pages = {482--489},
 publisher = {Informa {UK} Limited},
 tags = {Auditory,Humans,Tinnitus,Etiology},
 title = {Tinnitus pitch and minimum masking levels in different etiologies},
 url = {https://doi.org/10.3109%2F14992027.2014.893377},
 volume = {53},
 year = {2014}
}
[...]

for example. Would you be interested in this feature? If so, I'll open a separate pull request.

Cheers!

malfatti avatar Aug 05 '21 08:08 malfatti

Will it be merged? Tags are awesome!

VolkovIlia avatar Nov 13 '21 16:11 VolkovIlia

Yes this is definitely a useful feature and we can thank T. Malfatti for making a suggestion. As I looked into it I was unsure about the interface (keywords naming, options) and didn't want to put something in that I'd modify later. Good you remind me though, I'll dive into it again asap, it has only waited for too long already. Il 13 nov 2021, 17:52 +0100, Ilia Volkov @.***>, ha scritto:

Will it be merged? Tags are awesome! —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

perrette avatar Nov 14 '21 09:11 perrette

Any updates?))

Sorry for annoying asking comments, I am trying to integrate "papers" to my PhD workflow and this feature is very useful for sorting huge amount of articles. As a reason of my PhD is around chemistry and I am terrible coder. I'd love to help to contribute this feature by myself but can't (((

VolkovIlia avatar Dec 27 '21 10:12 VolkovIlia

Any news?))0

VolkovIlia avatar Feb 20 '22 21:02 VolkovIlia

Hey,

Since these changes can help others, instead of keeping them only local, I merged your dev branch with mine and pushed everything to the Dev branch in my fork :)

@VolkovIlia If you want to give it a try you can:

$ git clone https://github.com/malfatti/papers/ -b Dev
$ cd papers
$ pip install --user .

malfatti avatar Jun 13 '22 18:06 malfatti

Thanks @malfatti

perrette avatar Jun 14 '22 07:06 perrette

Hi @malfatti, I was about to merge your pull request (and put aside my secondary concerns for now -- as I have no time to look into that anyway), but the CI fails on add_attachment. Looking at the logs makes me think that's because you changed the default naming convention and papers are not regrouped by year any more, is that correct?

perrette avatar Jun 14 '22 12:06 perrette

Hey,

That is weird, because I actually did not change the default (see papers/bib.py line 420):

    def rename_entry_files(self, e, copy=False, nameformat='year,/,ID')

I added the nameformat argument, but the default value is such that the pdf should be at 2013/perrete_2013.pdf ( perrete_2013 being whatever the ID becomes according to the config file). Therefore, dirmains[-2] should be self.year :/

Now that I think of it, this test line will fail for any config that does not use a name format that have pdfs organized in year subfolders (dirmains[-2] would then likely ever be self.year).

malfatti avatar Jun 16 '22 17:06 malfatti