From bd3a00c2d9fa31501672c436faccba3a2ce490af Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sat, 27 Feb 2021 14:37:24 +0100 Subject: [PATCH] include patches --- Dockerfile | 6 ++++-- hack/patches/mechsoup-link-regex.patch | 21 +++++++++++++++++++++ pylokid/__init__.py | 2 +- pyproject.toml | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 hack/patches/mechsoup-link-regex.patch diff --git a/Dockerfile b/Dockerfile index 8838d94..1fdf0eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,13 +39,15 @@ COPY --from=builder \ /app/dist /app/dist RUN pip install /app/dist/pylokid-*-py3-none-any.whl -COPY hack/patches/*.patch /tmp +COPY hack/patches/*.patch /tmp/ # The ugliest possible way to workaround https://github.com/MechanicalSoup/MechanicalSoup/issues/356 # For some unknown reasons Lodur now wants "Content-Type: application/pdf" set in the multipart # data section. And as I couln't figure out yet how to do that in MechanicalSoup and I only upload PDFs # I just patch it to hardcode it. YOLO -RUN patch -p0 /usr/local/lib/python3.9/site-packages/mechanicalsoup/browser.py < /tmp/mechsoup-browser-content-type.patch +RUN \ + patch -p0 /usr/local/lib/python3.9/site-packages/mechanicalsoup/browser.py < /tmp/mechsoup-browser-content-type.patch && \ + patch -p0 /usr/local/lib/python3.9/site-packages/mechanicalsoup/stateful_browser.py < /tmp/mechsoup-link-regex.patch ## ----------- Step 4 FROM base AS runtime diff --git a/hack/patches/mechsoup-link-regex.patch b/hack/patches/mechsoup-link-regex.patch new file mode 100644 index 0000000..aa6e183 --- /dev/null +++ b/hack/patches/mechsoup-link-regex.patch @@ -0,0 +1,21 @@ +--- /home/tobru/.cache/pypoetry/virtualenvs/pylokid-JpqZeVMm-py3.9/lib/python3.9/site-packages/mechanicalsoup/stateful_browser.py.orig 2021-02-27 14:21:53.979582533 +0100 ++++ /home/tobru/.cache/pypoetry/virtualenvs/pylokid-JpqZeVMm-py3.9/lib/python3.9/site-packages/mechanicalsoup/stateful_browser.py 2021-02-27 14:23:17.680374365 +0100 +@@ -259,7 +259,7 @@ + for link in self.links(*args, **kwargs): + print(" ", link) + +- def links(self, url_regex=None, link_text=None, *args, **kwargs): ++ def links(self, url_regex=None, link_text=None, link_regex=None, *args, **kwargs): + """Return links in the page, as a list of bs4.element.Tag objects. + + To return links matching specific criteria, specify ``url_regex`` +@@ -276,6 +276,9 @@ + if link_text is not None: + all_links = [a for a in all_links + if a.text == link_text] ++ if link_regex is not None: ++ all_links = [a for a in all_links ++ if re.search(link_regex, a.text)] + return all_links + + def find_link(self, *args, **kwargs): diff --git a/pylokid/__init__.py b/pylokid/__init__.py index 2ee739d..b68dbf1 100644 --- a/pylokid/__init__.py +++ b/pylokid/__init__.py @@ -2,6 +2,6 @@ Pylokid. From Mail to Lodur - all automated. """ -__version__ = "3.0.1" +__version__ = "3.0.2" __git_version__ = "0" __url__ = "https://github.com/tobru/pylokid" diff --git a/pyproject.toml b/pyproject.toml index 5e6dff4..7ca879b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pylokid" -version = "3.0.1" +version = "3.0.2" description = "" authors = ["Tobias Brunner "] license = "MIT"