{"action":"created","comment":{"url":"https://api.github.com/repos/datalad/datalad/pulls/comments/28936103","id":28936103,"diff_hunk":"@@ -10,55 +10,166 @@\n \n \"\"\"\n \n-import os\n-# All this should be replaced with a use of patoolib, but\n-# after figure out why\n-# https://github.com/wummel/patool/issues/2\n-# Fixed in 1.2 release, but there is no __version__ to assess reliably (yet)\n+from distutils.version import StrictVersion\n import patoolib\n-import re\n+# There were issues, so let's stay consistently with recent version\n+assert(StrictVersion(patoolib.__version__) >= \"1.7\")\n \n-from os.path import join\n+import os\n+from os.path import join as opj, exists\n \n import logging\n lgr = logging.getLogger('datalad.files')\n \n+# Monkey-patch patoolib's logging, so it logs coherently with the rest of\n+# datalad\n+import patoolib.util\n+#\n+# Seems have managed with swallow_outputs\n+#\n+# def _patool_log(level, msg):\n+#     lgr.log(level, \"patool: %s\" % msg)\n+#\n+# def _patool_log_info(msg, *args, **kwargs):\n+#     _patool_log(logging.DEBUG, msg)\n+#\n+# def _patool_log_error(msg, *args, **kwargs):\n+#     _patool_log(logging.ERROR, msg)\n+#\n+# patoolib.util.log_info = _patool_log_info\n+# patoolib.util.log_error = _patool_log_error\n+# patoolib.util.log_internal_error = _patool_log_error\n+\n+# we need to decorate patool.util.run\n+# because otherwise it just lets processes to spit out everything to std and we\n+# do want to use it at \"verbosity>=0\" so we could get idea on what is going on.\n+# And I don't want to mock for every invocation\n+from ..support.exceptions import CommandError\n+\n+from ..cmd import Runner\n+_runner = Runner()\n+\n+def _patool_run(cmd, verbosity=0, **kwargs):\n+    \"\"\"Decorated runner for patool so it doesn't spit out outputs to stdout\"\"\"\n+    # use our runner\n+    try:\n+        # kwargs_ = kwargs[:];         kwargs_['shell'] = True\n+        _runner.run(cmd, **kwargs)\n+        return 0\n+    except CommandError as e:\n+        return e.code\n+    except Exception as e:\n+        lgr.error(\"While invoking runner caught unexpected exception: %s\" % e)\n+        return 100  # unknown beast\n+patoolib.util.run = _patool_run\n+\n+\n+# yoh: only keys are used atm, logic in decompress_file is replaced to use\n+# patool\n+\n DECOMPRESSORS = {\n-    '\\.(tar\\.bz|tbz)$' : 'tar -xjvf %(file)s -C %(dir)s',\n-    '\\.(tar\\.xz)$' : 'tar -xJvf %(file)s -C %(dir)s',\n-    '\\.(tar\\.gz|tgz)$' : 'tar -xzvf %(file)s -C %(dir)s',\n-    '\\.(zip)$' : 'unzip %(file)s -d %(dir)s',\n+    '\\.(tar\\.bz|tbz)$': 'tar -xjvf %(file)s -C %(dir)s',\n+    '\\.(tar\\.xz)$': 'tar -xJvf %(file)s -C %(dir)s',\n+    '\\.(tar\\.gz|tgz)$': 'tar -xzvf %(file)s -C %(dir)s',\n+    '\\.(zip)$': 'unzip %(file)s -d %(dir)s',\n     }\n \n+from ..utils import on_windows\n+def unixify_path(path):\n+    \"\"\"On windows convert paths from drive:\\d\\file to /drive/d/file\n+\n+    This overcomes problems with various cmdline tools we are to use,\n+    such as tar etc\n+    \"\"\"\n+    if on_windows:\n+        drive, path_ = os.path.splitdrive(path)\n+        path_ = path_.split(os.sep)\n+        path_ = '/'.join(path_)\n+        if drive:\n+            # last one must be :\n+            assert(drive[-1] == \":\")\n+            return '/%s%s' % (drive[:-1], path_)\n+        else:\n+            return path_\n+    else:\n+        return path\n+\n+\n+def decompress_file(archive, dir_, leading_directories='strip'):\n+    \"\"\"Decompress `archive` into a directory `dir_`\n+\n+    Parameters\n+    ----------\n+    archive: str\n+    dir_: str\n+    leading_directories: {'strip', None}","path":"datalad/support/archives.py","position":107,"original_position":107,"commit_id":"6e164253e2dee5aacb03dbdc4196e3b073c91b49","original_commit_id":"6e164253e2dee5aacb03dbdc4196e3b073c91b49","user":{"login":"bpoldrack","id":10498301,"avatar_url":"https://avatars.githubusercontent.com/u/10498301?v=3","gravatar_id":"","url":"https://api.github.com/users/bpoldrack","html_url":"https://github.com/bpoldrack","followers_url":"https://api.github.com/users/bpoldrack/followers","following_url":"https://api.github.com/users/bpoldrack/following{/other_user}","gists_url":"https://api.github.com/users/bpoldrack/gists{/gist_id}","starred_url":"https://api.github.com/users/bpoldrack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpoldrack/subscriptions","organizations_url":"https://api.github.com/users/bpoldrack/orgs","repos_url":"https://api.github.com/users/bpoldrack/repos","events_url":"https://api.github.com/users/bpoldrack/events{/privacy}","received_events_url":"https://api.github.com/users/bpoldrack/received_events","type":"User","site_admin":false},"body":"May be add an explaining line here.","created_at":"2015-04-23T04:36:38Z","updated_at":"2015-04-23T04:36:38Z","html_url":"https://github.com/datalad/datalad/pull/126#discussion_r28936103","pull_request_url":"https://api.github.com/repos/datalad/datalad/pulls/126","_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments/28936103"},"html":{"href":"https://github.com/datalad/datalad/pull/126#discussion_r28936103"},"pull_request":{"href":"https://api.github.com/repos/datalad/datalad/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/datalad/datalad/pulls/126","id":33866474,"html_url":"https://github.com/datalad/datalad/pull/126","diff_url":"https://github.com/datalad/datalad/pull/126.diff","patch_url":"https://github.com/datalad/datalad/pull/126.patch","issue_url":"https://api.github.com/repos/datalad/datalad/issues/126","number":126,"state":"open","locked":false,"title":"WiP RF patool logging etc","user":{"login":"yarikoptic","id":39889,"avatar_url":"https://avatars.githubusercontent.com/u/39889?v=3","gravatar_id":"","url":"https://api.github.com/users/yarikoptic","html_url":"https://github.com/yarikoptic","followers_url":"https://api.github.com/users/yarikoptic/followers","following_url":"https://api.github.com/users/yarikoptic/following{/other_user}","gists_url":"https://api.github.com/users/yarikoptic/gists{/gist_id}","starred_url":"https://api.github.com/users/yarikoptic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarikoptic/subscriptions","organizations_url":"https://api.github.com/users/yarikoptic/orgs","repos_url":"https://api.github.com/users/yarikoptic/repos","events_url":"https://api.github.com/users/yarikoptic/events{/privacy}","received_events_url":"https://api.github.com/users/yarikoptic/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-22T14:55:59Z","updated_at":"2015-04-23T04:36:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f02c40146f57d3c8bd633df3f4d29495bd783753","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/datalad/datalad/pulls/126/commits","review_comments_url":"https://api.github.com/repos/datalad/datalad/pulls/126/comments","review_comment_url":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datalad/datalad/issues/126/comments","statuses_url":"https://api.github.com/repos/datalad/datalad/statuses/6e164253e2dee5aacb03dbdc4196e3b073c91b49","head":{"label":"yarikoptic:rf-patool-logging-etc","ref":"rf-patool-logging-etc","sha":"6e164253e2dee5aacb03dbdc4196e3b073c91b49","user":{"login":"yarikoptic","id":39889,"avatar_url":"https://avatars.githubusercontent.com/u/39889?v=3","gravatar_id":"","url":"https://api.github.com/users/yarikoptic","html_url":"https://github.com/yarikoptic","followers_url":"https://api.github.com/users/yarikoptic/followers","following_url":"https://api.github.com/users/yarikoptic/following{/other_user}","gists_url":"https://api.github.com/users/yarikoptic/gists{/gist_id}","starred_url":"https://api.github.com/users/yarikoptic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarikoptic/subscriptions","organizations_url":"https://api.github.com/users/yarikoptic/orgs","repos_url":"https://api.github.com/users/yarikoptic/repos","events_url":"https://api.github.com/users/yarikoptic/events{/privacy}","received_events_url":"https://api.github.com/users/yarikoptic/received_events","type":"User","site_admin":false},"repo":{"id":30428483,"name":"datalad","full_name":"yarikoptic/datalad","owner":{"login":"yarikoptic","id":39889,"avatar_url":"https://avatars.githubusercontent.com/u/39889?v=3","gravatar_id":"","url":"https://api.github.com/users/yarikoptic","html_url":"https://github.com/yarikoptic","followers_url":"https://api.github.com/users/yarikoptic/followers","following_url":"https://api.github.com/users/yarikoptic/following{/other_user}","gists_url":"https://api.github.com/users/yarikoptic/gists{/gist_id}","starred_url":"https://api.github.com/users/yarikoptic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yarikoptic/subscriptions","organizations_url":"https://api.github.com/users/yarikoptic/orgs","repos_url":"https://api.github.com/users/yarikoptic/repos","events_url":"https://api.github.com/users/yarikoptic/events{/privacy}","received_events_url":"https://api.github.com/users/yarikoptic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yarikoptic/datalad","description":"Keep scientific data under control by git  and git-annex","fork":true,"url":"https://api.github.com/repos/yarikoptic/datalad","forks_url":"https://api.github.com/repos/yarikoptic/datalad/forks","keys_url":"https://api.github.com/repos/yarikoptic/datalad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yarikoptic/datalad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yarikoptic/datalad/teams","hooks_url":"https://api.github.com/repos/yarikoptic/datalad/hooks","issue_events_url":"https://api.github.com/repos/yarikoptic/datalad/issues/events{/number}","events_url":"https://api.github.com/repos/yarikoptic/datalad/events","assignees_url":"https://api.github.com/repos/yarikoptic/datalad/assignees{/user}","branches_url":"https://api.github.com/repos/yarikoptic/datalad/branches{/branch}","tags_url":"https://api.github.com/repos/yarikoptic/datalad/tags","blobs_url":"https://api.github.com/repos/yarikoptic/datalad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yarikoptic/datalad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yarikoptic/datalad/git/refs{/sha}","trees_url":"https://api.github.com/repos/yarikoptic/datalad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yarikoptic/datalad/statuses/{sha}","languages_url":"https://api.github.com/repos/yarikoptic/datalad/languages","stargazers_url":"https://api.github.com/repos/yarikoptic/datalad/stargazers","contributors_url":"https://api.github.com/repos/yarikoptic/datalad/contributors","subscribers_url":"https://api.github.com/repos/yarikoptic/datalad/subscribers","subscription_url":"https://api.github.com/repos/yarikoptic/datalad/subscription","commits_url":"https://api.github.com/repos/yarikoptic/datalad/commits{/sha}","git_commits_url":"https://api.github.com/repos/yarikoptic/datalad/git/commits{/sha}","comments_url":"https://api.github.com/repos/yarikoptic/datalad/comments{/number}","issue_comment_url":"https://api.github.com/repos/yarikoptic/datalad/issues/comments{/number}","contents_url":"https://api.github.com/repos/yarikoptic/datalad/contents/{+path}","compare_url":"https://api.github.com/repos/yarikoptic/datalad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yarikoptic/datalad/merges","archive_url":"https://api.github.com/repos/yarikoptic/datalad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yarikoptic/datalad/downloads","issues_url":"https://api.github.com/repos/yarikoptic/datalad/issues{/number}","pulls_url":"https://api.github.com/repos/yarikoptic/datalad/pulls{/number}","milestones_url":"https://api.github.com/repos/yarikoptic/datalad/milestones{/number}","notifications_url":"https://api.github.com/repos/yarikoptic/datalad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yarikoptic/datalad/labels{/name}","releases_url":"https://api.github.com/repos/yarikoptic/datalad/releases{/id}","created_at":"2015-02-06T19:12:34Z","updated_at":"2015-04-20T14:36:16Z","pushed_at":"2015-04-23T02:04:09Z","git_url":"git://github.com/yarikoptic/datalad.git","ssh_url":"git@github.com:yarikoptic/datalad.git","clone_url":"https://github.com/yarikoptic/datalad.git","svn_url":"https://github.com/yarikoptic/datalad","homepage":null,"size":1577,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"datalad:master","ref":"master","sha":"d0a55f4f580e3e4a0448965cd434ebeabd5586f8","user":{"login":"datalad","id":8927200,"avatar_url":"https://avatars.githubusercontent.com/u/8927200?v=3","gravatar_id":"","url":"https://api.github.com/users/datalad","html_url":"https://github.com/datalad","followers_url":"https://api.github.com/users/datalad/followers","following_url":"https://api.github.com/users/datalad/following{/other_user}","gists_url":"https://api.github.com/users/datalad/gists{/gist_id}","starred_url":"https://api.github.com/users/datalad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datalad/subscriptions","organizations_url":"https://api.github.com/users/datalad/orgs","repos_url":"https://api.github.com/users/datalad/repos","events_url":"https://api.github.com/users/datalad/events{/privacy}","received_events_url":"https://api.github.com/users/datalad/received_events","type":"Organization","site_admin":false},"repo":{"id":14052034,"name":"datalad","full_name":"datalad/datalad","owner":{"login":"datalad","id":8927200,"avatar_url":"https://avatars.githubusercontent.com/u/8927200?v=3","gravatar_id":"","url":"https://api.github.com/users/datalad","html_url":"https://github.com/datalad","followers_url":"https://api.github.com/users/datalad/followers","following_url":"https://api.github.com/users/datalad/following{/other_user}","gists_url":"https://api.github.com/users/datalad/gists{/gist_id}","starred_url":"https://api.github.com/users/datalad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datalad/subscriptions","organizations_url":"https://api.github.com/users/datalad/orgs","repos_url":"https://api.github.com/users/datalad/repos","events_url":"https://api.github.com/users/datalad/events{/privacy}","received_events_url":"https://api.github.com/users/datalad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datalad/datalad","description":"Keep scientific data under control by git  and git-annex","fork":false,"url":"https://api.github.com/repos/datalad/datalad","forks_url":"https://api.github.com/repos/datalad/datalad/forks","keys_url":"https://api.github.com/repos/datalad/datalad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datalad/datalad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datalad/datalad/teams","hooks_url":"https://api.github.com/repos/datalad/datalad/hooks","issue_events_url":"https://api.github.com/repos/datalad/datalad/issues/events{/number}","events_url":"https://api.github.com/repos/datalad/datalad/events","assignees_url":"https://api.github.com/repos/datalad/datalad/assignees{/user}","branches_url":"https://api.github.com/repos/datalad/datalad/branches{/branch}","tags_url":"https://api.github.com/repos/datalad/datalad/tags","blobs_url":"https://api.github.com/repos/datalad/datalad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datalad/datalad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datalad/datalad/git/refs{/sha}","trees_url":"https://api.github.com/repos/datalad/datalad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datalad/datalad/statuses/{sha}","languages_url":"https://api.github.com/repos/datalad/datalad/languages","stargazers_url":"https://api.github.com/repos/datalad/datalad/stargazers","contributors_url":"https://api.github.com/repos/datalad/datalad/contributors","subscribers_url":"https://api.github.com/repos/datalad/datalad/subscribers","subscription_url":"https://api.github.com/repos/datalad/datalad/subscription","commits_url":"https://api.github.com/repos/datalad/datalad/commits{/sha}","git_commits_url":"https://api.github.com/repos/datalad/datalad/git/commits{/sha}","comments_url":"https://api.github.com/repos/datalad/datalad/comments{/number}","issue_comment_url":"https://api.github.com/repos/datalad/datalad/issues/comments{/number}","contents_url":"https://api.github.com/repos/datalad/datalad/contents/{+path}","compare_url":"https://api.github.com/repos/datalad/datalad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datalad/datalad/merges","archive_url":"https://api.github.com/repos/datalad/datalad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datalad/datalad/downloads","issues_url":"https://api.github.com/repos/datalad/datalad/issues{/number}","pulls_url":"https://api.github.com/repos/datalad/datalad/pulls{/number}","milestones_url":"https://api.github.com/repos/datalad/datalad/milestones{/number}","notifications_url":"https://api.github.com/repos/datalad/datalad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datalad/datalad/labels{/name}","releases_url":"https://api.github.com/repos/datalad/datalad/releases{/id}","created_at":"2013-11-01T19:40:08Z","updated_at":"2015-04-22T13:55:04Z","pushed_at":"2015-04-23T04:23:58Z","git_url":"git://github.com/datalad/datalad.git","ssh_url":"git@github.com:datalad/datalad.git","clone_url":"https://github.com/datalad/datalad.git","svn_url":"https://github.com/datalad/datalad","homepage":null,"size":2482,"stargazers_count":23,"watchers_count":23,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":56,"forks":5,"open_issues":56,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/126"},"html":{"href":"https://github.com/datalad/datalad/pull/126"},"issue":{"href":"https://api.github.com/repos/datalad/datalad/issues/126"},"comments":{"href":"https://api.github.com/repos/datalad/datalad/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/datalad/datalad/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datalad/datalad/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/datalad/datalad/statuses/6e164253e2dee5aacb03dbdc4196e3b073c91b49"}}}}