1
1
"""Takes Issues Filed in the last week and puts them in a file for the upcoming stream"""
2
2
import os
3
- from venv import create
4
- import httpx
5
- from datetime import datetime , timedelta
6
3
import pathlib
7
- from jinja2 import FileSystemLoader , Environment
4
+ from datetime import datetime , timedelta
5
+
6
+ import httpx
7
+ from jinja2 import Environment , FileSystemLoader
8
+
8
9
# Get the date of the next friday
9
10
10
- api_key : str = os .environ .get (' GITHUB_API_KEY' , None )
11
+ api_key : str = os .environ .get (" GITHUB_API_KEY" , None )
11
12
12
13
loader = FileSystemLoader ("./app/templates" )
13
14
environment = Environment (loader = loader )
14
15
16
+
15
17
def get_last_friday ():
16
18
"""Returns the previous friday"""
17
19
upcoming_friday = datetime .today () - timedelta (4 - datetime .today ().weekday ())
18
20
last_friday = upcoming_friday - timedelta (days = 7 )
19
21
return last_friday .isoformat ()
20
-
22
+
23
+
21
24
def get_issues_from_github ():
22
25
"""Returns the issues filed in the last week"""
23
- url = ' https://api.github.com/repos/kjaymiller/Python-Community-News/issues'
26
+ url = " https://api.github.com/repos/kjaymiller/Python-Community-News/issues"
24
27
since_date = get_last_friday ()
25
- params = {
26
- "query" : "label=Content" ,
27
- "since" : since_date
28
- }
28
+ params = {"labels" : "Content" , "since" : since_date }
29
29
request = httpx .get (url , params = params )
30
30
return request .json ()
31
31
32
+
32
33
def create_post_for_week ():
33
34
"""Creates a markdown document for this week for render_engine to process"""
34
- friday = (datetime .today () - timedelta (4 - datetime .today ().weekday ())).strftime ("%Y-%m-%d" )
35
- current_week = pathlib .Path ('app/content' ).joinpath (friday ).with_suffix ('.md' )
35
+ friday = (datetime .today () - timedelta (4 - datetime .today ().weekday ())).strftime (
36
+ "%Y-%m-%d"
37
+ )
38
+ current_week = pathlib .Path ("app/content" ).joinpath (friday ).with_suffix (".md" )
36
39
issues = get_issues_from_github ()
37
40
template = environment .get_template ("content_gen/episode_template.md" )
38
41
return current_week .write_text (template .render (issues = issues , date = friday ))
39
42
43
+
40
44
if __name__ == "__main__" :
41
- print (create_post_for_week ())
45
+ print (create_post_for_week ())
0 commit comments