From 33c377c74c934dae469d5061d2b5b220ad77a5a9 Mon Sep 17 00:00:00 2001 From: Phyks Date: Thu, 15 May 2014 18:34:59 +0200 Subject: [PATCH] Better arXiv version handling in filenames + skip option --- README.md | 2 +- backend.py | 2 +- main.py | 12 +++++++++--- params.py.example | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3df527d..60e0acd 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,9 @@ Here are some sources of inspirations for this project : A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns. -30. Skip article 40. Option to automatically confirm 50. Anti-duplicate ? +55. Customization options for naming 60. Check stored versions when updating arxiv papers 65. Look for published version in arXiv 70. Export of bibtex diff --git a/backend.py b/backend.py index 2c78241..9cd12eb 100644 --- a/backend.py +++ b/backend.py @@ -39,7 +39,7 @@ def getNewName(src, bibtex, tag=''): if('archiveprefix' in bibtex and 'arXiv' in bibtex['archiveprefix']): new_name = new_name.replace("%v", - bibtex['eprint'][bibtex['eprint'].rfind('v'):]) + '-'+bibtex['eprint'][bibtex['eprint'].rfind('v'):]) else: new_name = new_name.replace("%v", '') diff --git a/main.py b/main.py index fd2f194..fcc0673 100755 --- a/main.py +++ b/main.py @@ -417,11 +417,15 @@ if __name__ == '__main__': help="disable auto-download of bibtex") parser_import.add_argument('file', nargs='+', help="path to the file to import") + parser_import.add_argument('--skip', nargs='+', + help="path to files to skip") parser_import.set_defaults(func='import') parser_delete = subparsers.add_parser('delete', help="delete help") parser_delete.add_argument('entries', metavar='entry', nargs='+', help="a filename or an identifier") + parser_delete.add_argument('--skip', nargs='+', + help="path to files to skip") group = parser_delete.add_mutually_exclusive_group() group.add_argument('--id', action="store_true", default=False, help="id based deletion") @@ -435,6 +439,8 @@ if __name__ == '__main__': parser_edit = subparsers.add_parser('edit', help="edit help") parser_edit.add_argument('entries', metavar='entry', nargs='+', help="a filename or an identifier") + parser_edit.add_argument('--skip', nargs='+', + help="path to files to skip") group = parser_edit.add_mutually_exclusive_group() group.add_argument('--id', action="store_true", default=False, help="id based deletion") @@ -479,7 +485,7 @@ if __name__ == '__main__': sys.exit() if args.func == 'import': - for filename in args.file: + for filename in list(set(args.file) - set(args.skip)): new_name = addFile(filename, args.type, args.manual) if new_name is not False: print(sys.argv[2]+" successfully imported as " + @@ -490,7 +496,7 @@ if __name__ == '__main__': sys.exit() elif args.func == 'delete': - for filename in args.entries: + for filename in list(set(args.entries) - set(args.skip)): if not args.force: confirm = tools.rawInput("Are you sure you want to " + "delete "+filename+" ? [y/N] ") @@ -507,7 +513,7 @@ if __name__ == '__main__': sys.exit() elif args.func == 'edit': - for filename in args.entries: + for filename in list(set(args.entries) - set(args.skip)): if args.file: file_id = 'file' elif args.id: diff --git a/params.py.example b/params.py.example index 6f04822..6c51b73 100644 --- a/params.py.example +++ b/params.py.example @@ -15,6 +15,6 @@ proxies = [ # %Y = published year # %t = title # %a = authors -# %v = arXiv version -format_articles = "%f_%l-%j-%Y-%v" +# %v = arXiv version (e.g. '-v1') or nothing if not an arXiv paper +format_articles = "%f_%l-%j-%Y%v" format_books = "%a-%t"