{"action":"created","comment":{"url":"https://api.github.com/repos/datalad/datalad/pulls/comments/84575491","pull_request_review_id":5347917,"id":84575491,"diff_hunk":"@@ -0,0 +1,92 @@\n+# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-\n+# ex: set sts=4 ts=4 sw=4 noet:\n+# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n+#\n+#   See COPYING file distributed along with the datalad package for the\n+#   copyright and license terms.\n+#\n+# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##\n+\"\"\"Parser for RFC822-based metadata specifications\n+\n+This is inspired by (and very similiar to) Debian's package meta data format.\n+The main difference is that information spread across multiple files in Debian\n+packages, is concentrated in one file.\n+\n+The main advantage of this format is that it is proven to be hand-editable,\n+i.e. can be composed from scratch, by hand, in an editor -- with a good\n+chance of producing syntax-compliant content with the first attempt.\n+\"\"\"\n+\n+import email\n+from os.path import join as opj\n+from datalad.metadata.parsers.base import BaseMetadataParser\n+from datalad.interface.base import dedent_docstring\n+\n+\n+def _split_list_field(content):\n+    return [i.strip() for i in content.split(',') if i.strip()]\n+\n+\n+def _beautify_multiline_field(content):\n+    content = dedent_docstring(content)\n+    lines = content.split('\\n')\n+    title = ''\n+    if len(lines):\n+        title = lines[0]\n+    if len(lines) > 1:\n+        content = ''\n+        for l in lines[1:]:\n+            l = l.strip()\n+            content = '{}{}{}'.format(\n+                content,\n+                ' ' if len(content) and l != '.' and content[-1] != '\\n' else '',\n+                l if l != '.' else '\\n')\n+    return title, content\n+\n+\n+class MetadataParser(BaseMetadataParser):\n+    _metadata_compliance = \"http://docs.datalad.org/metadata.html#v0-1\"\n+    _core_metadata_filenames = [opj('.datalad', 'meta.rfc822')]\n+\n+    def _get_metadata(self, ds_identifier, meta, full):\n+        spec = email.parser.Parser().parse(\n+            open(self.get_core_metadata_filenames()[0]),\n+            headersonly=True)\n+\n+        # loop over all recognized headers and translate them\n+        for header, dataladterm in \\\n+                (('name', 'name'),\n+                 ('license', 'license'),\n+                 ('author', 'author'),\n+                 ('maintainer', 'doap:maintainer'),\n+                 ('audience', 'doap:audience'),\n+                 ('homepage', 'doap:homepage'),\n+                 ('version', 'doap:Version'),\n+                 ('funding', 'foaf:fundedBy'),\n+                 ('issue-tracker', 'bug-database'),\n+                 ('cita-as', 'citation'),","path":"datalad/metadata/parsers/datalad_rfc822.py","position":67,"original_position":67,"commit_id":"8452130cacf1e85b57d3a02336e88854dfdcaa25","original_commit_id":"8452130cacf1e85b57d3a02336e88854dfdcaa25","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":"cite-as","created_at":"2016-10-22T11:40:03Z","updated_at":"2016-10-22T11:40:03Z","html_url":"https://github.com/datalad/datalad/pull/1023#discussion_r84575491","pull_request_url":"https://api.github.com/repos/datalad/datalad/pulls/1023","_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments/84575491"},"html":{"href":"https://github.com/datalad/datalad/pull/1023#discussion_r84575491"},"pull_request":{"href":"https://api.github.com/repos/datalad/datalad/pulls/1023"}}},"pull_request":{"url":"https://api.github.com/repos/datalad/datalad/pulls/1023","id":89520833,"html_url":"https://github.com/datalad/datalad/pull/1023","diff_url":"https://github.com/datalad/datalad/pull/1023.diff","patch_url":"https://github.com/datalad/datalad/pull/1023.patch","issue_url":"https://api.github.com/repos/datalad/datalad/issues/1023","number":1023,"state":"open","locked":false,"title":"NF: RFC822-based meta data format targeting manual meta data entry scenarios","user":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"body":"Which invents as little as possible. Objectives:\r\n\r\n1. Compact\r\n2. Suitable for hand-editing (we have two JSON-based ones already)\r\n3. Flexible enough to be able to capture pretty much anything I could think of\r\n\r\nChoosing Debian's RFC822 felt natural. Pretty much all these files are composed by hand (that's proof enough).\r\n\r\nThe idea is to merge the various ideas from Debian's metadata files into a single spec file (control, copyright, ...). If necessary, we could have multiple files of course, but it doesn't look like we need it (yet).\r\n\r\nAt this point, the implementation represents the minimal technical infrastructure to support this format on a demo level, and to get the discussion going.","created_at":"2016-10-16T09:36:54Z","updated_at":"2016-10-22T11:45:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb9f9a2e00a2205c14b43e828d70fbdcabac810b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/datalad/datalad/pulls/1023/commits","review_comments_url":"https://api.github.com/repos/datalad/datalad/pulls/1023/comments","review_comment_url":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datalad/datalad/issues/1023/comments","statuses_url":"https://api.github.com/repos/datalad/datalad/statuses/8452130cacf1e85b57d3a02336e88854dfdcaa25","head":{"label":"mih:nf-rfc882meta","ref":"nf-rfc882meta","sha":"8452130cacf1e85b57d3a02336e88854dfdcaa25","user":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"repo":{"id":34503646,"name":"datalad","full_name":"mih/datalad","owner":{"login":"mih","id":136479,"avatar_url":"https://avatars.githubusercontent.com/u/136479?v=3","gravatar_id":"","url":"https://api.github.com/users/mih","html_url":"https://github.com/mih","followers_url":"https://api.github.com/users/mih/followers","following_url":"https://api.github.com/users/mih/following{/other_user}","gists_url":"https://api.github.com/users/mih/gists{/gist_id}","starred_url":"https://api.github.com/users/mih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mih/subscriptions","organizations_url":"https://api.github.com/users/mih/orgs","repos_url":"https://api.github.com/users/mih/repos","events_url":"https://api.github.com/users/mih/events{/privacy}","received_events_url":"https://api.github.com/users/mih/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mih/datalad","description":"Keep scientific data under control by git  and git-annex","fork":true,"url":"https://api.github.com/repos/mih/datalad","forks_url":"https://api.github.com/repos/mih/datalad/forks","keys_url":"https://api.github.com/repos/mih/datalad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mih/datalad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mih/datalad/teams","hooks_url":"https://api.github.com/repos/mih/datalad/hooks","issue_events_url":"https://api.github.com/repos/mih/datalad/issues/events{/number}","events_url":"https://api.github.com/repos/mih/datalad/events","assignees_url":"https://api.github.com/repos/mih/datalad/assignees{/user}","branches_url":"https://api.github.com/repos/mih/datalad/branches{/branch}","tags_url":"https://api.github.com/repos/mih/datalad/tags","blobs_url":"https://api.github.com/repos/mih/datalad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mih/datalad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mih/datalad/git/refs{/sha}","trees_url":"https://api.github.com/repos/mih/datalad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mih/datalad/statuses/{sha}","languages_url":"https://api.github.com/repos/mih/datalad/languages","stargazers_url":"https://api.github.com/repos/mih/datalad/stargazers","contributors_url":"https://api.github.com/repos/mih/datalad/contributors","subscribers_url":"https://api.github.com/repos/mih/datalad/subscribers","subscription_url":"https://api.github.com/repos/mih/datalad/subscription","commits_url":"https://api.github.com/repos/mih/datalad/commits{/sha}","git_commits_url":"https://api.github.com/repos/mih/datalad/git/commits{/sha}","comments_url":"https://api.github.com/repos/mih/datalad/comments{/number}","issue_comment_url":"https://api.github.com/repos/mih/datalad/issues/comments{/number}","contents_url":"https://api.github.com/repos/mih/datalad/contents/{+path}","compare_url":"https://api.github.com/repos/mih/datalad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mih/datalad/merges","archive_url":"https://api.github.com/repos/mih/datalad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mih/datalad/downloads","issues_url":"https://api.github.com/repos/mih/datalad/issues{/number}","pulls_url":"https://api.github.com/repos/mih/datalad/pulls{/number}","milestones_url":"https://api.github.com/repos/mih/datalad/milestones{/number}","notifications_url":"https://api.github.com/repos/mih/datalad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mih/datalad/labels{/name}","releases_url":"https://api.github.com/repos/mih/datalad/releases{/id}","deployments_url":"https://api.github.com/repos/mih/datalad/deployments","created_at":"2015-04-24T07:11:39Z","updated_at":"2016-02-23T15:27:28Z","pushed_at":"2016-10-22T07:49:51Z","git_url":"git://github.com/mih/datalad.git","ssh_url":"git@github.com:mih/datalad.git","clone_url":"https://github.com/mih/datalad.git","svn_url":"https://github.com/mih/datalad","homepage":null,"size":6513,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"datalad:master","ref":"master","sha":"c03aab56acc8dd5d96038b0089c2a3443af4d0a8","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 with 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}","deployments_url":"https://api.github.com/repos/datalad/datalad/deployments","created_at":"2013-11-01T19:40:08Z","updated_at":"2016-10-22T02:55:40Z","pushed_at":"2016-10-22T08:56:12Z","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":"http://datalad.org","size":10180,"stargazers_count":42,"watchers_count":42,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":222,"forks":10,"open_issues":222,"watchers":42,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datalad/datalad/pulls/1023"},"html":{"href":"https://github.com/datalad/datalad/pull/1023"},"issue":{"href":"https://api.github.com/repos/datalad/datalad/issues/1023"},"comments":{"href":"https://api.github.com/repos/datalad/datalad/issues/1023/comments"},"review_comments":{"href":"https://api.github.com/repos/datalad/datalad/pulls/1023/comments"},"review_comment":{"href":"https://api.github.com/repos/datalad/datalad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datalad/datalad/pulls/1023/commits"},"statuses":{"href":"https://api.github.com/repos/datalad/datalad/statuses/8452130cacf1e85b57d3a02336e88854dfdcaa25"}}}}
{"actor":{"display_login":"yarikoptic"}}