{"action":"created","comment":{"url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/comments/43737393","id":43737393,"diff_hunk":"@@ -95,5 +96,93 @@ def export_all(pretty):\n     click.echo(json.dumps(volumes, indent=indent))\n \n \n+@libreant_db.command(name='append-file', help='uploads a file to an existing volume')\n+@click.option('-i', '--volumeid', type=click.STRING, )\n+@click.option('-f', '--filepath', type=click.Path(exists=True,resolve_path=True), multiple=True, help='the path to the media to be uploaded')\n+@click.option('-n', '--name', type=click.STRING, multiple=True, help='[optional] name of the media including the extension')\n+@click.option('-m', '--mime', type=click.STRING, multiple=True, help='[optional] mime type of the media')\n+@click.option('-t', '--notes', type=click.STRING, multiple=True, help='[optional] notes about the media')\n+def append_file(volumeid,filepath,name,mime,notes):\n+    #attachments = map_attachments(filepath,name,mime,notes)\n+    attachments = map_attachments(filename=list(filepath) if not filepath==None else [],\\\n+                                  name=list(name) if not name==None else [],\\\n+                                  mime=list(mime) if not mime==None else [],\\\n+                                  notes=list(notes) if not notes==None else [])\n+    try:\n+        arc.insert_attachments(volumeid,attachments)\n+    except:\n+        click.secho('An upload error occurred in updating an attachment!',fg='yellow', err=True)\n+        exit(4)\n+\n+\n+@libreant_db.command(name='insert-volume', help='uploads a volume to the db')\n+@click.option('-l', '--language', type=click.STRING, help='specify the language of the media you are going to upload')\n+@click.option('-f', '--filepath', type=click.Path(exists=True,resolve_path=True), multiple=True, help='the path to the media to be uploaded')\n+@click.option('-n', '--name', type=click.STRING, multiple=True, help='[optional] name of the media including the extension')\n+@click.option('-m', '--mime', type=click.STRING, multiple=True, help='[optional] mime type of the media')\n+@click.option('-t', '--notes', type=click.STRING, multiple=True, help='[optional] notes about the media')\n+@click.option('-x', '--extravalues', type=click.STRING, help='[optional] additional parameters')\n+def insert_volume(language,filepath,name,mime,notes,extravalues):\n+    def check_extra_values(x_values):\n+        #TODO: raise(NotImplemented)\n+    #if len(extravalues)>0:\n+    #    check_extra_values(extravalues)\n+    #else:\n+    #    pass\n+    metadata = {\"_language\":language}\n+    if extravalues:\n+        for key,value in extravalues:\n+            metadata[key] = value\n+    attachments = map_attachments(filename=list(filepath) if not filepath==None else [],\\\n+                                  name=list(name) if not name==None else [],\\\n+                                  mime=list(mime) if not mime==None else [],\\\n+                                  notes=list(notes) if not notes==None else [])\n+    try:\n+        arc.insert_volume(metadata,attachments)\n+    except:\n+        click.secho('An upload error have occurred!', fg=\"yellow\", err=True)\n+        exit(4)\n+\n+def map_attachments(filename, name, mime, notes):\n+    i = 0\n+    const_names = list() # [\"file\",\"name\",\"mime\",\"notes\"]\n+    attr_list = list()\n+    attachments = list()\n+    arglen = len(filename) if isinstance(filename,list) else 0\n+\n+    if arglen>1:","path":"cli/libreant_db.py","position":75,"original_position":75,"commit_id":"c937840e58e625e3fd1db95b619eb3574327f099","original_commit_id":"c937840e58e625e3fd1db95b619eb3574327f099","user":{"login":"boyska","id":14236,"avatar_url":"https://avatars.githubusercontent.com/u/14236?v=3","gravatar_id":"","url":"https://api.github.com/users/boyska","html_url":"https://github.com/boyska","followers_url":"https://api.github.com/users/boyska/followers","following_url":"https://api.github.com/users/boyska/following{/other_user}","gists_url":"https://api.github.com/users/boyska/gists{/gist_id}","starred_url":"https://api.github.com/users/boyska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boyska/subscriptions","organizations_url":"https://api.github.com/users/boyska/orgs","repos_url":"https://api.github.com/users/boyska/repos","events_url":"https://api.github.com/users/boyska/events{/privacy}","received_events_url":"https://api.github.com/users/boyska/received_events","type":"User","site_admin":false},"body":"why is such a thing needed? What's the real difference between a list with length of 1 and another with the length of 2?","created_at":"2015-11-03T11:22:53Z","updated_at":"2015-11-03T11:22:53Z","html_url":"https://github.com/insomnia-lab/libreant/pull/209#discussion_r43737393","pull_request_url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209","_links":{"self":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/comments/43737393"},"html":{"href":"https://github.com/insomnia-lab/libreant/pull/209#discussion_r43737393"},"pull_request":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209"}}},"pull_request":{"url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209","id":49375060,"html_url":"https://github.com/insomnia-lab/libreant/pull/209","diff_url":"https://github.com/insomnia-lab/libreant/pull/209.diff","patch_url":"https://github.com/insomnia-lab/libreant/pull/209.patch","issue_url":"https://api.github.com/repos/insomnia-lab/libreant/issues/209","number":209,"state":"open","locked":false,"title":"Insert-volume/ feature in libreant-db cli","user":{"login":"leophys","id":382161,"avatar_url":"https://avatars.githubusercontent.com/u/382161?v=3","gravatar_id":"","url":"https://api.github.com/users/leophys","html_url":"https://github.com/leophys","followers_url":"https://api.github.com/users/leophys/followers","following_url":"https://api.github.com/users/leophys/following{/other_user}","gists_url":"https://api.github.com/users/leophys/gists{/gist_id}","starred_url":"https://api.github.com/users/leophys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leophys/subscriptions","organizations_url":"https://api.github.com/users/leophys/orgs","repos_url":"https://api.github.com/users/leophys/repos","events_url":"https://api.github.com/users/leophys/events{/privacy}","received_events_url":"https://api.github.com/users/leophys/received_events","type":"User","site_admin":false},"body":"Hi.\r\nI've tried to add the insert-volume/append-file feature to the cli utility libreant-db.\r\nNow there are two more subcommands defined:\r\n - libreant-db insert-volume\r\n - libreant-db append-file\r\n\r\nThe first one uploads a volume to the selected libreant instance and (optionally)\r\nappends files (repeating the same flags is correctly treated as a multiple file upload).\r\nThe second one appends a (list of) file(s) to a given existing volume.","created_at":"2015-11-01T16:22:38Z","updated_at":"2015-11-03T11:22:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6e6f64ae601d0cea9fef0b33312eda727825575","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209/commits","review_comments_url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209/comments","review_comment_url":"https://api.github.com/repos/insomnia-lab/libreant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/insomnia-lab/libreant/issues/209/comments","statuses_url":"https://api.github.com/repos/insomnia-lab/libreant/statuses/c937840e58e625e3fd1db95b619eb3574327f099","head":{"label":"leophys:upload-file","ref":"upload-file","sha":"c937840e58e625e3fd1db95b619eb3574327f099","user":{"login":"leophys","id":382161,"avatar_url":"https://avatars.githubusercontent.com/u/382161?v=3","gravatar_id":"","url":"https://api.github.com/users/leophys","html_url":"https://github.com/leophys","followers_url":"https://api.github.com/users/leophys/followers","following_url":"https://api.github.com/users/leophys/following{/other_user}","gists_url":"https://api.github.com/users/leophys/gists{/gist_id}","starred_url":"https://api.github.com/users/leophys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leophys/subscriptions","organizations_url":"https://api.github.com/users/leophys/orgs","repos_url":"https://api.github.com/users/leophys/repos","events_url":"https://api.github.com/users/leophys/events{/privacy}","received_events_url":"https://api.github.com/users/leophys/received_events","type":"User","site_admin":false},"repo":{"id":28694605,"name":"libreant","full_name":"leophys/libreant","owner":{"login":"leophys","id":382161,"avatar_url":"https://avatars.githubusercontent.com/u/382161?v=3","gravatar_id":"","url":"https://api.github.com/users/leophys","html_url":"https://github.com/leophys","followers_url":"https://api.github.com/users/leophys/followers","following_url":"https://api.github.com/users/leophys/following{/other_user}","gists_url":"https://api.github.com/users/leophys/gists{/gist_id}","starred_url":"https://api.github.com/users/leophys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leophys/subscriptions","organizations_url":"https://api.github.com/users/leophys/orgs","repos_url":"https://api.github.com/users/leophys/repos","events_url":"https://api.github.com/users/leophys/events{/privacy}","received_events_url":"https://api.github.com/users/leophys/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leophys/libreant","description":"{,e}Book archive, focused on small grassroot archives, distributed search, support to different kind of objects","fork":true,"url":"https://api.github.com/repos/leophys/libreant","forks_url":"https://api.github.com/repos/leophys/libreant/forks","keys_url":"https://api.github.com/repos/leophys/libreant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leophys/libreant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leophys/libreant/teams","hooks_url":"https://api.github.com/repos/leophys/libreant/hooks","issue_events_url":"https://api.github.com/repos/leophys/libreant/issues/events{/number}","events_url":"https://api.github.com/repos/leophys/libreant/events","assignees_url":"https://api.github.com/repos/leophys/libreant/assignees{/user}","branches_url":"https://api.github.com/repos/leophys/libreant/branches{/branch}","tags_url":"https://api.github.com/repos/leophys/libreant/tags","blobs_url":"https://api.github.com/repos/leophys/libreant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leophys/libreant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leophys/libreant/git/refs{/sha}","trees_url":"https://api.github.com/repos/leophys/libreant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leophys/libreant/statuses/{sha}","languages_url":"https://api.github.com/repos/leophys/libreant/languages","stargazers_url":"https://api.github.com/repos/leophys/libreant/stargazers","contributors_url":"https://api.github.com/repos/leophys/libreant/contributors","subscribers_url":"https://api.github.com/repos/leophys/libreant/subscribers","subscription_url":"https://api.github.com/repos/leophys/libreant/subscription","commits_url":"https://api.github.com/repos/leophys/libreant/commits{/sha}","git_commits_url":"https://api.github.com/repos/leophys/libreant/git/commits{/sha}","comments_url":"https://api.github.com/repos/leophys/libreant/comments{/number}","issue_comment_url":"https://api.github.com/repos/leophys/libreant/issues/comments{/number}","contents_url":"https://api.github.com/repos/leophys/libreant/contents/{+path}","compare_url":"https://api.github.com/repos/leophys/libreant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leophys/libreant/merges","archive_url":"https://api.github.com/repos/leophys/libreant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leophys/libreant/downloads","issues_url":"https://api.github.com/repos/leophys/libreant/issues{/number}","pulls_url":"https://api.github.com/repos/leophys/libreant/pulls{/number}","milestones_url":"https://api.github.com/repos/leophys/libreant/milestones{/number}","notifications_url":"https://api.github.com/repos/leophys/libreant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leophys/libreant/labels{/name}","releases_url":"https://api.github.com/repos/leophys/libreant/releases{/id}","created_at":"2015-01-01T20:12:03Z","updated_at":"2015-02-27T16:33:34Z","pushed_at":"2015-11-01T16:09:58Z","git_url":"git://github.com/leophys/libreant.git","ssh_url":"git@github.com:leophys/libreant.git","clone_url":"https://github.com/leophys/libreant.git","svn_url":"https://github.com/leophys/libreant","homepage":null,"size":544,"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":"insomnia-lab:dev","ref":"dev","sha":"66299659163211fdff844fe7bb00f4d23011e3c3","user":{"login":"insomnia-lab","id":7016964,"avatar_url":"https://avatars.githubusercontent.com/u/7016964?v=3","gravatar_id":"","url":"https://api.github.com/users/insomnia-lab","html_url":"https://github.com/insomnia-lab","followers_url":"https://api.github.com/users/insomnia-lab/followers","following_url":"https://api.github.com/users/insomnia-lab/following{/other_user}","gists_url":"https://api.github.com/users/insomnia-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/insomnia-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/insomnia-lab/subscriptions","organizations_url":"https://api.github.com/users/insomnia-lab/orgs","repos_url":"https://api.github.com/users/insomnia-lab/repos","events_url":"https://api.github.com/users/insomnia-lab/events{/privacy}","received_events_url":"https://api.github.com/users/insomnia-lab/received_events","type":"Organization","site_admin":false},"repo":{"id":27069249,"name":"libreant","full_name":"insomnia-lab/libreant","owner":{"login":"insomnia-lab","id":7016964,"avatar_url":"https://avatars.githubusercontent.com/u/7016964?v=3","gravatar_id":"","url":"https://api.github.com/users/insomnia-lab","html_url":"https://github.com/insomnia-lab","followers_url":"https://api.github.com/users/insomnia-lab/followers","following_url":"https://api.github.com/users/insomnia-lab/following{/other_user}","gists_url":"https://api.github.com/users/insomnia-lab/gists{/gist_id}","starred_url":"https://api.github.com/users/insomnia-lab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/insomnia-lab/subscriptions","organizations_url":"https://api.github.com/users/insomnia-lab/orgs","repos_url":"https://api.github.com/users/insomnia-lab/repos","events_url":"https://api.github.com/users/insomnia-lab/events{/privacy}","received_events_url":"https://api.github.com/users/insomnia-lab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/insomnia-lab/libreant","description":"{,e}Book archive, focused on small grassroot archives, distributed search, support to different kind of objects","fork":false,"url":"https://api.github.com/repos/insomnia-lab/libreant","forks_url":"https://api.github.com/repos/insomnia-lab/libreant/forks","keys_url":"https://api.github.com/repos/insomnia-lab/libreant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/insomnia-lab/libreant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/insomnia-lab/libreant/teams","hooks_url":"https://api.github.com/repos/insomnia-lab/libreant/hooks","issue_events_url":"https://api.github.com/repos/insomnia-lab/libreant/issues/events{/number}","events_url":"https://api.github.com/repos/insomnia-lab/libreant/events","assignees_url":"https://api.github.com/repos/insomnia-lab/libreant/assignees{/user}","branches_url":"https://api.github.com/repos/insomnia-lab/libreant/branches{/branch}","tags_url":"https://api.github.com/repos/insomnia-lab/libreant/tags","blobs_url":"https://api.github.com/repos/insomnia-lab/libreant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/insomnia-lab/libreant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/insomnia-lab/libreant/git/refs{/sha}","trees_url":"https://api.github.com/repos/insomnia-lab/libreant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/insomnia-lab/libreant/statuses/{sha}","languages_url":"https://api.github.com/repos/insomnia-lab/libreant/languages","stargazers_url":"https://api.github.com/repos/insomnia-lab/libreant/stargazers","contributors_url":"https://api.github.com/repos/insomnia-lab/libreant/contributors","subscribers_url":"https://api.github.com/repos/insomnia-lab/libreant/subscribers","subscription_url":"https://api.github.com/repos/insomnia-lab/libreant/subscription","commits_url":"https://api.github.com/repos/insomnia-lab/libreant/commits{/sha}","git_commits_url":"https://api.github.com/repos/insomnia-lab/libreant/git/commits{/sha}","comments_url":"https://api.github.com/repos/insomnia-lab/libreant/comments{/number}","issue_comment_url":"https://api.github.com/repos/insomnia-lab/libreant/issues/comments{/number}","contents_url":"https://api.github.com/repos/insomnia-lab/libreant/contents/{+path}","compare_url":"https://api.github.com/repos/insomnia-lab/libreant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/insomnia-lab/libreant/merges","archive_url":"https://api.github.com/repos/insomnia-lab/libreant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/insomnia-lab/libreant/downloads","issues_url":"https://api.github.com/repos/insomnia-lab/libreant/issues{/number}","pulls_url":"https://api.github.com/repos/insomnia-lab/libreant/pulls{/number}","milestones_url":"https://api.github.com/repos/insomnia-lab/libreant/milestones{/number}","notifications_url":"https://api.github.com/repos/insomnia-lab/libreant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/insomnia-lab/libreant/labels{/name}","releases_url":"https://api.github.com/repos/insomnia-lab/libreant/releases{/id}","created_at":"2014-11-24T09:31:52Z","updated_at":"2015-05-26T16:28:36Z","pushed_at":"2015-11-03T08:18:28Z","git_url":"git://github.com/insomnia-lab/libreant.git","ssh_url":"git@github.com:insomnia-lab/libreant.git","clone_url":"https://github.com/insomnia-lab/libreant.git","svn_url":"https://github.com/insomnia-lab/libreant","homepage":null,"size":1492,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":43,"forks":8,"open_issues":43,"watchers":8,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209"},"html":{"href":"https://github.com/insomnia-lab/libreant/pull/209"},"issue":{"href":"https://api.github.com/repos/insomnia-lab/libreant/issues/209"},"comments":{"href":"https://api.github.com/repos/insomnia-lab/libreant/issues/209/comments"},"review_comments":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209/comments"},"review_comment":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/insomnia-lab/libreant/pulls/209/commits"},"statuses":{"href":"https://api.github.com/repos/insomnia-lab/libreant/statuses/c937840e58e625e3fd1db95b619eb3574327f099"}}}}