Browse Source

include patches

master v3.0.2
Tobias Brunner 2 months ago
parent
commit
bd3a00c2d9
  1. 6
      Dockerfile
  2. 21
      hack/patches/mechsoup-link-regex.patch
  3. 2
      pylokid/__init__.py
  4. 2
      pyproject.toml

6
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

21
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):

2
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"

2
pyproject.toml

@ -1,6 +1,6 @@
[tool.poetry]
name = "pylokid"
version = "3.0.1"
version = "3.0.2"
description = ""
authors = ["Tobias Brunner <tobias@tobru.ch>"]
license = "MIT"

Loading…
Cancel
Save