mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
tempfile: PEP8 compliancy, pylint and docs (#30859)
This PR includes; - PEP8 compliancy fixes - pylint fixes - Documentation updates
This commit is contained in:
parent
f64a8f58a3
commit
c46401e41f
2 changed files with 15 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright: (c) 2016 Krzysztof Magosa <krzysztof@magosa.pl>
|
|
||||||
|
# Copyright: (c) 2016, Krzysztof Magosa <krzysztof@magosa.pl>
|
||||||
# Copyright: (c) 2017, Ansible Project
|
# Copyright: (c) 2017, Ansible Project
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
@ -11,7 +12,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'status': ['preview'],
|
'status': ['preview'],
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: tempfile
|
module: tempfile
|
||||||
|
@ -28,23 +28,18 @@ options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether to create file or directory.
|
- Whether to create file or directory.
|
||||||
required: false
|
choices: [ directory, file ]
|
||||||
choices: [ "file", "directory" ]
|
|
||||||
default: file
|
default: file
|
||||||
path:
|
path:
|
||||||
description:
|
description:
|
||||||
- Location where temporary file or directory should be created. If path is not specified default system temporary directory will be used.
|
- Location where temporary file or directory should be created. If path is not specified default system temporary directory will be used.
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
prefix:
|
prefix:
|
||||||
description:
|
description:
|
||||||
- Prefix of file/directory name created by module.
|
- Prefix of file/directory name created by module.
|
||||||
required: false
|
|
||||||
default: ansible.
|
default: ansible.
|
||||||
suffix:
|
suffix:
|
||||||
description:
|
description:
|
||||||
- Suffix of file/directory name created by module.
|
- Suffix of file/directory name created by module.
|
||||||
required: false
|
|
||||||
default: ""
|
default: ""
|
||||||
notes:
|
notes:
|
||||||
- For Windows targets, use the M(win_tempfile) module instead.
|
- For Windows targets, use the M(win_tempfile) module instead.
|
||||||
|
@ -73,17 +68,19 @@ path:
|
||||||
from os import close
|
from os import close
|
||||||
from tempfile import mkstemp, mkdtemp
|
from tempfile import mkstemp, mkdtemp
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec=dict(
|
||||||
state = dict(default='file', choices=['file', 'directory']),
|
state=dict(type='str', default='file', choices=['file', 'directory']),
|
||||||
path = dict(default=None),
|
path=dict(type='path'),
|
||||||
prefix = dict(default='ansible.'),
|
prefix=dict(type='str', default='ansible.'),
|
||||||
suffix = dict(default='')
|
suffix=dict(type='str', default=''),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -91,19 +88,20 @@ def main():
|
||||||
handle, path = mkstemp(
|
handle, path = mkstemp(
|
||||||
prefix=module.params['prefix'],
|
prefix=module.params['prefix'],
|
||||||
suffix=module.params['suffix'],
|
suffix=module.params['suffix'],
|
||||||
dir=module.params['path']
|
dir=module.params['path'],
|
||||||
)
|
)
|
||||||
close(handle)
|
close(handle)
|
||||||
elif module.params['state'] == 'directory':
|
elif module.params['state'] == 'directory':
|
||||||
path = mkdtemp(
|
path = mkdtemp(
|
||||||
prefix=module.params['prefix'],
|
prefix=module.params['prefix'],
|
||||||
suffix=module.params['suffix'],
|
suffix=module.params['suffix'],
|
||||||
dir=module.params['path']
|
dir=module.params['path'],
|
||||||
)
|
)
|
||||||
|
|
||||||
module.exit_json(changed=True, path=path)
|
module.exit_json(changed=True, path=path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
module.fail_json(msg=to_native(e), exception=format_exc())
|
module.fail_json(msg=to_native(e), exception=format_exc())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -149,7 +149,6 @@ lib/ansible/modules/database/vertica/vertica_facts.py
|
||||||
lib/ansible/modules/database/vertica/vertica_role.py
|
lib/ansible/modules/database/vertica/vertica_role.py
|
||||||
lib/ansible/modules/database/vertica/vertica_schema.py
|
lib/ansible/modules/database/vertica/vertica_schema.py
|
||||||
lib/ansible/modules/database/vertica/vertica_user.py
|
lib/ansible/modules/database/vertica/vertica_user.py
|
||||||
lib/ansible/modules/files/tempfile.py
|
|
||||||
lib/ansible/modules/monitoring/bigpanda.py
|
lib/ansible/modules/monitoring/bigpanda.py
|
||||||
lib/ansible/modules/monitoring/datadog_event.py
|
lib/ansible/modules/monitoring/datadog_event.py
|
||||||
lib/ansible/modules/monitoring/icinga2_feature.py
|
lib/ansible/modules/monitoring/icinga2_feature.py
|
||||||
|
|
Loading…
Reference in a new issue