Pylint 1.4.3 completely stopped recognizing the star-args condition.
In order to avoid pylint error with > 1.4.3 stop caring for star-args
and add cmdline option to ignore those errors completly so older pylint
versions are happy too.
Also fix type() vs isinstance() checks, isinstance is generally a more
correct approach to check for classes.
In some 'admin' files the type() -> isinstance() fix required to invert
the order in which ComplexList and MappingList are checked as the latter
is a subclass of ComplexList, so it needs to be checked first otherwise
the check for isinstance(option, ComplexList) matches for both and the
code stops functioning properly.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
pylint -d c,r,i,W0613 -r n -f colorized \
--notes= \
--ignored-classes=cherrypy,API \
+ --disable=star-args \
./ipsilon
pep8:
pylint -d c,r,i,W0613 -r n -f colorized \
--notes= \
--ignored-classes=cherrypy \
+ --disable=star-args \
./tests
pep8 tests
aname = '%s_%s' % (name, a)
if aname in kwargs:
value.append(a)
- elif type(option) is pconfig.ComplexList:
- value = get_complex_list_value(name,
+ elif isinstance(option, pconfig.MappingList):
+ value = get_mapping_list_value(name,
option.get_value(),
**kwargs)
if value is None:
continue
- elif type(option) is pconfig.MappingList:
- value = get_mapping_list_value(name,
+ elif isinstance(option, pconfig.ComplexList):
+ value = get_complex_list_value(name,
option.get_value(),
**kwargs)
if value is None:
targs['order_name'] = '%s_order_form' % self.name
targs['order_action'] = self.order.url
- # pylint: disable=star-args
return self._template(self.template, **targs)
def root(self, *args, **kwargs):
def scheme(self):
cherrypy.response.headers.update({'Content-Type': 'image/svg+xml'})
urls = self.get_menu_urls()
- # pylint: disable=star-args
return str(self._template('admin/ipsilon-scheme.svg', **urls))
scheme.public_function = True
kwargs['sections'].append(targs)
- # pylint: disable=star-args
return self._template(self.template, **kwargs)
raise Exception('No unique user object could be found!')
data = dict()
for name, value in result[0][1].iteritems():
- if type(value) is list and len(value) == 1:
+ if isinstance(value, list) and len(value) == 1:
value = value[0]
data[name] = value
return data
confopts = {'instance': opts['instance']}
tmpl = Template(CONF_TEMPLATE)
- hunk = tmpl.substitute(**confopts) # pylint: disable=star-args
+ hunk = tmpl.substitute(**confopts)
with open(opts['httpd_conf'], 'a') as httpd_conf:
httpd_conf.write(hunk)
error_username=not username
)
self.lm.set_auth_error()
- # pylint: disable=star-args
return self._template(self.formtemplate, **context)
def make_userdata(self, fas_data):
'service': opts['form_service']}
tmpl = Template(CONF_TEMPLATE)
- hunk = tmpl.substitute(**confopts) # pylint: disable=star-args
+ hunk = tmpl.substitute(**confopts)
with open(opts['httpd_conf'], 'a') as httpd_conf:
httpd_conf.write(hunk)
confopts['gssapisslonly'] = 'On'
tmpl = Template(CONF_TEMPLATE)
- hunk = tmpl.substitute(**confopts) # pylint: disable=star-args
+ hunk = tmpl.substitute(**confopts)
with open(opts['httpd_conf'], 'a') as httpd_conf:
httpd_conf.write(hunk)
error_username=not username
)
self.lm.set_auth_error()
- # pylint: disable=star-args
return self._template('login/form.html', **context)
error_username=not username
)
self.lm.set_auth_error()
- # pylint: disable=star-args
return self._template('login/form.html', **context)
error_username=not username
)
self.lm.set_auth_error()
- # pylint: disable=star-args
return self._template('login/form.html', **context)
def GET(self, *args, **kwargs):
context = self.create_tmpl_context()
- # pylint: disable=star-args
return self._template(self.formtemplate, **context)
def root(self, *args, **kwargs):
if args is not None:
first = args[0] if len(args) > 0 else None
second = first[0] if len(first) > 0 else None
- if type(second) is dict:
+ if isinstance(second, dict):
form = second.get('form', None)
return form
"authz_details": ad,
}
context.update(dict((self.trans.get_POST_tuple(),)))
- # pylint: disable=star-args
return self._template('openid/consent_form.html', **context)
def _response(self, request, session):
value = kwargs[name]
if isinstance(option, pconfig.List):
value = [x.strip() for x in value.split('\n')]
+ # for normal lists we want unordered comparison
+ if set(value) == set(option.get_value()):
+ continue
elif isinstance(option, pconfig.Condition):
value = True
else:
aname = '%s_%s' % (name, a)
if aname in kwargs:
value.append(a)
- elif type(option) is pconfig.ComplexList:
+ elif isinstance(option, pconfig.MappingList):
current = deepcopy(option.get_value())
- value = get_complex_list_value(name,
+ value = get_mapping_list_value(name,
current,
**kwargs)
# if current value is None do nothing
if option.get_value() is None:
continue
# else pass and let it continue as None
- elif type(option) is pconfig.MappingList:
+ elif isinstance(option, pconfig.ComplexList):
current = deepcopy(option.get_value())
- value = get_mapping_list_value(name,
+ value = get_complex_list_value(name,
current,
**kwargs)
# if current value is None do nothing
continue
if value != option.get_value():
- if (type(option) is pconfig.List and
- set(value) == set(option.get_value())):
- continue
cherrypy.log.error("Storing %s = %s" %
(name, value), severity=logging.DEBUG)
new_db_values[name] = value
],
"submit": 'Return to application',
}
- # pylint: disable=star-args
return self._template('saml2/post_response.html', **context)
else:
@allowed_nameids.setter
def allowed_nameids(self, value):
- if type(value) is not list:
+ if not isinstance(value, list):
raise ValueError("Must be a list")
self._staging['allowed nameids'] = ','.join(value)
def write_from_template(destfile, template, opts):
with open(template) as f:
t = Template(f.read())
- text = t.substitute(**opts) # pylint: disable=star-args
+ text = t.substitute(**opts)
with open(destfile, 'w+') as f:
f.write(text)
return None
def _str_import_value(self, value):
- if type(value) is not str:
+ if not isinstance(value, str):
raise ValueError('Value must be string')
self._assigned_value = value
return None
def import_value(self, value):
- if type(value) is not str:
+ if not isinstance(value, str):
raise ValueError('Value (type: %s) must be string' % type(value))
self._assigned_value = [x.strip() for x in value.split(',')]
def _check_value(self, value):
if value is None:
return
- if type(value) is not list:
+ if not isinstance(value, list):
raise ValueError('The value type must be a list, not "%s"' %
type(value))
return None
def import_value(self, value):
- if type(value) is not str:
+ if not isinstance(value, str):
raise ValueError('The value type must be a string, not "%s"' %
type(value))
jsonval = json.loads(value)
def _check_value(self, value):
if value is None:
return
- if type(value) is not list:
+ if not isinstance(value, list):
raise ValueError('The value type must be a list, not "%s"' %
type(value))
for v in value:
- if type(v) is not list:
+ if not isinstance(v, list):
raise ValueError('Each element must be a list, not "%s"' %
type(v))
if len(v) != 2:
' not %d' % len(v))
def import_value(self, value):
- if type(value) is not str:
+ if not isinstance(value, str):
raise ValueError('Value (type: %s) must be string' % type(value))
jsonval = json.loads(value)
self.set_value(jsonval)
return '%s=%s' % (self.name, self.get_value())
def set_value(self, value):
- if type(value) is not list:
+ if not isinstance(value, list):
value = [value]
self._assigned_value = list()
for val in value:
self._assigned_value = None
def unset_value(self, value):
- if type(value) is str:
+ if isinstance(value, str):
value = [value]
unset = list()
for val in value:
# It's not possible to share connections for SQLite between
# threads, so let's use the SingletonThreadPool for them
pool_args = {'poolclass': SingletonThreadPool}
- # pylint: disable=star-args
self._dbengine = create_engine(engine_name, **pool_args)
self.is_readonly = False
return False
def __call__(self, *args, **kwargs):
- # pylint: disable=star-args
cherrypy.response.headers.update(self.default_headers)
self.user = UserSession().get_user()
super(Errors, self).__init__(*args, **kwargs)
def _error_template(self, *args, **kwargs):
- # pylint: disable=star-args
output_page = self._template(*args, **kwargs)
# for some reason cherrypy will choke if the output
# is a unicode object, so use str() here to please it
return False
def __call__(self, *args, **kwargs):
- # pylint: disable=star-args
cherrypy.response.headers.update(self.default_headers)
self.user = UserSession().get_user()
return model
def _template(self, *args, **kwargs):
- # pylint: disable=star-args
t = self._site['template_env'].get_template(args[0])
m = self._template_model()
m.update(kwargs)
def logout(self, user):
if user is not None:
- if not type(user) is User:
+ if not isinstance(user, User):
raise TypeError
# Completely reset user data
cherrypy.log.error('%s %s' % (user.name, user.fullname),
args = {}
while True:
- # pylint: disable=star-args
r = self.access(action, url, krb=krb, **args)
if r.status_code == 303 or r.status_code == 302:
if not follow_redirect: