Skip to content

Commit 03d3dd7

Browse files
rhoerbec00kiemon5ter
authored andcommitted
fix PEP-8 violations in src/satosa excluding subdirs
checking tool: flake8 --max-line-length 119
1 parent 4065cfd commit 03d3dd7

File tree

12 files changed

+29
-41
lines changed

12 files changed

+29
-41
lines changed

src/satosa/attribute_mapping.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def to_internal(self, attribute_profile, external_dict):
9898
external_dict)
9999
if attribute_values: # Only insert key if it has some values
100100
logger.debug("backend attribute '%s' mapped to %s" % (external_attribute_name,
101-
internal_attribute_name))
101+
internal_attribute_name))
102102
internal_dict[internal_attribute_name] = attribute_values
103103
else:
104104
logger.debug("skipped backend attribute '%s': no value found", external_attribute_name)
@@ -122,7 +122,7 @@ def _render_attribute_template(self, template, data):
122122
t = Template(template, cache_enabled=True, imports=["from satosa.attribute_mapping import scope"])
123123
try:
124124
return t.render(**data).split(self.multivalue_separator)
125-
except (NameError, TypeError) as e:
125+
except (NameError, TypeError):
126126
return []
127127

128128
def _handle_template_attributes(self, attribute_profile, internal_dict):
@@ -187,8 +187,7 @@ def from_internal(self, attribute_profile, internal_dict):
187187
if attribute_profile not in attribute_mapping:
188188
# skip this internal attribute if we have no mapping in the specified profile
189189
logger.debug("no mapping found for '%s' in attribute profile '%s'" %
190-
(internal_attribute_name,
191-
attribute_profile))
190+
(internal_attribute_name, attribute_profile))
192191
continue
193192

194193
external_attribute_names = self.from_internal_attributes[internal_attribute_name][attribute_profile]

src/satosa/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ def __init__(self, config):
7272
self.request_micro_services = []
7373
logger.info("Loading micro services...")
7474
if "MICRO_SERVICES" in self.config:
75-
self.request_micro_services.extend(load_request_microservices(self.config.get("CUSTOM_PLUGIN_MODULE_PATHS"),
76-
self.config["MICRO_SERVICES"],
77-
self.config["INTERNAL_ATTRIBUTES"],
78-
self.config["BASE"]))
75+
self.request_micro_services.extend(load_request_microservices(
76+
self.config.get("CUSTOM_PLUGIN_MODULE_PATHS"),
77+
self.config["MICRO_SERVICES"],
78+
self.config["INTERNAL_ATTRIBUTES"],
79+
self.config["BASE"]))
7980
self._link_micro_services(self.request_micro_services, self._auth_req_finish)
8081

