GitHub PullRequestReviewCommentEvent at 2014-02-05 13:24:23
Repository: balaio
Actor: gustavofonseca
Payload: {"comment":{"url":"https://api.github.com/repos/scieloorg/balaio/pulls/comments/9460159","id":9460159,"diff_hunk":"@@ -0,0 +1,175 @@\n+#coding: utf-8\n+import time\n+from datetime import datetime\n+from StringIO import StringIO\n+from multiprocessing.dummy import Pool as ThreadPool\n+\n+import transaction\n+import scieloapi\n+\n+import utils\n+import models\n+import meta_extractor\n+from checkin import PackageAnalyzer\n+from uploader import StaticScieloBackend\n+\n+\n+FILES_EXTENSION = ['xml', 'pdf',]\n+IMAGES_EXTENSION = ['tif', 'eps']\n+NAME_ZIP_FILE = 'images.zip'\n+STATIC_PATH = 'articles'\n+\n+\n+class CheckoutList(list):\n+    \"\"\"\n+    Child class adapted to have a specific behavior in append method.\n+    \"\"\"\n+\n+    def append(self, item):\n+        \"\"\"\n+        Add the param item on a parent list if is a expected type\n+\n+        :param item: Any Attempt like object\n+        \"\"\"\n+        if isinstance(item, models.Attempt):\n+            item.queued_checkout=True\n+\n+        super(CheckoutList, self).append(item)\n+\n+\n+def get_static(attempt, ext):\n+    \"\"\"\n+    Get the static files from the zip file\n+    Return a generator to a specific extension\n+    \"\"\"\n+\n+    pkg_analyzer = PackageAnalyzer(attempt.filepath)\n+\n+    return pkg_analyzer.get_fps(ext)\n+\n+\n+def upload_static_files(attempt, conn_static):\n+    \"\"\"\n+    Send the ``PDF``, ``XML`` files to the static server\n+\n+    :param attempt: Attempt object\n+    :param cfg: cfguration file\n+    \"\"\"\n+    uri_dict = {}\n+    dict_img = {}\n+\n+    with conn_static as static:\n+\n+        for ext in FILES_EXTENSION:\n+            for stc in get_static(attempt, ext):\n+                uri = static.send(StringIO(stc.read()),\n+                                  utils.get_static_path(STATIC_PATH,\n+                                            attempt.articlepkg.aid, stc.name))\n+                uri_dict[ext] = uri\n+\n+        for ext in IMAGES_EXTENSION:\n+            for stc in get_static(attempt, ext):\n+                dict_img[stc.name] = stc.read()","path":"balaio/checkout.py","position":72,"original_position":72,"commit_id":"6c3cb23adbc3b795d65aeabde6821fc0065e028d","original_commit_id":"6c3cb23adbc3b795d65aeabde6821fc0065e028d","user":{"login":"gustavofonseca","id":161335,"avatar_url":"https://gravatar.com/avatar/8b09d1fd6b426a5873362967360612cb?d=https%3A%2F%2Fidenticons.github.com%2F6cf4f7603131fbcfe3d668fed3c6f4f3.png&r=x","gravatar_id":"8b09d1fd6b426a5873362967360612cb","url":"https://api.github.com/users/gustavofonseca","html_url":"https://github.com/gustavofonseca","followers_url":"https://api.github.com/users/gustavofonseca/followers","following_url":"https://api.github.com/users/gustavofonseca/following{/other_user}","gists_url":"https://api.github.com/users/gustavofonseca/gists{/gist_id}","starred_url":"https://api.github.com/users/gustavofonseca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gustavofonseca/subscriptions","organizations_url":"https://api.github.com/users/gustavofonseca/orgs","repos_url":"https://api.github.com/users/gustavofonseca/repos","events_url":"https://api.github.com/users/gustavofonseca/events{/privacy}","received_events_url":"https://api.github.com/users/gustavofonseca/received_events","type":"User","site_admin":false},"body":"O consumo de memória de `dict_img` é potencialmente alto. E se `utils.zip_files` fosse o encarregado de carregar os bytes?","created_at":"2014-02-05T13:24:23Z","updated_at":"2014-02-05T13:24:23Z","html_url":"https://github.com/scieloorg/balaio/pull/222#discussion_r9460159","pull_request_url":"https://api.github.com/repos/scieloorg/balaio/pulls/222","_links":{"self":{"href":"https://api.github.com/repos/scieloorg/balaio/pulls/comments/9460159"},"html":{"href":"https://github.com/scieloorg/balaio/pull/222#discussion_r9460159"},"pull_request":{"href":"https://api.github.com/repos/scieloorg/balaio/pulls/222"}}}}