file: pylint fixes and docs (#30849)
This PR includes; - pylint fixes - Documentation updatespull/4420/head
parent
a6415f9ad9
commit
2f8c88b687
|
@ -27,17 +27,15 @@ description:
|
||||||
notes:
|
notes:
|
||||||
- For Windows targets, use the M(win_file) module instead.
|
- For Windows targets, use the M(win_file) module instead.
|
||||||
- See also M(copy), M(template), M(assemble)
|
- See also M(copy), M(template), M(assemble)
|
||||||
requirements: [ ]
|
|
||||||
author:
|
author:
|
||||||
- "Ansible Core Team"
|
- Ansible Core Team
|
||||||
- "Michael DeHaan"
|
- Michael DeHaan
|
||||||
options:
|
options:
|
||||||
path:
|
path:
|
||||||
description:
|
description:
|
||||||
- 'path to the file being managed. Aliases: I(dest), I(name)'
|
- 'path to the file being managed. Aliases: I(dest), I(name)'
|
||||||
required: true
|
required: true
|
||||||
default: []
|
aliases: [ dest, name ]
|
||||||
aliases: ['dest', 'name']
|
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- If C(directory), all immediate subdirectories will be created if they
|
- If C(directory), all immediate subdirectories will be created if they
|
||||||
|
@ -51,37 +49,31 @@ options:
|
||||||
If C(touch) (new in 1.4), an empty file will be created if the C(path) does not
|
If C(touch) (new in 1.4), an empty file will be created if the C(path) does not
|
||||||
exist, while an existing file or directory will receive updated file access and
|
exist, while an existing file or directory will receive updated file access and
|
||||||
modification times (similar to the way `touch` works from the command line).
|
modification times (similar to the way `touch` works from the command line).
|
||||||
required: false
|
|
||||||
default: file
|
default: file
|
||||||
choices: [ file, link, directory, hard, touch, absent ]
|
choices: [ absent, directory, file, hard, link, touch ]
|
||||||
src:
|
src:
|
||||||
required: false
|
|
||||||
default: null
|
|
||||||
description:
|
description:
|
||||||
- path of the file to link to (applies only to C(state=link)). Will accept absolute,
|
- path of the file to link to (applies only to C(state=link)). Will accept absolute,
|
||||||
relative and nonexisting paths. Relative paths are not expanded.
|
relative and nonexisting paths. Relative paths are not expanded.
|
||||||
recurse:
|
recurse:
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
version_added: "1.1"
|
|
||||||
description:
|
description:
|
||||||
- recursively set the specified file attributes (applies only to state=directory)
|
- recursively set the specified file attributes (applies only to state=directory)
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
|
version_added: "1.1"
|
||||||
force:
|
force:
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
description:
|
description:
|
||||||
- 'force the creation of the symlinks in two cases: the source file does
|
- 'force the creation of the symlinks in two cases: the source file does
|
||||||
not exist (but will appear later); the destination exists and is a file (so, we need to unlink the
|
not exist (but will appear later); the destination exists and is a file (so, we need to unlink the
|
||||||
"path" file and create symlink to the "src" file in place of it).'
|
"path" file and create symlink to the "src" file in place of it).'
|
||||||
|
type: bool
|
||||||
|
default: 'no'
|
||||||
follow:
|
follow:
|
||||||
required: false
|
|
||||||
default: "no"
|
|
||||||
choices: [ "yes", "no" ]
|
|
||||||
version_added: "1.8"
|
|
||||||
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.8"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -145,7 +137,7 @@ def get_state(b_path):
|
||||||
return 'directory'
|
return 'directory'
|
||||||
elif os.stat(b_path).st_nlink > 1:
|
elif os.stat(b_path).st_nlink > 1:
|
||||||
return 'hard'
|
return 'hard'
|
||||||
else:
|
|
||||||
# could be many other things, but defaulting to file
|
# could be many other things, but defaulting to file
|
||||||
return 'file'
|
return 'file'
|
||||||
|
|
||||||
|
@ -371,7 +363,7 @@ def main():
|
||||||
elif prev_state == 'directory':
|
elif prev_state == 'directory':
|
||||||
if not force:
|
if not force:
|
||||||
module.fail_json(path=path, msg='refusing to convert between %s and %s for %s' % (prev_state, state, path))
|
module.fail_json(path=path, msg='refusing to convert between %s and %s for %s' % (prev_state, state, path))
|
||||||
elif len(os.listdir(b_path)) > 0:
|
elif os.listdir(b_path):
|
||||||
# refuse to replace a directory that has files in it
|
# refuse to replace a directory that has files in it
|
||||||
module.fail_json(path=path, msg='the directory %s is not empty, refusing to convert it' % path)
|
module.fail_json(path=path, msg='the directory %s is not empty, refusing to convert it' % path)
|
||||||
elif prev_state in ('file', 'hard') and not force:
|
elif prev_state in ('file', 'hard') and not force:
|
||||||
|
|
Loading…
Reference in New Issue