PEP 8 + minor changes

This commit is contained in:
Jonathan Lestrelin 2017-08-20 14:49:50 +02:00
parent c3593ddd19
commit 0dc048d5c7
2 changed files with 15 additions and 10 deletions

4
.coafile Normal file
View File

@ -0,0 +1,4 @@
[python]
bears = PyUnusedCodeBear,PySafetyBear,PyFlakesBear,PEP8Bear,BanditBear,PyCommentedCodeBear,VultureBear,InvalidLinkBear,PyImportSortBear
files = *.py
use_spaces = true

View File

@ -25,16 +25,16 @@
# Copyright (C) 2012 Red Hat, Inc. # Copyright (C) 2012 Red Hat, Inc.
# Author: Luke Macken <lmacken@redhat.com> # Author: Luke Macken <lmacken@redhat.com>
import subprocess from os import getenv
import re from os import walk
from os import walk, getenv
from os.path import expanduser from os.path import expanduser
import re
from gi.repository import GLib import subprocess
import dbus import dbus
import dbus.glib import dbus.glib
import dbus.service import dbus.service
from gi.repository import GLib
# Convenience shorthand for declaring dbus interface methods. # Convenience shorthand for declaring dbus interface methods.
# s.b.n. -> search_bus_name # s.b.n. -> search_bus_name
@ -58,7 +58,7 @@ class SearchPassService(dbus.service.Object):
bus_name = dbus.service.BusName(self.bus_name, bus=self.session_bus) bus_name = dbus.service.BusName(self.bus_name, bus=self.session_bus)
dbus.service.Object.__init__(self, bus_name, self._object_path) dbus.service.Object.__init__(self, bus_name, self._object_path)
self.password_store = getenv('PASSWORD_STORE_DIR') or \ self.password_store = getenv('PASSWORD_STORE_DIR') or \
expanduser('~/.password-store') expanduser('~/.password-store')
@dbus.service.method(in_signature='sasu', **sbn) @dbus.service.method(in_signature='sasu', **sbn)
def ActivateResult(self, id, terms, timestamp): def ActivateResult(self, id, terms, timestamp):
@ -89,7 +89,7 @@ class SearchPassService(dbus.service.Object):
def get_password_names(self, name): def get_password_names(self, name):
names = [] names = []
for root, dirs, files in walk(self.password_store): for root, dirs, files in walk(self.password_store):
dir_path = root[len(self.password_store) + 1 :] dir_path = root[len(self.password_store) + 1:]
for file in files: for file in files:
file_path = '{0}/{1}'.format(dir_path, file) file_path = '{0}/{1}'.format(dir_path, file)
if re.match(r'.*{0}.*\.gpg$'.format(name), if re.match(r'.*{0}.*\.gpg$'.format(name),
@ -113,10 +113,11 @@ class SearchPassService(dbus.service.Object):
except dbus.DBusException: except dbus.DBusException:
subprocess.run(['pass', 'show', '-c', name]) subprocess.run(['pass', 'show', '-c', name])
def main(): def main():
service = SearchPassService() SearchPassService()
loop = GLib.MainLoop() GLib.MainLoop().run()
loop.run()
if __name__ == '__main__': if __name__ == '__main__':
main() main()