{"action":"created","comment":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/comments/22442365","id":22442365,"diff_hunk":"@@ -122,17 +122,53 @@ def inputs_to_dict(resource, resource_name):\n     if not resource:\n         return None\n     try:\n-        if os.path.exists(resource):\n-            with open(resource, 'r') as f:\n-                return yaml.load(f.read())\n-        else:\n-            return yaml.load(resource)\n-    except yaml.error.YAMLError as e:\n-        msg = (\"'{0}' must be a valid YAML. {1}\"\n-               .format(resource_name, str(e)))\n+        # parse resource as string representation of a dictionary\n+        parsed_dict = plain_string_to_dict(resource)\n+    except CloudifyCliError:\n+        try:\n+            # if resource is a path - parse as a yaml file\n+            if os.path.exists(resource):\n+                with open(resource, 'r') as f:\n+                    return yaml.load(f.read())\n+            else:\n+                # parse resource content as yaml\n+                parsed_dict = yaml.load(resource)\n+        except yaml.error.YAMLError as e:\n+            msg = (\"'{0}' is not a valid YAML. {1}\"\n+                   .format(resource_name, str(e)))\n+            raise CloudifyCliError(msg)\n+\n+    if isinstance(parsed_dict, dict):\n+        return parsed_dict\n+    else:\n+        msg = \"Invalid input: {0}. {1} must be either be a path to a valid \" \\\n+              \"YAML file, a string formatted as a valid YAML or a string \" \\\n+              \"formatted as a dictionary (key1=value1;key2=value2)\"\\\n+            .format(resource, resource_name)\n         raise CloudifyCliError(msg)\n \n \n+def plain_string_to_dict(input_string):\n+    input_string = str(input_string).strip()\n+    input_dict = {}\n+    mapped_inputs = input_string.split(';')\n+    for mapped_input in mapped_inputs:\n+        mapped_input = str(mapped_input).strip()\n+        if len(mapped_input) == 0:","path":"cloudify_cli/utils.py","position":44,"original_position":44,"commit_id":"dafb1fb624e4d816a3c8c504da15469365443473","original_commit_id":"dafb1fb624e4d816a3c8c504da15469365443473","user":{"login":"dankilman","id":1008577,"avatar_url":"https://avatars.githubusercontent.com/u/1008577?v=3","gravatar_id":"","url":"https://api.github.com/users/dankilman","html_url":"https://github.com/dankilman","followers_url":"https://api.github.com/users/dankilman/followers","following_url":"https://api.github.com/users/dankilman/following{/other_user}","gists_url":"https://api.github.com/users/dankilman/gists{/gist_id}","starred_url":"https://api.github.com/users/dankilman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankilman/subscriptions","organizations_url":"https://api.github.com/users/dankilman/orgs","repos_url":"https://api.github.com/users/dankilman/repos","events_url":"https://api.github.com/users/dankilman/events{/privacy}","received_events_url":"https://api.github.com/users/dankilman/received_events","type":"User","site_admin":false},"body":"empty string have a boolean value of false.\r\nbecause you know mapped input is a string you can simply do\r\n`if not mapped_input` instead of `if len(mapped_input) == 0`","created_at":"2015-01-04T20:36:05Z","updated_at":"2015-01-04T20:36:05Z","html_url":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106#discussion_r22442365","pull_request_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106","_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/comments/22442365"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106#discussion_r22442365"},"pull_request":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106"}}},"pull_request":{"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106","id":26798529,"html_url":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106","diff_url":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106.diff","patch_url":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106.patch","issue_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/106","number":106,"state":"open","locked":false,"title":"parsing input as a string dict","user":{"login":"noakup","id":1745412,"avatar_url":"https://avatars.githubusercontent.com/u/1745412?v=3","gravatar_id":"","url":"https://api.github.com/users/noakup","html_url":"https://github.com/noakup","followers_url":"https://api.github.com/users/noakup/followers","following_url":"https://api.github.com/users/noakup/following{/other_user}","gists_url":"https://api.github.com/users/noakup/gists{/gist_id}","starred_url":"https://api.github.com/users/noakup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noakup/subscriptions","organizations_url":"https://api.github.com/users/noakup/orgs","repos_url":"https://api.github.com/users/noakup/repos","events_url":"https://api.github.com/users/noakup/events{/privacy}","received_events_url":"https://api.github.com/users/noakup/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-04T19:34:15Z","updated_at":"2015-01-04T20:36:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7c93f6dc790b8387f5f778c2a76f5763629b9cb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106/commits","review_comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106/comments","review_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/106/comments","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/statuses/dafb1fb624e4d816a3c8c504da15469365443473","head":{"label":"cloudify-cosmo:CFY-1904-Support_CLI_inputs_formatted_as_plain_string","ref":"CFY-1904-Support_CLI_inputs_formatted_as_plain_string","sha":"dafb1fb624e4d816a3c8c504da15469365443473","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326701,"name":"cloudify-cli","full_name":"cloudify-cosmo/cloudify-cli","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-cli","description":"Cloudify's CLI","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/comments/{number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/releases{/id}","created_at":"2014-04-01T11:12:15Z","updated_at":"2015-01-04T14:42:08Z","pushed_at":"2015-01-04T20:34:07Z","git_url":"git://github.com/cloudify-cosmo/cloudify-cli.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-cli.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-cli.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-cli","homepage":null,"size":5078,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":5,"default_branch":"master"}},"base":{"label":"cloudify-cosmo:master","ref":"master","sha":"ae920671ff132ef1012302e3c373879fcf7af35c","user":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"repo":{"id":18326701,"name":"cloudify-cli","full_name":"cloudify-cosmo/cloudify-cli","owner":{"login":"cloudify-cosmo","id":6260555,"avatar_url":"https://avatars.githubusercontent.com/u/6260555?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudify-cosmo","html_url":"https://github.com/cloudify-cosmo","followers_url":"https://api.github.com/users/cloudify-cosmo/followers","following_url":"https://api.github.com/users/cloudify-cosmo/following{/other_user}","gists_url":"https://api.github.com/users/cloudify-cosmo/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudify-cosmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudify-cosmo/subscriptions","organizations_url":"https://api.github.com/users/cloudify-cosmo/orgs","repos_url":"https://api.github.com/users/cloudify-cosmo/repos","events_url":"https://api.github.com/users/cloudify-cosmo/events{/privacy}","received_events_url":"https://api.github.com/users/cloudify-cosmo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudify-cosmo/cloudify-cli","description":"Cloudify's CLI","fork":false,"url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli","forks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/forks","keys_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/teams","hooks_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/hooks","issue_events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/events{/number}","events_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/events","assignees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/assignees{/user}","branches_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/branches{/branch}","tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/tags","blobs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/languages","stargazers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/stargazers","contributors_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/contributors","subscribers_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/subscribers","subscription_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/subscription","commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/comments/{number}","contents_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/contents/{+path}","compare_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/merges","archive_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/downloads","issues_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues{/number}","pulls_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/labels{/name}","releases_url":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/releases{/id}","created_at":"2014-04-01T11:12:15Z","updated_at":"2015-01-04T14:42:08Z","pushed_at":"2015-01-04T20:34:07Z","git_url":"git://github.com/cloudify-cosmo/cloudify-cli.git","ssh_url":"git@github.com:cloudify-cosmo/cloudify-cli.git","clone_url":"https://github.com/cloudify-cosmo/cloudify-cli.git","svn_url":"https://github.com/cloudify-cosmo/cloudify-cli","homepage":null,"size":5078,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106"},"html":{"href":"https://github.com/cloudify-cosmo/cloudify-cli/pull/106"},"issue":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/106"},"comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/cloudify-cosmo/cloudify-cli/statuses/dafb1fb624e4d816a3c8c504da15469365443473"}}}}