{"action":"created","comment":{"url":"https://api.github.com/repos/project-generator/project_generator/pulls/comments/35732733","id":35732733,"diff_hunk":"@@ -0,0 +1,62 @@\n+# Copyright 2014-2015 0xc0170\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+import os\n+import yaml\n+import logging\n+\n+from .project import Project, ProjectWorkspace\n+from .settings import ProjectSettings\n+from .tools_supported import ToolsSupported\n+from .targets import Targets\n+from .util import flatten, uniqify, load_yaml_records\n+from project import *\n+\n+class Generator:\n+    def __init__(self, projects_file):\n+        if type(projects_file) is not dict:\n+            try:\n+                with open(projects_file, 'rt') as f:\n+                    self.projects_dict = yaml.load(f)\n+            except IOError:\n+               raise IOError(\"The main pgen projects file %s doesn't exist.\" % projects_file)\n+        else:\n+            self.projects_dict = projects_file\n+        self.workspaces = {}\n+        self.settings = ProjectSettings()\n+        if 'settings' in self.projects_dict:\n+            self.settings.update(self.projects_dict['settings'])\n+\n+    def generate(self, name = ''):\n+        if 'projects' in self.projects_dict:\n+            projects = []\n+            if name != '':\n+                if name in self.projects_dict['projects'].keys():\n+                    records = self.projects_dict['projects'][name]\n+                    yield Project(name, load_yaml_records(uniqify(flatten(records))), self)\n+                else:\n+                    raise RuntimeError(\"You specified an invalid project name.\")\n+            else:\n+                for name, records in self.projects_dict['projects'].items():\n+                    if type(records) is dict:\n+                        # workspace\n+                        for n, r in records.items():\n+                            project = Project(n, load_yaml_records(uniqify(flatten(r))), self)\n+                            yield project\n+                            projects.append(projects)\n+                        self.workspaces[name] = ProjectWorkspace(name, projects, self)\n+                    else:\n+                        yield Project(name, load_yaml_records(uniqify(flatten(records))), self)","path":"project_generator/generate.py","position":53,"original_position":60,"commit_id":"79b0df0eaf5a1b7323b4381b22168827c692d257","original_commit_id":"aff9f66a7229679b8f7d022d928a534b5d4695bd","user":{"login":"0xc0170","id":2963726,"avatar_url":"https://avatars.githubusercontent.com/u/2963726?v=3","gravatar_id":"","url":"https://api.github.com/users/0xc0170","html_url":"https://github.com/0xc0170","followers_url":"https://api.github.com/users/0xc0170/followers","following_url":"https://api.github.com/users/0xc0170/following{/other_user}","gists_url":"https://api.github.com/users/0xc0170/gists{/gist_id}","starred_url":"https://api.github.com/users/0xc0170/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xc0170/subscriptions","organizations_url":"https://api.github.com/users/0xc0170/orgs","repos_url":"https://api.github.com/users/0xc0170/repos","events_url":"https://api.github.com/users/0xc0170/events{/privacy}","received_events_url":"https://api.github.com/users/0xc0170/received_events","type":"User","site_admin":false},"body":"Why it yields Project, but not workspace?","created_at":"2015-07-29T07:09:24Z","updated_at":"2015-07-29T07:09:24Z","html_url":"https://github.com/project-generator/project_generator/pull/241#discussion_r35732733","pull_request_url":"https://api.github.com/repos/project-generator/project_generator/pulls/241","_links":{"self":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/comments/35732733"},"html":{"href":"https://github.com/project-generator/project_generator/pull/241#discussion_r35732733"},"pull_request":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/241"}}},"pull_request":{"url":"https://api.github.com/repos/project-generator/project_generator/pulls/241","id":41060634,"html_url":"https://github.com/project-generator/project_generator/pull/241","diff_url":"https://github.com/project-generator/project_generator/pull/241.diff","patch_url":"https://github.com/project-generator/project_generator/pull/241.patch","issue_url":"https://api.github.com/repos/project-generator/project_generator/issues/241","number":241,"state":"open","locked":false,"title":"Removed pgen workspaces. Workspaces is now Generator. Generator has t…","user":{"login":"sarahmarshy","id":12565767,"avatar_url":"https://avatars.githubusercontent.com/u/12565767?v=3","gravatar_id":"","url":"https://api.github.com/users/sarahmarshy","html_url":"https://github.com/sarahmarshy","followers_url":"https://api.github.com/users/sarahmarshy/followers","following_url":"https://api.github.com/users/sarahmarshy/following{/other_user}","gists_url":"https://api.github.com/users/sarahmarshy/gists{/gist_id}","starred_url":"https://api.github.com/users/sarahmarshy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarahmarshy/subscriptions","organizations_url":"https://api.github.com/users/sarahmarshy/orgs","repos_url":"https://api.github.com/users/sarahmarshy/repos","events_url":"https://api.github.com/users/sarahmarshy/events{/privacy}","received_events_url":"https://api.github.com/users/sarahmarshy/received_events","type":"User","site_admin":false},"body":"…he ability to produce iterator object of generated projects. Tests were updated to reflect these changes.","created_at":"2015-07-28T21:07:36Z","updated_at":"2015-07-29T07:09:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70010466b6a2255bda82fa2bd55f50e84d49cb7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/project-generator/project_generator/pulls/241/commits","review_comments_url":"https://api.github.com/repos/project-generator/project_generator/pulls/241/comments","review_comment_url":"https://api.github.com/repos/project-generator/project_generator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/project-generator/project_generator/issues/241/comments","statuses_url":"https://api.github.com/repos/project-generator/project_generator/statuses/79b0df0eaf5a1b7323b4381b22168827c692d257","head":{"label":"sarahmarshy:pgen_v0.7","ref":"pgen_v0.7","sha":"79b0df0eaf5a1b7323b4381b22168827c692d257","user":{"login":"sarahmarshy","id":12565767,"avatar_url":"https://avatars.githubusercontent.com/u/12565767?v=3","gravatar_id":"","url":"https://api.github.com/users/sarahmarshy","html_url":"https://github.com/sarahmarshy","followers_url":"https://api.github.com/users/sarahmarshy/followers","following_url":"https://api.github.com/users/sarahmarshy/following{/other_user}","gists_url":"https://api.github.com/users/sarahmarshy/gists{/gist_id}","starred_url":"https://api.github.com/users/sarahmarshy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarahmarshy/subscriptions","organizations_url":"https://api.github.com/users/sarahmarshy/orgs","repos_url":"https://api.github.com/users/sarahmarshy/repos","events_url":"https://api.github.com/users/sarahmarshy/events{/privacy}","received_events_url":"https://api.github.com/users/sarahmarshy/received_events","type":"User","site_admin":false},"repo":{"id":36387714,"name":"project_generator","full_name":"sarahmarshy/project_generator","owner":{"login":"sarahmarshy","id":12565767,"avatar_url":"https://avatars.githubusercontent.com/u/12565767?v=3","gravatar_id":"","url":"https://api.github.com/users/sarahmarshy","html_url":"https://github.com/sarahmarshy","followers_url":"https://api.github.com/users/sarahmarshy/followers","following_url":"https://api.github.com/users/sarahmarshy/following{/other_user}","gists_url":"https://api.github.com/users/sarahmarshy/gists{/gist_id}","starred_url":"https://api.github.com/users/sarahmarshy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sarahmarshy/subscriptions","organizations_url":"https://api.github.com/users/sarahmarshy/orgs","repos_url":"https://api.github.com/users/sarahmarshy/repos","events_url":"https://api.github.com/users/sarahmarshy/events{/privacy}","received_events_url":"https://api.github.com/users/sarahmarshy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sarahmarshy/project_generator","description":"Project generators for various embedded tools (IDE). IAR, uVision, Makefile, CoIDE, Eclipse and many more in the roadmap!","fork":true,"url":"https://api.github.com/repos/sarahmarshy/project_generator","forks_url":"https://api.github.com/repos/sarahmarshy/project_generator/forks","keys_url":"https://api.github.com/repos/sarahmarshy/project_generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sarahmarshy/project_generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sarahmarshy/project_generator/teams","hooks_url":"https://api.github.com/repos/sarahmarshy/project_generator/hooks","issue_events_url":"https://api.github.com/repos/sarahmarshy/project_generator/issues/events{/number}","events_url":"https://api.github.com/repos/sarahmarshy/project_generator/events","assignees_url":"https://api.github.com/repos/sarahmarshy/project_generator/assignees{/user}","branches_url":"https://api.github.com/repos/sarahmarshy/project_generator/branches{/branch}","tags_url":"https://api.github.com/repos/sarahmarshy/project_generator/tags","blobs_url":"https://api.github.com/repos/sarahmarshy/project_generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sarahmarshy/project_generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sarahmarshy/project_generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/sarahmarshy/project_generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sarahmarshy/project_generator/statuses/{sha}","languages_url":"https://api.github.com/repos/sarahmarshy/project_generator/languages","stargazers_url":"https://api.github.com/repos/sarahmarshy/project_generator/stargazers","contributors_url":"https://api.github.com/repos/sarahmarshy/project_generator/contributors","subscribers_url":"https://api.github.com/repos/sarahmarshy/project_generator/subscribers","subscription_url":"https://api.github.com/repos/sarahmarshy/project_generator/subscription","commits_url":"https://api.github.com/repos/sarahmarshy/project_generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/sarahmarshy/project_generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/sarahmarshy/project_generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/sarahmarshy/project_generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/sarahmarshy/project_generator/contents/{+path}","compare_url":"https://api.github.com/repos/sarahmarshy/project_generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sarahmarshy/project_generator/merges","archive_url":"https://api.github.com/repos/sarahmarshy/project_generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sarahmarshy/project_generator/downloads","issues_url":"https://api.github.com/repos/sarahmarshy/project_generator/issues{/number}","pulls_url":"https://api.github.com/repos/sarahmarshy/project_generator/pulls{/number}","milestones_url":"https://api.github.com/repos/sarahmarshy/project_generator/milestones{/number}","notifications_url":"https://api.github.com/repos/sarahmarshy/project_generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sarahmarshy/project_generator/labels{/name}","releases_url":"https://api.github.com/repos/sarahmarshy/project_generator/releases{/id}","created_at":"2015-05-27T18:37:46Z","updated_at":"2015-05-27T18:37:50Z","pushed_at":"2015-07-28T22:24:38Z","git_url":"git://github.com/sarahmarshy/project_generator.git","ssh_url":"git@github.com:sarahmarshy/project_generator.git","clone_url":"https://github.com/sarahmarshy/project_generator.git","svn_url":"https://github.com/sarahmarshy/project_generator","homepage":"","size":1316,"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":"master"}},"base":{"label":"project-generator:master","ref":"master","sha":"8217041d417ed8131ebca9a677e34aed12b11edc","user":{"login":"project-generator","id":11992191,"avatar_url":"https://avatars.githubusercontent.com/u/11992191?v=3","gravatar_id":"","url":"https://api.github.com/users/project-generator","html_url":"https://github.com/project-generator","followers_url":"https://api.github.com/users/project-generator/followers","following_url":"https://api.github.com/users/project-generator/following{/other_user}","gists_url":"https://api.github.com/users/project-generator/gists{/gist_id}","starred_url":"https://api.github.com/users/project-generator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-generator/subscriptions","organizations_url":"https://api.github.com/users/project-generator/orgs","repos_url":"https://api.github.com/users/project-generator/repos","events_url":"https://api.github.com/users/project-generator/events{/privacy}","received_events_url":"https://api.github.com/users/project-generator/received_events","type":"Organization","site_admin":false},"repo":{"id":22783065,"name":"project_generator","full_name":"project-generator/project_generator","owner":{"login":"project-generator","id":11992191,"avatar_url":"https://avatars.githubusercontent.com/u/11992191?v=3","gravatar_id":"","url":"https://api.github.com/users/project-generator","html_url":"https://github.com/project-generator","followers_url":"https://api.github.com/users/project-generator/followers","following_url":"https://api.github.com/users/project-generator/following{/other_user}","gists_url":"https://api.github.com/users/project-generator/gists{/gist_id}","starred_url":"https://api.github.com/users/project-generator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/project-generator/subscriptions","organizations_url":"https://api.github.com/users/project-generator/orgs","repos_url":"https://api.github.com/users/project-generator/repos","events_url":"https://api.github.com/users/project-generator/events{/privacy}","received_events_url":"https://api.github.com/users/project-generator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/project-generator/project_generator","description":"Project generators for various embedded tools (IDE). IAR, uVision, Makefile, CoIDE, Eclipse and many more in the roadmap!","fork":false,"url":"https://api.github.com/repos/project-generator/project_generator","forks_url":"https://api.github.com/repos/project-generator/project_generator/forks","keys_url":"https://api.github.com/repos/project-generator/project_generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/project-generator/project_generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/project-generator/project_generator/teams","hooks_url":"https://api.github.com/repos/project-generator/project_generator/hooks","issue_events_url":"https://api.github.com/repos/project-generator/project_generator/issues/events{/number}","events_url":"https://api.github.com/repos/project-generator/project_generator/events","assignees_url":"https://api.github.com/repos/project-generator/project_generator/assignees{/user}","branches_url":"https://api.github.com/repos/project-generator/project_generator/branches{/branch}","tags_url":"https://api.github.com/repos/project-generator/project_generator/tags","blobs_url":"https://api.github.com/repos/project-generator/project_generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/project-generator/project_generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/project-generator/project_generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/project-generator/project_generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/project-generator/project_generator/statuses/{sha}","languages_url":"https://api.github.com/repos/project-generator/project_generator/languages","stargazers_url":"https://api.github.com/repos/project-generator/project_generator/stargazers","contributors_url":"https://api.github.com/repos/project-generator/project_generator/contributors","subscribers_url":"https://api.github.com/repos/project-generator/project_generator/subscribers","subscription_url":"https://api.github.com/repos/project-generator/project_generator/subscription","commits_url":"https://api.github.com/repos/project-generator/project_generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/project-generator/project_generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/project-generator/project_generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/project-generator/project_generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/project-generator/project_generator/contents/{+path}","compare_url":"https://api.github.com/repos/project-generator/project_generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/project-generator/project_generator/merges","archive_url":"https://api.github.com/repos/project-generator/project_generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/project-generator/project_generator/downloads","issues_url":"https://api.github.com/repos/project-generator/project_generator/issues{/number}","pulls_url":"https://api.github.com/repos/project-generator/project_generator/pulls{/number}","milestones_url":"https://api.github.com/repos/project-generator/project_generator/milestones{/number}","notifications_url":"https://api.github.com/repos/project-generator/project_generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/project-generator/project_generator/labels{/name}","releases_url":"https://api.github.com/repos/project-generator/project_generator/releases{/id}","created_at":"2014-08-09T09:22:51Z","updated_at":"2015-07-08T20:09:56Z","pushed_at":"2015-07-28T22:24:38Z","git_url":"git://github.com/project-generator/project_generator.git","ssh_url":"git@github.com:project-generator/project_generator.git","clone_url":"https://github.com/project-generator/project_generator.git","svn_url":"https://github.com/project-generator/project_generator","homepage":"","size":3133,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":20,"forks":13,"open_issues":20,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/241"},"html":{"href":"https://github.com/project-generator/project_generator/pull/241"},"issue":{"href":"https://api.github.com/repos/project-generator/project_generator/issues/241"},"comments":{"href":"https://api.github.com/repos/project-generator/project_generator/issues/241/comments"},"review_comments":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/241/comments"},"review_comment":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/project-generator/project_generator/pulls/241/commits"},"statuses":{"href":"https://api.github.com/repos/project-generator/project_generator/statuses/79b0df0eaf5a1b7323b4381b22168827c692d257"}}}}