diff options
author | Alejandro Gallo <aamsgallo@gmail.com> | 2021-12-23 20:08:04 +0100 |
---|---|---|
committer | Alejandro Gallo <aamsgallo@gmail.com> | 2021-12-23 20:08:04 +0100 |
commit | 9e124a87e1cbf1569496b492e9a661ab1c5f800b (patch) | |
tree | 4e3d3242aa45bb6ecafbb8c298ee34d90f268c03 | |
parent | fb7e1079a9b90d3cee20de6846c56a519368fe94 (diff) | |
parent | c81b5512fa0a594e9490a0a3885fe4480fd4990f (diff) |
Merge branch 'master' into webappwebapp
91 files changed, 4216 insertions, 749 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a41feed1..aed1406b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 @@ -1,25 +1,35 @@ -1933 Alejandro Gallo <aamsgallo@gmail.com> +2018 Alejandro Gallo <aamsgallo@gmail.com> 38 Nicolò Balzarotti <anothersms@gmail.com> 16 michaelplews <michael.plews@gmail.com> 13 Jackson Woodruff <woodruff.jackson@gmail.com> +10 Alex Fikl <alexfikl@gmail.com> 10 Matthieu Coudron <mattator@gmail.com> 10 Michael R. Plews <michael.plews@gmail.com> 9 Matthieu Coudron <coudron@iij.ad.jp> 9 alejandrogallo <alejandrogallo@users.noreply.github.com> -6 Alexander Von Moll <avonmoll@gmail.com> +7 Alexander Von Moll <avonmoll@gmail.com> 6 Alexandru Fikl <alexfikl@gmail.com> -5 Alex Fikl <alexfikl@gmail.com> 2 JP-Ellis <josh@jpellis.me> 2 Katrin Leinweber <9948149+katrinleinweber@users.noreply.github.com> 2 Michael Plews <michael.plews@gmail.com> +2 sebastien.popoff@espci.fr <sebastien.popoff@espci.fr> 1 Andrew <axr8451@rit.edu> +1 Andrey Akinshin <andrey.akinshin@gmail.com> 1 CosmosAtlas <zhuwenhan950913@gmail.com> 1 Dennis Bruggner <dennis@bruggner.net> 1 Felix Hummel <felix.hummel@tuwien.ac.at> 1 Fritzkefit <e1125349@student.tuwien.ac.at> +1 Henning Timm <henning.timm@tu-dortmund.de> +1 Henrik Grimler <henrik@grimler.se> +1 Michael McMahon <michael@gnu.org> 1 Oliver Lantwin <oliver.lantwin@cern.ch> +1 Sébastien M. P <sebastien.popoff@espci.fr> 1 Theo Tsatsoulis <T.Tsatsoulis@fkf.mpg.de> 1 Theodoros Tsatsoulis <T.Tsatsoulis@fkf.mpg.de> 1 Theodoros Tsatsoulis <tsatsoulis.thodoris@gmail.com> 1 Zach Langley <zblangley@gmail.com> +1 ccat3z <c0ldcat3z@gmail.com> +1 d70-t <tobi@die70.de> +1 jghauser <julian@julianhauser.com> 1 mftrhu <mftrhu+github@inventati.org> +1 prataffel <24615963+prataffel@users.noreply.github.com> diff --git a/CHANGELOG.md b/CHANGELOG.md index af5132f0..745c1be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,14 @@ use emacs-like hooks for some commands. - Add command `exec` to run python scripts in the environment of the papis executable. +## papis picker +- You can now pick several elements with the key binding `c-t` + +## `papis merge` +- Add the command `papis merge` to merge documents in pairs. + +## `papis browse` +- Add `-n` and `--print` to just print the url to be opened. VERSION v0.11 ============= diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 48d71a36..7db00182 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -51,7 +51,7 @@ the documents in ``firefox``, for some reason, the you would write Here we wrote also the special section ``[settings]``, which sets global settings that are valid in all libraries. Of course, every setting set -within ``[settings]`` can be overriden by any library through the mechanism +within ``[settings]`` can be overridden by any library through the mechanism previously discussed. A more complete example of a configuration file is the following @@ -159,8 +159,8 @@ configuration file. An example of a project using a local configuration file can be seen `here <https://github.com/alejandrogallo/datasheets/blob/master/.papis.config/>`_ , where the repository includes documents for component datasheets -and everytime ``papis`` is using that library the ``.papis.config`` -file is also read and some settings will be getting overriden. +and every time ``papis`` is using that library the ``.papis.config`` +file is also read and some settings will be getting overridden. Python configuration file ------------------------- diff --git a/doc/source/default-settings.rst b/doc/source/default-settings.rst index e09afffa..b614c39b 100644 --- a/doc/source/default-settings.rst +++ b/doc/source/default-settings.rst @@ -123,7 +123,7 @@ Tools options As for now papis is not intended to detect the type of document to be opened and decide upon how to open the document. You should set this to the right program for the tool. If you are on linux you might want - to take a look at `ranger <http://ranger.nongnu.org>`_ or let + to take a look at `ranger <http://ranger.github.io>`_ or let the default handle it in your system. For mac users you might set this to ``open``. @@ -252,7 +252,7 @@ Bibtex options .. note:: Special characters will be replaced when generating the ``ref`` entry (e.g. ``Ö → O``, ``.`` and other symbols will be striped from the - string). + string). If you want to add some punctuation, dots (``.``) and underscores (``_``) can be escaped by a backslash. For example, @@ -269,7 +269,7 @@ Bibtex options If set to ``True``, every time you run ``papis add`` the flag ``--confirm`` will be added automatically. If is set to ``True`` and you add it, i.e., you run ``papis add --confirm``, then it will - fave the contrary effect, i.e., it will not ask for confirmation. + have the contrary effect, i.e., it will not ask for confirmation. .. papis-config:: add-folder-name :default: empty string @@ -290,7 +290,7 @@ Bibtex options If set to ``True``, every time you run ``papis add`` the flag ``--interactive`` will be added automatically. If is set to ``True`` and you add it, i.e., you run ``papis add --interactive``, then it - will fave the contrary effect, i.e., it will not run in interactive mode. + will have the contrary effect, i.e., it will not run in interactive mode. .. papis-config:: add-edit @@ -583,6 +583,9 @@ or inside the library sections prepending a ``tui-``, .. papis-config:: go_bottom_key :section: tui +.. papis-config:: mark_key + :section: tui + FZF integration --------------- @@ -603,9 +606,9 @@ In comparison to the *built-in* papis tui the advantage of the fzf picker is that it is much faster, however a disadvantage is that it is restricted to one-line entries. Also it is important to notice that ``fzf`` will **only** -match against what is shown on the terminal screen, as oposed to the papis -matcher, that can match agains the **whole** title and **whole** author -text since this is controled by the ``match-format`` setting. +match against what is shown on the terminal screen, as opposed to the papis +matcher, that can match against the **whole** title and **whole** author +text since this is controlled by the ``match-format`` setting. However, for many uses it might not bother the user to have this limitation of fzf. @@ -615,7 +618,7 @@ of fzf. .. papis-config:: fzf-extra-flags - Extra flags to be passed to fzf everytime it gets called. + Extra flags to be passed to fzf every time it gets called. .. papis-config:: fzf-extra-bindings @@ -655,7 +658,7 @@ The following configuration fzf-extra-flags = ["--ansi", "--multi", "-i", "--preview", "echo {} | sed -r 's/~~/\\n/g; /^ *$/d' ", - "--preview-window", "bottom:wrap:20%", + "--preview-window", "bottom:wrap:20%%", "--color", "preview-fg:#F6E6E4,preview-bg:#5B6D5B"] fzf-extra-bindings = ["ctrl-s:jump", @@ -666,7 +669,10 @@ The following configuration will have unrestricted titles, author, journal etc fields against which the query will match and it will show in the ``fzf`` preview window a tidy description of the currently selected field by replacing the token ``~~`` by a newline. You can try this out and play with ``fzf`` customizations. - +Please note that ``bottom:wrap:20%%`` has two ``%`` since the config file +interpolator uses ``%`` as a reserved symbol, so it must be escaped +by writing two of them. + Other ----- @@ -716,13 +722,13 @@ Other .. papis-config:: time-stamp - Wether or not to add a timestamp to a document when is being added to + Whether or not to add a timestamp to a document when is being added to papis. If documents have a timestamp, then they will be sortable using `--sort time-added` option. .. papis-config:: formater - The formating language in python can be configured through plugins. + The formatting language in python can be configured through plugins. .. autoclass:: papis.format.PythonFormater diff --git a/doc/source/faq.rst b/doc/source/faq.rst index 50967143..8e98ec3e 100644 --- a/doc/source/faq.rst +++ b/doc/source/faq.rst @@ -16,4 +16,4 @@ Here are some problems that users have come across often: For more information you can also check the -`github faq <https://github.com/papis/papis/issues?utf8=%E2%9C%93&q=faq>`_ link. +`github faq <https://github.com/papis/papis/issues?utf8=%E2%9C%93&q=label:faq>`_ link. diff --git a/doc/source/git.rst b/doc/source/git.rst index 1d9f6bf7..4364c1a5 100644 --- a/doc/source/git.rst +++ b/doc/source/git.rst @@ -50,8 +50,8 @@ You can imagine that papis commands like ``rename`` and ``mv`` should also offer such functionality, and they indeed do through the ``--git`` flag. Go to their documentation for more information. -Updating the libray -------------------- +Updating the library +-------------------- You can use papis' simple ``git`` wrapper, diff --git a/doc/source/install.rst b/doc/source/install.rst index 05af6056..66ba91d5 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -78,10 +78,10 @@ First of all you have to get the code, open a terminal and hit :: - git clone https://github.com/alejandrogallo/papis.git + git clone https://github.com/papis/papis.git or download the -`zip file <https://github.com/alejandrogallo/papis/archive/master.zip>`_. +`zip file <https://github.com/papis/papis/archive/master.zip>`_. Go inside of the ``papis`` source folder and you can either use the ``Makefile`` diff --git a/papis/__init__.py b/papis/__init__.py index afa983c3..74b1e9f5 100644 --- a/papis/__init__.py +++ b/papis/__init__.py @@ -10,11 +10,11 @@ __email__ = 'aamsgallo@gmail.com' if os.environ.get('PAPIS_DEBUG'): import logging log_format = ( - '%(relativeCreated)d-' + - '%(levelname)s' + - ':' + - '%(name)s' + - ':' + - '%(message)s' + '%(relativeCreated)d-' + + '%(levelname)s' + + ':' + + '%(name)s' + + ':' + + '%(message)s' ) logging.basicConfig(format=log_format, level=logging.DEBUG) diff --git a/papis/api.py b/papis/api.py index b02ba62d..6e5a0c00 100644 --- a/papis/api.py +++ b/papis/api.py @@ -10,8 +10,7 @@ import papis.config import papis.pick import papis.database -LOGGER = logging.getLogger("api") -LOGGER.debug("importing") +logger = logging.getLogger("api") def get_lib_name() -> str: diff --git a/papis/arxiv.py b/papis/arxiv.py index 3b442472..88cbf1b3 100644 --- a/papis/arxiv.py +++ b/papis/arxiv.py @@ -17,14 +17,10 @@ """ import os import re -import bs4 import logging -import urllib.request # urlopen, Request -import urllib.parse # import urlencode from typing import Optional, List, Dict, Any import click -import arxiv2bib import papis.filetype import papis.downloaders.base @@ -63,7 +59,9 @@ def get_data( search_query = '+AND+'.join( [key+':'+str(clean_params[key]) for key in clean_params] ) - logger.debug("query = " + search_query) + logger.debug("query = '%s'", search_query) + + import urllib.parse params = urllib.parse.urlencode( { 'search_query': search_query, @@ -73,7 +71,9 @@ def get_data( ) main_url = "http://arxiv.org/api/query?" req_url = main_url + params - logger.debug("url = " + req_url) + logger.debug("url = '%s'", req_url) + + import urllib.request url = urllib.request.Request( req_url, headers={ @@ -81,6 +81,8 @@ def get_data( } ) xmldoc = urllib.request.urlopen(url).read() + + import bs4 soup = bs4.BeautifulSoup(xmldoc, 'html.parser') entries = soup.find_all("entry") @@ -107,10 +109,11 @@ def get_data( def validate_arxivid(arxivid: str) -> None: - from urllib.error import HTTPError, URLError + import urllib.request url = "https://arxiv.org/abs/{0}".format(arxivid) request = urllib.request.Request(url) + from urllib.error import HTTPError, URLError try: urllib.request.urlopen(request) except HTTPError: @@ -208,6 +211,7 @@ def explorer( """ logger = logging.getLogger('explore:arxiv') logger.info('Looking up...') + data = get_data( query=query, author=author, @@ -222,6 +226,7 @@ def explorer( max_results=max) docs = [papis.document.from_data(data=d) for d in data] ctx.obj['documents'] += docs + logger.info('%s documents found', len(docs)) @@ -258,18 +263,21 @@ class Downloader(papis.downloaders.Downloader): bib_url = self.get_bibtex_url() if not bib_url: return None + + import arxiv2bib bibtex_cli = arxiv2bib.Cli([bib_url]) bibtex_cli.run() - self.logger.debug("[bibtex url] = %s" % bib_url) + + self.logger.debug("bibtex_url = '%s'", bib_url) output = bibtex_cli.output # List[str] data = ''.join(output).replace('\n', ' ') self.bibtex_data = data def get_document_url(self) -> Optional[str]: arxivid = self._get_identifier() - self.logger.debug("arxivid %s" % arxivid) + self.logger.debug("arxivid = '%s'", arxivid) pdf_url = "https://arxiv.org/pdf/{arxivid}.pdf".format(arxivid=arxivid) - self.logger.debug("[pdf url] = %s" % pdf_url) + self.logger.debug("pdf_url = '%s'", pdf_url) return pdf_url @@ -306,22 +314,21 @@ class ArxividFromPdfImporter(papis.importer.Importer): @classmethod def match(cls, uri: str) -> Optional[papis.importer.Importer]: - if (os.path.isdir(uri) or not os.path.exists(uri) or - not papis.filetype.get_document_extension(uri) == 'pdf'): + if (os.path.isdir(uri) or not os.path.exists(uri) + or not papis.filetype.get_document_extension(uri) == 'pdf'): return None importer = ArxividFromPdfImporter(uri=uri) importer.arxivid = pdf_to_arxivid(uri, maxlines=2000) return importer if importer.arxivid else None def fetch(self) -> None: - self.logger.info( - "trying to parse arxivid from file {0}".format(self.uri)) + self.logger.info("Trying to parse arxivid from file '%s'", self.uri) if not self.arxivid: self.arxivid = pdf_to_arxivid(self.uri, maxlines=2000) if self.arxivid: - self.logger.info("Parsed arxivid {0}".format(self.arxivid)) + self.logger.info("Parsed arxivid '%s'", self.arxivid) self.logger.warning( - "There is no guarantee that this arxivid is the one") + |