Bug fixes
This commit is contained in:
parent
8ea7a27d33
commit
fd3dbf73c1
@ -77,16 +77,14 @@ class DictManageDialog(Dialog):
|
||||
# dict service list
|
||||
confs = config.dicts
|
||||
dicts = list()
|
||||
for clazz in service_manager.web_services:
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
dicts.append({
|
||||
'title': service.title,
|
||||
'unique': service.unique,
|
||||
'path': clazz.__path__,
|
||||
'enabled': confs.get(service.unique, dict()).get('enabled', True)
|
||||
})
|
||||
service_pool.put(service)
|
||||
services = service_manager.local_custom_services + service_manager.web_services
|
||||
for clazz in services:
|
||||
dicts.append({
|
||||
'title': clazz.__title__,
|
||||
'unique': clazz.__unique__,
|
||||
'path': clazz.__path__,
|
||||
'enabled': confs.get(clazz.__unique__, dict()).get('enabled', True)
|
||||
})
|
||||
# add dict
|
||||
for i, d in enumerate(dicts):
|
||||
self.add_dict_layout(i, **d)
|
||||
|
||||
@ -80,13 +80,14 @@ class OptionsDialog(Dialog):
|
||||
'web': [] #网络词典
|
||||
}
|
||||
for clazz in service_manager.local_services:
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
self.dict_services['local'].append({
|
||||
'title': service.title,
|
||||
'unique': service.unique
|
||||
})
|
||||
service_pool.put(service)
|
||||
if dicts.get(clazz.__unique__, dict()).get('enabled', True):
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
self.dict_services['local'].append({
|
||||
'title': service.title,
|
||||
'unique': service.unique
|
||||
})
|
||||
service_pool.put(service)
|
||||
for clazz in service_manager.web_services:
|
||||
if dicts.get(clazz.__unique__, dict()).get('enabled', True):
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
|
||||
@ -87,7 +87,10 @@ class ServiceManager(object):
|
||||
for name, clazz in inspect.getmembers(module, predicate=inspect.isclass):
|
||||
if clazz in base_class:
|
||||
continue
|
||||
if not(issubclass(clazz, WebService) or issubclass(clazz, LocalService)):
|
||||
continue
|
||||
service = service_wrap(clazz, *args)
|
||||
service.__title__ = getattr(clazz, '__register_label__', name)
|
||||
service.__unique__ = name
|
||||
service.__path__ = os.path.join(mypath, f)
|
||||
if issubclass(clazz, WebService):
|
||||
|
||||
@ -2,13 +2,17 @@
|
||||
# While not critical (and in no way guaranteed!), it would be nice to keep this
|
||||
# code compatible with Python 2.3.
|
||||
import sys
|
||||
try:
|
||||
from importlib import reload
|
||||
except:
|
||||
pass
|
||||
|
||||
def _resolve_name(name, package, level):
|
||||
"""Return the absolute name of the module to be imported."""
|
||||
if not hasattr(package, 'rindex'):
|
||||
raise ValueError("'package' not set to a string")
|
||||
dot = len(package)
|
||||
for x in xrange(level, 1, -1):
|
||||
for x in range(level, 1, -1):
|
||||
try:
|
||||
dot = package.rindex('.', 0, dot)
|
||||
except ValueError:
|
||||
@ -19,11 +23,9 @@ def _resolve_name(name, package, level):
|
||||
|
||||
def import_module(name, package=None):
|
||||
"""Import a module.
|
||||
|
||||
The 'package' argument is required when performing a relative import. It
|
||||
specifies the package to use as the anchor point from which to resolve the
|
||||
relative import to an absolute import.
|
||||
|
||||
"""
|
||||
if name.startswith('.'):
|
||||
if not package:
|
||||
@ -35,5 +37,9 @@ def import_module(name, package=None):
|
||||
level += 1
|
||||
name = _resolve_name(name[level:], package, level)
|
||||
|
||||
__import__(name)
|
||||
return sys.modules[name]
|
||||
if name in sys.modules:
|
||||
reload(sys.modules[name])
|
||||
else:
|
||||
__import__(name)
|
||||
return sys.modules[name]
|
||||
|
||||
@ -77,16 +77,14 @@ class DictManageDialog(Dialog):
|
||||
# dict service list
|
||||
confs = config.dicts
|
||||
dicts = list()
|
||||
for clazz in service_manager.web_services:
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
dicts.append({
|
||||
'title': service.title,
|
||||
'unique': service.unique,
|
||||
'path': clazz.__path__,
|
||||
'enabled': confs.get(service.unique, dict()).get('enabled', True)
|
||||
})
|
||||
service_pool.put(service)
|
||||
services = service_manager.local_custom_services + service_manager.web_services
|
||||
for clazz in services:
|
||||
dicts.append({
|
||||
'title': clazz.__title__,
|
||||
'unique': clazz.__unique__,
|
||||
'path': clazz.__path__,
|
||||
'enabled': confs.get(clazz.__unique__, dict()).get('enabled', True)
|
||||
})
|
||||
# add dict
|
||||
for i, d in enumerate(dicts):
|
||||
self.add_dict_layout(i, **d)
|
||||
|
||||
@ -80,13 +80,14 @@ class OptionsDialog(Dialog):
|
||||
'web': [] #网络词典
|
||||
}
|
||||
for clazz in service_manager.local_services:
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
self.dict_services['local'].append({
|
||||
'title': service.title,
|
||||
'unique': service.unique
|
||||
})
|
||||
service_pool.put(service)
|
||||
if dicts.get(clazz.__unique__, dict()).get('enabled', True):
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
if service and service.support:
|
||||
self.dict_services['local'].append({
|
||||
'title': service.title,
|
||||
'unique': service.unique
|
||||
})
|
||||
service_pool.put(service)
|
||||
for clazz in service_manager.web_services:
|
||||
if dicts.get(clazz.__unique__, dict()).get('enabled', True):
|
||||
service = service_pool.get(clazz.__unique__)
|
||||
|
||||
@ -82,7 +82,10 @@ class ServiceManager(object):
|
||||
for name, clazz in inspect.getmembers(module, predicate=inspect.isclass):
|
||||
if clazz in base_class:
|
||||
continue
|
||||
if not(issubclass(clazz, WebService) or issubclass(clazz, LocalService)):
|
||||
continue
|
||||
service = service_wrap(clazz, *args)
|
||||
service.__title__ = getattr(clazz, '__register_label__', name)
|
||||
service.__unique__ = name
|
||||
service.__path__ = os.path.join(mypath, f)
|
||||
if issubclass(clazz, WebService):
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
# While not critical (and in no way guaranteed!), it would be nice to keep this
|
||||
# code compatible with Python 2.3.
|
||||
import sys
|
||||
try:
|
||||
from importlib import reload
|
||||
except:
|
||||
pass
|
||||
|
||||
def _resolve_name(name, package, level):
|
||||
"""Return the absolute name of the module to be imported."""
|
||||
@ -33,6 +37,9 @@ def import_module(name, package=None):
|
||||
level += 1
|
||||
name = _resolve_name(name[level:], package, level)
|
||||
|
||||
__import__(name)
|
||||
if name in sys.modules:
|
||||
reload(sys.modules[name])
|
||||
else:
|
||||
__import__(name)
|
||||
return sys.modules[name]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user