mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Bulk autopep8 (modules)
As agreed in 2017-12-07 Core meeting bulk fix pep8 issues Generated using: autopep8 1.3.3 (pycodestyle: 2.3.1) autopep8 -r --max-line-length 160 --in-place --ignore E305,E402,E722,E741 lib/ansible/modules Manually fix issues that autopep8 has introduced
This commit is contained in:
parent
d13d7e9404
commit
c57a7f05e1
314 changed files with 3462 additions and 3383 deletions
|
@ -161,18 +161,21 @@ def lang_exists(cursor, lang):
|
|||
cursor.execute(query)
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
def lang_istrusted(cursor, lang):
|
||||
"""Checks if language is trusted for db"""
|
||||
query = "SELECT lanpltrusted FROM pg_language WHERE lanname='%s'" % lang
|
||||
cursor.execute(query)
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
|
||||
def lang_altertrust(cursor, lang, trust):
|
||||
"""Changes if language is trusted for db"""
|
||||
query = "UPDATE pg_language SET lanpltrusted = %s WHERE lanname=%s"
|
||||
cursor.execute(query, (trust, lang))
|
||||
return True
|
||||
|
||||
|
||||
def lang_add(cursor, lang, trust):
|
||||
"""Adds language for db"""
|
||||
if trust:
|
||||
|
@ -182,6 +185,7 @@ def lang_add(cursor, lang, trust):
|
|||
cursor.execute(query)
|
||||
return True
|
||||
|
||||
|
||||
def lang_drop(cursor, lang, cascade):
|
||||
"""Drops language for db"""
|
||||
cursor.execute("SAVEPOINT ansible_pgsql_lang_drop")
|
||||
|
@ -197,6 +201,7 @@ def lang_drop(cursor, lang, cascade):
|
|||
cursor.execute("RELEASE SAVEPOINT ansible_pgsql_lang_drop")
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
|
@ -212,7 +217,7 @@ def main():
|
|||
cascade=dict(type='bool', default='no'),
|
||||
fail_on_drop=dict(type='bool', default='yes'),
|
||||
),
|
||||
supports_check_mode = True
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
db = module.params["db"]
|
||||
|
@ -227,14 +232,14 @@ def main():
|
|||
module.fail_json(msg="the python psycopg2 module is required")
|
||||
|
||||
params_map = {
|
||||
"login_host":"host",
|
||||
"login_user":"user",
|
||||
"login_password":"password",
|
||||
"port":"port",
|
||||
"db":"database"
|
||||
"login_host": "host",
|
||||
"login_user": "user",
|
||||
"login_password": "password",
|
||||
"port": "port",
|
||||
"db": "database"
|
||||
}
|
||||
kw = dict( (params_map[k], v) for (k, v) in module.params.items()
|
||||
if k in params_map and v != "" )
|
||||
kw = dict((params_map[k], v) for (k, v) in module.params.items()
|
||||
if k in params_map and v != "")
|
||||
try:
|
||||
db_connection = psycopg2.connect(**kw)
|
||||
cursor = db_connection.cursor()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue