{"action":"created","comment":{"url":"https://api.github.com/repos/pyta-uoft/website/pulls/comments/65012522","id":65012522,"diff_hunk":"@@ -0,0 +1,77 @@\n+#!/usr/bin/env python\n+\n+\"\"\"\n+Process a CodeBlock and, if class is \"include\", search for the file in the\n+provided paths, and replace the CodeBlock with the file contents.\n+\"\"\"\n+\n+import sys\n+import os\n+import logging\n+from pandocfilters import toJSONFilter, CodeBlock\n+\n+# Set the log level, and message format.\n+logging.basicConfig(format='', level=logging.DEBUG)\n+\n+# Define all possible paths for examples defined to be included in the markdown\n+# file. For efficiency paths are listed in order of decreasing file amounts.\n+# Must end in backslash.\n+PATHS_TO_INCLUDED_CODE = [\"../pyta/examples/pylint/\", \"../pyta/examples/\"]\n+\n+\n+def _get_file_content(filename):\n+    \"\"\" Iterates through a list of potential directories,\n+    returns the content of a file, or None if not found.\n+    \"\"\"\n+\n+    # Check the mentioned directories for file.\n+    for pathname in PATHS_TO_INCLUDED_CODE:\n+\n+        full_file_path = pathname + filename\n+\n+        # Looks for the file in the list of possible paths.\n+        if os.path.isfile(full_file_path):\n+            # Given the relative path to the file, open it.\n+            # Automatically closes the file after finishes.\n+            with open(full_file_path, 'r') as content_file:\n+                content = content_file.read()\n+\n+            # Break out of loop, and return the content.\n+            return content\n+\n+\n+def include_examples(key, value, format, meta):\n+    \"\"\" Replace code block sections with the code from a file.\n+    The file includes the extension. Code blocks look like:\n+    ~~~~ {.<language_name> include=\"filename\"}\n+    ~~~~\n+    \"\"\"\n+\n+    # pandoc encounters a CodeBlock in the markdown file.\n+    if key == 'CodeBlock':\n+        # Unpack the values in the CodeBlock.\n+        # 'classes' is the name of the programming language.\n+        # 'namevals' is a list of the nameval and its value.\n+        # 'code' is content inside the CodeBlock.\n+        [[ident, classes, namevals], code] = value\n+\n+        # Find the file, and place its contents into a CodeBlock element.\n+        for nameval in namevals:\n+\n+            # Check the nameval of the CodeBlock, which looks like,\n+            # include=\"filename\"\n+            if nameval[0] == 'include':\n+\n+                # Get content from the file, or log a message of the file that\n+                # cannot be found.\n+                content = _get_file_content(nameval[1])\n+                if content is not None:\n+                    # Return the CodeBlock with the new content.\n+                    return CodeBlock([ident, classes, namevals], content)","path":"filters/includes.py","position":70,"original_position":70,"commit_id":"7131f2410daf89ddae6eec2baf1ad30244590061","original_commit_id":"7131f2410daf89ddae6eec2baf1ad30244590061","user":{"login":"nigef","id":4323647,"avatar_url":"https://avatars.githubusercontent.com/u/4323647?v=3","gravatar_id":"","url":"https://api.github.com/users/nigef","html_url":"https://github.com/nigef","followers_url":"https://api.github.com/users/nigef/followers","following_url":"https://api.github.com/users/nigef/following{/other_user}","gists_url":"https://api.github.com/users/nigef/gists{/gist_id}","starred_url":"https://api.github.com/users/nigef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nigef/subscriptions","organizations_url":"https://api.github.com/users/nigef/orgs","repos_url":"https://api.github.com/users/nigef/repos","events_url":"https://api.github.com/users/nigef/events{/privacy}","received_events_url":"https://api.github.com/users/nigef/received_events","type":"User","site_admin":false},"body":"nice, i may as well append the \".py\" here as well, to reduce syntax in the .md file","created_at":"2016-05-29T22:14:32Z","updated_at":"2016-05-29T22:14:32Z","html_url":"https://github.com/pyta-uoft/website/pull/16#discussion_r65012522","pull_request_url":"https://api.github.com/repos/pyta-uoft/website/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/comments/65012522"},"html":{"href":"https://github.com/pyta-uoft/website/pull/16#discussion_r65012522"},"pull_request":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/pyta-uoft/website/pulls/16","id":71008655,"html_url":"https://github.com/pyta-uoft/website/pull/16","diff_url":"https://github.com/pyta-uoft/website/pull/16.diff","patch_url":"https://github.com/pyta-uoft/website/pull/16.patch","issue_url":"https://api.github.com/repos/pyta-uoft/website/issues/16","number":16,"state":"open","locked":false,"title":"This PR goes along with pyta issue-4","user":{"login":"nigef","id":4323647,"avatar_url":"https://avatars.githubusercontent.com/u/4323647?v=3","gravatar_id":"","url":"https://api.github.com/users/nigef","html_url":"https://github.com/nigef","followers_url":"https://api.github.com/users/nigef/followers","following_url":"https://api.github.com/users/nigef/following{/other_user}","gists_url":"https://api.github.com/users/nigef/gists{/gist_id}","starred_url":"https://api.github.com/users/nigef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nigef/subscriptions","organizations_url":"https://api.github.com/users/nigef/orgs","repos_url":"https://api.github.com/users/nigef/repos","events_url":"https://api.github.com/users/nigef/events{/privacy}","received_events_url":"https://api.github.com/users/nigef/received_events","type":"User","site_admin":false},"body":"Added includes, improved some grammar, added relevant notes from deleted docstrings, formatted markdown code snippet.","created_at":"2016-05-23T06:02:27Z","updated_at":"2016-05-29T22:14:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f77d704f6453a7609c3e36ff3c8af85b2588f2ea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pyta-uoft/website/pulls/16/commits","review_comments_url":"https://api.github.com/repos/pyta-uoft/website/pulls/16/comments","review_comment_url":"https://api.github.com/repos/pyta-uoft/website/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pyta-uoft/website/issues/16/comments","statuses_url":"https://api.github.com/repos/pyta-uoft/website/statuses/7131f2410daf89ddae6eec2baf1ad30244590061","head":{"label":"nigef:with-pyta-issue-4","ref":"with-pyta-issue-4","sha":"7131f2410daf89ddae6eec2baf1ad30244590061","user":{"login":"nigef","id":4323647,"avatar_url":"https://avatars.githubusercontent.com/u/4323647?v=3","gravatar_id":"","url":"https://api.github.com/users/nigef","html_url":"https://github.com/nigef","followers_url":"https://api.github.com/users/nigef/followers","following_url":"https://api.github.com/users/nigef/following{/other_user}","gists_url":"https://api.github.com/users/nigef/gists{/gist_id}","starred_url":"https://api.github.com/users/nigef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nigef/subscriptions","organizations_url":"https://api.github.com/users/nigef/orgs","repos_url":"https://api.github.com/users/nigef/repos","events_url":"https://api.github.com/users/nigef/events{/privacy}","received_events_url":"https://api.github.com/users/nigef/received_events","type":"User","site_admin":false},"repo":{"id":57349965,"name":"website","full_name":"nigef/website","owner":{"login":"nigef","id":4323647,"avatar_url":"https://avatars.githubusercontent.com/u/4323647?v=3","gravatar_id":"","url":"https://api.github.com/users/nigef","html_url":"https://github.com/nigef","followers_url":"https://api.github.com/users/nigef/followers","following_url":"https://api.github.com/users/nigef/following{/other_user}","gists_url":"https://api.github.com/users/nigef/gists{/gist_id}","starred_url":"https://api.github.com/users/nigef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nigef/subscriptions","organizations_url":"https://api.github.com/users/nigef/orgs","repos_url":"https://api.github.com/users/nigef/repos","events_url":"https://api.github.com/users/nigef/events{/privacy}","received_events_url":"https://api.github.com/users/nigef/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nigef/website","description":"","fork":true,"url":"https://api.github.com/repos/nigef/website","forks_url":"https://api.github.com/repos/nigef/website/forks","keys_url":"https://api.github.com/repos/nigef/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nigef/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nigef/website/teams","hooks_url":"https://api.github.com/repos/nigef/website/hooks","issue_events_url":"https://api.github.com/repos/nigef/website/issues/events{/number}","events_url":"https://api.github.com/repos/nigef/website/events","assignees_url":"https://api.github.com/repos/nigef/website/assignees{/user}","branches_url":"https://api.github.com/repos/nigef/website/branches{/branch}","tags_url":"https://api.github.com/repos/nigef/website/tags","blobs_url":"https://api.github.com/repos/nigef/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nigef/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nigef/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/nigef/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nigef/website/statuses/{sha}","languages_url":"https://api.github.com/repos/nigef/website/languages","stargazers_url":"https://api.github.com/repos/nigef/website/stargazers","contributors_url":"https://api.github.com/repos/nigef/website/contributors","subscribers_url":"https://api.github.com/repos/nigef/website/subscribers","subscription_url":"https://api.github.com/repos/nigef/website/subscription","commits_url":"https://api.github.com/repos/nigef/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/nigef/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/nigef/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/nigef/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/nigef/website/contents/{+path}","compare_url":"https://api.github.com/repos/nigef/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nigef/website/merges","archive_url":"https://api.github.com/repos/nigef/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nigef/website/downloads","issues_url":"https://api.github.com/repos/nigef/website/issues{/number}","pulls_url":"https://api.github.com/repos/nigef/website/pulls{/number}","milestones_url":"https://api.github.com/repos/nigef/website/milestones{/number}","notifications_url":"https://api.github.com/repos/nigef/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nigef/website/labels{/name}","releases_url":"https://api.github.com/repos/nigef/website/releases{/id}","deployments_url":"https://api.github.com/repos/nigef/website/deployments","created_at":"2016-04-29T02:55:20Z","updated_at":"2016-04-29T02:55:21Z","pushed_at":"2016-05-29T19:42:15Z","git_url":"git://github.com/nigef/website.git","ssh_url":"git@github.com:nigef/website.git","clone_url":"https://github.com/nigef/website.git","svn_url":"https://github.com/nigef/website","homepage":null,"size":119,"stargazers_count":0,"watchers_count":0,"language":"CSS","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":"pyta-uoft:master","ref":"master","sha":"b5ddaa63be90a7fb4b3cdafe64c5043135a98da1","user":{"login":"pyta-uoft","id":18420574,"avatar_url":"https://avatars.githubusercontent.com/u/18420574?v=3","gravatar_id":"","url":"https://api.github.com/users/pyta-uoft","html_url":"https://github.com/pyta-uoft","followers_url":"https://api.github.com/users/pyta-uoft/followers","following_url":"https://api.github.com/users/pyta-uoft/following{/other_user}","gists_url":"https://api.github.com/users/pyta-uoft/gists{/gist_id}","starred_url":"https://api.github.com/users/pyta-uoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyta-uoft/subscriptions","organizations_url":"https://api.github.com/users/pyta-uoft/orgs","repos_url":"https://api.github.com/users/pyta-uoft/repos","events_url":"https://api.github.com/users/pyta-uoft/events{/privacy}","received_events_url":"https://api.github.com/users/pyta-uoft/received_events","type":"Organization","site_admin":false},"repo":{"id":56062212,"name":"website","full_name":"pyta-uoft/website","owner":{"login":"pyta-uoft","id":18420574,"avatar_url":"https://avatars.githubusercontent.com/u/18420574?v=3","gravatar_id":"","url":"https://api.github.com/users/pyta-uoft","html_url":"https://github.com/pyta-uoft","followers_url":"https://api.github.com/users/pyta-uoft/followers","following_url":"https://api.github.com/users/pyta-uoft/following{/other_user}","gists_url":"https://api.github.com/users/pyta-uoft/gists{/gist_id}","starred_url":"https://api.github.com/users/pyta-uoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pyta-uoft/subscriptions","organizations_url":"https://api.github.com/users/pyta-uoft/orgs","repos_url":"https://api.github.com/users/pyta-uoft/repos","events_url":"https://api.github.com/users/pyta-uoft/events{/privacy}","received_events_url":"https://api.github.com/users/pyta-uoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pyta-uoft/website","description":"","fork":false,"url":"https://api.github.com/repos/pyta-uoft/website","forks_url":"https://api.github.com/repos/pyta-uoft/website/forks","keys_url":"https://api.github.com/repos/pyta-uoft/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pyta-uoft/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pyta-uoft/website/teams","hooks_url":"https://api.github.com/repos/pyta-uoft/website/hooks","issue_events_url":"https://api.github.com/repos/pyta-uoft/website/issues/events{/number}","events_url":"https://api.github.com/repos/pyta-uoft/website/events","assignees_url":"https://api.github.com/repos/pyta-uoft/website/assignees{/user}","branches_url":"https://api.github.com/repos/pyta-uoft/website/branches{/branch}","tags_url":"https://api.github.com/repos/pyta-uoft/website/tags","blobs_url":"https://api.github.com/repos/pyta-uoft/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pyta-uoft/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pyta-uoft/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/pyta-uoft/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pyta-uoft/website/statuses/{sha}","languages_url":"https://api.github.com/repos/pyta-uoft/website/languages","stargazers_url":"https://api.github.com/repos/pyta-uoft/website/stargazers","contributors_url":"https://api.github.com/repos/pyta-uoft/website/contributors","subscribers_url":"https://api.github.com/repos/pyta-uoft/website/subscribers","subscription_url":"https://api.github.com/repos/pyta-uoft/website/subscription","commits_url":"https://api.github.com/repos/pyta-uoft/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/pyta-uoft/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/pyta-uoft/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/pyta-uoft/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/pyta-uoft/website/contents/{+path}","compare_url":"https://api.github.com/repos/pyta-uoft/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pyta-uoft/website/merges","archive_url":"https://api.github.com/repos/pyta-uoft/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pyta-uoft/website/downloads","issues_url":"https://api.github.com/repos/pyta-uoft/website/issues{/number}","pulls_url":"https://api.github.com/repos/pyta-uoft/website/pulls{/number}","milestones_url":"https://api.github.com/repos/pyta-uoft/website/milestones{/number}","notifications_url":"https://api.github.com/repos/pyta-uoft/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pyta-uoft/website/labels{/name}","releases_url":"https://api.github.com/repos/pyta-uoft/website/releases{/id}","deployments_url":"https://api.github.com/repos/pyta-uoft/website/deployments","created_at":"2016-04-12T12:44:56Z","updated_at":"2016-05-15T19:22:43Z","pushed_at":"2016-05-29T19:42:16Z","git_url":"git://github.com/pyta-uoft/website.git","ssh_url":"git@github.com:pyta-uoft/website.git","clone_url":"https://github.com/pyta-uoft/website.git","svn_url":"https://github.com/pyta-uoft/website","homepage":null,"size":133,"stargazers_count":3,"watchers_count":3,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/16"},"html":{"href":"https://github.com/pyta-uoft/website/pull/16"},"issue":{"href":"https://api.github.com/repos/pyta-uoft/website/issues/16"},"comments":{"href":"https://api.github.com/repos/pyta-uoft/website/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pyta-uoft/website/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/pyta-uoft/website/statuses/7131f2410daf89ddae6eec2baf1ad30244590061"}}}}
{"actor":{"display_login":"nigef"}}