{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/15938","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/15938/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/15938/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/15938/events","html_url":"https://github.com/ansible/ansible/pull/15938","id":155958734,"number":15938,"title":"New pyformat filter plugin to format python-style","user":{"login":"dagwieers","id":388198,"avatar_url":"https://avatars.githubusercontent.com/u/388198?v=3","gravatar_id":"","url":"https://api.github.com/users/dagwieers","html_url":"https://github.com/dagwieers","followers_url":"https://api.github.com/users/dagwieers/followers","following_url":"https://api.github.com/users/dagwieers/following{/other_user}","gists_url":"https://api.github.com/users/dagwieers/gists{/gist_id}","starred_url":"https://api.github.com/users/dagwieers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagwieers/subscriptions","organizations_url":"https://api.github.com/users/dagwieers/orgs","repos_url":"https://api.github.com/users/dagwieers/repos","events_url":"https://api.github.com/users/dagwieers/events{/privacy}","received_events_url":"https://api.github.com/users/dagwieers/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_pull_request","name":"feature_pull_request","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/8","html_url":"https://github.com/ansible/ansible/milestones/2.2.0","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/8/labels","id":1702615,"number":8,"title":"2.2.0","description":"","creator":{"login":"sivel","id":39340,"avatar_url":"https://avatars.githubusercontent.com/u/39340?v=3","gravatar_id":"","url":"https://api.github.com/users/sivel","html_url":"https://github.com/sivel","followers_url":"https://api.github.com/users/sivel/followers","following_url":"https://api.github.com/users/sivel/following{/other_user}","gists_url":"https://api.github.com/users/sivel/gists{/gist_id}","starred_url":"https://api.github.com/users/sivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivel/subscriptions","organizations_url":"https://api.github.com/users/sivel/orgs","repos_url":"https://api.github.com/users/sivel/repos","events_url":"https://api.github.com/users/sivel/events{/privacy}","received_events_url":"https://api.github.com/users/sivel/received_events","type":"User","site_admin":false},"open_issues":48,"closed_issues":14,"state":"open","created_at":"2016-04-12T23:10:49Z","updated_at":"2016-06-01T02:52:42Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-05-20T13:05:47Z","updated_at":"2016-06-01T13:27:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/15938","html_url":"https://github.com/ansible/ansible/pull/15938","diff_url":"https://github.com/ansible/ansible/pull/15938.diff","patch_url":"https://github.com/ansible/ansible/pull/15938.patch"},"body":"##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Feature Pull Request\r\n\r\n##### SUMMARY\r\n<!--- Describe the change, including rationale and design decisions -->\r\n\r\n<!---\r\nIf you are fixing an existing issue, please include \"Fixes #nnn\" in your\r\ncommit message and your description; but you should still explain what\r\nthe change does.\r\n-->\r\n\r\nThe existing jinja2 format filter is rather limited, and cannot use name placeholders in string formatting. This filter plugin makes it easier to pass any kind of information to a format string to do exactly what you like.\r\n\r\nFor more information regarding python formatting, see this: http://pyformat.info/\r\n\r\n##### EXAMPLE\r\nCreate a very specific date format\r\n\r\n```yaml\r\n- hosts: localhost\r\n  vars:\r\n    # Old style formatting\r\n    timestamp1: '{{ \"%(month)s%(day)s%(year)s\" | pyformat(ansible_date_time) }}'\r\n    # Old style formatting with key-value substitution\r\n    timestamp2: '{{ \"%(month)s%(day)s%(year)s\" | pyformat(ansible_date_time, year=ansible_date_time[\"year\"][2:4]) }}'\r\n    # New style formatting (python 2.7 and python 3+)\r\n    timestamp3: '{{ \"{month}{day}{year}\" | pyformat(ansible_date_time) }}'\r\n    # New style formatting with indentation (python 2.7 and python 3+)\r\n    timestamp3: '{{ \"{month:5}{day:5}{year:5}\" | pyformat(ansible_date_time) }}'\r\n  tasks:\r\n  - name: Old style formatting\r\n    debug: var=timestamp1\r\n  - name: Old style formatting with key-value substitution\r\n    debug: var=timestamp2\r\n  - name: New style formatting (python 2.7 and python 3+)\r\n    debug: var=timestamp3\r\n  - name: New style formatting with indentation (python 2.7 and python 3+)\r\n    debug: var=timestamp4\r\n```\r\n\r\n##### OUTPUT\r\n\r\n```\r\nPLAY [localhost] ***************************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [localhost]\r\n\r\nTASK [Old style formatting] ****************************************************\r\nok: [localhost] => {\r\n    \"timestamp1\": \"05202016\"\r\n}\r\n\r\nTASK [Old style formatting with key-value substitution] ************************\r\nok: [localhost] => {\r\n    \"timestamp2\": \"052016\"\r\n}\r\n\r\nTASK [New style formatting (python 2.7 and python 3+)] *************************\r\nok: [localhost] => {\r\n    \"timestamp3\": \"05202016\"\r\n}\r\n\r\nTASK [New style formatting with indentation (python 2.7 and python 3+)] *********\r\nok: [localhost] => {\r\n    \"timestamp4\": \"05   20   2016 \"\r\n}\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=5    changed=0    unreachable=0    failed=0\r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/222991589","html_url":"https://github.com/ansible/ansible/pull/15938#issuecomment-222991589","issue_url":"https://api.github.com/repos/ansible/ansible/issues/15938","id":222991589,"user":{"login":"dagwieers","id":388198,"avatar_url":"https://avatars.githubusercontent.com/u/388198?v=3","gravatar_id":"","url":"https://api.github.com/users/dagwieers","html_url":"https://github.com/dagwieers","followers_url":"https://api.github.com/users/dagwieers/followers","following_url":"https://api.github.com/users/dagwieers/following{/other_user}","gists_url":"https://api.github.com/users/dagwieers/gists{/gist_id}","starred_url":"https://api.github.com/users/dagwieers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagwieers/subscriptions","organizations_url":"https://api.github.com/users/dagwieers/orgs","repos_url":"https://api.github.com/users/dagwieers/repos","events_url":"https://api.github.com/users/dagwieers/events{/privacy}","received_events_url":"https://api.github.com/users/dagwieers/received_events","type":"User","site_admin":false},"created_at":"2016-06-01T13:27:31Z","updated_at":"2016-06-01T13:27:31Z","body":"I noticed that the python documentation no longer includes information on the old formatting syntax at: https://docs.python.org/2.6/library/string.html It no longer includes documentation that predates python 2.6(.9).\r\n\r\nAnother reason for including this pyformat filter IMO !"}}
{"actor":{"display_login":"dagwieers"}}