Eis-D-Z commented on code in PR #1715:
URL: https://github.com/apache/libcloud/pull/1715#discussion_r912785714


##########
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:
   Yes, this code was taken from the size scraping file. The only good thing is 
that it is enough to be downloaded once for both scripts.



-- 
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

Reply via email to