Refactor product releases writing
Create a common function to write resulting JSON files to the releases directory. It makes this task simpler to read and maintain, while making it modifiable at a central point in the future. One example of such modification could be the sorting of the versions in a uniform way for all the scripts.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import frontmatter
|
||||
import urllib.request
|
||||
|
||||
from glob import glob
|
||||
from os import path
|
||||
|
||||
@@ -47,3 +47,8 @@ def fetch_url(url, retry_count=2, timeout=5, data=None, headers=None, encoding='
|
||||
continue
|
||||
|
||||
raise last_exception
|
||||
|
||||
|
||||
def write_releases(product, releases, pathname="releases"):
|
||||
with open(f"{pathname}/{product}.json", "w") as f:
|
||||
f.write(json.dumps(releases, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user