{"action":"created","comment":{"url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/comments/42374661","id":42374661,"diff_hunk":"@@ -22,45 +22,42 @@\n # waive the privileges and immunities granted to it by virtue of its status\n # as an Intergovernmental Organization or submit itself to any jurisdiction.\n \n+\"\"\"Functions related to conversion and untarring.\"\"\"\n+\n+from __future__ import absolute_import, print_function, unicode_literals\n+\n import os\n import tarfile\n+import re\n \n-from invenio.utils.shell import run_shell_command, run_process_with_timeout, Timeout\n-from .output_utils import get_converted_image_name, \\\n-                                               write_message\n+from subprocess32 import check_output, TimeoutExpired\n+from wand.image import Image\n \n-def untar(original_tarball, sdir):\n-    \"\"\"\n-    Here we decide if our file is actually a tarball (sometimes the\n-    'tarballs' gotten from arXiv aren't actually tarballs.  If they\n-    'contain' only the TeX file, then they are just that file.), then\n-    we untar it if so and decide which of its constituents are the\n-    TeX file and which are the images.\n+from .errors import InvalidTarball\n+from .output_utils import get_converted_image_name, get_image_location\n \n-    @param: tarball (string): the name of the tar file from arXiv\n-    @param: dir (string): the directory where we would like it untarred to\n \n-    @return: (image_list, tex_file) (([string, string, ...], string)):\n-        list of images in the tarball and the name of the TeX file in the\n-        tarball.\n-    \"\"\"\n+def untar(original_tarball, output_directory=None):\n+    \"\"\"Untar given tarball file into directory.\n \n-    if not tarfile.is_tarfile(original_tarball):\n-        return ([], [], None)\n+    Here we decide if our file is actually a tarball, then\n+    we untar it and return a list of extracted files.\n \n-    tarball = tarfile.open(original_tarball)\n-    tarball.extractall(sdir)\n+    :param: tarball (string): the name of the tar file from arXiv\n+    :param: output_directory (string): the directory to untar in\n \n-    tex_output_contains = 'TeX'\n+    :return: list of absolute file paths\n+    \"\"\"\n+    if not tarfile.is_tarfile(original_tarball):\n+        raise InvalidTarball\n \n-    tex_file_extension = 'tex'\n-    image_output_contains = 'image'\n-    eps_output_contains = '- type eps'\n-    ps_output_contains = 'Postscript'\n+    tarball = tarfile.open(original_tarball)\n+    if not output_directory:\n+        # No directory given, so we use the same directory as the tarball\n+        output_directory = os.path.dirname(original_tarball)","path":"plotextractor/converter.py","position":61,"original_position":61,"commit_id":"9b916ba39d9fedb2108b61f614dbc6f2b5149781","original_commit_id":"9b916ba39d9fedb2108b61f614dbc6f2b5149781","user":{"login":"kaplun","id":119349,"avatar_url":"https://avatars.githubusercontent.com/u/119349?v=3","gravatar_id":"","url":"https://api.github.com/users/kaplun","html_url":"https://github.com/kaplun","followers_url":"https://api.github.com/users/kaplun/followers","following_url":"https://api.github.com/users/kaplun/following{/other_user}","gists_url":"https://api.github.com/users/kaplun/gists{/gist_id}","starred_url":"https://api.github.com/users/kaplun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaplun/subscriptions","organizations_url":"https://api.github.com/users/kaplun/orgs","repos_url":"https://api.github.com/users/kaplun/repos","events_url":"https://api.github.com/users/kaplun/events{/privacy}","received_events_url":"https://api.github.com/users/kaplun/received_events","type":"User","site_admin":false},"body":"At least be sure the checkmanifest trick is in place, which can save your day when making a release later on pypi","created_at":"2015-10-19T14:08:37Z","updated_at":"2015-10-19T14:08:37Z","html_url":"https://github.com/inspirehep/plotextractor/pull/1#discussion_r42374661","pull_request_url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/comments/42374661"},"html":{"href":"https://github.com/inspirehep/plotextractor/pull/1#discussion_r42374661"},"pull_request":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1","id":48068800,"html_url":"https://github.com/inspirehep/plotextractor/pull/1","diff_url":"https://github.com/inspirehep/plotextractor/pull/1.diff","patch_url":"https://github.com/inspirehep/plotextractor/pull/1.patch","issue_url":"https://api.github.com/repos/inspirehep/plotextractor/issues/1","number":1,"state":"open","locked":false,"title":"Restructuring","user":{"login":"jalavik","id":633680,"avatar_url":"https://avatars.githubusercontent.com/u/633680?v=3","gravatar_id":"","url":"https://api.github.com/users/jalavik","html_url":"https://github.com/jalavik","followers_url":"https://api.github.com/users/jalavik/followers","following_url":"https://api.github.com/users/jalavik/following{/other_user}","gists_url":"https://api.github.com/users/jalavik/gists{/gist_id}","starred_url":"https://api.github.com/users/jalavik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jalavik/subscriptions","organizations_url":"https://api.github.com/users/jalavik/orgs","repos_url":"https://api.github.com/users/jalavik/repos","events_url":"https://api.github.com/users/jalavik/events{/privacy}","received_events_url":"https://api.github.com/users/jalavik/received_events","type":"User","site_admin":false},"body":"Fully makes the plotextractor utility a standalone library with new features:\r\n\r\n* Removes integration with Invenio and the CLI.\r\n\r\n* Avoids usage of shell commands and instead uses ImageMagick bindings (Wand) for converting and rotating images\r\n\r\n* Removes MARCXML specific output and rather outputs Python dictionaries.\r\n\r\n* Adds tests and skeleton docs.\r\n\r\n@kaplun ","created_at":"2015-10-19T13:06:27Z","updated_at":"2015-10-19T14:08:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69e3eb829dba03da792c76d1b3678080051d0464","assignee":{"login":"jalavik","id":633680,"avatar_url":"https://avatars.githubusercontent.com/u/633680?v=3","gravatar_id":"","url":"https://api.github.com/users/jalavik","html_url":"https://github.com/jalavik","followers_url":"https://api.github.com/users/jalavik/followers","following_url":"https://api.github.com/users/jalavik/following{/other_user}","gists_url":"https://api.github.com/users/jalavik/gists{/gist_id}","starred_url":"https://api.github.com/users/jalavik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jalavik/subscriptions","organizations_url":"https://api.github.com/users/jalavik/orgs","repos_url":"https://api.github.com/users/jalavik/repos","events_url":"https://api.github.com/users/jalavik/events{/privacy}","received_events_url":"https://api.github.com/users/jalavik/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1/commits","review_comments_url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1/comments","review_comment_url":"https://api.github.com/repos/inspirehep/plotextractor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inspirehep/plotextractor/issues/1/comments","statuses_url":"https://api.github.com/repos/inspirehep/plotextractor/statuses/9b916ba39d9fedb2108b61f614dbc6f2b5149781","head":{"label":"jalavik:restructuring","ref":"restructuring","sha":"9b916ba39d9fedb2108b61f614dbc6f2b5149781","user":{"login":"jalavik","id":633680,"avatar_url":"https://avatars.githubusercontent.com/u/633680?v=3","gravatar_id":"","url":"https://api.github.com/users/jalavik","html_url":"https://github.com/jalavik","followers_url":"https://api.github.com/users/jalavik/followers","following_url":"https://api.github.com/users/jalavik/following{/other_user}","gists_url":"https://api.github.com/users/jalavik/gists{/gist_id}","starred_url":"https://api.github.com/users/jalavik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jalavik/subscriptions","organizations_url":"https://api.github.com/users/jalavik/orgs","repos_url":"https://api.github.com/users/jalavik/repos","events_url":"https://api.github.com/users/jalavik/events{/privacy}","received_events_url":"https://api.github.com/users/jalavik/received_events","type":"User","site_admin":false},"repo":{"id":42602222,"name":"plotextractor","full_name":"jalavik/plotextractor","owner":{"login":"jalavik","id":633680,"avatar_url":"https://avatars.githubusercontent.com/u/633680?v=3","gravatar_id":"","url":"https://api.github.com/users/jalavik","html_url":"https://github.com/jalavik","followers_url":"https://api.github.com/users/jalavik/followers","following_url":"https://api.github.com/users/jalavik/following{/other_user}","gists_url":"https://api.github.com/users/jalavik/gists{/gist_id}","starred_url":"https://api.github.com/users/jalavik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jalavik/subscriptions","organizations_url":"https://api.github.com/users/jalavik/orgs","repos_url":"https://api.github.com/users/jalavik/repos","events_url":"https://api.github.com/users/jalavik/events{/privacy}","received_events_url":"https://api.github.com/users/jalavik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jalavik/plotextractor","description":"Extract images and captions from TeX files in a tar archive.","fork":true,"url":"https://api.github.com/repos/jalavik/plotextractor","forks_url":"https://api.github.com/repos/jalavik/plotextractor/forks","keys_url":"https://api.github.com/repos/jalavik/plotextractor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jalavik/plotextractor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jalavik/plotextractor/teams","hooks_url":"https://api.github.com/repos/jalavik/plotextractor/hooks","issue_events_url":"https://api.github.com/repos/jalavik/plotextractor/issues/events{/number}","events_url":"https://api.github.com/repos/jalavik/plotextractor/events","assignees_url":"https://api.github.com/repos/jalavik/plotextractor/assignees{/user}","branches_url":"https://api.github.com/repos/jalavik/plotextractor/branches{/branch}","tags_url":"https://api.github.com/repos/jalavik/plotextractor/tags","blobs_url":"https://api.github.com/repos/jalavik/plotextractor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jalavik/plotextractor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jalavik/plotextractor/git/refs{/sha}","trees_url":"https://api.github.com/repos/jalavik/plotextractor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jalavik/plotextractor/statuses/{sha}","languages_url":"https://api.github.com/repos/jalavik/plotextractor/languages","stargazers_url":"https://api.github.com/repos/jalavik/plotextractor/stargazers","contributors_url":"https://api.github.com/repos/jalavik/plotextractor/contributors","subscribers_url":"https://api.github.com/repos/jalavik/plotextractor/subscribers","subscription_url":"https://api.github.com/repos/jalavik/plotextractor/subscription","commits_url":"https://api.github.com/repos/jalavik/plotextractor/commits{/sha}","git_commits_url":"https://api.github.com/repos/jalavik/plotextractor/git/commits{/sha}","comments_url":"https://api.github.com/repos/jalavik/plotextractor/comments{/number}","issue_comment_url":"https://api.github.com/repos/jalavik/plotextractor/issues/comments{/number}","contents_url":"https://api.github.com/repos/jalavik/plotextractor/contents/{+path}","compare_url":"https://api.github.com/repos/jalavik/plotextractor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jalavik/plotextractor/merges","archive_url":"https://api.github.com/repos/jalavik/plotextractor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jalavik/plotextractor/downloads","issues_url":"https://api.github.com/repos/jalavik/plotextractor/issues{/number}","pulls_url":"https://api.github.com/repos/jalavik/plotextractor/pulls{/number}","milestones_url":"https://api.github.com/repos/jalavik/plotextractor/milestones{/number}","notifications_url":"https://api.github.com/repos/jalavik/plotextractor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jalavik/plotextractor/labels{/name}","releases_url":"https://api.github.com/repos/jalavik/plotextractor/releases{/id}","created_at":"2015-09-16T17:20:01Z","updated_at":"2015-09-16T17:20:02Z","pushed_at":"2015-10-19T13:39:18Z","git_url":"git://github.com/jalavik/plotextractor.git","ssh_url":"git@github.com:jalavik/plotextractor.git","clone_url":"https://github.com/jalavik/plotextractor.git","svn_url":"https://github.com/jalavik/plotextractor","homepage":null,"size":306,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"inspirehep:master","ref":"master","sha":"51d589442f43ad621482e3216621f5dfce572c22","user":{"login":"inspirehep","id":356664,"avatar_url":"https://avatars.githubusercontent.com/u/356664?v=3","gravatar_id":"","url":"https://api.github.com/users/inspirehep","html_url":"https://github.com/inspirehep","followers_url":"https://api.github.com/users/inspirehep/followers","following_url":"https://api.github.com/users/inspirehep/following{/other_user}","gists_url":"https://api.github.com/users/inspirehep/gists{/gist_id}","starred_url":"https://api.github.com/users/inspirehep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspirehep/subscriptions","organizations_url":"https://api.github.com/users/inspirehep/orgs","repos_url":"https://api.github.com/users/inspirehep/repos","events_url":"https://api.github.com/users/inspirehep/events{/privacy}","received_events_url":"https://api.github.com/users/inspirehep/received_events","type":"Organization","site_admin":false},"repo":{"id":42449251,"name":"plotextractor","full_name":"inspirehep/plotextractor","owner":{"login":"inspirehep","id":356664,"avatar_url":"https://avatars.githubusercontent.com/u/356664?v=3","gravatar_id":"","url":"https://api.github.com/users/inspirehep","html_url":"https://github.com/inspirehep","followers_url":"https://api.github.com/users/inspirehep/followers","following_url":"https://api.github.com/users/inspirehep/following{/other_user}","gists_url":"https://api.github.com/users/inspirehep/gists{/gist_id}","starred_url":"https://api.github.com/users/inspirehep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspirehep/subscriptions","organizations_url":"https://api.github.com/users/inspirehep/orgs","repos_url":"https://api.github.com/users/inspirehep/repos","events_url":"https://api.github.com/users/inspirehep/events{/privacy}","received_events_url":"https://api.github.com/users/inspirehep/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inspirehep/plotextractor","description":"Extract images and captions from TeX files in a tar archive.","fork":false,"url":"https://api.github.com/repos/inspirehep/plotextractor","forks_url":"https://api.github.com/repos/inspirehep/plotextractor/forks","keys_url":"https://api.github.com/repos/inspirehep/plotextractor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inspirehep/plotextractor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inspirehep/plotextractor/teams","hooks_url":"https://api.github.com/repos/inspirehep/plotextractor/hooks","issue_events_url":"https://api.github.com/repos/inspirehep/plotextractor/issues/events{/number}","events_url":"https://api.github.com/repos/inspirehep/plotextractor/events","assignees_url":"https://api.github.com/repos/inspirehep/plotextractor/assignees{/user}","branches_url":"https://api.github.com/repos/inspirehep/plotextractor/branches{/branch}","tags_url":"https://api.github.com/repos/inspirehep/plotextractor/tags","blobs_url":"https://api.github.com/repos/inspirehep/plotextractor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inspirehep/plotextractor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inspirehep/plotextractor/git/refs{/sha}","trees_url":"https://api.github.com/repos/inspirehep/plotextractor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inspirehep/plotextractor/statuses/{sha}","languages_url":"https://api.github.com/repos/inspirehep/plotextractor/languages","stargazers_url":"https://api.github.com/repos/inspirehep/plotextractor/stargazers","contributors_url":"https://api.github.com/repos/inspirehep/plotextractor/contributors","subscribers_url":"https://api.github.com/repos/inspirehep/plotextractor/subscribers","subscription_url":"https://api.github.com/repos/inspirehep/plotextractor/subscription","commits_url":"https://api.github.com/repos/inspirehep/plotextractor/commits{/sha}","git_commits_url":"https://api.github.com/repos/inspirehep/plotextractor/git/commits{/sha}","comments_url":"https://api.github.com/repos/inspirehep/plotextractor/comments{/number}","issue_comment_url":"https://api.github.com/repos/inspirehep/plotextractor/issues/comments{/number}","contents_url":"https://api.github.com/repos/inspirehep/plotextractor/contents/{+path}","compare_url":"https://api.github.com/repos/inspirehep/plotextractor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inspirehep/plotextractor/merges","archive_url":"https://api.github.com/repos/inspirehep/plotextractor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inspirehep/plotextractor/downloads","issues_url":"https://api.github.com/repos/inspirehep/plotextractor/issues{/number}","pulls_url":"https://api.github.com/repos/inspirehep/plotextractor/pulls{/number}","milestones_url":"https://api.github.com/repos/inspirehep/plotextractor/milestones{/number}","notifications_url":"https://api.github.com/repos/inspirehep/plotextractor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inspirehep/plotextractor/labels{/name}","releases_url":"https://api.github.com/repos/inspirehep/plotextractor/releases{/id}","created_at":"2015-09-14T13:09:45Z","updated_at":"2015-09-16T17:19:43Z","pushed_at":"2015-10-19T13:39:18Z","git_url":"git://github.com/inspirehep/plotextractor.git","ssh_url":"git@github.com:inspirehep/plotextractor.git","clone_url":"https://github.com/inspirehep/plotextractor.git","svn_url":"https://github.com/inspirehep/plotextractor","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1"},"html":{"href":"https://github.com/inspirehep/plotextractor/pull/1"},"issue":{"href":"https://api.github.com/repos/inspirehep/plotextractor/issues/1"},"comments":{"href":"https://api.github.com/repos/inspirehep/plotextractor/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inspirehep/plotextractor/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/inspirehep/plotextractor/statuses/9b916ba39d9fedb2108b61f614dbc6f2b5149781"}}}}