PEP8 fixes: Ansible source_control module (#32323)

* PEP8 fixes: Ansible source_control module

* Some more cleanup changes

* More cleanups

* Fix copyright statement
pull/32597/head
Yadnyawalkya Tale 7 years ago committed by Dag Wieers
parent d9ef167e78
commit fcab13a668

@ -1,58 +1,53 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, André Paramés <git@andreparames.com> # Copyright: (c) 2013, André Paramés <git@andreparames.com>
# Based on the Git module by Michael DeHaan <michael.dehaan@gmail.com> # Based on the Git module by Michael DeHaan <michael.dehaan@gmail.com>
# 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)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = u''' DOCUMENTATION = u'''
--- ---
module: bzr module: bzr
author: "André Paramés (@andreparames)" author:
- André Paramés (@andreparames)
version_added: "1.1" version_added: "1.1"
short_description: Deploy software (or files) from bzr branches short_description: Deploy software (or files) from bzr branches
description: description:
- Manage I(bzr) branches to deploy files or software. - Manage I(bzr) branches to deploy files or software.
options: options:
name: name:
required: true
aliases: [ 'parent' ]
description: description:
- SSH or HTTP protocol address of the parent branch. - SSH or HTTP protocol address of the parent branch.
aliases: [ parent ]
required: yes
dest: dest:
required: true
description: description:
- Absolute path of where the branch should be cloned to. - Absolute path of where the branch should be cloned to.
required: yes
version: version:
required: false
default: "head"
description: description:
- What version of the branch to clone. This can be the - What version of the branch to clone. This can be the
bzr revno or revid. bzr revno or revid.
default: head
force: force:
required: false
default: "no"
choices: [ 'yes', 'no' ]
description: description:
- If C(yes), any modified files in the working - If C(yes), any modified files in the working
tree will be discarded. Before 1.9 the default tree will be discarded. Before 1.9 the default
value was "yes". value was C(yes).
type: bool
default: 'no'
executable: executable:
required: false
default: null
version_added: "1.4"
description: description:
- Path to bzr executable to use. If not supplied, - Path to bzr executable to use. If not supplied,
the normal mechanism for resolving binary paths will be used. the normal mechanism for resolving binary paths will be used.
version_added: '1.4'
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -139,16 +134,17 @@ class Bzr(object):
args_list = ["revert"] args_list = ["revert"]
return self._command(args_list, check_rc=True, cwd=self.dest) return self._command(args_list, check_rc=True, cwd=self.dest)
# =========================================== # ===========================================
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
dest=dict(required=True, type='path'), dest=dict(type='path', required=True),
name=dict(required=True, aliases=['parent']), name=dict(type='str', required=True, aliases=['parent']),
version=dict(default='head'), version=dict(type='str', default='head'),
force=dict(default='no', type='bool'), force=dict(type='bool', default='no', type='bool'),
executable=dict(default=None), executable=dict(type='str'),
) )
) )

