Added normpath filter (#78894)

Signed-off-by: Shivam Durgbuns <sdurgbun@redhat.com>
pull/78896/head
Shivam Durgbuns 2 years ago committed by GitHub
parent 7c4d5f5099
commit 6e949d8f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2021,7 +2021,6 @@ To join one or more path components:
.. versionadded:: 2.10
Manipulating strings
====================

@ -616,6 +616,7 @@ class FilterModule(object):
'win_dirname': partial(unicode_wrap, ntpath.dirname),
'win_splitdrive': partial(unicode_wrap, ntpath.splitdrive),
'commonpath': commonpath,
'normpath': partial(unicode_wrap, os.path.normpath),
# file glob
'fileglob': fileglob,

@ -0,0 +1,24 @@
DOCUMENTATION:
name: normpath
author: Shivam Durgbuns
version_added: "2.15"
short_description: Normalize a pathname
description:
- Returns the normalized pathname by collapsing redundant separators and up-level references
options:
_input:
description: A path
type: path
required: true
seealso:
- plugin: ansible.builtin.basename
plugin_type: filter
EXAMPLES: |
# To get a normalized path(ex. '/foo/bar') from the path(ex. '/foo//bar')
{{ path | normpath }}
RETURN:
_value:
description: The normalized path from the path given.
type: path
Loading…
Cancel
Save