{"action":"created","comment":{"url":"https://api.github.com/repos/aws/aws-cli/pulls/comments/24460951","id":24460951,"diff_hunk":"@@ -0,0 +1,254 @@\n+# Copyright (c) 2015 Amazon.com, Inc. or its affiliates.  All Rights Reserved\n+#\n+# Permission is hereby granted, free of charge, to any person obtaining a\n+# copy of this software and associated documentation files (the\n+# \"Software\"), to deal in the Software without restriction, including\n+# without limitation the rights to use, copy, modify, merge, publish, dis-\n+# tribute, sublicense, and/or sell copies of the Software, and to permit\n+# persons to whom the Software is furnished to do so, subject to the fol-\n+# lowing conditions:\n+#\n+# The above copyright notice and this permission notice shall be included\n+# in all copies or substantial portions of the Software.\n+#\n+# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-\n+# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n+# IN THE SOFTWARE.\n+#\n+import os\n+import json\n+import docutils.core\n+\n+\n+class TopicTagDB(object):\n+    \"\"\"This class acts like a database for the tags of all available topics.\n+\n+    A tag is an element in a topic reStructured text file that contains\n+    information about a topic. Information can range from titles to even\n+    related CLI commands. Here are all of the currently supported tags:\n+\n+    Tag                 Meaning                         Required?\n+    ---                 -------                         ---------\n+    :title:             The title of the topic          Yes\n+    :description:       Sentence description of topic   Yes\n+    :category:          Category topic falls under      Yes\n+    :related topic:     A related topic                 No\n+    :related command:   A related command               No\n+\n+    To see examples of how to specify tags looks in the directory\n+    awscli/topics. Note that tags can have multiple values by delimiting\n+    values with commas. All tags must be on their own line in the file.\n+\n+    This class can load a JSON index represeting all of topics and their tags,\n+    scan all of the topics and store the values of their tags, retrieve the\n+    tag value for a particular topic, query for all the topics with a specific\n+    tag and/or value, and save the loaded data back out to a JSON index.\n+\n+    The structure of the database can be viewed as a python dictionary:\n+\n+    {'topic-name-1': {\n+        'title': ['My First Topic Title'],","path":"awscli/topictags.py","position":54,"original_position":54,"commit_id":"6c1f554a182f74666a06cde0f65ae41468bf6452","original_commit_id":"6c1f554a182f74666a06cde0f65ae41468bf6452","user":{"login":"kyleknap","id":4605355,"avatar_url":"https://avatars.githubusercontent.com/u/4605355?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleknap","html_url":"https://github.com/kyleknap","followers_url":"https://api.github.com/users/kyleknap/followers","following_url":"https://api.github.com/users/kyleknap/following{/other_user}","gists_url":"https://api.github.com/users/kyleknap/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleknap/subscriptions","organizations_url":"https://api.github.com/users/kyleknap/orgs","repos_url":"https://api.github.com/users/kyleknap/repos","events_url":"https://api.github.com/users/kyleknap/events{/privacy}","received_events_url":"https://api.github.com/users/kyleknap/received_events","type":"User","site_admin":false},"body":"Yeah I was going to add something like that into the next pull request. I was going to put the validation at the command level. But I now that I think about it. @jamesls How would you feel if I added a ``get_tag_title()`` and ``get_tag_description()`` method to ``TopicTagDB`` that will raise an error if there are more than one values?","created_at":"2015-02-10T23:17:42Z","updated_at":"2015-02-10T23:17:42Z","html_url":"https://github.com/aws/aws-cli/pull/1132#discussion_r24460951","pull_request_url":"https://api.github.com/repos/aws/aws-cli/pulls/1132","_links":{"self":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/comments/24460951"},"html":{"href":"https://github.com/aws/aws-cli/pull/1132#discussion_r24460951"},"pull_request":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/1132"}}},"pull_request":{"url":"https://api.github.com/repos/aws/aws-cli/pulls/1132","id":28829072,"html_url":"https://github.com/aws/aws-cli/pull/1132","diff_url":"https://github.com/aws/aws-cli/pull/1132.diff","patch_url":"https://github.com/aws/aws-cli/pull/1132.patch","issue_url":"https://api.github.com/repos/aws/aws-cli/issues/1132","number":1132,"state":"open","locked":false,"title":"Tag parser","user":{"login":"kyleknap","id":4605355,"avatar_url":"https://avatars.githubusercontent.com/u/4605355?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleknap","html_url":"https://github.com/kyleknap","followers_url":"https://api.github.com/users/kyleknap/followers","following_url":"https://api.github.com/users/kyleknap/following{/other_user}","gists_url":"https://api.github.com/users/kyleknap/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleknap/subscriptions","organizations_url":"https://api.github.com/users/kyleknap/orgs","repos_url":"https://api.github.com/users/kyleknap/repos","events_url":"https://api.github.com/users/kyleknap/events{/privacy}","received_events_url":"https://api.github.com/users/kyleknap/received_events","type":"User","site_admin":false},"body":"This PR adds the class ``TopicTagDB`` to the CLI. It is a database like object will be used to help generate a related items sections from available topics in the CLI codebase across other topics and reference commands.\r\n\r\nTo add a topic to the CLI, the workflow is as follows:\r\n   1) Add a topic to the awscli/topics directory with the appropriate tags.\r\n   2) Run the make-topic-index script to generate a new index that can be loaded.\r\n\r\nThis reason an index is needed is to avoid having to scan through each topic file (from disk) each time you create a new ``TopicTagDB`` instance as this could get pretty time intensive if there were a lot of topics. \r\n\r\nThe structure of the database can be viewed as a python dictionary:\r\n```\r\n    {'topic-name-1': {\r\n        ':title:': ['My First Topic Title'],\r\n        ':description:': ['This describes my first topic'],\r\n        ':category:': ['General Topics', 'S3'],\r\n        ':related command:': ['aws s3'],\r\n        ':related topic:': ['topic-name-2']\r\n     },\r\n     'topic-name-2': { .....\r\n    }\r\n```\r\nThe keys of the dictionary are the CLI command names of the topics. These names are based off the name of the reStructed text file that corresponds to the topic. The value of these keys are dictionaries of tags, where the tags are keys and their value is a list of values for that tag. Note that all tag values for a specific tag of a specific topic are unique (no duplicates). All of the tags listed in the example is what is currently supported by the class.\r\n\r\nThe ``TopicTagDB`` class has the following public methods:\r\n* ``load_json_index()``: Loads a JSON index into memory.\r\n* ``save_json_index()``: Save the data in memory into a JSON file on disk.\r\n* ``get_all_topic_names()``: Get the names of all topic names loaded into memory.\r\n   Topic names are the name of their rst file\r\n* ``get_all_topic_src_files()``: Get the file paths for all of the topics in the awscli/topics directory\r\n* ``scan()``: Scan through all of the files provided and save the topic and tag into memory\r\n* ``query()``: Get all topics related to a specific tag and/or tag value\r\n* ``get_tag_value()``: Get the value of a specified tag and topic.\r\n\r\ncc @jamesls @danielgtaylor \r\n","created_at":"2015-02-06T18:07:25Z","updated_at":"2015-02-10T23:17:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32432fc8fea232d56a6f2d27be9fdbb06b0a5e04","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aws/aws-cli/pulls/1132/commits","review_comments_url":"https://api.github.com/repos/aws/aws-cli/pulls/1132/comments","review_comment_url":"https://api.github.com/repos/aws/aws-cli/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aws/aws-cli/issues/1132/comments","statuses_url":"https://api.github.com/repos/aws/aws-cli/statuses/6c1f554a182f74666a06cde0f65ae41468bf6452","head":{"label":"kyleknap:tag-parser","ref":"tag-parser","sha":"6c1f554a182f74666a06cde0f65ae41468bf6452","user":{"login":"kyleknap","id":4605355,"avatar_url":"https://avatars.githubusercontent.com/u/4605355?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleknap","html_url":"https://github.com/kyleknap","followers_url":"https://api.github.com/users/kyleknap/followers","following_url":"https://api.github.com/users/kyleknap/following{/other_user}","gists_url":"https://api.github.com/users/kyleknap/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleknap/subscriptions","organizations_url":"https://api.github.com/users/kyleknap/orgs","repos_url":"https://api.github.com/users/kyleknap/repos","events_url":"https://api.github.com/users/kyleknap/events{/privacy}","received_events_url":"https://api.github.com/users/kyleknap/received_events","type":"User","site_admin":false},"repo":{"id":12092925,"name":"aws-cli","full_name":"kyleknap/aws-cli","owner":{"login":"kyleknap","id":4605355,"avatar_url":"https://avatars.githubusercontent.com/u/4605355?v=3","gravatar_id":"","url":"https://api.github.com/users/kyleknap","html_url":"https://github.com/kyleknap","followers_url":"https://api.github.com/users/kyleknap/followers","following_url":"https://api.github.com/users/kyleknap/following{/other_user}","gists_url":"https://api.github.com/users/kyleknap/gists{/gist_id}","starred_url":"https://api.github.com/users/kyleknap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyleknap/subscriptions","organizations_url":"https://api.github.com/users/kyleknap/orgs","repos_url":"https://api.github.com/users/kyleknap/repos","events_url":"https://api.github.com/users/kyleknap/events{/privacy}","received_events_url":"https://api.github.com/users/kyleknap/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kyleknap/aws-cli","description":"Universal Command Line Interface for Amazon Web Services","fork":true,"url":"https://api.github.com/repos/kyleknap/aws-cli","forks_url":"https://api.github.com/repos/kyleknap/aws-cli/forks","keys_url":"https://api.github.com/repos/kyleknap/aws-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kyleknap/aws-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kyleknap/aws-cli/teams","hooks_url":"https://api.github.com/repos/kyleknap/aws-cli/hooks","issue_events_url":"https://api.github.com/repos/kyleknap/aws-cli/issues/events{/number}","events_url":"https://api.github.com/repos/kyleknap/aws-cli/events","assignees_url":"https://api.github.com/repos/kyleknap/aws-cli/assignees{/user}","branches_url":"https://api.github.com/repos/kyleknap/aws-cli/branches{/branch}","tags_url":"https://api.github.com/repos/kyleknap/aws-cli/tags","blobs_url":"https://api.github.com/repos/kyleknap/aws-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kyleknap/aws-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kyleknap/aws-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/kyleknap/aws-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kyleknap/aws-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/kyleknap/aws-cli/languages","stargazers_url":"https://api.github.com/repos/kyleknap/aws-cli/stargazers","contributors_url":"https://api.github.com/repos/kyleknap/aws-cli/contributors","subscribers_url":"https://api.github.com/repos/kyleknap/aws-cli/subscribers","subscription_url":"https://api.github.com/repos/kyleknap/aws-cli/subscription","commits_url":"https://api.github.com/repos/kyleknap/aws-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/kyleknap/aws-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/kyleknap/aws-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/kyleknap/aws-cli/issues/comments/{number}","contents_url":"https://api.github.com/repos/kyleknap/aws-cli/contents/{+path}","compare_url":"https://api.github.com/repos/kyleknap/aws-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kyleknap/aws-cli/merges","archive_url":"https://api.github.com/repos/kyleknap/aws-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kyleknap/aws-cli/downloads","issues_url":"https://api.github.com/repos/kyleknap/aws-cli/issues{/number}","pulls_url":"https://api.github.com/repos/kyleknap/aws-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/kyleknap/aws-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/kyleknap/aws-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kyleknap/aws-cli/labels{/name}","releases_url":"https://api.github.com/repos/kyleknap/aws-cli/releases{/id}","created_at":"2013-08-13T21:03:11Z","updated_at":"2014-07-28T21:42:02Z","pushed_at":"2015-02-10T22:03:33Z","git_url":"git://github.com/kyleknap/aws-cli.git","ssh_url":"git@github.com:kyleknap/aws-cli.git","clone_url":"https://github.com/kyleknap/aws-cli.git","svn_url":"https://github.com/kyleknap/aws-cli","homepage":null,"size":6212,"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":"develop"}},"base":{"label":"aws:develop","ref":"develop","sha":"7af0f465587041a14d1e49990424f7fe7b766ff5","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":6780767,"name":"aws-cli","full_name":"aws/aws-cli","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/aws-cli","description":"Universal Command Line Interface for Amazon Web Services","fork":false,"url":"https://api.github.com/repos/aws/aws-cli","forks_url":"https://api.github.com/repos/aws/aws-cli/forks","keys_url":"https://api.github.com/repos/aws/aws-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/aws-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/aws-cli/teams","hooks_url":"https://api.github.com/repos/aws/aws-cli/hooks","issue_events_url":"https://api.github.com/repos/aws/aws-cli/issues/events{/number}","events_url":"https://api.github.com/repos/aws/aws-cli/events","assignees_url":"https://api.github.com/repos/aws/aws-cli/assignees{/user}","branches_url":"https://api.github.com/repos/aws/aws-cli/branches{/branch}","tags_url":"https://api.github.com/repos/aws/aws-cli/tags","blobs_url":"https://api.github.com/repos/aws/aws-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/aws-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/aws-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/aws-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/aws-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/aws-cli/languages","stargazers_url":"https://api.github.com/repos/aws/aws-cli/stargazers","contributors_url":"https://api.github.com/repos/aws/aws-cli/contributors","subscribers_url":"https://api.github.com/repos/aws/aws-cli/subscribers","subscription_url":"https://api.github.com/repos/aws/aws-cli/subscription","commits_url":"https://api.github.com/repos/aws/aws-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/aws-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/aws-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/aws-cli/issues/comments/{number}","contents_url":"https://api.github.com/repos/aws/aws-cli/contents/{+path}","compare_url":"https://api.github.com/repos/aws/aws-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/aws-cli/merges","archive_url":"https://api.github.com/repos/aws/aws-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/aws-cli/downloads","issues_url":"https://api.github.com/repos/aws/aws-cli/issues{/number}","pulls_url":"https://api.github.com/repos/aws/aws-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/aws-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/aws-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/aws-cli/labels{/name}","releases_url":"https://api.github.com/repos/aws/aws-cli/releases{/id}","created_at":"2012-11-20T16:07:36Z","updated_at":"2015-02-10T21:10:38Z","pushed_at":"2015-02-10T21:10:37Z","git_url":"git://github.com/aws/aws-cli.git","ssh_url":"git@github.com:aws/aws-cli.git","clone_url":"https://github.com/aws/aws-cli.git","svn_url":"https://github.com/aws/aws-cli","homepage":null,"size":13715,"stargazers_count":2516,"watchers_count":2516,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":322,"mirror_url":null,"open_issues_count":113,"forks":322,"open_issues":113,"watchers":2516,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/1132"},"html":{"href":"https://github.com/aws/aws-cli/pull/1132"},"issue":{"href":"https://api.github.com/repos/aws/aws-cli/issues/1132"},"comments":{"href":"https://api.github.com/repos/aws/aws-cli/issues/1132/comments"},"review_comments":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/1132/comments"},"review_comment":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aws/aws-cli/pulls/1132/commits"},"statuses":{"href":"https://api.github.com/repos/aws/aws-cli/statuses/6c1f554a182f74666a06cde0f65ae41468bf6452"}}}}