Skip to content

Commit 7683625

Browse files
committed
Add dynamic meetup info
1 parent 5400b7a commit 7683625

File tree

5 files changed

+199
-10
lines changed

5 files changed

+199
-10
lines changed

Pipfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
utah = {editable = true, path = "."}
8+
meetup-api = "*"
9+
10+
[dev-packages]
11+
pytest = "*"
12+
13+
[requires]
14+
python_version = "3.6"

Pipfile.lock

+131
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@
33
This module is used as an example package for the Sept 2018 meetup,
44
and also used as an example on slcpy.com.
55

6+
# Standard Installation
7+
8+
- `pip install utah`
9+
- Set your `MEETUP_API_KEY` value: `$export MEETUP_API_KEY=api_key_value`, located at [meetup.com](https://secure.meetup.com/meetup_api/key/).
10+
- Test with `from utah import slcpython; slcpython.howdy()` in a python interpreter. You should see details of the next meetup.
11+
12+
# Dev Installation
13+
14+
- Install `pipenv`: `python3 -m pip install pipenv`.
15+
- Install the pipenv requirements: `pipenv sync --dev'
16+
- After hacking, use `pipenv install -e .`
17+
- For testing use: `python -m pytest`
18+
19+
620
## TODO
721

822
- [x] Add tests
9-
- [ ] Integrate meetup api to find latest meetups.
23+
- [x] Integrate `meetup api` to find latest meetups.
1024
- [ ] Research if public api exists.
1125
- [ ] Figure out friendly auth flow for API key.
26+
- [ ] Use rst for README

setup.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def readme():
88

99
setup(
1010
name='utah',
11-
version='0.2',
11+
version='0.9',
1212
description='The official module for Utah Python / SLCPython',
1313
long_description=readme(),
1414
classifiers=[
@@ -21,7 +21,10 @@ def readme():
2121
author_email='[email protected]',
2222
license='MIT',
2323
packages=['utah'],
24+
install_requires=[
25+
'meetup-api'
26+
],
2427
zip_safe=False,
2528
test_suite='nose.collector',
26-
test_require=['nose']
29+
test_require=['pytest', 'pipenv']
2730
)

utah/slcpython/__init__.py

+33-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1+
import os
2+
from datetime import datetime
3+
4+
import meetup.api
5+
from meetup.exceptions import ApiKeyError
6+
7+
8+
def get_group_next_event(urlname='slcpython'):
9+
# TODO: convert to async def
10+
api_key = os.environ['MEETUP_API_KEY']
11+
client = meetup.api.Client()
12+
group_info = client.GetGroup({'urlname': urlname})
13+
return group_info.next_event
14+
15+
116
def howdy():
2-
msg = """
3-
Howdy, Salt Lake City!
4-
"Our next meetup is on:"
5-
"Wednesday, September 5th, at 6:30 p.m."
6-
"and is about:"
7-
"A trio of python talks: Beginning / Intermediate / Advanced"
8-
"""
17+
try:
18+
next_event_info = get_group_next_event()
19+
next_datetime = datetime.fromtimestamp(
20+
next_event_info['time'] / 1000.0)
21+
datefmt = r'%A, %B %-d'
22+
timefmt = r'%-I:%M%p'
23+
time_msg = f"{next_datetime.strftime(datefmt)}, at {next_datetime.strftime(timefmt).lower()}"
24+
25+
msg = f"""
26+
Howdy, Salt Lake City! 🤠
27+
"Our next meetup is on:"
28+
"{time_msg}"
29+
"and is about:"
30+
"{next_event_info['name']}"
31+
"""
32+
except ApiKeyError:
33+
print('Meetup API key not set')
34+
935
print(msg)

0 commit comments

Comments
 (0)