Kami commented on code in PR #1715: URL: https://github.com/apache/libcloud/pull/1715#discussion_r908895328
########## contrib/scrape-ec2-prices.py: ########## @@ -161,82 +48,155 @@ "extra-large", ] -RE_NUMERIC_OTHER = re.compile(r"(?:([0-9]+)|([-A-Z_a-z]+)|([^-0-9A-Z_a-z]+))") - -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 download_json(): + response = requests.get(URL, stream=True) + try: + return open(TEMPFILE, "r") + except IOError: + with open(TEMPFILE, "wb") as fo: + for chunk in response.iter_content(chunk_size=2**20): + if chunk: + fo.write(chunk) + return open(TEMPFILE, "r") + + +def get_json(): + try: + return open(TEMPFILE, "r") + except IOError: + return download_json() + + +# Prices and sizes are in different dicts and categorized by sku +def get_all_prices(): + # return variable + # prices = {sku : {price: int, unit: string}} + prices = {} + current_sku = "" + current_rate_code = "" + amazonEC2_offer_code = "JRTCKXETXF" Review Comment: What is this code used for? Just trying to understand how it works. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@libcloud.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org