Commit 9d3465d2 authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

Some PEP8 cleanup

parent 0ff244f5
......@@ -43,7 +43,8 @@ async def connect_and_setup(uri, config):
for option_name, value in config.get('options', {}).items():
option = getattr(ldap, 'OPT_X_' + option_name.upper(), None)
if option:
logger.debug("Setting option %s(%s) to %s", option_name, option, value)
logger.debug("Setting option %s(%s) to %s",
option_name, option, value)
conn.set_option(option, value)
if option_name.upper().startswith('TLS_'):
reset_tls_ctx = True
......
......@@ -83,7 +83,8 @@ class Provider:
state_changed = Signal()
sid_discovered = Signal()
def __init__(self, uri, config, searchbase, scope=ldap0.SCOPE_BASE, cookie=None, mode='refreshAndPersist'):
def __init__(self, uri, config, searchbase, scope=ldap0.SCOPE_BASE,
cookie=None, mode='refreshAndPersist'):
self.uri = uri
self.config = config
self.base = searchbase
......@@ -158,8 +159,10 @@ class Provider:
def environment_update(self, cookie):
old_state = self.state
logger.debug("Update from environment, behind/catching_up: %s/%s", bool(self.behind), bool(self.catching_up))
logger.debug("Update from environment, cookie/self.cookie: %s vs. %s", cookie, self.cookie)
logger.debug("Update from environment, behind/catching_up: %s/%s",
bool(self.behind), bool(self.catching_up))
logger.debug("Update from environment, cookie/self.cookie: %s vs. %s",
cookie, self.cookie)
if cookie in self.cookie:
self.state = ReplicaState.UPTODATE
......@@ -218,7 +221,8 @@ class Provider:
class SyncreplEnvironment:
cookie_updated = Signal()
def __init__(self, uris, searchbase, scope=ldap0.SCOPE_BASE, cookie=None, config=None):
def __init__(self, uris, searchbase, scope=ldap0.SCOPE_BASE,
cookie=None, config=None):
self.base = searchbase
self.scope = scope
self.cookie = SyncreplCookie(cookie)
......@@ -229,7 +233,8 @@ class SyncreplEnvironment:
provider_config = None
if config:
provider_config = config.get(uri, config)
provider = Provider(uri, provider_config, searchbase, scope, cookie, mode='refreshAndPersist')
provider = Provider(uri, provider_config, searchbase, scope,
cookie, mode='refreshAndPersist')
provider.cookie_updated.connect(self.update_cookie)
self.cookie_updated.connect(provider.environment_update)
......
......@@ -64,7 +64,8 @@ class LDAPRequest(asyncio.Future):
async def __aiter__(self):
next_item = asyncio.create_task(self._queue.get())
while not self.done():
done, _ = await asyncio.wait({self, next_item}, return_when=asyncio.FIRST_COMPLETED)
done, _ = await asyncio.wait({self, next_item},
return_when=asyncio.FIRST_COMPLETED)
if next_item in done:
yield next_item.result()
next_item = asyncio.create_task(self._queue.get())
......
......@@ -43,7 +43,8 @@ parser.add_argument('-p', '--persist', action='store_const',
const='refreshAndPersist', default='refreshOnly',
help='Use refresh and persist mode')
parser.add_argument('-c', '--cookie', action='store', help='Initial cookie')
parser.add_argument('-v', '--verbose', action='store_true', help="Set log level to 'debug'")
parser.add_argument('-v', '--verbose', action='store_true',
help="Set log level to 'debug'")
parser.add_argument('args', nargs='+', help='URLs for servers to contact')
......@@ -53,7 +54,8 @@ class ProviderEntry(urwid.LineBox):
self.provider = provider
self.state = urwid.Text(provider.state.value)
self.body = urwid.Pile([self.state] + [urwid.Text(csn) for csn in provider.cookie])
self.body = urwid.Pile([self.state] +
[urwid.Text(csn) for csn in provider.cookie])
super().__init__(self.body, title=provider.uri)
......@@ -86,9 +88,10 @@ class App(urwid.Frame):
config=options.config)
header = urwid.Text(options.base)
self.body = urwid.Filler(urwid.Pile([ProviderEntry(provider) for uri, provider
in self.environment.providers.items()]))
#cell_width=100, h_sep=1, v_sep=1, align='left')
self.body = urwid.Filler(urwid.Pile(
[ProviderEntry(provider)
for uri, provider in self.environment.providers.items()]))
# cell_width=100, h_sep=1, v_sep=1, align='left')
self.log = urwid.Text("Inited")
super().__init__(self.body, header=header, footer=self.log)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment