Make releasedata.Product usable in 'with' expression (#294)
This way the writing of the JSON file is handled automatically if the update does not fail. It pave the way to further global improvements, such as a better error handling.
This commit is contained in:
18
src/typo3.py
18
src/typo3.py
@@ -1,13 +1,11 @@
|
||||
from common import dates, http, releasedata
|
||||
|
||||
product = releasedata.Product("typo3")
|
||||
data = http.fetch_url("https://get.typo3.org/api/v1/release/").json()
|
||||
for v in data:
|
||||
if v['type'] == 'development':
|
||||
continue
|
||||
with releasedata.ProductData("typo3") as product_data:
|
||||
data = http.fetch_url("https://get.typo3.org/api/v1/release/").json()
|
||||
for v in data:
|
||||
if v['type'] == 'development':
|
||||
continue
|
||||
|
||||
version = v["version"]
|
||||
date = dates.parse_datetime(v["date"], to_utc=False) # utc kept for now for backwards compatibility
|
||||
product.declare_version(version, date)
|
||||
|
||||
product.write()
|
||||
version = v["version"]
|
||||
date = dates.parse_datetime(v["date"], to_utc=False) # utc kept for now for backwards compatibility
|
||||
product_data.declare_version(version, date)
|
||||
|
||||
Reference in New Issue
Block a user