[mod] pep8 on hooks.py

This commit is contained in:
Laurent Peuch 2017-08-20 21:19:04 +02:00
parent 40ea2f9477
commit 83971afb9c

View file

@ -50,8 +50,10 @@ def hook_add(app, file):
path, filename = os.path.split(file)
priority, action = _extract_filename_parts(filename)
try: os.listdir(CUSTOM_HOOK_FOLDER + action)
except OSError: os.makedirs(CUSTOM_HOOK_FOLDER + action)
try:
os.listdir(CUSTOM_HOOK_FOLDER + action)
except OSError:
os.makedirs(CUSTOM_HOOK_FOLDER + action)
finalpath = CUSTOM_HOOK_FOLDER + action + '/' + priority + '-' + app
os.system('cp %s %s' % (file, finalpath))
@ -73,7 +75,8 @@ def hook_remove(app):
for script in os.listdir(CUSTOM_HOOK_FOLDER + action):
if script.endswith(app):
os.remove(CUSTOM_HOOK_FOLDER + action + '/' + script)
except OSError: pass
except OSError:
pass
def hook_info(action, name):
@ -165,6 +168,7 @@ def hook_list(action, list_by='name', show_info=False):
else:
if list_by == 'name':
result = set()
def _append_hook(d, priority, name, path):
# Add only the name
d.add(name)
@ -346,7 +350,7 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
# prepend environment variables
cmd = '{0} {1}'.format(
' '.join(['{0}={1}'.format(k, shell_quote(v)) \
' '.join(['{0}={1}'.format(k, shell_quote(v))
for k, v in env.items()]), cmd)
command.append(cmd.format(script=cmd_script, args=cmd_args))
@ -392,6 +396,7 @@ def _extract_filename_parts(filename):
_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.UNICODE).search
def shell_quote(s):
"""Return a shell-escaped version of the string *s*."""
s = str(s)