Flake8 on the script
@@ -4,11 +4,13 @@ import os
import requests
-PRICES_URL = "https://azure.microsoft.com/api/v3/pricing/virtual-machines/calculator/"
+PRICES_URL = ("https://azure.microsoft.com/api/v3/pricing/"
+ "virtual-machines/calculator/")
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
PRICING_FILE_PATH = os.path.join(BASE_PATH, '../libcloud/data/pricing.json')
PRICING_FILE_PATH = os.path.abspath(PRICING_FILE_PATH)
+
def get_azure_prices():
prices_raw = requests.get(PRICES_URL).json()
regions = []
@@ -17,7 +19,6 @@ def get_azure_prices():
result = {"windows": {}, "linux": {}}
parsed_sizes = {"lowpriority", "basic", "standard"}
- x=0
for offer, value in prices_raw['offers'].items():
size_raw = offer.split("-")
@@ -32,11 +33,11 @@ def get_azure_prices():
continue
for region, price in value['prices']['perhour'].items():
prices[region] = price['value']
- x+=1
result[size_raw[0]][size] = prices
return result
+
def write_azure_prices(file_path, prices):
with open(file_path, 'r') as f:
content = f.read()
@@ -53,9 +54,12 @@ def write_azure_prices(file_path, prices):
with open(file_path, 'w') as fp:
fp.write(content)
+
+
def main():
res = get_azure_prices()
write_azure_prices(PRICING_FILE_PATH, res)
+
if __name__ == "__main__":
main()
