refactoring
This commit is contained in:
parent
b95c3f57c4
commit
d7e01295f4
@ -1,7 +1,7 @@
|
|||||||
#-*- coding:utf-8 -*-
|
#-*- coding:utf-8 -*-
|
||||||
import re
|
import re
|
||||||
import FastWQ
|
import FastWQ
|
||||||
from .base import MdxService, export, register, with_styles, parse_html
|
from ..base import MdxService, export, register, with_styles, parse_html
|
||||||
|
|
||||||
PATH = FastWQ.LDOCE6_PATH
|
PATH = FastWQ.LDOCE6_PATH
|
||||||
|
|
||||||
0
src/fastwq/service/dict/__init__.py
Normal file
0
src/fastwq/service/dict/__init__.py
Normal file
@ -2,7 +2,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from .base import WebService, export, register
|
from ..base import WebService, export, register
|
||||||
|
|
||||||
|
|
||||||
@register([u'百词斩', u'Baicizhan'])
|
@register([u'百词斩', u'Baicizhan'])
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#-*- coding:utf-8 -*-
|
#-*- coding:utf-8 -*-
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from .base import WebService, export, register, with_styles, parse_html
|
from ..base import WebService, export, register, with_styles, parse_html
|
||||||
|
|
||||||
baidu_download_mp3 = True
|
baidu_download_mp3 = True
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#-*- coding:utf-8 -*-
|
#-*- coding:utf-8 -*-
|
||||||
import re
|
import re
|
||||||
from .base import WebService, export, register, with_styles, parse_html
|
from ..base import WebService, export, register, with_styles, parse_html
|
||||||
|
|
||||||
bing_download_mp3 = True
|
bing_download_mp3 = True
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
#-*- coding:utf-8 -*-
|
#-*- coding:utf-8 -*-
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
bing_download_mp3 = True
|
bing_download_mp3 = True
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ import urllib2
|
|||||||
|
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
# Anki buit-in BeautifulSoup is bs3 not bs4
|
# Anki buit-in BeautifulSoup is bs3 not bs4
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ import urllib2
|
|||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
|
|
||||||
from .base import WebService, export, with_styles, register
|
from ..base import WebService, export, with_styles, register
|
||||||
|
|
||||||
# Anki buit-in BeautifulSoup is bs3 not bs4
|
# Anki buit-in BeautifulSoup is bs3 not bs4
|
||||||
|
|
||||||
@ -6,8 +6,8 @@ import json
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from aqt.utils import showInfo, showText
|
from aqt.utils import showInfo, showText
|
||||||
|
|
||||||
from .base import WebService, export, with_styles, register
|
from ..base import WebService, export, with_styles, register
|
||||||
from ..utils import ignore_exception
|
from ...utils import ignore_exception
|
||||||
|
|
||||||
iciba_download_mp3 = True
|
iciba_download_mp3 = True
|
||||||
|
|
||||||
@ -8,9 +8,9 @@ Created: 12/20/2017
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from warnings import filterwarnings
|
from warnings import filterwarnings
|
||||||
from ..libs.bs4 import BeautifulSoup, Tag
|
from ...libs.bs4 import BeautifulSoup, Tag
|
||||||
|
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
filterwarnings('ignore')
|
filterwarnings('ignore')
|
||||||
import sys
|
import sys
|
||||||
@ -4,7 +4,7 @@ import re
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from aqt.utils import showInfo, showText
|
from aqt.utils import showInfo, showText
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
|
|
||||||
@register(u'海词迷你词典')
|
@register(u'海词迷你词典')
|
||||||
@ -3,7 +3,7 @@ import urllib2
|
|||||||
from urllib2 import quote
|
from urllib2 import quote
|
||||||
import json
|
import json
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
|
|
||||||
@register("Oxford")
|
@register("Oxford")
|
||||||
@ -1,7 +1,7 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
#from warnings import filterwarnings
|
#from warnings import filterwarnings
|
||||||
from ..libs.bs4 import Tag
|
from ...libs.bs4 import Tag
|
||||||
from .base import WebService, export, register, with_styles, parse_html
|
from ..base import WebService, export, register, with_styles, parse_html
|
||||||
|
|
||||||
#filterwarnings('ignore')
|
#filterwarnings('ignore')
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ import urlparse
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from aqt.utils import showInfo, showText
|
from aqt.utils import showInfo, showText
|
||||||
from .base import QueryResult, WebService, export, register, with_styles
|
from ..base import QueryResult, WebService, export, register, with_styles
|
||||||
|
|
||||||
|
|
||||||
@register('MDX_SERVER')
|
@register('MDX_SERVER')
|
||||||
@ -2,7 +2,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from aqt.utils import showInfo, showText
|
from aqt.utils import showInfo, showText
|
||||||
from .base import LocalService, export, register, with_styles
|
from ..base import LocalService, export, register, with_styles
|
||||||
|
|
||||||
path = u'D:\\dicts\\LDOCE\\d.txt'
|
path = u'D:\\dicts\\LDOCE\\d.txt'
|
||||||
|
|
||||||
@ -4,7 +4,7 @@ import urllib2
|
|||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
js = '''
|
js = '''
|
||||||
var initVoice = function () {
|
var initVoice = function () {
|
||||||
@ -4,7 +4,7 @@ import urllib2
|
|||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
|
|
||||||
@register([u'有道词典-法语', u'Youdao-French'])
|
@register([u'有道词典-法语', u'Youdao-French'])
|
||||||
@ -4,7 +4,7 @@ import urllib2
|
|||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
|
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showInfo
|
||||||
from .base import WebService, export, register, with_styles
|
from ..base import WebService, export, register, with_styles
|
||||||
|
|
||||||
|
|
||||||
@register([u'有道词典-韩语', u'Youdao-Korean'])
|
@register([u'有道词典-韩语', u'Youdao-Korean'])
|
||||||
@ -76,17 +76,20 @@ class ServiceManager(object):
|
|||||||
get service from service packages, available type is
|
get service from service packages, available type is
|
||||||
WebService, LocalService
|
WebService, LocalService
|
||||||
"""
|
"""
|
||||||
|
service_path = u'dict'
|
||||||
web_services, local_custom_services = list(), list()
|
web_services, local_custom_services = list(), list()
|
||||||
mypath = os.path.dirname(os.path.realpath(__file__))
|
mypath = os.path.dirname(os.path.realpath(__file__)) + os.path.sep + service_path
|
||||||
files = [f for f in os.listdir(mypath)
|
files = [f for f in os.listdir(mypath)
|
||||||
if f not in ('__init__.py', 'base.py', 'manager.py', 'pool.py') and not f.endswith('.pyc') and not os.path.isdir(mypath+os.sep+f)]
|
if f not in ('__init__.py') and not f.endswith('.pyc') and not os.path.isdir(mypath+os.sep+f)]
|
||||||
base_class = (WebService, LocalService,
|
base_class = (WebService, LocalService,
|
||||||
MdxService, StardictService)
|
MdxService, StardictService)
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
#try:
|
#try:
|
||||||
module = importlib.import_module(
|
module = importlib.import_module(
|
||||||
'.%s' % os.path.splitext(f)[0], __package__)
|
u'.%s.%s' % (service_path, os.path.splitext(f)[0]),
|
||||||
|
__package__
|
||||||
|
)
|
||||||
for name, cls in inspect.getmembers(module, predicate=inspect.isclass):
|
for name, cls in inspect.getmembers(module, predicate=inspect.isclass):
|
||||||
if cls in base_class:
|
if cls in base_class:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user