{"action":"created","comment":{"url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/comments/206825318","pull_request_review_id":142308959,"id":206825318,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjgyNTMxOA==","diff_hunk":"@@ -0,0 +1,258 @@\n+import os\n+import sys\n+import logging\n+import importlib\n+\n+from django.core.management.base import BaseCommand, CommandError\n+\n+from library.models import (WorkType, WorkAlternativeTitle, Work)\n+\n+from .feed_components import default_work_parser\n+\n+# get logger\n+logger = logging.getLogger(__name__)\n+\n+\n+class WorkCreator:\n+    \"\"\"Work creator and updater. Create and update works in the\n+    database provided a work file and a parser.\n+\n+    Args:\n+        work_file (str): Absolute path of the file storing the works data.\n+        parser (module): Custom python module used to extract data from file.\n+        dry_run (bool): Run script in test mode.\n+\n+    About parser:\n+        This module should define a method called `parse_work` which takes\n+        a file path as argument and return a dictionnary with the following:\n+            works (dict): keys are a query name worktype, values are\n+            a list such that each element of this list is a dictionnary with\n+            the following keys:\n+                    title (str): title of the work\n+                    subtitle (str): subtitle of the work\n+                    alternative_titles (list): list of alternative names of\n+                    a work\n+    \"\"\"\n+    def __init__(\n+            self,\n+            work_file,\n+            parser,\n+            debug):\n+        self.work_file = work_file\n+        self.parser = parser\n+        self.debug = debug\n+\n+    def remove_incorrect_works(self, work_listing):\n+        \"\"\"Remove works that have an incorrect structure in a list of works.\n+\n+        Return\n+            A new list with the incorrect works removed.\"\"\"\n+\n+        work_to_remove = []\n+\n+        logger.debug(\"Removing the incorrect work from the current work type.\")\n+        for dict_work in work_listing:\n+\n+            # check if it is a dictionary\n+            if not isinstance(dict_work, dict):\n+                work_to_remove.append(dict_work)\n+                logger.debug(\"Incorrect work : value is not a dictionary.\")\n+                continue\n+\n+            # check if it has a title field\n+            work_title = dict_work.get('title')\n+            if not work_title:\n+                work_to_remove.append(dict_work)\n+                logger.debug(\"Incorrect work : no title field found\")","path":"dakara_server/library/management/commands/createworks.py","position":66,"original_position":66,"commit_id":"18ea96325c6f371a6c74e11cd9625bbfbf4f2393","original_commit_id":"18ea96325c6f371a6c74e11cd9625bbfbf4f2393","user":{"login":"Neraste","id":1684705,"node_id":"MDQ6VXNlcjE2ODQ3MDU=","avatar_url":"https://avatars0.githubusercontent.com/u/1684705?v=4","gravatar_id":"","url":"https://api.github.com/users/Neraste","html_url":"https://github.com/Neraste","followers_url":"https://api.github.com/users/Neraste/followers","following_url":"https://api.github.com/users/Neraste/following{/other_user}","gists_url":"https://api.github.com/users/Neraste/gists{/gist_id}","starred_url":"https://api.github.com/users/Neraste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Neraste/subscriptions","organizations_url":"https://api.github.com/users/Neraste/orgs","repos_url":"https://api.github.com/users/Neraste/repos","events_url":"https://api.github.com/users/Neraste/events{/privacy}","received_events_url":"https://api.github.com/users/Neraste/received_events","type":"User","site_admin":false},"body":"Same as above.","created_at":"2018-08-01T10:14:08Z","updated_at":"2018-08-01T10:47:17Z","html_url":"https://github.com/DakaraProject/dakara-server/pull/69#discussion_r206825318","pull_request_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/comments/206825318"},"html":{"href":"https://github.com/DakaraProject/dakara-server/pull/69#discussion_r206825318"},"pull_request":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69","id":203018178,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDE4MTc4","html_url":"https://github.com/DakaraProject/dakara-server/pull/69","diff_url":"https://github.com/DakaraProject/dakara-server/pull/69.diff","patch_url":"https://github.com/DakaraProject/dakara-server/pull/69.patch","issue_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/69","number":69,"state":"open","locked":false,"title":"Createworks command","user":{"login":"Benstales","id":34867067,"node_id":"MDQ6VXNlcjM0ODY3MDY3","avatar_url":"https://avatars0.githubusercontent.com/u/34867067?v=4","gravatar_id":"","url":"https://api.github.com/users/Benstales","html_url":"https://github.com/Benstales","followers_url":"https://api.github.com/users/Benstales/followers","following_url":"https://api.github.com/users/Benstales/following{/other_user}","gists_url":"https://api.github.com/users/Benstales/gists{/gist_id}","starred_url":"https://api.github.com/users/Benstales/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Benstales/subscriptions","organizations_url":"https://api.github.com/users/Benstales/orgs","repos_url":"https://api.github.com/users/Benstales/repos","events_url":"https://api.github.com/users/Benstales/events{/privacy}","received_events_url":"https://api.github.com/users/Benstales/received_events","type":"User","site_admin":false},"body":"The createworks command allows the user to create and update works with their alternative titles associated.\r\n\r\n- Add a createworks.py in the command folder for library management.\r\n- Add tests_command_createworks.py to test the command.\r\n- Add a default parser for JSON file.\r\n\r\nAn idea of the JSON structure required for the default parser is in the tests_command_createworks.py.","created_at":"2018-07-21T17:04:06Z","updated_at":"2018-08-01T10:47:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"242b672eef1b057b8c6c32001ad49f576c6ddbd8","assignee":{"login":"Benstales","id":34867067,"node_id":"MDQ6VXNlcjM0ODY3MDY3","avatar_url":"https://avatars0.githubusercontent.com/u/34867067?v=4","gravatar_id":"","url":"https://api.github.com/users/Benstales","html_url":"https://github.com/Benstales","followers_url":"https://api.github.com/users/Benstales/followers","following_url":"https://api.github.com/users/Benstales/following{/other_user}","gists_url":"https://api.github.com/users/Benstales/gists{/gist_id}","starred_url":"https://api.github.com/users/Benstales/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Benstales/subscriptions","organizations_url":"https://api.github.com/users/Benstales/orgs","repos_url":"https://api.github.com/users/Benstales/repos","events_url":"https://api.github.com/users/Benstales/events{/privacy}","received_events_url":"https://api.github.com/users/Benstales/received_events","type":"User","site_admin":false},"assignees":[{"login":"Benstales","id":34867067,"node_id":"MDQ6VXNlcjM0ODY3MDY3","avatar_url":"https://avatars0.githubusercontent.com/u/34867067?v=4","gravatar_id":"","url":"https://api.github.com/users/Benstales","html_url":"https://github.com/Benstales","followers_url":"https://api.github.com/users/Benstales/followers","following_url":"https://api.github.com/users/Benstales/following{/other_user}","gists_url":"https://api.github.com/users/Benstales/gists{/gist_id}","starred_url":"https://api.github.com/users/Benstales/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Benstales/subscriptions","organizations_url":"https://api.github.com/users/Benstales/orgs","repos_url":"https://api.github.com/users/Benstales/repos","events_url":"https://api.github.com/users/Benstales/events{/privacy}","received_events_url":"https://api.github.com/users/Benstales/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":299056800,"node_id":"MDU6TGFiZWwyOTkwNTY4MDA=","url":"https://api.github.com/repos/DakaraProject/dakara-server/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69/commits","review_comments_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69/comments","review_comment_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/69/comments","statuses_url":"https://api.github.com/repos/DakaraProject/dakara-server/statuses/18ea96325c6f371a6c74e11cd9625bbfbf4f2393","head":{"label":"DakaraProject:feature/alternative_feeder","ref":"feature/alternative_feeder","sha":"18ea96325c6f371a6c74e11cd9625bbfbf4f2393","user":{"login":"DakaraProject","id":33006350,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDA2MzUw","avatar_url":"https://avatars0.githubusercontent.com/u/33006350?v=4","gravatar_id":"","url":"https://api.github.com/users/DakaraProject","html_url":"https://github.com/DakaraProject","followers_url":"https://api.github.com/users/DakaraProject/followers","following_url":"https://api.github.com/users/DakaraProject/following{/other_user}","gists_url":"https://api.github.com/users/DakaraProject/gists{/gist_id}","starred_url":"https://api.github.com/users/DakaraProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DakaraProject/subscriptions","organizations_url":"https://api.github.com/users/DakaraProject/orgs","repos_url":"https://api.github.com/users/DakaraProject/repos","events_url":"https://api.github.com/users/DakaraProject/events{/privacy}","received_events_url":"https://api.github.com/users/DakaraProject/received_events","type":"Organization","site_admin":false},"repo":{"id":47922096,"node_id":"MDEwOlJlcG9zaXRvcnk0NzkyMjA5Ng==","name":"dakara-server","full_name":"DakaraProject/dakara-server","owner":{"login":"DakaraProject","id":33006350,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDA2MzUw","avatar_url":"https://avatars0.githubusercontent.com/u/33006350?v=4","gravatar_id":"","url":"https://api.github.com/users/DakaraProject","html_url":"https://github.com/DakaraProject","followers_url":"https://api.github.com/users/DakaraProject/followers","following_url":"https://api.github.com/users/DakaraProject/following{/other_user}","gists_url":"https://api.github.com/users/DakaraProject/gists{/gist_id}","starred_url":"https://api.github.com/users/DakaraProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DakaraProject/subscriptions","organizations_url":"https://api.github.com/users/DakaraProject/orgs","repos_url":"https://api.github.com/users/DakaraProject/repos","events_url":"https://api.github.com/users/DakaraProject/events{/privacy}","received_events_url":"https://api.github.com/users/DakaraProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DakaraProject/dakara-server","description":"Dakara","fork":false,"url":"https://api.github.com/repos/DakaraProject/dakara-server","forks_url":"https://api.github.com/repos/DakaraProject/dakara-server/forks","keys_url":"https://api.github.com/repos/DakaraProject/dakara-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DakaraProject/dakara-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DakaraProject/dakara-server/teams","hooks_url":"https://api.github.com/repos/DakaraProject/dakara-server/hooks","issue_events_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/events{/number}","events_url":"https://api.github.com/repos/DakaraProject/dakara-server/events","assignees_url":"https://api.github.com/repos/DakaraProject/dakara-server/assignees{/user}","branches_url":"https://api.github.com/repos/DakaraProject/dakara-server/branches{/branch}","tags_url":"https://api.github.com/repos/DakaraProject/dakara-server/tags","blobs_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DakaraProject/dakara-server/statuses/{sha}","languages_url":"https://api.github.com/repos/DakaraProject/dakara-server/languages","stargazers_url":"https://api.github.com/repos/DakaraProject/dakara-server/stargazers","contributors_url":"https://api.github.com/repos/DakaraProject/dakara-server/contributors","subscribers_url":"https://api.github.com/repos/DakaraProject/dakara-server/subscribers","subscription_url":"https://api.github.com/repos/DakaraProject/dakara-server/subscription","commits_url":"https://api.github.com/repos/DakaraProject/dakara-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/DakaraProject/dakara-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/DakaraProject/dakara-server/contents/{+path}","compare_url":"https://api.github.com/repos/DakaraProject/dakara-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DakaraProject/dakara-server/merges","archive_url":"https://api.github.com/repos/DakaraProject/dakara-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DakaraProject/dakara-server/downloads","issues_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues{/number}","pulls_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls{/number}","milestones_url":"https://api.github.com/repos/DakaraProject/dakara-server/milestones{/number}","notifications_url":"https://api.github.com/repos/DakaraProject/dakara-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DakaraProject/dakara-server/labels{/name}","releases_url":"https://api.github.com/repos/DakaraProject/dakara-server/releases{/id}","deployments_url":"https://api.github.com/repos/DakaraProject/dakara-server/deployments","created_at":"2015-12-13T14:20:06Z","updated_at":"2018-07-24T18:22:15Z","pushed_at":"2018-07-30T20:18:36Z","git_url":"git://github.com/DakaraProject/dakara-server.git","ssh_url":"git@github.com:DakaraProject/dakara-server.git","clone_url":"https://github.com/DakaraProject/dakara-server.git","svn_url":"https://github.com/DakaraProject/dakara-server","homepage":"","size":709,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":11,"watchers":2,"default_branch":"develop"}},"base":{"label":"DakaraProject:develop","ref":"develop","sha":"b7b11cc0fd9605a4312d6ed36b20f97954b8d5b0","user":{"login":"DakaraProject","id":33006350,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDA2MzUw","avatar_url":"https://avatars0.githubusercontent.com/u/33006350?v=4","gravatar_id":"","url":"https://api.github.com/users/DakaraProject","html_url":"https://github.com/DakaraProject","followers_url":"https://api.github.com/users/DakaraProject/followers","following_url":"https://api.github.com/users/DakaraProject/following{/other_user}","gists_url":"https://api.github.com/users/DakaraProject/gists{/gist_id}","starred_url":"https://api.github.com/users/DakaraProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DakaraProject/subscriptions","organizations_url":"https://api.github.com/users/DakaraProject/orgs","repos_url":"https://api.github.com/users/DakaraProject/repos","events_url":"https://api.github.com/users/DakaraProject/events{/privacy}","received_events_url":"https://api.github.com/users/DakaraProject/received_events","type":"Organization","site_admin":false},"repo":{"id":47922096,"node_id":"MDEwOlJlcG9zaXRvcnk0NzkyMjA5Ng==","name":"dakara-server","full_name":"DakaraProject/dakara-server","owner":{"login":"DakaraProject","id":33006350,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMDA2MzUw","avatar_url":"https://avatars0.githubusercontent.com/u/33006350?v=4","gravatar_id":"","url":"https://api.github.com/users/DakaraProject","html_url":"https://github.com/DakaraProject","followers_url":"https://api.github.com/users/DakaraProject/followers","following_url":"https://api.github.com/users/DakaraProject/following{/other_user}","gists_url":"https://api.github.com/users/DakaraProject/gists{/gist_id}","starred_url":"https://api.github.com/users/DakaraProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DakaraProject/subscriptions","organizations_url":"https://api.github.com/users/DakaraProject/orgs","repos_url":"https://api.github.com/users/DakaraProject/repos","events_url":"https://api.github.com/users/DakaraProject/events{/privacy}","received_events_url":"https://api.github.com/users/DakaraProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DakaraProject/dakara-server","description":"Dakara","fork":false,"url":"https://api.github.com/repos/DakaraProject/dakara-server","forks_url":"https://api.github.com/repos/DakaraProject/dakara-server/forks","keys_url":"https://api.github.com/repos/DakaraProject/dakara-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DakaraProject/dakara-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DakaraProject/dakara-server/teams","hooks_url":"https://api.github.com/repos/DakaraProject/dakara-server/hooks","issue_events_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/events{/number}","events_url":"https://api.github.com/repos/DakaraProject/dakara-server/events","assignees_url":"https://api.github.com/repos/DakaraProject/dakara-server/assignees{/user}","branches_url":"https://api.github.com/repos/DakaraProject/dakara-server/branches{/branch}","tags_url":"https://api.github.com/repos/DakaraProject/dakara-server/tags","blobs_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DakaraProject/dakara-server/statuses/{sha}","languages_url":"https://api.github.com/repos/DakaraProject/dakara-server/languages","stargazers_url":"https://api.github.com/repos/DakaraProject/dakara-server/stargazers","contributors_url":"https://api.github.com/repos/DakaraProject/dakara-server/contributors","subscribers_url":"https://api.github.com/repos/DakaraProject/dakara-server/subscribers","subscription_url":"https://api.github.com/repos/DakaraProject/dakara-server/subscription","commits_url":"https://api.github.com/repos/DakaraProject/dakara-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/DakaraProject/dakara-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/DakaraProject/dakara-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/DakaraProject/dakara-server/contents/{+path}","compare_url":"https://api.github.com/repos/DakaraProject/dakara-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DakaraProject/dakara-server/merges","archive_url":"https://api.github.com/repos/DakaraProject/dakara-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DakaraProject/dakara-server/downloads","issues_url":"https://api.github.com/repos/DakaraProject/dakara-server/issues{/number}","pulls_url":"https://api.github.com/repos/DakaraProject/dakara-server/pulls{/number}","milestones_url":"https://api.github.com/repos/DakaraProject/dakara-server/milestones{/number}","notifications_url":"https://api.github.com/repos/DakaraProject/dakara-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DakaraProject/dakara-server/labels{/name}","releases_url":"https://api.github.com/repos/DakaraProject/dakara-server/releases{/id}","deployments_url":"https://api.github.com/repos/DakaraProject/dakara-server/deployments","created_at":"2015-12-13T14:20:06Z","updated_at":"2018-07-24T18:22:15Z","pushed_at":"2018-07-30T20:18:36Z","git_url":"git://github.com/DakaraProject/dakara-server.git","ssh_url":"git@github.com:DakaraProject/dakara-server.git","clone_url":"https://github.com/DakaraProject/dakara-server.git","svn_url":"https://github.com/DakaraProject/dakara-server","homepage":"","size":709,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":11,"watchers":2,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69"},"html":{"href":"https://github.com/DakaraProject/dakara-server/pull/69"},"issue":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/issues/69"},"comments":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/DakaraProject/dakara-server/statuses/18ea96325c6f371a6c74e11cd9625bbfbf4f2393"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Neraste"}}