This commit is contained in:
parent
888508d1c6
commit
bd3a00c2d9
|
@ -39,13 +39,15 @@ COPY --from=builder \
|
||||||
/app/dist /app/dist
|
/app/dist /app/dist
|
||||||
RUN pip install /app/dist/pylokid-*-py3-none-any.whl
|
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
|
# 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
|
# 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
|
# 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
|
# 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
|
## ----------- Step 4
|
||||||
FROM base AS runtime
|
FROM base AS runtime
|
||||||
|
|
21
hack/patches/mechsoup-link-regex.patch
Normal file
21
hack/patches/mechsoup-link-regex.patch
Normal file
|
@ -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,6 +2,6 @@
|
||||||
Pylokid. From Mail to Lodur - all automated.
|
Pylokid. From Mail to Lodur - all automated.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = "3.0.1"
|
__version__ = "3.0.2"
|
||||||
__git_version__ = "0"
|
__git_version__ = "0"
|
||||||
__url__ = "https://github.com/tobru/pylokid"
|
__url__ = "https://github.com/tobru/pylokid"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pylokid"
|
name = "pylokid"
|
||||||
version = "3.0.1"
|
version = "3.0.2"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Tobias Brunner <tobias@tobru.ch>"]
|
authors = ["Tobias Brunner <tobias@tobru.ch>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
Loading…
Reference in a new issue