forked from CMS/memberPlumbing
upcomingEvents: Use pyclip to copy the result to clipboard
This commit is contained in:
parent
981cb12aa6
commit
9cf12b1bdd
@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from datetime import datetime
|
||||
import sys
|
||||
|
||||
import pyclip
|
||||
|
||||
from .config import Config
|
||||
|
||||
@ -45,7 +48,7 @@ def format_section(title: str, blurb: str, events, truncate: bool):
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
def generate_post():
|
||||
config = Config()
|
||||
now = datetime.now()
|
||||
|
||||
@ -98,32 +101,36 @@ def main():
|
||||
</div>
|
||||
"""
|
||||
|
||||
print(header)
|
||||
print(
|
||||
format_section(
|
||||
"Upcoming Events",
|
||||
"Events that are currently open for registration.",
|
||||
upcoming_events,
|
||||
truncate=False,
|
||||
)
|
||||
yield header
|
||||
yield format_section(
|
||||
"Upcoming Events",
|
||||
"Events that are currently open for registration.",
|
||||
upcoming_events,
|
||||
truncate=False,
|
||||
)
|
||||
print(
|
||||
format_section(
|
||||
"Just Missed",
|
||||
"These classes are currently full at time of writing. If you are interested, please check the event's page; spots occasionally open up. Keep an eye on this newsletter to see when these classes are offered again.",
|
||||
full_events,
|
||||
truncate=True,
|
||||
)
|
||||
|
||||
yield format_section(
|
||||
"Just Missed",
|
||||
"These classes are currently full at time of writing. If you are interested, please check the event's page; spots occasionally open up. Keep an eye on this newsletter to see when these classes are offered again.",
|
||||
full_events,
|
||||
truncate=True,
|
||||
)
|
||||
print(
|
||||
format_section(
|
||||
"Ongoing",
|
||||
"These classes are ongoing. Registration is closed, but they may be offered again in the future.",
|
||||
ongoing_events,
|
||||
truncate=True,
|
||||
)
|
||||
|
||||
yield format_section(
|
||||
"Ongoing",
|
||||
"These classes are ongoing. Registration is closed, but they may be offered again in the future.",
|
||||
ongoing_events,
|
||||
truncate=True,
|
||||
)
|
||||
print(footer)
|
||||
|
||||
yield (footer)
|
||||
|
||||
|
||||
def main():
|
||||
result = "\n".join(generate_post())
|
||||
print(result)
|
||||
pyclip.copy(result)
|
||||
print("Copied to clipboard!", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
36
poetry.lock
generated
36
poetry.lock
generated
@ -724,6 +724,21 @@ files = [
|
||||
{file = "mysqlclient-2.1.1.tar.gz", hash = "sha256:828757e419fb11dd6c5ed2576ec92c3efaa93a0f7c39e263586d1ee779c3d782"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pasteboard"
|
||||
version = "0.3.3"
|
||||
description = "Pasteboard - Python interface for reading from NSPasteboard (macOS clipboard)"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6,<4.0"
|
||||
files = [
|
||||
{file = "pasteboard-0.3.3-cp36-cp36m-macosx_10_15_x86_64.whl", hash = "sha256:afd171e200316f6b3d3da381476921ca57cb8f26d2fa418f779454913918dbb9"},
|
||||
{file = "pasteboard-0.3.3-cp37-cp37m-macosx_10_15_x86_64.whl", hash = "sha256:f99dd6c7039b755756b2068942c4c2487d6366e5a56eafd6db0ae7aa2a371a0e"},
|
||||
{file = "pasteboard-0.3.3-cp38-cp38-macosx_10_15_x86_64.whl", hash = "sha256:19229dfa28f41afb5e731ac81e52bbc4212f67d678c082d3e3621cec0628a773"},
|
||||
{file = "pasteboard-0.3.3-cp39-cp39-macosx_10_15_x86_64.whl", hash = "sha256:20a5c53bae8ac8186ecdd621020fb1b072d45a35f9f11a8e4cd5e82d76b485d0"},
|
||||
{file = "pasteboard-0.3.3.tar.gz", hash = "sha256:d80275e76ff1eaaa5ca3d0e0fd8aecd5ea1298523dfd51f3774b5aaebdde02cf"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pathspec"
|
||||
version = "0.11.1"
|
||||
@ -766,6 +781,25 @@ typing-extensions = {version = ">=4.5", markers = "python_version < \"3.8\""}
|
||||
docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"]
|
||||
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"]
|
||||
|
||||
[[package]]
|
||||
name = "pyclip"
|
||||
version = "0.7.0"
|
||||
description = "Cross-platform clipboard utilities supporting both binary and text data."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "pyclip-0.7.0-py3-none-any.whl", hash = "sha256:a7b7ea2cfad2dd61e86a529af588d006070d3eb0bd32981afaee5215f4604fec"},
|
||||
{file = "pyclip-0.7.0.tar.gz", hash = "sha256:57602047a4ceab709bdcd42f3dde6449a3349b95c16154cfdce27376a2072491"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
pasteboard = {version = "0.3.3", markers = "platform_system == \"Darwin\""}
|
||||
pywin32 = {version = ">=1.0", markers = "platform_system == \"Windows\""}
|
||||
|
||||
[package.extras]
|
||||
test = ["pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "pywin32"
|
||||
version = "227"
|
||||
@ -1095,4 +1129,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "ad657c4c736847ce55f3049ce04eb4a8c502914e083004842ae1f4091dd44c66"
|
||||
content-hash = "5411556fafd7ccd3542124c1efeddecd7dcd00927c0e04d9f558c3a6862a1cb3"
|
||||
|
@ -23,6 +23,7 @@ lxml = "^4.5.0"
|
||||
peewee = "^3.13.2"
|
||||
mysqlclient = "^2.1.0"
|
||||
udm-rest-client = "^1.0.6"
|
||||
pyclip = "^0.7.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = "^22.3.0"
|
||||
|
Loading…
Reference in New Issue
Block a user