postgresql modules: fix by flake8 (#59497)

pull/59507/head^2
Andrey Klychkov 5 years ago committed by Abhijeet Kasurde
parent 93265bf92e
commit fd35833554

@ -265,8 +265,7 @@ def db_create(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn_
return True return True
else: else:
db_info = get_db_info(cursor, db) db_info = get_db_info(cursor, db)
if (encoding and if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']):
get_encoding_id(cursor, encoding) != db_info['encoding_id']):
raise NotSupportedError( raise NotSupportedError(
'Changing database encoding is not supported. ' 'Changing database encoding is not supported. '
'Current encoding: %s' % db_info['encoding'] 'Current encoding: %s' % db_info['encoding']
@ -301,8 +300,7 @@ def db_matches(cursor, db, owner, template, encoding, lc_collate, lc_ctype, conn
return False return False
else: else:
db_info = get_db_info(cursor, db) db_info = get_db_info(cursor, db)
if (encoding and if (encoding and get_encoding_id(cursor, encoding) != db_info['encoding_id']):
get_encoding_id(cursor, encoding) != db_info['encoding_id']):
return False return False
elif lc_collate and lc_collate != db_info['lc_collate']: elif lc_collate and lc_collate != db_info['lc_collate']:
return False return False

@ -174,7 +174,6 @@ from ansible.module_utils.postgres import (
postgres_common_argument_spec, postgres_common_argument_spec,
) )
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible.module_utils.database import pg_quote_identifier
executed_queries = [] executed_queries = []

@ -164,8 +164,6 @@ from ansible.module_utils.postgres import (
get_conn_params, get_conn_params,
postgres_common_argument_spec, postgres_common_argument_spec,
) )
from ansible.module_utils._text import to_native
from ansible.module_utils.database import pg_quote_identifier
executed_queries = [] executed_queries = []

@ -480,21 +480,17 @@ def main():
module.warn("cascade=true is ignored when state=present") module.warn("cascade=true is ignored when state=present")
# Check mutual exclusive parameters: # Check mutual exclusive parameters:
if state == 'absent' and (truncate or newname or columns or tablespace or if state == 'absent' and (truncate or newname or columns or tablespace or like or storage_params or unlogged or owner or including):
like or storage_params or unlogged or
owner or including):
module.fail_json(msg="%s: state=absent is mutually exclusive with: " module.fail_json(msg="%s: state=absent is mutually exclusive with: "
"truncate, rename, columns, tablespace, " "truncate, rename, columns, tablespace, "
"including, like, storage_params, unlogged, owner" % table) "including, like, storage_params, unlogged, owner" % table)
if truncate and (newname or columns or like or unlogged or if truncate and (newname or columns or like or unlogged or storage_params or owner or tablespace or including):
storage_params or owner or tablespace or including):
module.fail_json(msg="%s: truncate is mutually exclusive with: " module.fail_json(msg="%s: truncate is mutually exclusive with: "
"rename, columns, like, unlogged, including, " "rename, columns, like, unlogged, including, "
"storage_params, owner, tablespace" % table) "storage_params, owner, tablespace" % table)
if newname and (columns or like or unlogged or if newname and (columns or like or unlogged or storage_params or owner or tablespace or including):
storage_params or owner or tablespace or including):
module.fail_json(msg="%s: rename is mutually exclusive with: " module.fail_json(msg="%s: rename is mutually exclusive with: "
"columns, like, unlogged, including, " "columns, like, unlogged, including, "
"storage_params, owner, tablespace" % table) "storage_params, owner, tablespace" % table)

Loading…
Cancel
Save