{"action":"created","comment":{"url":"https://api.github.com/repos/coala-analyzer/coala/pulls/comments/67625860","id":67625860,"diff_hunk":"@@ -0,0 +1,219 @@\n+import json\n+from functools import partial\n+from collections import OrderedDict\n+\n+from coalib.bears.LocalBear import LocalBear\n+from coala_decorators.decorators import enforce_signature\n+from coalib.misc.Shell import run_shell_command\n+from coalib.results.Diff import Diff\n+from coalib.results.Result import Result\n+from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY\n+from coalib.settings.FunctionMetadata import FunctionMetadata\n+\n+\n+def _prepare_options(options):\n+    \"\"\"\n+    Checks for illegal options and raises ValueError.\n+\n+    :param options:\n+        The options dict that contains user/developer inputs.\n+    :raises ValueError:\n+        Raised when illegal options are specified.\n+    \"\"\"\n+    allowed_options = {\"executable\",\n+                       \"settings\"}\n+\n+    # Check for illegal superfluous options.\n+    superfluous_options = options.keys() - allowed_options\n+    if superfluous_options:\n+        raise ValueError(\n+            \"Invalid keyword arguments provided: \" +\n+            \", \".join(repr(s) for s in sorted(superfluous_options)))\n+\n+    if not 'settings' in options:\n+        options['settings'] = {}\n+\n+\n+def _create_wrapper(klass, options):\n+    class NoDefaultValue:\n+        pass\n+\n+    class ExternalBearWrapBase(LocalBear):\n+\n+        @staticmethod\n+        def create_arguments():\n+            \"\"\"\n+            This method has to be implemented by the class that uses\n+            the decorator in order to create the arguments needed for\n+            the executable.\n+            \"\"\"\n+            return ()\n+\n+        @classmethod\n+        def get_executable(cls):\n+            \"\"\"\n+            Returns the executable of this class.\n+\n+            :return:\n+                The executable name.\n+            \"\"\"\n+            return options[\"executable\"]\n+\n+        @staticmethod\n+        def _normalize_desc(description, setting_type,\n+                            default_value=NoDefaultValue):\n+            \"\"\"\n+            Normalizes the description of the parameters only if there\n+            is none provided.\n+\n+            :param description:\n+                The parameter description to be modified in case it is empty.\n+            :param setting_type:\n+                The type of the setting. It is needed to create the final\n+                tuple.\n+            :param default_value:\n+                The default value of the setting.\n+            :return:\n+                A value for the OrderedDict in the ``FunctionMetadata`` object.\n+            \"\"\"\n+            if description == \"\":\n+                description = FunctionMetadata.str_nodesc\n+\n+            if default_value is NoDefaultValue:\n+                return (description, setting_type)\n+            else:\n+                return (description + \" \" +\n+                        FunctionMetadata.str_optional.format(default_value),\n+                        setting_type, default_value)\n+\n+        @classmethod\n+        def get_non_optional_params(cls):\n+            \"\"\"\n+            Fetches the non_optional_params from ``options['settings']``\n+            and also normalizes their descriptions.\n+\n+            :return:\n+                An OrderedDict that is used to create a\n+                ``FunctionMetadata`` object.\n+            \"\"\"\n+            non_optional_params = {}\n+            for setting_name, description in options['settings'].items():\n+                if len(description) == 2:\n+                    non_optional_params[\n+                        setting_name] = cls._normalize_desc(description[0],\n+                                                            description[1])\n+            return OrderedDict(non_optional_params)\n+\n+        @classmethod\n+        def get_optional_params(cls):\n+            \"\"\"\n+            Fetches the optional_params from ``options['settings']``\n+            and also normalizes their descriptions.\n+\n+            :return:\n+                An OrderedDict that is used to create a\n+                ``FunctionMetadata`` object.\n+            \"\"\"\n+            optional_params = {}\n+            for setting_name, description in options['settings'].items():\n+                if len(description) == 3:\n+                    optional_params[\n+                        setting_name] = cls._normalize_desc(description[0],\n+                                                            description[1],\n+                                                            description[2])\n+            return OrderedDict(optional_params)\n+\n+        @classmethod\n+        def get_metadata(cls):\n+            return FunctionMetadata(\n+                'run',\n+                optional_params=cls.get_optional_params(),\n+                non_optional_params=cls.get_non_optional_params())\n+\n+        @classmethod\n+        def _prepare_settings(cls, settings):\n+            \"\"\"\n+            Adds the optional settings to the settings dict in-place.\n+\n+            :param settings:\n+                The settings dict.\n+            \"\"\"\n+            opt_params = dict(cls.get_optional_params())","path":"coalib/bearlib/abstractions/ExternalBearWrap.py","position":140,"original_position":141,"commit_id":"fbc917cf2147d2278157655138d88e1e649afb73","original_commit_id":"e17f3071b49a9c69c7dd04bf26a61953ab12672a","user":{"login":"Makman2","id":6023916,"avatar_url":"https://avatars.githubusercontent.com/u/6023916?v=3","gravatar_id":"","url":"https://api.github.com/users/Makman2","html_url":"https://github.com/Makman2","followers_url":"https://api.github.com/users/Makman2/followers","following_url":"https://api.github.com/users/Makman2/following{/other_user}","gists_url":"https://api.github.com/users/Makman2/gists{/gist_id}","starred_url":"https://api.github.com/users/Makman2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Makman2/subscriptions","organizations_url":"https://api.github.com/users/Makman2/orgs","repos_url":"https://api.github.com/users/Makman2/repos","events_url":"https://api.github.com/users/Makman2/events{/privacy}","received_events_url":"https://api.github.com/users/Makman2/received_events","type":"User","site_admin":false},"body":"no need to create another dict^^","created_at":"2016-06-19T23:34:02Z","updated_at":"2016-06-19T23:34:02Z","html_url":"https://github.com/coala-analyzer/coala/pull/2198#discussion_r67625860","pull_request_url":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198","_links":{"self":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/comments/67625860"},"html":{"href":"https://github.com/coala-analyzer/coala/pull/2198#discussion_r67625860"},"pull_request":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198"}}},"pull_request":{"url":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198","id":71855762,"html_url":"https://github.com/coala-analyzer/coala/pull/2198","diff_url":"https://github.com/coala-analyzer/coala/pull/2198.diff","patch_url":"https://github.com/coala-analyzer/coala/pull/2198.patch","issue_url":"https://api.github.com/repos/coala-analyzer/coala/issues/2198","number":2198,"state":"open","locked":false,"title":"ExternalBearWrap: write external_bear_wrap decorator base","user":{"login":"Redridge","id":8859650,"avatar_url":"https://avatars.githubusercontent.com/u/8859650?v=3","gravatar_id":"","url":"https://api.github.com/users/Redridge","html_url":"https://github.com/Redridge","followers_url":"https://api.github.com/users/Redridge/followers","following_url":"https://api.github.com/users/Redridge/following{/other_user}","gists_url":"https://api.github.com/users/Redridge/gists{/gist_id}","starred_url":"https://api.github.com/users/Redridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Redridge/subscriptions","organizations_url":"https://api.github.com/users/Redridge/orgs","repos_url":"https://api.github.com/users/Redridge/repos","events_url":"https://api.github.com/users/Redridge/events{/privacy}","received_events_url":"https://api.github.com/users/Redridge/received_events","type":"User","site_admin":false},"body":"external_bear_wrap decorator that gets an executable name as argument.","created_at":"2016-05-30T05:59:32Z","updated_at":"2016-06-19T23:34:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a44334fdbd9839b5f0610c894970f5cac4547312","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198/commits","review_comments_url":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198/comments","review_comment_url":"https://api.github.com/repos/coala-analyzer/coala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coala-analyzer/coala/issues/2198/comments","statuses_url":"https://api.github.com/repos/coala-analyzer/coala/statuses/fbc917cf2147d2278157655138d88e1e649afb73","head":{"label":"coala-analyzer:red/ExternalBearWrap","ref":"red/ExternalBearWrap","sha":"fbc917cf2147d2278157655138d88e1e649afb73","user":{"login":"coala-analyzer","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala-analyzer","html_url":"https://github.com/coala-analyzer","followers_url":"https://api.github.com/users/coala-analyzer/followers","following_url":"https://api.github.com/users/coala-analyzer/following{/other_user}","gists_url":"https://api.github.com/users/coala-analyzer/gists{/gist_id}","starred_url":"https://api.github.com/users/coala-analyzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala-analyzer/subscriptions","organizations_url":"https://api.github.com/users/coala-analyzer/orgs","repos_url":"https://api.github.com/users/coala-analyzer/repos","events_url":"https://api.github.com/users/coala-analyzer/events{/privacy}","received_events_url":"https://api.github.com/users/coala-analyzer/received_events","type":"Organization","site_admin":false},"repo":{"id":19816973,"name":"coala","full_name":"coala-analyzer/coala","owner":{"login":"coala-analyzer","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala-analyzer","html_url":"https://github.com/coala-analyzer","followers_url":"https://api.github.com/users/coala-analyzer/followers","following_url":"https://api.github.com/users/coala-analyzer/following{/other_user}","gists_url":"https://api.github.com/users/coala-analyzer/gists{/gist_id}","starred_url":"https://api.github.com/users/coala-analyzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala-analyzer/subscriptions","organizations_url":"https://api.github.com/users/coala-analyzer/orgs","repos_url":"https://api.github.com/users/coala-analyzer/repos","events_url":"https://api.github.com/users/coala-analyzer/events{/privacy}","received_events_url":"https://api.github.com/users/coala-analyzer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coala-analyzer/coala","description":"Easy to use code analysis framework/application - yes! For all languages!","fork":false,"url":"https://api.github.com/repos/coala-analyzer/coala","forks_url":"https://api.github.com/repos/coala-analyzer/coala/forks","keys_url":"https://api.github.com/repos/coala-analyzer/coala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coala-analyzer/coala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coala-analyzer/coala/teams","hooks_url":"https://api.github.com/repos/coala-analyzer/coala/hooks","issue_events_url":"https://api.github.com/repos/coala-analyzer/coala/issues/events{/number}","events_url":"https://api.github.com/repos/coala-analyzer/coala/events","assignees_url":"https://api.github.com/repos/coala-analyzer/coala/assignees{/user}","branches_url":"https://api.github.com/repos/coala-analyzer/coala/branches{/branch}","tags_url":"https://api.github.com/repos/coala-analyzer/coala/tags","blobs_url":"https://api.github.com/repos/coala-analyzer/coala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coala-analyzer/coala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coala-analyzer/coala/git/refs{/sha}","trees_url":"https://api.github.com/repos/coala-analyzer/coala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coala-analyzer/coala/statuses/{sha}","languages_url":"https://api.github.com/repos/coala-analyzer/coala/languages","stargazers_url":"https://api.github.com/repos/coala-analyzer/coala/stargazers","contributors_url":"https://api.github.com/repos/coala-analyzer/coala/contributors","subscribers_url":"https://api.github.com/repos/coala-analyzer/coala/subscribers","subscription_url":"https://api.github.com/repos/coala-analyzer/coala/subscription","commits_url":"https://api.github.com/repos/coala-analyzer/coala/commits{/sha}","git_commits_url":"https://api.github.com/repos/coala-analyzer/coala/git/commits{/sha}","comments_url":"https://api.github.com/repos/coala-analyzer/coala/comments{/number}","issue_comment_url":"https://api.github.com/repos/coala-analyzer/coala/issues/comments{/number}","contents_url":"https://api.github.com/repos/coala-analyzer/coala/contents/{+path}","compare_url":"https://api.github.com/repos/coala-analyzer/coala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coala-analyzer/coala/merges","archive_url":"https://api.github.com/repos/coala-analyzer/coala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coala-analyzer/coala/downloads","issues_url":"https://api.github.com/repos/coala-analyzer/coala/issues{/number}","pulls_url":"https://api.github.com/repos/coala-analyzer/coala/pulls{/number}","milestones_url":"https://api.github.com/repos/coala-analyzer/coala/milestones{/number}","notifications_url":"https://api.github.com/repos/coala-analyzer/coala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coala-analyzer/coala/labels{/name}","releases_url":"https://api.github.com/repos/coala-analyzer/coala/releases{/id}","deployments_url":"https://api.github.com/repos/coala-analyzer/coala/deployments","created_at":"2014-05-15T11:35:34Z","updated_at":"2016-06-19T15:46:07Z","pushed_at":"2016-06-19T23:33:08Z","git_url":"git://github.com/coala-analyzer/coala.git","ssh_url":"git@github.com:coala-analyzer/coala.git","clone_url":"https://github.com/coala-analyzer/coala.git","svn_url":"https://github.com/coala-analyzer/coala","homepage":"http://coala-analyzer.org/","size":11956,"stargazers_count":224,"watchers_count":224,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":144,"mirror_url":null,"open_issues_count":202,"forks":144,"open_issues":202,"watchers":224,"default_branch":"master"}},"base":{"label":"coala-analyzer:master","ref":"master","sha":"4919317ea8232408f293582d9d850c73f97b6199","user":{"login":"coala-analyzer","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala-analyzer","html_url":"https://github.com/coala-analyzer","followers_url":"https://api.github.com/users/coala-analyzer/followers","following_url":"https://api.github.com/users/coala-analyzer/following{/other_user}","gists_url":"https://api.github.com/users/coala-analyzer/gists{/gist_id}","starred_url":"https://api.github.com/users/coala-analyzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala-analyzer/subscriptions","organizations_url":"https://api.github.com/users/coala-analyzer/orgs","repos_url":"https://api.github.com/users/coala-analyzer/repos","events_url":"https://api.github.com/users/coala-analyzer/events{/privacy}","received_events_url":"https://api.github.com/users/coala-analyzer/received_events","type":"Organization","site_admin":false},"repo":{"id":19816973,"name":"coala","full_name":"coala-analyzer/coala","owner":{"login":"coala-analyzer","id":10620750,"avatar_url":"https://avatars.githubusercontent.com/u/10620750?v=3","gravatar_id":"","url":"https://api.github.com/users/coala-analyzer","html_url":"https://github.com/coala-analyzer","followers_url":"https://api.github.com/users/coala-analyzer/followers","following_url":"https://api.github.com/users/coala-analyzer/following{/other_user}","gists_url":"https://api.github.com/users/coala-analyzer/gists{/gist_id}","starred_url":"https://api.github.com/users/coala-analyzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coala-analyzer/subscriptions","organizations_url":"https://api.github.com/users/coala-analyzer/orgs","repos_url":"https://api.github.com/users/coala-analyzer/repos","events_url":"https://api.github.com/users/coala-analyzer/events{/privacy}","received_events_url":"https://api.github.com/users/coala-analyzer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coala-analyzer/coala","description":"Easy to use code analysis framework/application - yes! For all languages!","fork":false,"url":"https://api.github.com/repos/coala-analyzer/coala","forks_url":"https://api.github.com/repos/coala-analyzer/coala/forks","keys_url":"https://api.github.com/repos/coala-analyzer/coala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coala-analyzer/coala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coala-analyzer/coala/teams","hooks_url":"https://api.github.com/repos/coala-analyzer/coala/hooks","issue_events_url":"https://api.github.com/repos/coala-analyzer/coala/issues/events{/number}","events_url":"https://api.github.com/repos/coala-analyzer/coala/events","assignees_url":"https://api.github.com/repos/coala-analyzer/coala/assignees{/user}","branches_url":"https://api.github.com/repos/coala-analyzer/coala/branches{/branch}","tags_url":"https://api.github.com/repos/coala-analyzer/coala/tags","blobs_url":"https://api.github.com/repos/coala-analyzer/coala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coala-analyzer/coala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coala-analyzer/coala/git/refs{/sha}","trees_url":"https://api.github.com/repos/coala-analyzer/coala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coala-analyzer/coala/statuses/{sha}","languages_url":"https://api.github.com/repos/coala-analyzer/coala/languages","stargazers_url":"https://api.github.com/repos/coala-analyzer/coala/stargazers","contributors_url":"https://api.github.com/repos/coala-analyzer/coala/contributors","subscribers_url":"https://api.github.com/repos/coala-analyzer/coala/subscribers","subscription_url":"https://api.github.com/repos/coala-analyzer/coala/subscription","commits_url":"https://api.github.com/repos/coala-analyzer/coala/commits{/sha}","git_commits_url":"https://api.github.com/repos/coala-analyzer/coala/git/commits{/sha}","comments_url":"https://api.github.com/repos/coala-analyzer/coala/comments{/number}","issue_comment_url":"https://api.github.com/repos/coala-analyzer/coala/issues/comments{/number}","contents_url":"https://api.github.com/repos/coala-analyzer/coala/contents/{+path}","compare_url":"https://api.github.com/repos/coala-analyzer/coala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coala-analyzer/coala/merges","archive_url":"https://api.github.com/repos/coala-analyzer/coala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coala-analyzer/coala/downloads","issues_url":"https://api.github.com/repos/coala-analyzer/coala/issues{/number}","pulls_url":"https://api.github.com/repos/coala-analyzer/coala/pulls{/number}","milestones_url":"https://api.github.com/repos/coala-analyzer/coala/milestones{/number}","notifications_url":"https://api.github.com/repos/coala-analyzer/coala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coala-analyzer/coala/labels{/name}","releases_url":"https://api.github.com/repos/coala-analyzer/coala/releases{/id}","deployments_url":"https://api.github.com/repos/coala-analyzer/coala/deployments","created_at":"2014-05-15T11:35:34Z","updated_at":"2016-06-19T15:46:07Z","pushed_at":"2016-06-19T23:33:08Z","git_url":"git://github.com/coala-analyzer/coala.git","ssh_url":"git@github.com:coala-analyzer/coala.git","clone_url":"https://github.com/coala-analyzer/coala.git","svn_url":"https://github.com/coala-analyzer/coala","homepage":"http://coala-analyzer.org/","size":11956,"stargazers_count":224,"watchers_count":224,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":144,"mirror_url":null,"open_issues_count":202,"forks":144,"open_issues":202,"watchers":224,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198"},"html":{"href":"https://github.com/coala-analyzer/coala/pull/2198"},"issue":{"href":"https://api.github.com/repos/coala-analyzer/coala/issues/2198"},"comments":{"href":"https://api.github.com/repos/coala-analyzer/coala/issues/2198/comments"},"review_comments":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198/comments"},"review_comment":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coala-analyzer/coala/pulls/2198/commits"},"statuses":{"href":"https://api.github.com/repos/coala-analyzer/coala/statuses/fbc917cf2147d2278157655138d88e1e649afb73"}}}}
{"actor":{"display_login":"Makman2"}}