mirror of
				https://github.com/ansible-collections/community.general.git
				synced 2025-10-25 05:23:58 -07:00 
			
		
		
		
	pip: PEP8 compliancy and doc fixes
This PR includes: - PEP8 compliancy fixes - Documentation fixes
This commit is contained in:
		
					parent
					
						
							
								a71ca66e6e
							
						
					
				
			
			
				commit
				
					
						1241d0a3f4
					
				
			
		
					 2 changed files with 26 additions and 49 deletions
				
			
		|  | @ -1,22 +1,20 @@ | ||||||
| #!/usr/bin/python | #!/usr/bin/python | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
| 
 | 
 | ||||||
| # (c) 2012, Matt Wright <matt@nobien.net> | # Copyright: (c) 2012, Matt Wright <matt@nobien.net> | ||||||
| # 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': 'core'} |                     'supported_by': 'core'} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| DOCUMENTATION = ''' | DOCUMENTATION = ''' | ||||||
| --- | --- | ||||||
| module: pip | module: pip | ||||||
| short_description: Manages Python library dependencies. | short_description: Manages Python library dependencies | ||||||
| description: | description: | ||||||
|      - "Manage Python library dependencies. To use this module, one of the following keys is required: C(name) |      - "Manage Python library dependencies. To use this module, one of the following keys is required: C(name) | ||||||
|        or C(requirements)." |        or C(requirements)." | ||||||
|  | @ -26,19 +24,13 @@ options: | ||||||
|     description: |     description: | ||||||
|       - The name of a Python library to install or the url of the remote package. |       - The name of a Python library to install or the url of the remote package. | ||||||
|       - As of 2.2 you can supply a list of names. |       - As of 2.2 you can supply a list of names. | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   version: |   version: | ||||||
|     description: |     description: | ||||||
|       - The version number to install of the Python library specified in the I(name) parameter |       - The version number to install of the Python library specified in the I(name) parameter. | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   requirements: |   requirements: | ||||||
|     description: |     description: | ||||||
|       - The path to a pip requirements file, which should be local to the remote system. |       - The path to a pip requirements file, which should be local to the remote system. | ||||||
|         File can be specified as a relative path if using the chdir option. |         File can be specified as a relative path if using the chdir option. | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   virtualenv: |   virtualenv: | ||||||
|     description: |     description: | ||||||
|       - An optional path to a I(virtualenv) directory to install into. |       - An optional path to a I(virtualenv) directory to install into. | ||||||
|  | @ -47,62 +39,51 @@ options: | ||||||
|         If the virtualenv does not exist, it will be created before installing |         If the virtualenv does not exist, it will be created before installing | ||||||
|         packages. The optional virtualenv_site_packages, virtualenv_command, |         packages. The optional virtualenv_site_packages, virtualenv_command, | ||||||
|         and virtualenv_python options affect the creation of the virtualenv. |         and virtualenv_python options affect the creation of the virtualenv. | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   virtualenv_site_packages: |   virtualenv_site_packages: | ||||||
|     version_added: "1.0" |  | ||||||
|     description: |     description: | ||||||
|       - Whether the virtual environment will inherit packages from the |       - Whether the virtual environment will inherit packages from the | ||||||
|         global site-packages directory.  Note that if this setting is |         global site-packages directory.  Note that if this setting is | ||||||
|         changed on an already existing virtual environment it will not |         changed on an already existing virtual environment it will not | ||||||
|         have any effect, the environment must be deleted and newly |         have any effect, the environment must be deleted and newly | ||||||
|         created. |         created. | ||||||
|     required: false |     type: bool | ||||||
|     default: "no" |     default: "no" | ||||||
|     choices: [ "yes", "no" ] |     version_added: "1.0" | ||||||
|   virtualenv_command: |   virtualenv_command: | ||||||
|     version_added: "1.1" |  | ||||||
|     description: |     description: | ||||||
|       - The command or a pathname to the command to create the virtual |       - The command or a pathname to the command to create the virtual | ||||||
|         environment with. For example C(pyvenv), C(virtualenv), |         environment with. For example C(pyvenv), C(virtualenv), | ||||||
|         C(virtualenv2), C(~/bin/virtualenv), C(/usr/local/bin/virtualenv). |         C(virtualenv2), C(~/bin/virtualenv), C(/usr/local/bin/virtualenv). | ||||||
|     required: false |  | ||||||
|     default: virtualenv |     default: virtualenv | ||||||
|  |     version_added: "1.1" | ||||||
|   virtualenv_python: |   virtualenv_python: | ||||||
|     version_added: "2.0" |  | ||||||
|     description: |     description: | ||||||
|       - The Python executable used for creating the virtual environment. |       - The Python executable used for creating the virtual environment. | ||||||
|         For example C(python3.5), C(python2.7). When not specified, the |         For example C(python3.5), C(python2.7). When not specified, the | ||||||
|         Python version used to run the ansible module is used. This parameter |         Python version used to run the ansible module is used. This parameter | ||||||
|         should not be used when C(virtualenv_command) is using C(pyvenv) or |         should not be used when C(virtualenv_command) is using C(pyvenv) or | ||||||
|         the C(-m venv) module. |         the C(-m venv) module. | ||||||
|     required: false |     version_added: "2.0" | ||||||
|     default: null |  | ||||||
|   state: |   state: | ||||||
|     description: |     description: | ||||||
|       - The state of module |       - The state of module | ||||||
|       - The 'forcereinstall' option is only available in Ansible 2.1 and above. |       - The 'forcereinstall' option is only available in Ansible 2.1 and above. | ||||||
|     required: false |     choices: [ absent, forcereinstall, latest, present ] | ||||||
|     default: present |     default: present | ||||||
|     choices: [ "present", "absent", "latest", "forcereinstall" ] |  | ||||||
|   extra_args: |   extra_args: | ||||||
|     description: |     description: | ||||||
|       - Extra arguments passed to pip. |       - Extra arguments passed to pip. | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|     version_added: "1.0" |     version_added: "1.0" | ||||||
|   editable: |   editable: | ||||||
|     description: |     description: | ||||||
|       - Pass the editable flag. |       - Pass the editable flag. | ||||||
|     required: false |     type: bool | ||||||
|     default: false |     default: 'no' | ||||||
|     version_added: "2.0" |     version_added: "2.0" | ||||||
|   chdir: |   chdir: | ||||||
|     description: |     description: | ||||||
|       - cd into this directory before running the command |       - cd into this directory before running the command | ||||||
|     version_added: "1.3" |     version_added: "1.3" | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   executable: |   executable: | ||||||
|     description: |     description: | ||||||
|       - The explicit executable or a pathname to the executable to be used to |       - The explicit executable or a pathname to the executable to be used to | ||||||
|  | @ -113,8 +94,6 @@ options: | ||||||
|         By default, it will take the appropriate version for the python interpreter |         By default, it will take the appropriate version for the python interpreter | ||||||
|         use by ansible, e.g. pip3 on python 3, and pip2 or pip on python 2. |         use by ansible, e.g. pip3 on python 3, and pip2 or pip on python 2. | ||||||
|     version_added: "1.3" |     version_added: "1.3" | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
|   umask: |   umask: | ||||||
|     description: |     description: | ||||||
|       - The system umask to apply before installing the pip package. This is |       - The system umask to apply before installing the pip package. This is | ||||||
|  | @ -123,17 +102,17 @@ options: | ||||||
|         packages which are to be used by all users. Note that this requires you |         packages which are to be used by all users. Note that this requires you | ||||||
|         to specify desired umask mode in octal, with a leading 0 (e.g., 0077). |         to specify desired umask mode in octal, with a leading 0 (e.g., 0077). | ||||||
|     version_added: "2.1" |     version_added: "2.1" | ||||||
|     required: false |  | ||||||
|     default: null |  | ||||||
| 
 |  | ||||||
