minor PEP8 cleanup (" -> ')
This commit is contained in:
parent
6416b66f6e
commit
61fb3b1044
18 changed files with 456 additions and 456 deletions
|
@ -24,7 +24,7 @@ cdef class Aggregate:
|
|||
def _link_module(Aggregate self, Module module):
|
||||
# check for name (=type) collision
|
||||
if module._name in self._modules.keys():
|
||||
raise ModuleCollision(module._name, None, "name", None)
|
||||
raise ModuleCollision(module._name, None, 'name', None)
|
||||
|
||||
# check if requirements are satisfied
|
||||
unsatisfied_deps = module._requires - set(self._provided.keys())
|
||||
|
@ -36,10 +36,10 @@ cdef class Aggregate:
|
|||
common_collisions = {nc for nc in new_commons if nc in self._attrs and not nc in self._common.keys()}
|
||||
if common_collisions:
|
||||
colliding_module_names = {self._attrs[x]._name for x in common_collisions}
|
||||
raise ModuleCollision(module._name, colliding_module_names, "non-common method", common_collisions)
|
||||
raise ModuleCollision(module._name, colliding_module_names, 'non-common method', common_collisions)
|
||||
|
||||
# check for an attr collision
|
||||
module_attrs = {x for x in dir(module) if x[0] != "_"}
|
||||
module_attrs = {x for x in dir(module) if x[0] != '_'}
|
||||
attr_collisions = (module_attrs - module._common) & (set(self._attrs.keys()) | set(self._common.keys()))
|
||||
if attr_collisions:
|
||||
colliding_module_names = set()
|
||||
|
@ -50,13 +50,13 @@ cdef class Aggregate:
|
|||
if collision in self._common:
|
||||
colliding_module_names.add(self._common[collision]._name)
|
||||
|
||||
raise ModuleCollision(module._name, colliding_module_names, "attribute", attr_collisions)
|
||||
raise ModuleCollision(module._name, colliding_module_names, 'attribute', attr_collisions)
|
||||
|
||||
# check for a provided keyword collision
|
||||
provided_collisions = module._provides & set(self._provided.keys())
|
||||
if provided_collisions:
|
||||
colliding_module_names = {self._provided[x]._name for x in provided_collisions}
|
||||
raise ModuleCollision(module._name, colliding_module_names, "provided keyword", provided_collisions)
|
||||
raise ModuleCollision(module._name, colliding_module_names, 'provided keyword', provided_collisions)
|
||||
|
||||
# link the module
|
||||
self._modules[module._name] = module
|
||||
|
@ -81,7 +81,7 @@ cdef class Aggregate:
|
|||
module._top = self
|
||||
|
||||
# call the module's _on_link method, if it has one
|
||||
if hasattr(module, "_on_link"):
|
||||
if hasattr(module, '_on_link'):
|
||||
module._on_link()
|
||||
|
||||
def _unlink_module(Aggregate self, str module_name):
|
||||
|
@ -142,19 +142,19 @@ cdef class Aggregate:
|
|||
module_count = len(self._modules)
|
||||
|
||||
if module_count:
|
||||
lines = ["Aggregate("]
|
||||
lines = ['Aggregate(']
|
||||
|
||||
|
||||
for i, module in enumerate(self._modules.values()):
|
||||
if i + 1 < module_count:
|
||||
comma = ","
|
||||
comma = ','
|
||||
else:
|
||||
comma = ""
|
||||
comma = ''
|
||||
|
||||
lines.append(" %s%s" %(repr(module), comma))
|
||||
lines.append(' %s%s' %(repr(module), comma))
|
||||
|
||||
lines.append(")")
|
||||
lines.append(')')
|
||||
|
||||
return "\n".join(lines)
|
||||
return '\n'.join(lines)
|
||||
else:
|
||||
return "Aggregate()"
|
||||
return 'Aggregate()'
|
||||
|
|
|
@ -23,7 +23,7 @@ cdef class CommonMethod:
|
|||
return return_values
|
||||
|
||||
def __repr__(self):
|
||||
return "CommonMethod(name=%s)" %(self.method_name)
|
||||
return 'CommonMethod(name=%s)' %(self.method_name)
|
||||
|
||||
@property
|
||||
def _name(self):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
cdef class Module:
|
||||
def __init__(self, name, provides=set(), requires=set(), common=set()):
|
||||
"""
|
||||
'''
|
||||
* Modules are identified by their name which has to be unique within the Aggregate's namespace.
|
||||
* The provides sequence contains keywords which are copied into Aggregate's _provided list.
|
||||
Two modules providing the same export can't be linked into the same Aggregate.
|
||||
|
@ -9,9 +9,9 @@ cdef class Module:
|
|||
* All names in the Module's namespace that don't begin with an underscore will be exported
|
||||
into the Aggregate's namespace.
|
||||
* If you want to call one method on multiple modules, these modules must all export the method name
|
||||
in their "common" set. Otherwise a name collision is raised. Their methods will be called in the
|
||||
in their 'common' set. Otherwise a name collision is raised. Their methods will be called in the
|
||||
same order in which the modules were linked.
|
||||
"""
|
||||
'''
|
||||
|
||||
self._top = None
|
||||
self._name = name
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""
|
||||
'''
|
||||
Overwatch Aggregate Object type
|
||||
|
||||
TODO Method overrides: _common gets renamed to _call_all and we add _call_last.
|
||||
"""
|
||||
'''
|
||||
|
||||
class ModuleCollision(Exception):
|
||||
def __init__(self, colliding_module_name, resident_module_names, item_type, items):
|
||||
|
@ -12,7 +12,7 @@ class ModuleCollision(Exception):
|
|||
self.items = items
|
||||
|
||||
def __str__(self):
|
||||
if self.item_type == "name":
|
||||
if self.item_type == 'name':
|
||||
return "Unable to link module '%s': name already present in Aggregate." %(self.colliding_module_name)
|
||||
else:
|
||||
return "Unable to link module '%s': %s(s) '%s' already provided by module(s) '%s'." %(self.colliding_module_name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue