subversion: PEP8 compliancy and doc fixes (#30909)

This PR includes:
- PEP8 compliancy fixes
- Documentation fixes
This commit is contained in:
Dag Wieers 2017-10-30 01:09:00 +01:00 committed by GitHub
parent 86bb82a220
commit 16bbc19674
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 63 deletions

View file

@ -1,115 +1,98 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# Copyright: (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# 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
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: subversion
short_description: Deploys a subversion repository.
short_description: Deploys a subversion repository
description:
- Deploy given repository URL / revision to dest. If dest exists, update to the specified revision, otherwise perform a checkout.
version_added: "0.7"
author: "Dane Summers (@dsummersl) <njharman@gmail.com>"
author:
- Dane Summers (@dsummersl) <njharman@gmail.com>
notes:
- Requires I(svn) to be installed on the client.
- This module does not handle externals
requirements: []
- This module does not handle externals.
options:
repo:
description:
- The subversion URL to the repository.
required: true
aliases: [ name, repository ]
default: null
dest:
description:
- Absolute path where the repository should be deployed.
required: true
default: null
revision:
description:
- Specific revision to checkout.
required: false
default: HEAD
aliases: [ version ]
force:
description:
- If C(yes), modified files will be discarded. If C(no), module will fail if it encounters modified files.
Prior to 1.9 the default was `yes`.
required: false
Prior to 1.9 the default was C(yes).
type: bool
default: "no"
choices: [ "yes", "no" ]
username:
description:
- --username parameter passed to svn.
required: false
default: null
- C(--username) parameter passed to svn.
password:
description:
- --password parameter passed to svn.
required: false
default: null
- C(--password) parameter passed to svn.
executable:
required: false
default: null
version_added: "1.4"
description:
- Path to svn executable to use. If not supplied,
the normal mechanism for resolving binary paths will be used.
version_added: "1.4"
checkout:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.3"
description:
- If no, do not check out the repository if it does not exist locally
- If C(no), do not check out the repository if it does not exist locally.
type: bool
default: "yes"
version_added: "2.3"
update:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.3"
description:
- If 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.3"
export:
required: false
default: "no"
choices: [ "yes", "no" ]
version_added: "1.6"
description:
- If C(yes), do export instead of checkout/update.
type: bool
default: "no"
version_added: "1.6"
switch:
required: false
default: "yes"
choices: [ "yes", "no" ]
version_added: "2.0"
description:
- If C(no), do not call svn switch before update.
default: "yes"
version_added: "2.0"
type: bool
'''
EXAMPLES = '''
# Checkout subversion repository to specified folder.
- subversion:
- name: Checkout subversion repository to specified folder
subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /src/checkout
# Export subversion directory to folder
- subversion:
- name: Export subversion directory to folder
subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /src/export
# Example just get information about the repository whether or not it has
# already been cloned locally.
- name: Get information about the repository whether or not it has already been cloned locally
- subversion:
repo: svn+ssh://an.example.org/path/to/repo
dest: /srv/checkout
@ -124,8 +107,7 @@ from ansible.module_utils.basic import AnsibleModule
class Subversion(object):
def __init__(
self, module, dest, repo, revision, username, password, svn_path):
def __init__(self, module, dest, repo, revision, username, password, svn_path):
self.module = module
self.dest = dest
self.repo = repo
@ -199,7 +181,7 @@ class Subversion(object):
def has_local_mods(self):
'''True if revisioned files have been added or modified. Unrevisioned files are ignored.'''
lines = self._exec(["status", "--quiet", "--ignore-externals", self.dest])
lines = self._exec(["status", "--quiet", "--ignore-externals", self.dest])
# The --quiet option will return only modified files.
# Match only revisioned files, i.e. ignore status '?'.
regex = re.compile(r'^[^?X]')
@ -218,24 +200,22 @@ class Subversion(object):
return change, curr, head
# ===========================================
def main():
module = AnsibleModule(
argument_spec=dict(
dest=dict(type='path'),
repo=dict(required=True, aliases=['name', 'repository']),
revision=dict(default='HEAD', aliases=['rev', 'version']),
force=dict(default='no', type='bool'),
username=dict(required=False),
password=dict(required=False, no_log=True),
executable=dict(default=None, type='path'),
export=dict(default=False, required=False, type='bool'),
checkout=dict(default=True, required=False, type='bool'),
update=dict(default=True, required=False, type='bool'),
switch=dict(default=True, required=False, type='bool'),
repo=dict(type='str', required=True, aliases=['name', 'repository']),
revision=dict(type='str', default='HEAD', aliases=['rev', 'version']),
force=dict(type='bool', default=False),
username=dict(type='str'),
password=dict(type='str', no_log=True),
executable=dict(type='path'),
export=dict(type='bool', default=False),
checkout=dict(type='bool', default=True),
update=dict(type='bool', default=True),
switch=dict(type='bool', default=True),
),
supports_check_mode=True
supports_check_mode=True,
)
dest = module.params['dest']

View file

@ -319,7 +319,6 @@ lib/ansible/modules/packaging/os/zypper_repository.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/source_control/subversion.py
lib/ansible/modules/storage/infinidat/infini_export.py
lib/ansible/modules/storage/infinidat/infini_export_client.py
lib/ansible/modules/storage/infinidat/infini_fs.py