{"action":"created","comment":{"url":"https://api.github.com/repos/ESSS/hookman/pulls/comments/200186061","pull_request_review_id":134452782,"id":200186061,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDE4NjA2MQ==","diff_hunk":"@@ -0,0 +1,265 @@\n+import importlib\r\n+import inspect\r\n+import os\r\n+from pathlib import Path\r\n+from textwrap import dedent\r\n+from typing import List, NamedTuple\r\n+\r\n+from hookman.hooks import HooksSpecs\r\n+\r\n+INDENTATION = \"    \"\r\n+NEW_LINE = \"\\n\"\r\n+\r\n+\r\n+class Hook(NamedTuple):\r\n+    \"\"\"\r\n+    Class to assist on the process to generate the files\r\n+\r\n+    name: Name of the Hook\r\n+    macro_name: Name of the Hook in Upper Case\r\n+    r_type: Type of the return from the hook\r\n+\r\n+    args: The name of each argument\r\n+        Ex.: v1, v2, v3\r\n+    args_type: The type of each argument\r\n+        Ex.: int, float, int\r\n+    args_with_type: The name of the argument with the type\r\n+        Ex.: int v1, float v2, int v3\r\n+\r\n+    function_name: Full name of the hook function\r\n+        Ex.: project_name_version_hook_name -> alfasim_v4_friction_factory\r\n+    \"\"\"\r\n+    name: str\r\n+    macro_name: str\r\n+    r_type: str\r\n+    args: str\r\n+    args_type: str\r\n+    args_with_type: str\r\n+    function_name: str\r\n+\r\n+\r\n+class HookManGenerator():\r\n+    \"\"\"\r\n+    Class to assist in the process of creating necessary files for the hookman\r\n+    \"\"\"\r\n+\r\n+    def __init__(self, hook_spec_file_path: Path) -> None:\r\n+        \"\"\"\r\n+        Receives a path to a hooks specification file.\r\n+        if the Path provided is not a file an exception FileNotFoundError is raised.\r\n+        If the File provided doesn't have a spec object, a RuntimeError is raised.\r\n+        \"\"\"\r\n+        if hook_spec_file_path.is_file():\r\n+            hook_spec_module = self._import_hook_specification_file(hook_spec_file_path)\r\n+            self._populate_local_variables(hook_spec_module.specs)\r\n+        else:\r\n+            raise FileNotFoundError(\"You must inform a file.\")\r\n+\r\n+    def _import_hook_specification_file(self, hook_spec_file_path: Path) -> HooksSpecs:\r\n+        \"\"\"\r\n+        Returns the \"HooksSpecs\" object that defines the hook specification provide from the project.\r\n+        The file is considered valid if the importlib can access the object called \"specs\"\r\n+\r\n+        :param hook_spec_file_path: Path to the location of the file\r\n+        :return: A Python module that represent specification from the given file\r\n+        \"\"\"\r\n+        spec = importlib.util.spec_from_file_location('hook_specs', hook_spec_file_path)\r\n+        module = importlib.util.module_from_spec(spec)\r\n+        spec.loader.exec_module(module)\r\n+        try:\r\n+            getattr(module, 'specs')\r\n+        except AttributeError:\r\n+            raise RuntimeError(\"Invalid file, specs not defined.\")\r\n+\r\n+        return module\r\n+\r\n+    def _populate_local_variables(self, hook_specs: HooksSpecs):\r\n+        \"\"\"\r\n+        Populate the self.hooks property with the given hook specification.\r\n+        See the docstring from the Hook type for more details about the self.hooks\r\n+        \"\"\"\r\n+        self.project_name = hook_specs.project_name.lower()\r\n+        self.pyd_name = hook_specs.pyd_name\r\n+        self.version = f'v{hook_specs.version}'\r\n+\r\n+        def format_arguments(text_list: List[str]) -> str:\r\n+            \"\"\"\r\n+            Format the REPR from the args list (\"['v1', 'v2']\") to an acceptable format (\"v1, v2\")\r\n+            \"\"\"\r\n+            text = str(text_list)\r\n+            return text.replace('[', '').replace(']', '').replace('\\'', '')\r\n+\r\n+        self.hooks = []\r\n+        for hook_spec in hook_specs.hooks:\r\n+            hook_arg_spec = inspect.getfullargspec(hook_spec)\r\n+            hook_arguments = hook_arg_spec.args\r\n+            hook_types = hook_arg_spec.annotations\r\n+            self.hooks.append(\r\n+                Hook(\r\n+                    name=hook_spec.__name__.lower(),\r\n+                    macro_name=hook_spec.__name__.upper(),\r\n+                    r_type=hook_arg_spec.annotations['return'],\r\n+                    args=format_arguments(hook_arguments),\r","path":"hookman/hook_man_generator.py","position":102,"original_position":102,"commit_id":"94d180915ed6657c2519a02b61acf667dd083b55","original_commit_id":"e2308b3492d0c7ebd6b647c4c65098139f931fc0","user":{"login":"williamjamir","id":5083518,"node_id":"MDQ6VXNlcjUwODM1MTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5083518?v=4","gravatar_id":"","url":"https://api.github.com/users/williamjamir","html_url":"https://github.com/williamjamir","followers_url":"https://api.github.com/users/williamjamir/followers","following_url":"https://api.github.com/users/williamjamir/following{/other_user}","gists_url":"https://api.github.com/users/williamjamir/gists{/gist_id}","starred_url":"https://api.github.com/users/williamjamir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williamjamir/subscriptions","organizations_url":"https://api.github.com/users/williamjamir/orgs","repos_url":"https://api.github.com/users/williamjamir/repos","events_url":"https://api.github.com/users/williamjamir/events{/privacy}","received_events_url":"https://api.github.com/users/williamjamir/received_events","type":"User","site_admin":false},"body":"- [ ] Check what needs to be done","created_at":"2018-07-04T18:31:01Z","updated_at":"2018-07-04T18:31:01Z","html_url":"https://github.com/ESSS/hookman/pull/1#discussion_r200186061","pull_request_url":"https://api.github.com/repos/ESSS/hookman/pulls/1","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/comments/200186061"},"html":{"href":"https://github.com/ESSS/hookman/pull/1#discussion_r200186061"},"pull_request":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/1"}},"in_reply_to_id":199775365},"pull_request":{"url":"https://api.github.com/repos/ESSS/hookman/pulls/1","id":198768358,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NzY4MzU4","html_url":"https://github.com/ESSS/hookman/pull/1","diff_url":"https://github.com/ESSS/hookman/pull/1.diff","patch_url":"https://github.com/ESSS/hookman/pull/1.patch","issue_url":"https://api.github.com/repos/ESSS/hookman/issues/1","number":1,"state":"open","locked":false,"title":"Add hookman generator","user":{"login":"williamjamir","id":5083518,"node_id":"MDQ6VXNlcjUwODM1MTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5083518?v=4","gravatar_id":"","url":"https://api.github.com/users/williamjamir","html_url":"https://github.com/williamjamir","followers_url":"https://api.github.com/users/williamjamir/followers","following_url":"https://api.github.com/users/williamjamir/following{/other_user}","gists_url":"https://api.github.com/users/williamjamir/gists{/gist_id}","starred_url":"https://api.github.com/users/williamjamir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williamjamir/subscriptions","organizations_url":"https://api.github.com/users/williamjamir/orgs","repos_url":"https://api.github.com/users/williamjamir/repos","events_url":"https://api.github.com/users/williamjamir/events{/privacy}","received_events_url":"https://api.github.com/users/williamjamir/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-02T19:26:04Z","updated_at":"2018-07-04T18:31:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b9e75c6e923a86be38906e98d01416cf96b9c77","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ESSS/hookman/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ESSS/hookman/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ESSS/hookman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ESSS/hookman/issues/1/comments","statuses_url":"https://api.github.com/repos/ESSS/hookman/statuses/94d180915ed6657c2519a02b61acf667dd083b55","head":{"label":"ESSS:add-hookman","ref":"add-hookman","sha":"94d180915ed6657c2519a02b61acf667dd083b55","user":{"login":"ESSS","id":1074769,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNzQ3Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/1074769?v=4","gravatar_id":"","url":"https://api.github.com/users/ESSS","html_url":"https://github.com/ESSS","followers_url":"https://api.github.com/users/ESSS/followers","following_url":"https://api.github.com/users/ESSS/following{/other_user}","gists_url":"https://api.github.com/users/ESSS/gists{/gist_id}","starred_url":"https://api.github.com/users/ESSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESSS/subscriptions","organizations_url":"https://api.github.com/users/ESSS/orgs","repos_url":"https://api.github.com/users/ESSS/repos","events_url":"https://api.github.com/users/ESSS/events{/privacy}","received_events_url":"https://api.github.com/users/ESSS/received_events","type":"Organization","site_admin":false},"repo":{"id":139453138,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk0NTMxMzg=","name":"hookman","full_name":"ESSS/hookman","owner":{"login":"ESSS","id":1074769,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNzQ3Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/1074769?v=4","gravatar_id":"","url":"https://api.github.com/users/ESSS","html_url":"https://github.com/ESSS","followers_url":"https://api.github.com/users/ESSS/followers","following_url":"https://api.github.com/users/ESSS/following{/other_user}","gists_url":"https://api.github.com/users/ESSS/gists{/gist_id}","starred_url":"https://api.github.com/users/ESSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESSS/subscriptions","organizations_url":"https://api.github.com/users/ESSS/orgs","repos_url":"https://api.github.com/users/ESSS/repos","events_url":"https://api.github.com/users/ESSS/events{/privacy}","received_events_url":"https://api.github.com/users/ESSS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ESSS/hookman","description":null,"fork":false,"url":"https://api.github.com/repos/ESSS/hookman","forks_url":"https://api.github.com/repos/ESSS/hookman/forks","keys_url":"https://api.github.com/repos/ESSS/hookman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ESSS/hookman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ESSS/hookman/teams","hooks_url":"https://api.github.com/repos/ESSS/hookman/hooks","issue_events_url":"https://api.github.com/repos/ESSS/hookman/issues/events{/number}","events_url":"https://api.github.com/repos/ESSS/hookman/events","assignees_url":"https://api.github.com/repos/ESSS/hookman/assignees{/user}","branches_url":"https://api.github.com/repos/ESSS/hookman/branches{/branch}","tags_url":"https://api.github.com/repos/ESSS/hookman/tags","blobs_url":"https://api.github.com/repos/ESSS/hookman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ESSS/hookman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ESSS/hookman/git/refs{/sha}","trees_url":"https://api.github.com/repos/ESSS/hookman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ESSS/hookman/statuses/{sha}","languages_url":"https://api.github.com/repos/ESSS/hookman/languages","stargazers_url":"https://api.github.com/repos/ESSS/hookman/stargazers","contributors_url":"https://api.github.com/repos/ESSS/hookman/contributors","subscribers_url":"https://api.github.com/repos/ESSS/hookman/subscribers","subscription_url":"https://api.github.com/repos/ESSS/hookman/subscription","commits_url":"https://api.github.com/repos/ESSS/hookman/commits{/sha}","git_commits_url":"https://api.github.com/repos/ESSS/hookman/git/commits{/sha}","comments_url":"https://api.github.com/repos/ESSS/hookman/comments{/number}","issue_comment_url":"https://api.github.com/repos/ESSS/hookman/issues/comments{/number}","contents_url":"https://api.github.com/repos/ESSS/hookman/contents/{+path}","compare_url":"https://api.github.com/repos/ESSS/hookman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ESSS/hookman/merges","archive_url":"https://api.github.com/repos/ESSS/hookman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ESSS/hookman/downloads","issues_url":"https://api.github.com/repos/ESSS/hookman/issues{/number}","pulls_url":"https://api.github.com/repos/ESSS/hookman/pulls{/number}","milestones_url":"https://api.github.com/repos/ESSS/hookman/milestones{/number}","notifications_url":"https://api.github.com/repos/ESSS/hookman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ESSS/hookman/labels{/name}","releases_url":"https://api.github.com/repos/ESSS/hookman/releases{/id}","deployments_url":"https://api.github.com/repos/ESSS/hookman/deployments","created_at":"2018-07-02T14:16:32Z","updated_at":"2018-07-02T15:59:54Z","pushed_at":"2018-07-04T17:54:44Z","git_url":"git://github.com/ESSS/hookman.git","ssh_url":"git@github.com:ESSS/hookman.git","clone_url":"https://github.com/ESSS/hookman.git","svn_url":"https://github.com/ESSS/hookman","homepage":null,"size":31,"stargazers_count":0,"watchers_count":0,"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":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ESSS:master","ref":"master","sha":"58988eb2c5c85662ba8ae316207c2bba0bebc7b3","user":{"login":"ESSS","id":1074769,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNzQ3Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/1074769?v=4","gravatar_id":"","url":"https://api.github.com/users/ESSS","html_url":"https://github.com/ESSS","followers_url":"https://api.github.com/users/ESSS/followers","following_url":"https://api.github.com/users/ESSS/following{/other_user}","gists_url":"https://api.github.com/users/ESSS/gists{/gist_id}","starred_url":"https://api.github.com/users/ESSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESSS/subscriptions","organizations_url":"https://api.github.com/users/ESSS/orgs","repos_url":"https://api.github.com/users/ESSS/repos","events_url":"https://api.github.com/users/ESSS/events{/privacy}","received_events_url":"https://api.github.com/users/ESSS/received_events","type":"Organization","site_admin":false},"repo":{"id":139453138,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk0NTMxMzg=","name":"hookman","full_name":"ESSS/hookman","owner":{"login":"ESSS","id":1074769,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNzQ3Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/1074769?v=4","gravatar_id":"","url":"https://api.github.com/users/ESSS","html_url":"https://github.com/ESSS","followers_url":"https://api.github.com/users/ESSS/followers","following_url":"https://api.github.com/users/ESSS/following{/other_user}","gists_url":"https://api.github.com/users/ESSS/gists{/gist_id}","starred_url":"https://api.github.com/users/ESSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ESSS/subscriptions","organizations_url":"https://api.github.com/users/ESSS/orgs","repos_url":"https://api.github.com/users/ESSS/repos","events_url":"https://api.github.com/users/ESSS/events{/privacy}","received_events_url":"https://api.github.com/users/ESSS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ESSS/hookman","description":null,"fork":false,"url":"https://api.github.com/repos/ESSS/hookman","forks_url":"https://api.github.com/repos/ESSS/hookman/forks","keys_url":"https://api.github.com/repos/ESSS/hookman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ESSS/hookman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ESSS/hookman/teams","hooks_url":"https://api.github.com/repos/ESSS/hookman/hooks","issue_events_url":"https://api.github.com/repos/ESSS/hookman/issues/events{/number}","events_url":"https://api.github.com/repos/ESSS/hookman/events","assignees_url":"https://api.github.com/repos/ESSS/hookman/assignees{/user}","branches_url":"https://api.github.com/repos/ESSS/hookman/branches{/branch}","tags_url":"https://api.github.com/repos/ESSS/hookman/tags","blobs_url":"https://api.github.com/repos/ESSS/hookman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ESSS/hookman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ESSS/hookman/git/refs{/sha}","trees_url":"https://api.github.com/repos/ESSS/hookman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ESSS/hookman/statuses/{sha}","languages_url":"https://api.github.com/repos/ESSS/hookman/languages","stargazers_url":"https://api.github.com/repos/ESSS/hookman/stargazers","contributors_url":"https://api.github.com/repos/ESSS/hookman/contributors","subscribers_url":"https://api.github.com/repos/ESSS/hookman/subscribers","subscription_url":"https://api.github.com/repos/ESSS/hookman/subscription","commits_url":"https://api.github.com/repos/ESSS/hookman/commits{/sha}","git_commits_url":"https://api.github.com/repos/ESSS/hookman/git/commits{/sha}","comments_url":"https://api.github.com/repos/ESSS/hookman/comments{/number}","issue_comment_url":"https://api.github.com/repos/ESSS/hookman/issues/comments{/number}","contents_url":"https://api.github.com/repos/ESSS/hookman/contents/{+path}","compare_url":"https://api.github.com/repos/ESSS/hookman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ESSS/hookman/merges","archive_url":"https://api.github.com/repos/ESSS/hookman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ESSS/hookman/downloads","issues_url":"https://api.github.com/repos/ESSS/hookman/issues{/number}","pulls_url":"https://api.github.com/repos/ESSS/hookman/pulls{/number}","milestones_url":"https://api.github.com/repos/ESSS/hookman/milestones{/number}","notifications_url":"https://api.github.com/repos/ESSS/hookman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ESSS/hookman/labels{/name}","releases_url":"https://api.github.com/repos/ESSS/hookman/releases{/id}","deployments_url":"https://api.github.com/repos/ESSS/hookman/deployments","created_at":"2018-07-02T14:16:32Z","updated_at":"2018-07-02T15:59:54Z","pushed_at":"2018-07-04T17:54:44Z","git_url":"git://github.com/ESSS/hookman.git","ssh_url":"git@github.com:ESSS/hookman.git","clone_url":"https://github.com/ESSS/hookman.git","svn_url":"https://github.com/ESSS/hookman","homepage":null,"size":31,"stargazers_count":0,"watchers_count":0,"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":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/1"},"html":{"href":"https://github.com/ESSS/hookman/pull/1"},"issue":{"href":"https://api.github.com/repos/ESSS/hookman/issues/1"},"comments":{"href":"https://api.github.com/repos/ESSS/hookman/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ESSS/hookman/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ESSS/hookman/statuses/94d180915ed6657c2519a02b61acf667dd083b55"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"williamjamir"}}