| notes: | notes: | ||||||
|    - Please note that virtualenv (U(http://www.virtualenv.org/)) must be |    - Please note that virtualenv (U(http://www.virtualenv.org/)) must be | ||||||
|      installed on the remote host if the virtualenv parameter is specified and |      installed on the remote host if the virtualenv parameter is specified and | ||||||
|      the virtualenv needs to be created. |      the virtualenv needs to be created. | ||||||
|    - By default, this module will use the appropriate version of pip for the |    - By default, this module will use the appropriate version of pip for the | ||||||
|      interpreter used by ansible (e.g. pip3 when using python 3, pip2 otherwise) |      interpreter used by ansible (e.g. pip3 when using python 3, pip2 otherwise) | ||||||
| requirements: [ "virtualenv", "pip" ] | requirements: | ||||||
| author: "Matt Wright (@mattupstate)" | - pip | ||||||
|  | - virtualenv | ||||||
|  | author: | ||||||
|  | - Matt Wright (@mattupstate) | ||||||
| ''' | ''' | ||||||
| 
 | 
 | ||||||
| EXAMPLES = ''' | EXAMPLES = ''' | ||||||
|  | @ -307,8 +286,8 @@ def _get_pip(module, env=None, executable=None): | ||||||
|             else: |             else: | ||||||
|                 # For-else: Means that we did not break out of the loop |                 # For-else: Means that we did not break out of the loop | ||||||
|                 # (therefore, that pip was not found) |                 # (therefore, that pip was not found) | ||||||
|                 module.fail_json(msg='Unable to find any of %s to use.  pip' |                 module.fail_json(msg='Unable to find any of %s to use.  pip' + | ||||||
|                         ' needs to be installed.' % ', '.join(candidate_pip_basenames)) |                                      ' needs to be installed.' % ', '.join(candidate_pip_basenames)) | ||||||
|         else: |         else: | ||||||
|             # If we're using a virtualenv we must use the pip from the |             # If we're using a virtualenv we must use the pip from the | ||||||
|             # virtualenv |             # virtualenv | ||||||
|  | @ -322,10 +301,9 @@ def _get_pip(module, env=None, executable=None): | ||||||
|             else: |             else: | ||||||
|                 # For-else: Means that we did not break out of the loop |                 # For-else: Means that we did not break out of the loop | ||||||
|                 # (therefore, that pip was not found) |                 # (therefore, that pip was not found) | ||||||
|                 module.fail_json(msg='Unable to find pip in the virtualenv,' |                 module.fail_json(msg='Unable to find pip in the virtualenv, %s, ' % env + | ||||||
|                         ' %s, under any of these names: %s. Make sure pip is' |                                      'under any of these names: %s. ' % (', '.join(candidate_pip_basenames)) + | ||||||
|                         ' present in the virtualenv.' % (env, |                                      'Make sire pip is present in the virtualenv.') | ||||||
|                             ', '.join(candidate_pip_basenames))) |  | ||||||
| 
 | 
 | ||||||
|     return pip |     return pip | ||||||
| 
 | 
 | ||||||
|  | @ -374,24 +352,24 @@ def main(): | ||||||
| 
 | 
 | ||||||
|     module = AnsibleModule( |     module = AnsibleModule( | ||||||
|         argument_spec=dict( |         argument_spec=dict( | ||||||
|             state=dict(default='present', choices=state_map.keys()), |             state=dict(type='str', default='present', choices=state_map.keys()), | ||||||
|             name=dict(type='list'), |             name=dict(type='list'), | ||||||
|             version=dict(type='str'), |             version=dict(type='str'), | ||||||
|             requirements=dict(type='str'), |             requirements=dict(type='str'), | ||||||
|             virtualenv=dict(type='path'), |             virtualenv=dict(type='path'), | ||||||
|             virtualenv_site_packages=dict(default=False, type='bool'), |             virtualenv_site_packages=dict(type='bool', default=False), | ||||||
|             virtualenv_command=dict(default='virtualenv', type='path'), |             virtualenv_command=dict(type='path', default='virtualenv'), | ||||||
|             virtualenv_python=dict(type='str'), |             virtualenv_python=dict(type='str'), | ||||||
|             use_mirrors=dict(default=True, type='bool'), |             use_mirrors=dict(type='bool', default=True), | ||||||
|             extra_args=dict(type='str'), |             extra_args=dict(type='str'), | ||||||
|             editable=dict(default=False, type='bool'), |             editable=dict(type='bool', default=False), | ||||||
|             chdir=dict(type='path'), |             chdir=dict(type='path'), | ||||||
|             executable=dict(type='path'), |             executable=dict(type='path'), | ||||||
|             umask=dict(type='str'), |             umask=dict(type='str'), | ||||||
|         ), |         ), | ||||||
|         required_one_of=[['name', 'requirements']], |         required_one_of=[['name', 'requirements']], | ||||||
|         mutually_exclusive=[['name', 'requirements'], ['executable', 'virtualenv']], |         mutually_exclusive=[['name', 'requirements'], ['executable', 'virtualenv']], | ||||||
|         supports_check_mode=True |         supports_check_mode=True, | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     state = module.params['state'] |     state = module.params['state'] | ||||||
|  |  | ||||||
|  | @ -344,7 +344,6 @@ lib/ansible/modules/packaging/language/cpanm.py | ||||||
| lib/ansible/modules/packaging/language/gem.py | lib/ansible/modules/packaging/language/gem.py | ||||||
| lib/ansible/modules/packaging/language/maven_artifact.py | lib/ansible/modules/packaging/language/maven_artifact.py | ||||||
| lib/ansible/modules/packaging/language/pear.py | lib/ansible/modules/packaging/language/pear.py | ||||||
| lib/ansible/modules/packaging/language/pip.py |  | ||||||
| lib/ansible/modules/packaging/os/apk.py | lib/ansible/modules/packaging/os/apk.py | ||||||
| lib/ansible/modules/packaging/os/apt.py | lib/ansible/modules/packaging/os/apt.py | ||||||
| lib/ansible/modules/packaging/os/apt_key.py | lib/ansible/modules/packaging/os/apt_key.py | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue