{"action":"closed","number":21363,"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/21363","id":30598357,"html_url":"https://github.com/saltstack/salt/pull/21363","diff_url":"https://github.com/saltstack/salt/pull/21363.diff","patch_url":"https://github.com/saltstack/salt/pull/21363.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/21363","number":21363,"state":"closed","locked":false,"title":"[QUESTION] Rework `file.replace` to remove `fileinput`","user":{"login":"lorengordon","id":8457307,"avatar_url":"https://avatars.githubusercontent.com/u/8457307?v=3","gravatar_id":"","url":"https://api.github.com/users/lorengordon","html_url":"https://github.com/lorengordon","followers_url":"https://api.github.com/users/lorengordon/followers","following_url":"https://api.github.com/users/lorengordon/following{/other_user}","gists_url":"https://api.github.com/users/lorengordon/gists{/gist_id}","starred_url":"https://api.github.com/users/lorengordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorengordon/subscriptions","organizations_url":"https://api.github.com/users/lorengordon/orgs","repos_url":"https://api.github.com/users/lorengordon/repos","events_url":"https://api.github.com/users/lorengordon/events{/privacy}","received_events_url":"https://api.github.com/users/lorengordon/received_events","type":"User","site_admin":false},"body":"Fixes saltstack#21362.\r\n\r\n- Eliminate `fileinput`; utilize `salt.utils.fopen` instead\r\n- Utilize `with` for file-handles instead of `try-finally`\r\n- Catch and raise IOError and OSError exceptions on potential file read/write errors\r\n- Search first to avoid updating timestamps if no changes have been made\r\n- When making changes to the file, create a temp file to read from; temp file becomes the backup\r\n- Add function _mkstemp_copy() to handle creation of the temp copy\r\n- More granular control over when to keep/delete the backup; don't clobber existing backup file unless changes are made","created_at":"2015-03-05T21:39:22Z","updated_at":"2015-03-09T17:11:15Z","closed_at":"2015-03-09T17:11:15Z","merged_at":"2015-03-09T17:11:15Z","merge_commit_sha":"d0dbab15fa7d15a26bcfe4412267fd7c83be4d4c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/21363/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/21363/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/21363/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/16d68801ab6f3b8f283fcc6c8d1b7bf6f9212d33","head":{"label":"lorengordon:file-replace-rework","ref":"file-replace-rework","sha":"16d68801ab6f3b8f283fcc6c8d1b7bf6f9212d33","user":{"login":"lorengordon","id":8457307,"avatar_url":"https://avatars.githubusercontent.com/u/8457307?v=3","gravatar_id":"","url":"https://api.github.com/users/lorengordon","html_url":"https://github.com/lorengordon","followers_url":"https://api.github.com/users/lorengordon/followers","following_url":"https://api.github.com/users/lorengordon/following{/other_user}","gists_url":"https://api.github.com/users/lorengordon/gists{/gist_id}","starred_url":"https://api.github.com/users/lorengordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorengordon/subscriptions","organizations_url":"https://api.github.com/users/lorengordon/orgs","repos_url":"https://api.github.com/users/lorengordon/repos","events_url":"https://api.github.com/users/lorengordon/events{/privacy}","received_events_url":"https://api.github.com/users/lorengordon/received_events","type":"User","site_admin":false},"repo":{"id":25579590,"name":"salt","full_name":"lorengordon/salt","owner":{"login":"lorengordon","id":8457307,"avatar_url":"https://avatars.githubusercontent.com/u/8457307?v=3","gravatar_id":"","url":"https://api.github.com/users/lorengordon","html_url":"https://github.com/lorengordon","followers_url":"https://api.github.com/users/lorengordon/followers","following_url":"https://api.github.com/users/lorengordon/following{/other_user}","gists_url":"https://api.github.com/users/lorengordon/gists{/gist_id}","starred_url":"https://api.github.com/users/lorengordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorengordon/subscriptions","organizations_url":"https://api.github.com/users/lorengordon/orgs","repos_url":"https://api.github.com/users/lorengordon/repos","events_url":"https://api.github.com/users/lorengordon/events{/privacy}","received_events_url":"https://api.github.com/users/lorengordon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lorengordon/salt","description":"Infrastructure automation and management system","fork":true,"url":"https://api.github.com/repos/lorengordon/salt","forks_url":"https://api.github.com/repos/lorengordon/salt/forks","keys_url":"https://api.github.com/repos/lorengordon/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lorengordon/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lorengordon/salt/teams","hooks_url":"https://api.github.com/repos/lorengordon/salt/hooks","issue_events_url":"https://api.github.com/repos/lorengordon/salt/issues/events{/number}","events_url":"https://api.github.com/repos/lorengordon/salt/events","assignees_url":"https://api.github.com/repos/lorengordon/salt/assignees{/user}","branches_url":"https://api.github.com/repos/lorengordon/salt/branches{/branch}","tags_url":"https://api.github.com/repos/lorengordon/salt/tags","blobs_url":"https://api.github.com/repos/lorengordon/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lorengordon/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lorengordon/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/lorengordon/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lorengordon/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/lorengordon/salt/languages","stargazers_url":"https://api.github.com/repos/lorengordon/salt/stargazers","contributors_url":"https://api.github.com/repos/lorengordon/salt/contributors","subscribers_url":"https://api.github.com/repos/lorengordon/salt/subscribers","subscription_url":"https://api.github.com/repos/lorengordon/salt/subscription","commits_url":"https://api.github.com/repos/lorengordon/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/lorengordon/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/lorengordon/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/lorengordon/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/lorengordon/salt/contents/{+path}","compare_url":"https://api.github.com/repos/lorengordon/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lorengordon/salt/merges","archive_url":"https://api.github.com/repos/lorengordon/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lorengordon/salt/downloads","issues_url":"https://api.github.com/repos/lorengordon/salt/issues{/number}","pulls_url":"https://api.github.com/repos/lorengordon/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/lorengordon/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/lorengordon/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lorengordon/salt/labels{/name}","releases_url":"https://api.github.com/repos/lorengordon/salt/releases{/id}","created_at":"2014-10-22T12:13:14Z","updated_at":"2015-03-09T11:33:53Z","pushed_at":"2015-03-09T11:33:52Z","git_url":"git://github.com/lorengordon/salt.git","ssh_url":"git@github.com:lorengordon/salt.git","clone_url":"https://github.com/lorengordon/salt.git","svn_url":"https://github.com/lorengordon/salt","homepage":"saltstack.com","size":86593,"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":"saltstack:2015.2","ref":"2015.2","sha":"0e8a47f8a95739f1134db38d4ce6899960ec71fb","user":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"repo":{"id":1390248,"name":"salt","full_name":"saltstack/salt","owner":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saltstack/salt","description":"Infrastructure automation and management system","fork":false,"url":"https://api.github.com/repos/saltstack/salt","forks_url":"https://api.github.com/repos/saltstack/salt/forks","keys_url":"https://api.github.com/repos/saltstack/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saltstack/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saltstack/salt/teams","hooks_url":"https://api.github.com/repos/saltstack/salt/hooks","issue_events_url":"https://api.github.com/repos/saltstack/salt/issues/events{/number}","events_url":"https://api.github.com/repos/saltstack/salt/events","assignees_url":"https://api.github.com/repos/saltstack/salt/assignees{/user}","branches_url":"https://api.github.com/repos/saltstack/salt/branches{/branch}","tags_url":"https://api.github.com/repos/saltstack/salt/tags","blobs_url":"https://api.github.com/repos/saltstack/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saltstack/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saltstack/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/saltstack/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/saltstack/salt/languages","stargazers_url":"https://api.github.com/repos/saltstack/salt/stargazers","contributors_url":"https://api.github.com/repos/saltstack/salt/contributors","subscribers_url":"https://api.github.com/repos/saltstack/salt/subscribers","subscription_url":"https://api.github.com/repos/saltstack/salt/subscription","commits_url":"https://api.github.com/repos/saltstack/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/saltstack/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/saltstack/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/saltstack/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/saltstack/salt/contents/{+path}","compare_url":"https://api.github.com/repos/saltstack/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saltstack/salt/merges","archive_url":"https://api.github.com/repos/saltstack/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saltstack/salt/downloads","issues_url":"https://api.github.com/repos/saltstack/salt/issues{/number}","pulls_url":"https://api.github.com/repos/saltstack/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/saltstack/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/saltstack/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saltstack/salt/labels{/name}","releases_url":"https://api.github.com/repos/saltstack/salt/releases{/id}","created_at":"2011-02-20T20:16:56Z","updated_at":"2015-03-09T17:09:57Z","pushed_at":"2015-03-09T17:11:15Z","git_url":"git://github.com/saltstack/salt.git","ssh_url":"git@github.com:saltstack/salt.git","clone_url":"https://github.com/saltstack/salt.git","svn_url":"https://github.com/saltstack/salt","homepage":"saltstack.com","size":190342,"stargazers_count":4800,"watchers_count":4800,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1994,"mirror_url":null,"open_issues_count":2368,"forks":1994,"open_issues":2368,"watchers":4800,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/21363"},"html":{"href":"https://github.com/saltstack/salt/pull/21363"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/21363"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/21363/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/21363/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/21363/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/16d68801ab6f3b8f283fcc6c8d1b7bf6f9212d33"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"comments":1,"review_comments":0,"commits":5,"additions":175,"deletions":59,"changed_files":1}}