mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
replace: PEP8 compliancy, pylint and docs (#30856)
This PR includes; - PEP8 compliancy fixes - pylint fixes - Documentation updates
This commit is contained in:
parent
25e17b4035
commit
5175bd8ebd
2 changed files with 14 additions and 22 deletions
|
@ -29,13 +29,12 @@ description:
|
||||||
version_added: "1.6"
|
version_added: "1.6"
|
||||||
options:
|
options:
|
||||||
path:
|
path:
|
||||||
required: true
|
|
||||||
aliases: [ dest, destfile, name ]
|
|
||||||
description:
|
description:
|
||||||
- The file to modify.
|
- The file to modify.
|
||||||
- Before 2.3 this option was only usable as I(dest), I(destfile) and I(name).
|
- Before 2.3 this option was only usable as I(dest), I(destfile) and I(name).
|
||||||
regexp:
|
aliases: [ dest, destfile, name ]
|
||||||
required: true
|
required: true
|
||||||
|
regexp:
|
||||||
description:
|
description:
|
||||||
- The regular expression to look for in the contents of the file.
|
- The regular expression to look for in the contents of the file.
|
||||||
Uses Python regular expressions; see
|
Uses Python regular expressions; see
|
||||||
|
@ -50,52 +49,46 @@ options:
|
||||||
- Note that, as of ansible 2, short form tasks should have any escape
|
- Note that, as of ansible 2, short form tasks should have any escape
|
||||||
sequences backslash-escaped in order to prevent them being parsed
|
sequences backslash-escaped in order to prevent them being parsed
|
||||||
as string literal escapes. See the examples.
|
as string literal escapes. See the examples.
|
||||||
|
required: true
|
||||||
replace:
|
replace:
|
||||||
required: false
|
|
||||||
description:
|
description:
|
||||||
- The string to replace regexp matches. May contain backreferences
|
- The string to replace regexp matches. May contain backreferences
|
||||||
that will get expanded with the regexp capture groups if the regexp
|
that will get expanded with the regexp capture groups if the regexp
|
||||||
matches. If not set, matches are removed entirely.
|
matches. If not set, matches are removed entirely.
|
||||||
after:
|
after:
|
||||||
required: false
|
|
||||||
version_added: "2.4"
|
|
||||||
description:
|
description:
|
||||||
- If specified, the line after the replace/remove will start. Can be used
|
- If specified, the line after the replace/remove will start. Can be used
|
||||||
in combination with C(before).
|
in combination with C(before).
|
||||||
Uses Python regular expressions; see
|
Uses Python regular expressions; see
|
||||||
U(http://docs.python.org/2/library/re.html).
|
U(http://docs.python.org/2/library/re.html).
|
||||||
before:
|
|
||||||
required: false
|
|
||||||
version_added: "2.4"
|
version_added: "2.4"
|
||||||
|
before:
|
||||||
description:
|
description:
|
||||||
- If specified, the line before the replace/remove will occur. Can be used
|
- If specified, the line before the replace/remove will occur. Can be used
|
||||||
in combination with C(after).
|
in combination with C(after).
|
||||||
Uses Python regular expressions; see
|
Uses Python regular expressions; see
|
||||||
U(http://docs.python.org/2/library/re.html).
|
U(http://docs.python.org/2/library/re.html).
|
||||||
|
version_added: "2.4"
|
||||||
backup:
|
backup:
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
description:
|
description:
|
||||||
- Create a backup file including the timestamp information so you can
|
- Create a backup file including the timestamp information so you can
|
||||||
get the original file back if you somehow clobbered it incorrectly.
|
get the original file back if you somehow clobbered it incorrectly.
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
others:
|
others:
|
||||||
description:
|
description:
|
||||||
- All arguments accepted by the M(file) module also work here.
|
- All arguments accepted by the M(file) module also work here.
|
||||||
required: false
|
|
||||||
follow:
|
follow:
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
version_added: "1.9"
|
|
||||||
description:
|
description:
|
||||||
- 'This flag indicates that filesystem links, if they exist, should be followed.'
|
- 'This flag indicates that filesystem links, if they exist, should be followed.'
|
||||||
|
type: bool
|
||||||
|
default: "no"
|
||||||
|
version_added: "1.9"
|
||||||
encoding:
|
encoding:
|
||||||
required: false
|
|
||||||
default: "utf-8"
|
|
||||||
version_added: "2.4"
|
|
||||||
description:
|
description:
|
||||||
- "The character encoding for reading and writing the file."
|
- "The character encoding for reading and writing the file."
|
||||||
|
default: "utf-8"
|
||||||
|
version_added: "2.4"
|
||||||
notes:
|
notes:
|
||||||
- As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
|
- As of Ansible 2.3, the I(dest) option has been changed to I(path) as default, but I(dest) still works as well.
|
||||||
"""
|
"""
|
||||||
|
@ -167,7 +160,7 @@ from ansible.module_utils.basic import AnsibleModule
|
||||||
def write_changes(module, contents, path):
|
def write_changes(module, contents, path):
|
||||||
|
|
||||||
tmpfd, tmpfile = tempfile.mkstemp()
|
tmpfd, tmpfile = tempfile.mkstemp()
|
||||||
f = os.fdopen(tmpfd,'wb')
|
f = os.fdopen(tmpfd, 'wb')
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
@ -180,7 +173,7 @@ def write_changes(module, contents, path):
|
||||||
valid = rc == 0
|
valid = rc == 0
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg='failed to validate: '
|
module.fail_json(msg='failed to validate: '
|
||||||
'rc:%s error:%s' % (rc,err))
|
'rc:%s error:%s' % (rc, err))
|
||||||
if valid:
|
if valid:
|
||||||
module.atomic_move(tmpfile, path, unsafe_writes=module.params['unsafe_writes'])
|
module.atomic_move(tmpfile, path, unsafe_writes=module.params['unsafe_writes'])
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,6 @@ lib/ansible/modules/database/vertica/vertica_user.py
|
||||||
lib/ansible/modules/files/archive.py
|
lib/ansible/modules/files/archive.py
|
||||||
lib/ansible/modules/files/assemble.py
|
lib/ansible/modules/files/assemble.py
|
||||||
lib/ansible/modules/files/blockinfile.py
|
lib/ansible/modules/files/blockinfile.py
|
||||||
lib/ansible/modules/files/replace.py
|
|
||||||
lib/ansible/modules/files/synchronize.py
|
lib/ansible/modules/files/synchronize.py
|
||||||
lib/ansible/modules/files/tempfile.py
|
lib/ansible/modules/files/tempfile.py
|
||||||
lib/ansible/modules/monitoring/bigpanda.py
|
lib/ansible/modules/monitoring/bigpanda.py
|
||||||
|
|
Loading…
Reference in a new issue