8182
self.response_micro_services.extend(

src/satosa/context.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ class SATOSABadContextError(SATOSAError):
88
pass
99

1010

11-
"""
12-
Holds methods for sending internal data through the satosa proxy
13-
"""
1411
class Context(object):
1512
"""
16-
Holds information about the current request.
13+
Holds methods for sharing proxy data through the current request
1714
"""
1815
KEY_BACKEND_METADATA_STORE = 'metadata_store'
1916
KEY_TARGET_ENTITYID = 'target_entity_id'

src/satosa/deprecated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class UserIdHashType(Enum):
9393
unspecified = 6
9494

9595
def __getattr__(self, name):
96-
if name is not "_value_":
96+
if name != "_value_":
9797
msg = "UserIdHashType is deprecated and will be removed."
9898
_warnings.warn(msg, DeprecationWarning)
9999
return self.__getattribute__(name)

src/satosa/internal_data.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import warnings as _warnings
22

3-
from satosa.internal import InternalData
4-
from satosa.internal import AuthenticationInformation
5-
from satosa.deprecated import UserIdHashType
6-
from satosa.deprecated import UserIdHasher
7-
from satosa.deprecated import InternalRequest
8-
from satosa.deprecated import InternalResponse
9-
103

114
_warnings.warn(
125
"internal_data is deprecated; use satosa.internal instead.",

src/satosa/metadata_creation/description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def add_logo(self, text, width, height, lang=None):
9191
:param lang: language
9292
"""
9393

94-
logo_entry ={"text": text, "width": width, "height": height}
94+
logo_entry = {"text": text, "width": width, "height": height}
9595
if lang:
9696
logo_entry["lang"] = lang
9797
self._logos.append(logo_entry)

src/satosa/metadata_creation/saml_metadata.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,9 @@ def _create_frontend_metadata(frontend_modules, backend_modules):
7474
for co_name in co_names:
7575
logger.info("Creating metadata for CO {}".format(co_name))
7676
idp_config = copy.deepcopy(frontend.config["idp_config"])
77-
idp_config = frontend._add_endpoints_to_config(
78-
idp_config,
79-
co_name,
80-
backend.name)
77+
idp_config = frontend._add_endpoints_to_config(idp_config, co_name, backend.name)
8178
idp_config = frontend._add_entity_id(idp_config, co_name)
82-
idp_config = frontend._overlay_for_saml_metadata(
83-
idp_config,
84-
co_name)
79+
idp_config = frontend._overlay_for_saml_metadata(idp_config, co_name)
8580
entity_desc = _create_entity_descriptor(idp_config)
8681
frontend_metadata[frontend.name].append(entity_desc)
8782

src/satosa/plugin_loader.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ def load_backends(config, callback, internal_attributes):
4141
:param callback: Function that will be called by the backend after the authentication is done.
4242
:return: A list of backend modules
4343
"""
44-
backend_modules = _load_plugins(config.get("CUSTOM_PLUGIN_MODULE_PATHS"), config["BACKEND_MODULES"], backend_filter,
45-
config["BASE"], internal_attributes, callback)
44+
backend_modules = _load_plugins(
45+
config.get("CUSTOM_PLUGIN_MODULE_PATHS"),
46+
config["BACKEND_MODULES"],
47+
backend_filter, config["BASE"],
48+
internal_attributes, callback)
4649
logger.info("Setup backends: %s" % [backend.name for backend in backend_modules])
4750
return backend_modules
4851

@@ -184,7 +187,8 @@ def _load_plugins(plugin_paths, plugins, plugin_filter, base_url, internal_attri
184187
def _load_endpoint_module(plugin_config, plugin_filter):
185188
_mandatory_params = ("name", "module", "config")
186189
if not all(k in plugin_config for k in _mandatory_params):
187-
raise SATOSAConfigurationError("Missing mandatory plugin configuration parameter: {}".format(_mandatory_params))
190+
raise SATOSAConfigurationError(
191+
"Missing mandatory plugin configuration parameter: {}".format(_mandatory_params))
188192

189193
return _load_plugin_module(plugin_config, plugin_filter)
190194

@@ -202,7 +206,8 @@ def _load_plugin_module(plugin_config, plugin_filter):
202206
def _load_microservice(plugin_config, plugin_filter):
203207
_mandatory_params = ("name", "module")
204208
if not all(k in plugin_config for k in _mandatory_params):
205-
raise SATOSAConfigurationError("Missing mandatory plugin configuration parameter: {}".format(_mandatory_params))
209+
raise SATOSAConfigurationError(
210+
"Missing mandatory plugin configuration parameter: {}".format(_mandatory_params))
206211

207212
return _load_plugin_module(plugin_config, plugin_filter)
208213

src/satosa/proxy_server.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def __call__(self, environ, start_response, debug=False):
9999
context.path = path
100100

101101
# copy wsgi.input stream to allow it to be re-read later by satosa plugins
102-
# see: http://stackoverflow.com/questions/1783383/how-do-i-copy-wsgi-input-if-i-want-to-process-post-data-more-than-once
102+
# see: http://stackoverflow.com/
103+
# questions/1783383/how-do-i-copy-wsgi-input-if-i-want-to-process-post-data-more-than-once
103104
content_length = int(environ.get('CONTENT_LENGTH', '0') or '0')
104105
body = io.BytesIO(environ['wsgi.input'].read(content_length))
105106
environ['wsgi.input'] = body
@@ -115,9 +116,7 @@ def __call__(self, environ, start_response, debug=False):
115116
raise resp
116117
return resp(environ, start_response)
117118
except SATOSANoBoundEndpointError:
118-
resp = NotFound(
119-
"The Service or Identity Provider"
120-
"you requested could not be found.")
119+
resp = NotFound("The Service or Identity Provider you requested could not be found.")
121120
return resp(environ, start_response)
122121
except Exception as err:
123122
if type(err) != UnknownSystemEntity:
@@ -142,7 +141,7 @@ def make_app(satosa_config):
142141
root_logger.setLevel(logging.DEBUG)
143142

144143
try:
145-
pkg = pkg_resources.get_distribution(module.__name__)
144+
_ = pkg_resources.get_distribution(module.__name__)
146145
logger.info("Running SATOSA version %s",
147146
pkg_resources.get_distribution("SATOSA").version)
148147
except (NameError, pkg_resources.DistributionNotFound):

src/satosa/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ class Unauthorized(Response):
112112
_status = "401 Unauthorized"
113113

114114
def __init__(self, message, headers=None, content=None):
115-
super().__init__(message, headers=headers, content=content)
115+
super().__init__(message, headers=headers, content=content)

0 commit comments

Comments
 (0)