@ -1,24 +1,21 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# (c) 2013, Yeukhon Wong <yeukhon@acm.org> # Copyright: (c) 2013, Yeukhon Wong <yeukhon@acm.org>
# (c) 2014, Nate Coraor <nate@bx.psu.edu> # Copyright: (c) 2014, Nate Coraor <nate@bx.psu.edu>
#
# 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)
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: hg module: hg
short_description: Manages Mercurial (hg) repositories. short_description: Manages Mercurial (hg) repositories
description: description:
- Manages Mercurial (hg) repositories. Supports SSH, HTTP/S and local address. - Manages Mercurial (hg) repositories. Supports SSH, HTTP/S and local address.
version_added: "1.0" version_added: "1.0"
@ -27,76 +24,64 @@ options:
repo: repo:
description: description:
- The repository address. - The repository address.
required: true required: yes
default: null
aliases: [ name ] aliases: [ name ]
dest: dest:
description: description:
- Absolute path of where the repository should be cloned to. - Absolute path of where the repository should be cloned to.
This parameter is required, unless clone and update are set to no This parameter is required, unless clone and update are set to no
required: true required: yes
default: null
revision: revision:
description: description:
- Equivalent C(-r) option in hg command which could be the changeset, revision number, - Equivalent C(-r) option in hg command which could be the changeset, revision number,
branch name or even tag. branch name or even tag.
required: false
default: null
aliases: [ version ] aliases: [ version ]
force: force:
description: description:
- Discards uncommitted changes. Runs C(hg update -C). Prior to - Discards uncommitted changes. Runs C(hg update -C). Prior to
1.9, the default was `yes`. 1.9, the default was `yes`.
required: false type: bool
default: "no" default: 'no'
choices: [ "yes", "no" ]
purge: purge:
description: description:
- Deletes untracked files. Runs C(hg purge). - Deletes untracked files. Runs C(hg purge).
required: false type: bool
default: "no" default: 'no'
choices: [ "yes", "no" ]
update: update:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.0"
description: description:
- If C(no), do not retrieve new revisions from the origin repository - If C(no), do not retrieve new revisions from the origin repository
type: bool
default: 'yes'
version_added: '2.0'
clone: clone:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.3"
description: description:
- If C(no), do not clone the repository if it does not exist locally. - If C(no), do not clone the repository if it does not exist locally.
type: bool
default: 'yes'
version_added: '2.3'
executable: executable:
required: false
default: null
version_added: "1.4"
description: description:
- Path to hg executable to use. If not supplied, - Path to hg executable to use. If not supplied,
the normal mechanism for resolving binary paths will be used. the normal mechanism for resolving binary paths will be used.
version_added: '1.4'
notes: notes:
- "This module does not support push capability. See U(https://github.com/ansible/ansible/issues/31156)." - This module does not support push capability. See U(https://github.com/ansible/ansible/issues/31156).
- "If the task seems to be hanging, first verify remote host is in C(known_hosts). - "If the task seems to be hanging, first verify remote host is in C(known_hosts).
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt, SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
one solution is to add the remote host public key in C(/etc/ssh/ssh_known_hosts) before calling one solution is to add the remote host public key in C(/etc/ssh/ssh_known_hosts) before calling
the hg module, with the following command: ssh-keyscan remote_host.com >> /etc/ssh/ssh_known_hosts." the hg module, with the following command: ssh-keyscan remote_host.com >> /etc/ssh/ssh_known_hosts."
requirements: [ ]
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Ensure the current working copy is inside the stable branch and deletes untracked files if any. - name: Ensure the current working copy is inside the stable branch and deletes untracked files if any.
- hg: hg:
repo: https://bitbucket.org/user/repo1 repo: https://bitbucket.org/user/repo1
dest: /home/user/repo1 dest: /home/user/repo1
revision: stable revision: stable
purge: yes purge: yes
# Example just get information about the repository whether or not it has - name: Get information about the repository whether or not it has already been cloned locally.
# already been cloned locally. hg:
- hg:
repo: git://bitbucket.org/user/repo repo: git://bitbucket.org/user/repo
dest: /srv/checkout dest: /srv/checkout
clone: no clone: no
@ -110,7 +95,6 @@ from ansible.module_utils._text import to_native
class Hg(object): class Hg(object):
def __init__(self, module, dest, repo, revision, hg_path): def __init__(self, module, dest, repo, revision, hg_path):
self.module = module self.module = module
self.dest = dest self.dest = dest
@ -229,19 +213,20 @@ class Hg(object):
return True return True
return False return False
# =========================================== # ===========================================
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
repo = dict(required=True, aliases=['name']), repo=dict(type='str', required=True, aliases=['name']),
dest=dict(type='path'), dest=dict(type='path'),
revision = dict(default=None, aliases=['version']), revision=dict(type='str', default=None, aliases=['version']),
force = dict(default='no', type='bool'), force=dict(type='bool', default=False),
purge = dict(default='no', type='bool'), purge=dict(type='bool', default=False),
update = dict(default='yes', type='bool'), update=dict(type='bool', default=True),
clone = dict(default='yes', type='bool'), clone=dict(type='bool', default=True),
executable = dict(default=None), executable=dict(type='str', default=None),
), ),
) )
repo = module.params['repo'] repo = module.params['repo']
@ -304,7 +289,9 @@ def main():
after = hg.get_revision() after = hg.get_revision()
if before != after or cleaned: if before != after or cleaned:
changed = True changed = True
module.exit_json(before=before, after=after, changed=changed, cleaned=cleaned) module.exit_json(before=before, after=after, changed=changed, cleaned=cleaned)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

@ -303,8 +303,6 @@ lib/ansible/modules/packaging/os/yum.py
lib/ansible/modules/packaging/os/zypper.py lib/ansible/modules/packaging/os/zypper.py
lib/ansible/modules/packaging/os/zypper_repository.py lib/ansible/modules/packaging/os/zypper_repository.py
lib/ansible/modules/remote_management/stacki/stacki_host.py lib/ansible/modules/remote_management/stacki/stacki_host.py
lib/ansible/modules/source_control/bzr.py
lib/ansible/modules/source_control/hg.py
lib/ansible/modules/storage/infinidat/infini_export.py lib/ansible/modules/storage/infinidat/infini_export.py
lib/ansible/modules/storage/infinidat/infini_export_client.py lib/ansible/modules/storage/infinidat/infini_export_client.py
lib/ansible/modules/storage/infinidat/infini_fs.py lib/ansible/modules/storage/infinidat/infini_fs.py

Loading…
Cancel
Save