{"action":"created","comment":{"url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/comments/92390855","pull_request_review_id":12904398,"id":92390855,"diff_hunk":"@@ -100,6 +111,26 @@ def __init__(self, path=None, cache_content=False, env_replace=True, parent_env=\n         else:\n             self.parent_env = {}\n \n+    @contextmanager\n+    def _open_dockerfile(self, mode):\n+        if self.fileobj is not None:\n+            try:\n+                self.fileobj.seek(0)\n+            except IOError:","path":"dockerfile_parse/parser.py","position":50,"original_position":50,"commit_id":"afab0ca62b4890f2562b6ddf365de7537a743037","original_commit_id":"afab0ca62b4890f2562b6ddf365de7537a743037","user":{"login":"lcarva","id":5272931,"avatar_url":"https://avatars.githubusercontent.com/u/5272931?v=3","gravatar_id":"","url":"https://api.github.com/users/lcarva","html_url":"https://github.com/lcarva","followers_url":"https://api.github.com/users/lcarva/followers","following_url":"https://api.github.com/users/lcarva/following{/other_user}","gists_url":"https://api.github.com/users/lcarva/gists{/gist_id}","starred_url":"https://api.github.com/users/lcarva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcarva/subscriptions","organizations_url":"https://api.github.com/users/lcarva/orgs","repos_url":"https://api.github.com/users/lcarva/repos","events_url":"https://api.github.com/users/lcarva/events{/privacy}","received_events_url":"https://api.github.com/users/lcarva/received_events","type":"User","site_admin":false},"body":"Not rewinding the file will cause unexpected behavior when using this class.\r\nCan the \"requirement\" be that the file must be seekable?\r\n\r\nPerhaps this can be enforced with a `seek(0)` call in `__init__` to fail immediately and provide a meaningful error message?","created_at":"2016-12-14T13:22:11Z","updated_at":"2016-12-14T13:22:11Z","html_url":"https://github.com/DBuildService/dockerfile-parse/pull/23#discussion_r92390855","pull_request_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/comments/92390855"},"html":{"href":"https://github.com/DBuildService/dockerfile-parse/pull/23#discussion_r92390855"},"pull_request":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23","id":97230516,"html_url":"https://github.com/DBuildService/dockerfile-parse/pull/23","diff_url":"https://github.com/DBuildService/dockerfile-parse/pull/23.diff","patch_url":"https://github.com/DBuildService/dockerfile-parse/pull/23.patch","issue_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/23","number":23,"state":"open","locked":false,"title":"Add ability to cache content with a file-like object.","user":{"login":"lachmanfrantisek","id":20214043,"avatar_url":"https://avatars.githubusercontent.com/u/20214043?v=3","gravatar_id":"","url":"https://api.github.com/users/lachmanfrantisek","html_url":"https://github.com/lachmanfrantisek","followers_url":"https://api.github.com/users/lachmanfrantisek/followers","following_url":"https://api.github.com/users/lachmanfrantisek/following{/other_user}","gists_url":"https://api.github.com/users/lachmanfrantisek/gists{/gist_id}","starred_url":"https://api.github.com/users/lachmanfrantisek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lachmanfrantisek/subscriptions","organizations_url":"https://api.github.com/users/lachmanfrantisek/orgs","repos_url":"https://api.github.com/users/lachmanfrantisek/repos","events_url":"https://api.github.com/users/lachmanfrantisek/events{/privacy}","received_events_url":"https://api.github.com/users/lachmanfrantisek/received_events","type":"User","site_admin":false},"body":"I have implemented a possibility to cache content with the file-like object. So, it won't be necessary to write `Dockerfile` to disk.\r\n\r\nIt adds a property `fileobj` to `parser`. If it is not `None`, the content will be written to this `fileobj` instead of the `./Dockerfile` file.\r\n\r\nHere is an example of usage with StringIO:\r\n\r\n```python\r\ncontent = r\"\"\"\r\nFROM fedora:latest\r\nMAINTAINER Franta\r\n\r\nENV a=aaa\r\n\"\"\"\r\n\r\ndockerfile = six.StringIO(content)\r\ndfp = dockerfile_parse.DockerfileParser(fileobj=dockerfile,\r\n                                     cache_content=True,\r\n                                     env_replace=False)\r\n```\r\n\r\nCan you please have a look at it?\r\n\r\nThanks","created_at":"2016-12-09T00:41:24Z","updated_at":"2016-12-14T13:22:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4309ecb1c85e3a51b5500ff06cf5896735f0b9c4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23/commits","review_comments_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23/comments","review_comment_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/23/comments","statuses_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/statuses/afab0ca62b4890f2562b6ddf365de7537a743037","head":{"label":"lachmanfrantisek:creating-file-optional","ref":"creating-file-optional","sha":"afab0ca62b4890f2562b6ddf365de7537a743037","user":{"login":"lachmanfrantisek","id":20214043,"avatar_url":"https://avatars.githubusercontent.com/u/20214043?v=3","gravatar_id":"","url":"https://api.github.com/users/lachmanfrantisek","html_url":"https://github.com/lachmanfrantisek","followers_url":"https://api.github.com/users/lachmanfrantisek/followers","following_url":"https://api.github.com/users/lachmanfrantisek/following{/other_user}","gists_url":"https://api.github.com/users/lachmanfrantisek/gists{/gist_id}","starred_url":"https://api.github.com/users/lachmanfrantisek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lachmanfrantisek/subscriptions","organizations_url":"https://api.github.com/users/lachmanfrantisek/orgs","repos_url":"https://api.github.com/users/lachmanfrantisek/repos","events_url":"https://api.github.com/users/lachmanfrantisek/events{/privacy}","received_events_url":"https://api.github.com/users/lachmanfrantisek/received_events","type":"User","site_admin":false},"repo":{"id":75983044,"name":"dockerfile-parse","full_name":"lachmanfrantisek/dockerfile-parse","owner":{"login":"lachmanfrantisek","id":20214043,"avatar_url":"https://avatars.githubusercontent.com/u/20214043?v=3","gravatar_id":"","url":"https://api.github.com/users/lachmanfrantisek","html_url":"https://github.com/lachmanfrantisek","followers_url":"https://api.github.com/users/lachmanfrantisek/followers","following_url":"https://api.github.com/users/lachmanfrantisek/following{/other_user}","gists_url":"https://api.github.com/users/lachmanfrantisek/gists{/gist_id}","starred_url":"https://api.github.com/users/lachmanfrantisek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lachmanfrantisek/subscriptions","organizations_url":"https://api.github.com/users/lachmanfrantisek/orgs","repos_url":"https://api.github.com/users/lachmanfrantisek/repos","events_url":"https://api.github.com/users/lachmanfrantisek/events{/privacy}","received_events_url":"https://api.github.com/users/lachmanfrantisek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lachmanfrantisek/dockerfile-parse","description":"Python library for parsing Dockerfile files.","fork":true,"url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse","forks_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/forks","keys_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/teams","hooks_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/hooks","issue_events_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/issues/events{/number}","events_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/events","assignees_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/assignees{/user}","branches_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/branches{/branch}","tags_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/tags","blobs_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/git/refs{/sha}","trees_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/statuses/{sha}","languages_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/languages","stargazers_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/stargazers","contributors_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/contributors","subscribers_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/subscribers","subscription_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/subscription","commits_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/commits{/sha}","git_commits_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/git/commits{/sha}","comments_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/comments{/number}","issue_comment_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/issues/comments{/number}","contents_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/contents/{+path}","compare_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/merges","archive_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/downloads","issues_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/issues{/number}","pulls_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/pulls{/number}","milestones_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/milestones{/number}","notifications_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/labels{/name}","releases_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/releases{/id}","deployments_url":"https://api.github.com/repos/lachmanfrantisek/dockerfile-parse/deployments","created_at":"2016-12-08T23:15:21Z","updated_at":"2016-12-08T23:15:22Z","pushed_at":"2016-12-14T11:46:08Z","git_url":"git://github.com/lachmanfrantisek/dockerfile-parse.git","ssh_url":"git@github.com:lachmanfrantisek/dockerfile-parse.git","clone_url":"https://github.com/lachmanfrantisek/dockerfile-parse.git","svn_url":"https://github.com/lachmanfrantisek/dockerfile-parse","homepage":null,"size":67,"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":"DBuildService:master","ref":"master","sha":"ab94e0669d85a616f6566b08e170acfdc914e13c","user":{"login":"DBuildService","id":9337743,"avatar_url":"https://avatars.githubusercontent.com/u/9337743?v=3","gravatar_id":"","url":"https://api.github.com/users/DBuildService","html_url":"https://github.com/DBuildService","followers_url":"https://api.github.com/users/DBuildService/followers","following_url":"https://api.github.com/users/DBuildService/following{/other_user}","gists_url":"https://api.github.com/users/DBuildService/gists{/gist_id}","starred_url":"https://api.github.com/users/DBuildService/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBuildService/subscriptions","organizations_url":"https://api.github.com/users/DBuildService/orgs","repos_url":"https://api.github.com/users/DBuildService/repos","events_url":"https://api.github.com/users/DBuildService/events{/privacy}","received_events_url":"https://api.github.com/users/DBuildService/received_events","type":"Organization","site_admin":false},"repo":{"id":37669690,"name":"dockerfile-parse","full_name":"DBuildService/dockerfile-parse","owner":{"login":"DBuildService","id":9337743,"avatar_url":"https://avatars.githubusercontent.com/u/9337743?v=3","gravatar_id":"","url":"https://api.github.com/users/DBuildService","html_url":"https://github.com/DBuildService","followers_url":"https://api.github.com/users/DBuildService/followers","following_url":"https://api.github.com/users/DBuildService/following{/other_user}","gists_url":"https://api.github.com/users/DBuildService/gists{/gist_id}","starred_url":"https://api.github.com/users/DBuildService/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DBuildService/subscriptions","organizations_url":"https://api.github.com/users/DBuildService/orgs","repos_url":"https://api.github.com/users/DBuildService/repos","events_url":"https://api.github.com/users/DBuildService/events{/privacy}","received_events_url":"https://api.github.com/users/DBuildService/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DBuildService/dockerfile-parse","description":"Python library for parsing Dockerfile files.","fork":false,"url":"https://api.github.com/repos/DBuildService/dockerfile-parse","forks_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/forks","keys_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/teams","hooks_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/hooks","issue_events_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/events{/number}","events_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/events","assignees_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/assignees{/user}","branches_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/branches{/branch}","tags_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/tags","blobs_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/git/refs{/sha}","trees_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/statuses/{sha}","languages_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/languages","stargazers_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/stargazers","contributors_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/contributors","subscribers_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/subscribers","subscription_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/subscription","commits_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/commits{/sha}","git_commits_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/git/commits{/sha}","comments_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/comments{/number}","issue_comment_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/comments{/number}","contents_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/contents/{+path}","compare_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/merges","archive_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/downloads","issues_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues{/number}","pulls_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls{/number}","milestones_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/milestones{/number}","notifications_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/labels{/name}","releases_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/releases{/id}","deployments_url":"https://api.github.com/repos/DBuildService/dockerfile-parse/deployments","created_at":"2015-06-18T15:59:46Z","updated_at":"2016-11-15T06:01:11Z","pushed_at":"2016-12-14T11:46:09Z","git_url":"git://github.com/DBuildService/dockerfile-parse.git","ssh_url":"git@github.com:DBuildService/dockerfile-parse.git","clone_url":"https://github.com/DBuildService/dockerfile-parse.git","svn_url":"https://github.com/DBuildService/dockerfile-parse","homepage":null,"size":74,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23"},"html":{"href":"https://github.com/DBuildService/dockerfile-parse/pull/23"},"issue":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/23"},"comments":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/DBuildService/dockerfile-parse/statuses/afab0ca62b4890f2562b6ddf365de7537a743037"}}}}
{"actor":{"display_login":"lcarva"}}