misc: pylint fix unneeded-not (#52222)

This commit is contained in:
Lauréline Guérin 2021-03-22 11:14:42 +01:00
parent 17d73057b7
commit d88dd530f6
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
34 changed files with 102 additions and 102 deletions

View File

@ -521,7 +521,7 @@ class WorkflowRoleDirectory(Directory):
self.formdef = formdef
def _q_lookup(self, component):
if not component in self.formdef.workflow.roles:
if component not in self.formdef.workflow.roles:
raise TraversalError()
if not self.formdef.workflow_roles:
@ -1096,7 +1096,7 @@ class FormDefPage(Directory):
form = Form(enctype='multipart/form-data')
for status in self.formdef.workflow.possible_status:
default = status.id
if not default in [x.id for x in new_workflow.possible_status]:
if default not in [x.id for x in new_workflow.possible_status]:
default = new_workflow_status[0]
form.add(
SingleSelectWidget,

View File

@ -890,7 +890,7 @@ class SettingsDirectory(QommonSettingsDirectory):
get_session().message = ('error', _('Empty theme file.'))
return redirect('themes')
theme_name = filename_list[0].split('/')[0]
if not ('%s/desc.xml' % theme_name) in filename_list:
if ('%s/desc.xml' % theme_name) not in filename_list:
get_session().message = ('error', _('Theme is missing a desc.xml file.'))
return redirect('themes')
desc_xml = z.read('%s/desc.xml' % theme_name)

View File

@ -1639,7 +1639,7 @@ class WorkflowPage(Directory):
for field in self.workflow.variables_formdef.fields:
if field.varname:
r += htmltext('<li><a href="variables/fields/%s/">%s') % (field.id, field.label)
if not '*' in field.varname:
if '*' not in field.varname:
r += htmltext(' <code class="varname">{{form_option_%s}}</code>') % field.varname
r += htmltext('</a></li>')
r += htmltext('</ul>')

View File

@ -68,7 +68,7 @@ def posted_json_data_to_formdata_data(formdef, data):
for field in formdef.get_all_fields():
if not field.varname:
continue
if not field.varname in data:
if field.varname not in data:
continue
raw = '%s_raw' % field.varname
structured = '%s_structured' % field.varname
@ -1192,7 +1192,7 @@ def reverse_geocoding(request, *args, **kwargs):
def geocoding(request, *args, **kwargs):
if not 'q' in request.GET:
if 'q' not in request.GET:
return HttpResponseBadRequest()
q = request.GET['q']
url = get_publisher().get_geocoding_service_url()

View File

@ -103,7 +103,7 @@ def geojson_formdatas(formdatas, geoloc_key='base', fields=None):
geojson = {'type': 'FeatureCollection', 'features': []}
for formdata in formdatas:
if not formdata.geolocations or not geoloc_key in formdata.geolocations:
if not formdata.geolocations or geoloc_key not in formdata.geolocations:
continue
coords = misc.normalize_geolocation(formdata.geolocations[geoloc_key])
status = formdata.get_status()
@ -297,7 +297,7 @@ class UserViewDirectory(Directory):
categories = {}
formdata_by_category = {}
for formdata in formdatas:
if not formdata.formdef.category_id in categories:
if formdata.formdef.category_id not in categories:
categories[formdata.formdef.category_id] = formdata.formdef.category
formdata_by_category[formdata.formdef.category_id] = []
formdata_by_category[formdata.formdef.category_id].append(formdata)
@ -945,7 +945,7 @@ class ManagementDirectory(Directory):
session = get_session()
visited_objects = session.get_visited_objects(exclude_user=session.user)
for formdata in formdatas:
if not formdata.formdef.workflow_id in workflows:
if formdata.formdef.workflow_id not in workflows:
workflows[formdata.formdef.workflow_id] = formdata.formdef.workflow
classes = ['status-%s-%s' % (formdata.formdef.workflow.id, formdata.status)]
@ -1972,7 +1972,7 @@ class FormPage(Directory):
# filter actions to get those that can be run by the user,
# either because of actual roles, or because the action is
# accessible to functions.
if not logged_users_role().id in action_dict.get('roles') or []:
if logged_users_role().id not in action_dict.get('roles') or []:
action_dict['roles'] = [x for x in user.get_roles() if x in action_dict.get('roles') or []]
if action_dict['roles']:
# action is accessible with user roles, remove mentions of functions
@ -2937,7 +2937,7 @@ class FormBackOfficeStatusPage(FormStatusPage):
if formdata.formdef.geolocations and formdata.geolocations:
r += htmltext('<div class="geolocations">')
for geoloc_key in formdata.formdef.geolocations:
if not geoloc_key in formdata.geolocations:
if geoloc_key not in formdata.geolocations:
continue
r += htmltext('<h3>%s</h3>') % formdata.formdef.geolocations[geoloc_key]
geoloc_value = formdata.geolocations[geoloc_key]
@ -3000,7 +3000,7 @@ class FormBackOfficeStatusPage(FormStatusPage):
categories = {}
formdata_by_category = {}
for formdata in formdatas:
if not formdata.formdef.category_id in categories:
if formdata.formdef.category_id not in categories:
categories[formdata.formdef.category_id] = formdata.formdef.category
formdata_by_category[formdata.formdef.category_id] = []
formdata_by_category[formdata.formdef.category_id].append(formdata)

View File

@ -168,7 +168,7 @@ class RootDirectory(BackofficeRootDirectory):
def generate_header_menu(self, selected=None):
s = ['<ul id="sidepage-menu">\n']
for menu_item in self.get_menu_items():
if not 'icon' in menu_item:
if 'icon' not in menu_item:
continue
if menu_item.get('slug') == selected:
s.append('<li class="active">')
@ -186,7 +186,7 @@ class RootDirectory(BackofficeRootDirectory):
menu_items = self.get_menu_items()
r += htmltext('<ul class="apps">')
for menu_item in menu_items:
if not 'icon' in menu_item:
if 'icon' not in menu_item:
continue
if menu_item['icon'] == 'studio':
continue

View File

@ -49,7 +49,7 @@ class CardDef(FormDef):
category_class = CardDefCategory
def data_class(self, mode=None):
if not 'carddef' in sys.modules:
if 'carddef' not in sys.modules:
sys.modules['carddef'] = sys.modules[__name__]
if hasattr(sys.modules['carddef'], self.data_class_name):
data_class = getattr(sys.modules['carddef'], self.data_class_name)

View File

@ -185,7 +185,7 @@ class CmdCheckHobos(Command):
themes_json = {'themes': themes_json}
for theme_data in themes_json.get('themes'):
if theme_data.get('id') == theme_id:
if not 'module' in theme_data:
if 'module' not in theme_data:
theme_data['module'] = theme_module
break
else:
@ -253,7 +253,7 @@ class CmdCheckHobos(Command):
# create or update profile fields
for attribute in profile.get('fields', []):
field_id = '_' + attribute['name']
if not field_id in profile_fields:
if field_id not in profile_fields:
field_class = StringField
if attribute['kind'] == 'email':
field_class = EmailField
@ -304,9 +304,9 @@ class CmdCheckHobos(Command):
if not pub.cfg.get('identification'):
pub.cfg['identification'] = {}
methods = pub.cfg['identification'].get('methods', [])
if idps and not 'idp' in methods:
if idps and 'idp' not in methods:
methods.append('idp')
elif not idps and not 'password' in methods:
elif not idps and 'password' not in methods:
methods.append('password')
pub.cfg['identification']['methods'] = methods
if not pub.cfg.get('sp'):
@ -327,7 +327,7 @@ class CmdCheckHobos(Command):
spconfig['saml2_providerid'] = spconfig['saml2_base_url'] + '/metadata'
MethodAdminDirectory().generate_rsa_keypair()
if not 'saml_identities' in pub.cfg:
if 'saml_identities' not in pub.cfg:
pub.cfg['saml_identities'] = {}
if idps:
@ -387,11 +387,11 @@ class CmdCheckHobos(Command):
except (configparser.NoOptionError, configparser.NoSectionError):
pass
if not 'hobo' in config.sections():
if 'hobo' not in config.sections():
config.add_section('hobo')
config.set('hobo', 'timestamp', self.all_services.get('timestamp'))
if not 'options' in config.sections():
if 'options' not in config.sections():
config.add_section('options')
variables = {}
@ -450,7 +450,7 @@ class CmdCheckHobos(Command):
variables[key] = value
if variables:
if not 'variables' in config.sections():
if 'variables' not in config.sections():
config.add_section('variables')
for key, value in variables.items():
key = force_str(key)
@ -462,9 +462,9 @@ class CmdCheckHobos(Command):
value = force_str(value)
config.set('variables', key, value)
if not 'api-secrets' in config.sections():
if 'api-secrets' not in config.sections():
config.add_section('api-secrets')
if not 'wscall-secrets' in config.sections():
if 'wscall-secrets' not in config.sections():
config.add_section('wscall-secrets')
for key, value in api_secrets.items():
config.set('api-secrets', key, value)
@ -524,7 +524,7 @@ class CmdCheckHobos(Command):
# legacy way to create a database name, if it contained an
# underscore character, use the first part as a prefix
database_name = pub.cfg['postgresql'].get('database', 'wcs')
if not domain_table_name in database_name:
if domain_table_name not in database_name:
database_name = '%s_%s' % (database_name.split('_')[0], domain_table_name)
database_name = self.normalize_database_name(database_name)

View File

@ -54,7 +54,7 @@ data_source_functions = {}
def register_data_source_function(function, function_name=None):
if not function_name:
function_name = function.__name__
if not function_name in data_source_functions:
if function_name not in data_source_functions:
data_source_functions[function_name] = function
@ -561,7 +561,7 @@ class NamedDataSource(XmlStorableObject):
url = get_variadic_url(url, vars)
if not url:
return ''
if not '?' in url:
if '?' not in url:
url += '?' + self.query_parameter + '='
else:
url += '&' + self.query_parameter + '='

View File

@ -312,7 +312,7 @@ class Field:
if hasattr(self, attribute) and getattr(self, attribute) is not None:
val = getattr(self, attribute)
field[attribute] = val
if not 'type' in field:
if 'type' not in field:
field['type'] = self.key
return field
@ -674,7 +674,7 @@ class WidgetField(Field):
if hasattr(self, k):
kwargs[k] = getattr(self, k)
if self.widget_class is StringWidget and not 'size' in kwargs and value:
if self.widget_class is StringWidget and 'size' not in kwargs and value:
# set a size if there is not one already defined, this will be for
# example the case with ItemField
kwargs['size'] = len(value)
@ -813,7 +813,7 @@ field_types = []
def register_field_class(klass):
if not klass in field_classes:
if klass not in field_classes:
field_classes.append(klass)
if not issubclass(klass, WidgetField):
field_types.append((klass.key, klass.description))

View File

@ -217,7 +217,7 @@ class FormDef(StorableObject):
f.id = str(i)
for formdata in self.data_class().select():
for f in self.fields:
if not f.label in formdata.data:
if f.label not in formdata.data:
continue
formdata.data[f.id] = formdata.data[f.label]
del formdata.data[f.label]
@ -302,7 +302,7 @@ class FormDef(StorableObject):
return '_wcs_%s' % self.url_name.title()
def data_class(self, mode=None):
if not 'formdef' in sys.modules:
if 'formdef' not in sys.modules:
sys.modules['formdef'] = sys.modules[__name__]
if hasattr(sys.modules['formdef'], self.data_class_name):
data_class = getattr(sys.modules['formdef'], self.data_class_name)
@ -751,7 +751,7 @@ class FormDef(StorableObject):
if field.condition:
field.varnames = field.get_condition_varnames(formdef=self)
for varname in field.varnames:
if not varname in live_condition_fields:
if varname not in live_condition_fields:
live_condition_fields[varname] = []
live_condition_fields[varname].append(field)
if field.key == 'item' and field.data_source:
@ -762,7 +762,7 @@ class FormDef(StorableObject):
continue
varnames = data_source.get_referenced_varnames(formdef=self)
for varname in varnames:
if not varname in live_condition_fields:
if varname not in live_condition_fields:
live_condition_fields[varname] = []
live_condition_fields[varname].append(field)
if field.prefill and field.prefill.get('type') == 'string':
@ -774,7 +774,7 @@ class FormDef(StorableObject):
live_condition_fields[varname].append(field)
if field.key == 'comment':
for varname in field.get_referenced_varnames(formdef=self, value=field.label):
if not varname in live_condition_fields:
if varname not in live_condition_fields:
live_condition_fields[varname] = []
live_condition_fields[varname].append(field)

View File

@ -158,7 +158,7 @@ class FormStatusPage(Directory, FormTemplateMixin):
self.filled = filled
self._q_exports = self._q_exports_orig[:]
for q in self._q_extra_exports:
if not q in self._q_exports:
if q not in self._q_exports:
self._q_exports.append(q)
if self.formdata and self.formdef.workflow and register_workflow_subdirs:

View File

@ -98,7 +98,7 @@ def tryauth(url):
if get_request().user:
return redirect(url)
ident_methods = get_cfg('identification', {}).get('methods', ['idp'])
if not 'idp' in ident_methods:
if 'idp' not in ident_methods:
# when configured with local logins and not logged in, redirect to
# asked url.
return redirect(url)
@ -913,7 +913,7 @@ class FormPage(Directory, FormTemplateMixin):
for k, v in data.items():
req.form['f%s' % k] = v
for field in self.formdef.fields:
if not field.id in data:
if field.id not in data:
continue
if field.convert_value_to_str:
req.form['f%s' % field.id] = field.convert_value_to_str(data[field.id])

View File

@ -56,7 +56,7 @@ class MailTemplate(XmlStorableObject):
suffix_no = 0
known_slugs = {x.slug: x.id for x in self.select(ignore_migration=True, ignore_errors=True)}
while True:
if not new_slug in known_slugs:
if new_slug not in known_slugs:
break
suffix_no += 1
new_slug = '%s-%s' % (base_new_slug, suffix_no)

View File

@ -63,7 +63,7 @@ def pagination_links(offset, limit, total_count, load_js=True):
if 2 not in page_numbers:
page_numbers.insert(1, Ellipsis)
if last_page not in page_numbers:
if not last_page - 1 in page_numbers:
if last_page - 1 not in page_numbers:
page_numbers.append(Ellipsis)
page_numbers.append(last_page)

View File

@ -62,9 +62,9 @@ def cron_worker(publisher, now, job_name=None):
continue
if job.weekdays and now[6] not in job.weekdays:
continue
if job.hours and not now[3] in job.hours:
if job.hours and now[3] not in job.hours:
continue
if minutes and not now[4] in minutes:
if minutes and now[4] not in minutes:
continue
publisher.install_lang()

View File

@ -927,7 +927,7 @@ class EmailWidget(StringWidget):
def __init__(self, *args, **kwargs):
StringWidget.__init__(self, *args, **kwargs)
if not 'size' in kwargs:
if 'size' not in kwargs:
self.attrs['size'] = '35'
def add_media(self):
@ -947,7 +947,7 @@ class EmailWidget(StringWidget):
StringWidget._parse(self, request)
if self.value is not None:
# basic tests first
if not '@' in self.value[1:-1]:
if '@' not in self.value[1:-1]:
self.error = _('must be a valid email address')
return
if self.value[0] != '"' and ' ' in self.value:
@ -2415,7 +2415,7 @@ $(function() {
% {'id': self.name, 'data_type': data_type}
)
if not '[var_' in url:
if '[var_' not in url:
r += htmltext(
"""
$("#form_%(id)s").data('uiAutocomplete').options.url = '%(url)s';

View File

@ -61,7 +61,7 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
mapped_script_name = mappings.get(script_name, script_name)
if not mapped_script_name:
continue
if not mapped_script_name in self.javascript_scripts:
if mapped_script_name not in self.javascript_scripts:
if script_name == 'qommon.map.js':
self.add_javascript(['jquery.js'])
self.add_javascript(['../xstatic/leaflet.js'])
@ -112,7 +112,7 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
def add_javascript_code(self, code):
if not self.javascript_code_parts:
self.javascript_code_parts = []
if not code in self.javascript_code_parts:
if code not in self.javascript_code_parts:
self.javascript_code_parts.append(code)
def get_javascript_for_header(self):
@ -139,7 +139,7 @@ class HTTPResponse(quixote.http_response.HTTPResponse):
def add_css_include(self, css_include):
if not self.css_includes:
self.css_includes = []
if not css_include in self.css_includes:
if css_include not in self.css_includes:
self.css_includes.append(css_include)
def get_css_includes_for_header(self):

View File

@ -603,7 +603,7 @@ class MethodDirectory(Directory):
user.name = username
if formdef:
data = formdef.get_data(form)
if identities_cfg.get('email-as-username', False) and not 'email' in data:
if identities_cfg.get('email-as-username', False) and 'email' not in data:
data['email'] = username
user.set_attributes_from_formdata(data)
user.form_data = data
@ -1358,7 +1358,7 @@ TextsDirectory.register(
def handle_unused_accounts(publisher):
if not 'password' in get_cfg('identification', {}).get('methods', []):
if 'password' not in get_cfg('identification', {}).get('methods', []):
return
identities_cfg = get_cfg('identities', {})
warn_about_unused_account_delay = identities_cfg.get('warn_about_unused_account_delay', 0)
@ -1410,7 +1410,7 @@ def handle_unused_accounts(publisher):
def handle_expired_tokens(publisher):
if not 'password' in get_cfg('identification', {}).get('methods', []):
if 'password' not in get_cfg('identification', {}).get('methods', []):
return
now = time.time()
for token_key in tokens.Token.keys():

View File

@ -141,7 +141,7 @@ class MyspaceDirectory(Directory):
def password(self):
ident_methods = get_cfg('identification', {}).get('methods', ['idp']) or []
if not 'password' in ident_methods:
if 'password' not in ident_methods:
raise errors.TraversalError()
user = get_request().user

View File

@ -185,7 +185,7 @@ class WorkSheet:
self.workbook = workbook
def write(self, row, column, value, **kwargs):
if not row in self.cells:
if row not in self.cells:
self.cells[row] = {}
self.cells[row][column] = WorkCell(self, value, **kwargs)

View File

@ -351,7 +351,7 @@ class QommonPublisher(Publisher):
lang = request.language
else:
lang = self.get_site_language()
if lang is None or not lang in [x[0] for x in settings.LANGUAGES]:
if lang is None or lang not in [x[0] for x in settings.LANGUAGES]:
lang = 'en'
translation.activate(lang)
self.gettext = translation.gettext

View File

@ -476,7 +476,7 @@ class Saml2Directory(Directory):
if user.form_data is None:
user.form_data = {}
for key, field_id in attribute_mapping.items():
if not key in d:
if key not in d:
continue
field_value = d[key]
field = dict_fields.get(field_id)

View File

@ -606,7 +606,7 @@ class StorableObject:
for attr in attribute:
attr_value = fix_key(attr)
index_name = '%s-%s' % (index, attr_value)
if not index_name in hashed_indexes:
if index_name not in hashed_indexes:
hashed_indexes[index_name] = []
hashed_indexes[index_name].append(str(object.id))
@ -817,7 +817,7 @@ class StorableObject:
ids = [str(x) for x in pickle.load(fd)]
else:
ids = []
if not str(self.id) in ids:
if str(self.id) not in ids:
ids.append(str(self.id))
with open(index_file, 'wb') as fd:
pickle.dump(ids, fd, protocol=2)

View File

@ -73,7 +73,7 @@ class Substitutions:
# adding the current user, as it may be None if he is not logged
# in.
return
if not source in self.sources:
if source not in self.sources:
self.sources.append(source)
self.invalidate_cache()

View File

@ -219,7 +219,7 @@ class StaticsDirectory(Directory):
for directory in directories:
if directory[0] == '/':
yield directory
elif not ':' in directory:
elif ':' not in directory:
yield os.path.join(get_publisher().data_dir, directory)
else:
directory_type, value = directory.split(':')
@ -305,7 +305,7 @@ class RootDirectory(Directory):
):
return get_publisher().ident_methods['fc']().logout()
if not 'idp' in ident_methods:
if 'idp' not in ident_methods:
get_session_manager().expire_session()
return redirect(get_publisher().get_root_url())

View File

@ -546,52 +546,52 @@ def do_formdef_tables(formdef, conn=None, cur=None, rebuild_views=False, rebuild
)
# migrations
if not 'fts' in existing_fields:
if 'fts' not in existing_fields:
# full text search
cur.execute('''ALTER TABLE %s ADD COLUMN fts tsvector''' % table_name)
cur.execute('''CREATE INDEX %s_fts ON %s USING gin(fts)''' % (table_name, table_name))
if not 'workflow_roles' in existing_fields:
if 'workflow_roles' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN workflow_roles bytea''' % table_name)
cur.execute('''ALTER TABLE %s ADD COLUMN workflow_roles_array text[]''' % table_name)
if not 'concerned_roles_array' in existing_fields:
if 'concerned_roles_array' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN concerned_roles_array text[]''' % table_name)
if not 'actions_roles_array' in existing_fields:
if 'actions_roles_array' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN actions_roles_array text[]''' % table_name)
if not 'page_no' in existing_fields:
if 'page_no' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN page_no varchar''' % table_name)
if not 'anonymised' in existing_fields:
if 'anonymised' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN anonymised timestamptz''' % table_name)
if not 'tracking_code' in existing_fields:
if 'tracking_code' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN tracking_code varchar''' % table_name)
if not 'backoffice_submission' in existing_fields:
if 'backoffice_submission' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN backoffice_submission boolean''' % table_name)
if not 'submission_context' in existing_fields:
if 'submission_context' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN submission_context bytea''' % table_name)
if 'submission_agent_id' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN submission_agent_id varchar''' % table_name)
if not 'submission_channel' in existing_fields:
if 'submission_channel' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN submission_channel varchar''' % table_name)
if not 'criticality_level' in existing_fields:
if 'criticality_level' not in existing_fields:
cur.execute(
'''ALTER TABLE %s ADD COLUMN criticality_level integer NOT NULL DEFAULT(0)''' % table_name
)
if not 'last_update_time' in existing_fields:
if 'last_update_time' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN last_update_time timestamp''' % table_name)
if not 'digest' in existing_fields:
if 'digest' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN digest varchar''' % table_name)
if not 'user_label' in existing_fields:
if 'user_label' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN user_label varchar''' % table_name)
if 'prefilling_data' not in existing_fields:
@ -653,11 +653,11 @@ def do_formdef_tables(formdef, conn=None, cur=None, rebuild_views=False, rebuild
cur.close()
actions = []
if not 'concerned_roles_array' in existing_fields:
if 'concerned_roles_array' not in existing_fields:
actions.append('rebuild_security')
elif not 'actions_roles_array' in existing_fields:
elif 'actions_roles_array' not in existing_fields:
actions.append('rebuild_security')
if not 'tracking_code' in existing_fields:
if 'tracking_code' not in existing_fields:
# if tracking code has just been added to the table we need to make
# sure the tracking code table does exist.
actions.append('do_tracking_code_table')
@ -683,13 +683,13 @@ def do_formdef_indexes(formdef, created, conn, cur, concurrently=False):
if concurrently:
create_index = 'CREATE INDEX CONCURRENTLY'
if not evolutions_table_name + '_fid' in existing_indexes:
if evolutions_table_name + '_fid' not in existing_indexes:
cur.execute(
'''%s %s_fid ON %s (formdata_id)''' % (create_index, evolutions_table_name, evolutions_table_name)
)
for attr in ('receipt_time', 'anonymised', 'user_id', 'status'):
if not table_name + '_' + attr + '_idx' in existing_indexes:
if table_name + '_' + attr + '_idx' not in existing_indexes:
cur.execute(
'%(create_index)s %(table_name)s_%(attr)s_idx ON %(table_name)s (%(attr)s)'
% {'create_index': create_index, 'table_name': table_name, 'attr': attr}
@ -779,15 +779,15 @@ def do_user_table():
)
# migrations
if not 'fts' in existing_fields:
if 'fts' not in existing_fields:
# full text search
cur.execute('''ALTER TABLE %s ADD COLUMN fts tsvector''' % table_name)
cur.execute('''CREATE INDEX %s_fts ON %s USING gin(fts)''' % (table_name, table_name))
if not 'verified_fields' in existing_fields:
if 'verified_fields' not in existing_fields:
cur.execute('ALTER TABLE %s ADD COLUMN verified_fields text[]' % table_name)
if not 'ascii_name' in existing_fields:
if 'ascii_name' not in existing_fields:
cur.execute('ALTER TABLE %s ADD COLUMN ascii_name varchar' % table_name)
if 'deleted_timestamp' not in existing_fields:
@ -931,7 +931,7 @@ def do_session_table():
)
# migrations
if not 'last_update_time' in existing_fields:
if 'last_update_time' not in existing_fields:
cur.execute('''ALTER TABLE %s ADD COLUMN last_update_time timestamp DEFAULT NOW()''' % table_name)
cur.execute('''CREATE INDEX %s_ts ON %s (last_update_time)''' % (table_name, table_name))
@ -1094,7 +1094,7 @@ def do_loggederrors_table(concurrently=False):
existing_indexes = set([x[0] for x in cur.fetchall()])
for attr in ('formdef_id', 'workflow_id'):
if not table_name + '_' + attr + '_idx' in existing_indexes:
if table_name + '_' + attr + '_idx' not in existing_indexes:
cur.execute(
'%(create_index)s %(table_name)s_%(attr)s_idx ON %(table_name)s (%(attr)s)'
% {'create_index': create_index, 'table_name': table_name, 'attr': attr}
@ -3085,7 +3085,7 @@ class AnyFormData(SqlMixin):
def load_all_evolutions(cls, formdatas):
classes = {}
for formdata in formdatas:
if not formdata._table_name in classes:
if formdata._table_name not in classes:
classes[formdata._table_name] = []
classes[formdata._table_name].append(formdata)
for formdatas in classes.values():
@ -3182,7 +3182,7 @@ def get_weekday_totals(period_start=None, period_end=None, criterias=None):
result = [(int(x), y) for x, y in result]
coverage = [x[0] for x in result]
for weekday in range(7):
if not weekday in coverage:
if weekday not in coverage:
result.append((weekday, 0))
result.sort()
@ -3208,7 +3208,7 @@ def get_hour_totals(period_start=None, period_end=None, criterias=None):
coverage = [x[0] for x in result]
for hour in range(24):
if not hour in coverage:
if hour not in coverage:
result.append((hour, 0))
result.sort()
@ -3237,7 +3237,7 @@ def get_monthly_totals(period_start=None, period_end=None, criterias=None):
last_month = raw_result[-1][0]
while current_month < last_month:
label = '%d-%02d' % current_month.timetuple()[:2]
if not label in coverage:
if label not in coverage:
result.append((label, 0))
current_month = current_month + datetime.timedelta(days=31)
current_month = current_month - datetime.timedelta(days=current_month.day - 1)
@ -3268,7 +3268,7 @@ def get_yearly_totals(period_start=None, period_end=None, criterias=None):
last_year = raw_result[-1][0]
while current_year < last_year:
label = str(current_year.year)
if not label in coverage:
if label not in coverage:
result.append((label, 0))
current_year = current_year + datetime.timedelta(days=366)
result.sort()

View File

@ -122,7 +122,7 @@ class AddAttachmentWorkflowStatusItem(WorkflowStatusItem):
def init(cls):
FormStatusPage._q_extra_exports.append('attachment')
FormStatusPage.attachment = form_attachment
if not 'lookup_wf_attachment' in FileDirectory._lookup_methods:
if 'lookup_wf_attachment' not in FileDirectory._lookup_methods:
FileDirectory._lookup_methods.append('lookup_wf_attachment')
FileDirectory.lookup_wf_attachment = lookup_wf_attachment

View File

@ -261,7 +261,7 @@ class ExportToModel(WorkflowStatusItem):
return _('no model set')
def fill_form(self, form, formdata, user, **kwargs):
if not self.method == 'interactive':
if self.method != 'interactive':
return
label = self.label
if not label:
@ -271,7 +271,7 @@ class ExportToModel(WorkflowStatusItem):
widget.backoffice_info_text = self.backoffice_info_text
def submit_form(self, form, formdata, user, evo):
if not self.method == 'interactive':
if self.method != 'interactive':
return
if not self.model_file:
return

View File

@ -107,7 +107,7 @@ class FormWorkflowStatusItem(WorkflowStatusItem):
@classmethod
def init(cls):
if not 'lookup_wf_form_file' in FileDirectory._lookup_methods:
if 'lookup_wf_form_file' not in FileDirectory._lookup_methods:
FileDirectory._lookup_methods.append('lookup_wf_form_file')
FileDirectory.lookup_wf_form_file = lookup_wf_form_file

View File

@ -111,7 +111,7 @@ class ResubmitWorkflowStatusItem(WorkflowStatusItem):
for suffix in ('', '_raw', '_structured'):
old_key = '%s%s' % (orig_formdata_field_id, suffix)
new_key = '%s%s' % (field.id, suffix)
if not old_key in formdata.data:
if old_key not in formdata.data:
continue
new_formdata.data[new_key] = formdata.data[old_key]

View File

@ -98,7 +98,7 @@ class AddRoleWorkflowStatusItem(WorkflowStatusItem):
def perform_local(self, user, formdata, role_id):
if not user.roles:
user.roles = []
if not role_id in user.roles:
if role_id not in user.roles:
user.roles.append(role_id)
user.store()
request = get_request()

View File

@ -315,7 +315,7 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
'action_on_network_errors',
'action_on_bad_data',
):
if not attribute in parameters:
if attribute not in parameters:
continue
if attribute == 'action_on_bad_data':
attrs = {

View File

@ -78,7 +78,7 @@ from .qommon.upload_storage import get_storage_object
from .roles import get_user_roles
from .roles import logged_users_role
if not __name__.startswith('wcs.') and not __name__ == "__main__":
if not __name__.startswith('wcs.') and __name__ != "__main__":
raise ImportError('Import of workflows module must be absolute (import wcs.workflows)')
@ -261,7 +261,7 @@ class AttachmentEvolutionPart:
os.mkdir(dirname)
# there is not filename, or it was a temporary one: create it
if not 'filename' in odict or odict['filename'].startswith('uuid-'):
if 'filename' not in odict or odict['filename'].startswith('uuid-'):
filename = file_digest(self.fp)
dirname = os.path.join(dirname, filename[:4])
if not os.path.exists(dirname):
@ -400,7 +400,7 @@ class Workflow(StorableObject):
def migrate(self):
changed = False
if not 'roles' in self.__dict__ or self.roles is None:
if 'roles' not in self.__dict__ or self.roles is None:
self.roles = {'_receiver': _('Recipient')}
changed = True
@ -2453,7 +2453,7 @@ item_classes = []
def register_item_class(klass):
if not klass.key in [x.key for x in item_classes]:
if klass.key not in [x.key for x in item_classes]:
item_classes.append(klass)
klass.init()
@ -2481,7 +2481,7 @@ class CommentableWorkflowStatusItem(WorkflowStatusItem):
return _('not completed')
def fill_form(self, form, formdata, user, **kwargs):
if not 'comment' in [x.name for x in form.widgets]:
if 'comment' not in [x.name for x in form.widgets]:
if self.label is None:
title = _('Comment')
else: