Kami commented on code in PR #1715: URL: https://github.com/apache/libcloud/pull/1715#discussion_r908894718
########## 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") Review Comment: I assume this requires us to cache whole massive JSON dictionary in memory, right? I guess it's fine and we probably already did the same before. -- 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