本文整理汇总了Python中utils.Utils.reflection_call方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.reflection_call方法的具体用法?Python Utils.reflection_call怎么用?Python Utils.reflection_call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Utils
的用法示例。
在下文中一共展示了Utils.reflection_call方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
class BaseWebservice:
webservice_dict = {'twitter' : 'twitter_webservice',\
'instructors' : 'instructors_webservice',\
'keyword' : 'keyword_webservice'}
def __init__(self):
self.name = 'base webservice'
self.utils = Utils()
def getWebData(self, record, keyword, keywordResourceType):
return []
def tag2webservice(self, resourceType):
if self.webservice_dict.has_key(resourceType):
return self.webservice_dict[resourceType]
else:
return ''
def callWebservice(self, resourceType, record, keyword, keywordResourceType):
print 'callWebservice resourceType:' + resourceType
webservice = self.tag2webservice(resourceType)
if webservice != '':
className = resourceType[0 : 1].upper() + resourceType[1 :] + 'Webservice'
print 'webservice:' + webservice + ' className:' + className
result = self.utils.reflection_call('webservice.' + webservice, className, 'getWebData', record.line, {'record' : record, 'keyword' : keyword, 'keywordResourceType' : keywordResourceType})
print result
return result
else:
return ''
示例2: Bookmark
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
class Bookmark(BaseExtension):
rounter = {'' : '',\
'' : ''}
raw_data = ''
jobj_list = []
tag = Tag()
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
self.loadBookmark()
self.form_dict = None
def existChild(self, pid):
return self.raw_data.lower().find('"parentId":"' + pid + '"') != -1
def loadBookmark(self):
if os.path.exists('extensions/bookmark/data/chrome_bookmarks.json'):
f = open('extensions/bookmark/data/chrome_bookmarks.json', 'rU')
self.raw_data = f.read()
self.jobj_list = json.loads(self.raw_data)
f.close()
def updateBookmark(self):
if os.path.exists(Config.bookmark_file_path):
subprocess.check_output("mv " + Config.bookmark_file_path + " extensions/bookmark/data/chrome_bookmarks.json", shell=True)
self.loadBookmark()
def getAlias(self, rID, rTitle, file, nocache):
alias = ''
use_cache = not nocache
record = None
if rID.startswith('loop-h-'):
file = file[0 : file.find('db/')] + 'extensions/history/data/' + file[file.rfind('/') + 1 :] + '-history'
print file
record = self.utils.getRecord(rTitle, path=file, matchType=2, use_cache=use_cache, accurate=False)
#print record.line
elif rID.startswith('loop-hc-'):
file = file[0 : file.find('db/')] + 'extensions/content/data/' + file[file.rfind('/') + 1 :] + '-history-content'
print file
record = self.utils.getRecord(rTitle, path=file, matchType=2, use_cache=use_cache)
elif rTitle.startswith('library/'):
record = self.utils.crossref2Record(rTitle.replace('==', '->'))
else:
record = self.utils.getRecord(rID.strip(), path=file, log=True, use_cache=use_cache)
if record != None and record.get_id().strip() != '':
ret = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'alias'})
if ret != None:
alias = ret.strip()
print 'alias:' + alias
if alias.find(',') != -1:
return alias.split(',')
elif alias != '':
return [alias]
else:
return []
def needBR(self):
if self.form_dict['column'] != '1' and self.form_dict.has_key('extension_count') and int(self.form_dict['extension_count']) > 12:
return True
if self.form_dict['column'] == '3' and int(self.form_dict['extension_count']) > 10:
return True
return False
def excute(self, form_dict):
self.form_dict = form_dict
divID = form_dict['divID'].encode('utf8')
nocache = True
if form_dict.has_key('nocache'):
nocache = form_dict['nocache'].encode('utf8')
rID = form_dict['rID'].encode('utf8')
fileName = form_dict['fileName'].encode('utf8')
originFileName = form_dict['originFileName']
rTitle = form_dict['rTitle'].encode('utf8').replace('%20', ' ')
alias = self.getAlias(rID.strip(), rTitle, originFileName, nocache)
if rTitle.startswith('library/'):
rTitle = rTitle.replace('==', '->')
if rTitle.find('->') != -1:
rTitle = rTitle[rTitle.find('->') + 2 :]
else:
rTitle = rTitle[rTitle.find('#') + 1 :]
print divID
'''
if divID.find('-cloud-') != -1:
html = ''
cloud_bookmark = self.genWebsiteHtml(rTitle, form_dict['originFileName'])
if cloud_bookmark.find('<li>') != -1:
html += 'cloud bookmark(' + rTitle + '):<br>' + cloud_bookmark
else:
html = ''
return html
#.........这里部分代码省略.........
示例3: History
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
class History(BaseExtension):
raw_data = ''
jobj_list = []
tag = Tag()
"""docstring for History"""
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
#self.loadHistory()
self.form_dict = None
self.divID = ''
def loadHistory(self):
self.updateHistory()
if os.path.exists('extensions/history/data/chrome_history.json'):
f = open('extensions/history/data/chrome_history.json', 'rU')
self.raw_data = f.read()
self.jobj_list = json.loads(self.raw_data)
f.close()
def updateHistory(self):
if os.path.exists(Config.history_file_path):
subprocess.check_output("mv " + Config.history_file_path + " extensions/history/data/chrome_history.json", shell=True)
self.loadHistory()
def getAlias(self, rID, file, nocache):
alias = ''
use_cache = nocache == False
record = self.utils.getRecord(rID.strip(), path=file, log=True, use_cache=use_cache)
if record != None and record.get_id().strip() != '':
ret = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'alias'})
if ret != None:
alias = ret.strip()
#print 'alias:' + alias
if alias.find(',') != -1:
return record, alias.split(',')
elif alias != '':
return record, [alias]
else:
return record, []
def needBR(self):
return self.form_dict['column'] != '1' and self.form_dict.has_key('extension_count') and int(self.form_dict['extension_count']) > 12
def getDeleteButton(self, divID, historyFile, url):
deleteScript = "$.post('/exec', {command : 'deleteRow', fileName : '" + historyFile + "', key : '" + url + "'}, function(data){" + "var target=document.getElementById('" + divID.replace('-history', '') + '-nav-history' + "');hidendiv_2('" + divID + "');navTopic(target,'" + divID.replace('-history', '') + "','" + divID.replace('-history', '') + '-nav-' + "',9);" + "});"
deleteButton = ' <a target="_blank" href="javascript:void(0);" onclick="' + deleteScript + '" style="color:#999966; font-size: 10pt;"><image src="' + Config.website_icons['delete'] + '" width="14" height="12"></image></a>'
return deleteButton
def getClickCount(self, record):
if record.line.find('clickcount:') != -1:
return self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'clickcount'}).strip()
else:
return '1'
def genQuickAccessSyncButton(self, rid, quickAccessHistoryFile, divID, objID):
script = "$.post('/syncQuickAccess', {rid : '" + rid + "', fileName : '" + quickAccessHistoryFile + "'},function(data) { "
script += "refreshTab2('" + divID + "', '" + objID + "', 'history');"
script += "});"
html = '<a target="_blank" href="javascript:void(0);" onclick="' + script + '">' + self.utils.getIconHtml('', 'sync') + '</a>'
return html
def getRefreshID(self, divID, text):
if text == Config.history_quick_access_name:
return 'td-' + divID.replace('history', 'a-qa-')
else:
return 'td-' + divID.replace('history', 'a-')
def excute(self, form_dict):
self.form_dict = form_dict
if form_dict.has_key('command'):
return self.excuteCommand(form_dict);
else:
#print '---excute---'
print form_dict
nocache = True
if form_dict.has_key('nocache'):
nocache = form_dict['nocache'].encode('utf8')
rTitle = form_dict['rTitle'].encode('utf8').replace('%20', ' ').strip()
fileName = form_dict['fileName'].strip()
if rTitle.startswith('library'):
rTitle = rTitle.replace('==', '->')
fileName = rTitle[0 : rTitle.find('#')]
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
class ScheduleManager:
def __init__(self):
self.utils = Utils()
self.schedulingHistory = {}
self.jobResultDict = {}
def runJob(self, classPath, param):
#obj = r.get_class('extensions.code.code.Code')
result = ''
obj = param['record'].get_class(classPath)
if obj != None:
result = obj.excute(param)
return result
def schedulingJob(self, descList, args, parentJob, isRecursion=False):
result = ''
if len(descList) > 0:
matchedText = descList[0][0]
desc = descList[0][1]
crossref = descList[0][3]
parentRecord = descList[0][5]
path = crossref
if path.find('#') != -1:
path = path[0 : path.find('#')]
line = ' | ' + matchedText + ' | | ' + desc
record = Record(line)
if path != '':
parentRecord.set_path(path)
if isRecursion == False:
print 'scheduling:' + matchedText
if desc.find('class:') != -1:
classes = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', line, {'tag' : 'class:'})
for acls in classes.split(','):
acls = acls.strip()
text = acls
value = acls
if self.utils.getValueOrTextCheck(acls):
text = self.utils.getValueOrText(acls, returnType='text')
value = self.utils.getValueOrText(acls, returnType='value')
parentJobResult = 0
if self.jobResultDict.has_key(parentJob):
parentJobResult = self.jobResultDict[parentJob]['jobResult']
param = {'record' : record, 'parentRecord' : parentRecord, 'from' : matchedText, 'class' : value[value.rfind('.') + 1 :], 'args' : args, 'parentJobResult' : parentJobResult, 'parentJob' : parentJob}
#value = value[0 : value.rfind('.')] + '.Main'
resultDict = self.runJob(value, param)
jobTitle = resultDict['jobTitle']
if resultDict.has_key('jobEnd'):
if self.jobResultDict.has_key(matchedText):
self.jobResultDict[matchedText]['jobResult'] = self.jobResultDict[matchedText]['jobResult'] + resultDict['jobResult']
resultDict = self.jobResultDict[matchedText]
else:
self.jobResultDict[matchedText] = resultDict
else:
self.jobResultDict[matchedText] = resultDict
result += resultDict['result']
result += '<br>'
result += 'jobResult:' + str(resultDict['jobResult'])
result += '<br>'
else:
return ''
if desc.find('searchin:') != -1:
searchin = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', line, {'tag' : 'searchin:'})
for si in searchin.split(','):
si = si.strip()
if si.startswith('>'):
#if self.schedulingHistory.has_key(si.lower()):
# continue
#else:
# self.schedulingHistory[si.lower()] = ''
print 'scheduling:' + si
descList = self.utils.processCommand(si, '', style='', nojs=False, noFilterBox=True, unfoldSearchin=False, returnMatchedDesc=True)
result += self.schedulingJob(descList, args, matchedText, isRecursion=True)
return result
def scheduling(self, command):
print 'scheduling'
self.schedulingHistory = {}
#.........这里部分代码省略.........
示例5: Filefinder
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
#.........这里部分代码省略.........
count = 1
for alias in aliasList:
count += 1
html += self.utils.toSmartLink(alias.strip(), engin=netdisk, showText=str('<font size="2">' + alias + '</font>'), rid=self.form_dict['rID'], library=self.form_dict['originFileName'], module='filefinder') + ' '
#html += ' '
html += '</div>'
if rID.startswith('loop') == False:
fileDivID = divID + '-dbfile-' + str(random.randint(0, 1000))
fileLinkID = divID + '-dbfile-a-' + str(random.randint(0, 1000))
html += '<div id="' + fileDivID + '" class="ref">'
if len(aliasList) == 0:
script = "var postArgs = {name : 'filefinder', rID : '" + rID + "', rTitle : '" + rTitle +"', check: 'false', fileName : '" + fileName + "', divID : '" + fileDivID + "', originFileName : '" + form_dict['originFileName'] + "'};";
script += "$('#' + '" + fileDivID +"').load('/extensions', postArgs, function(data) { });$('#' + '" + fileDivID +"').html('Loading...');"
html += '<a id="' + fileLinkID + '" href="javascript:void(0);" onclick="' + script + '" style="font-size:12pt;">Search Local DB</a><br> '
else:
html += '<br>Search Local DB<br>'
k_list = [rTitle.replace('%20', ' ')] + aliasList
for keyword in k_list:
script = "var postArgs = {name : 'filefinder', rID : '" + rID + "', rTitle : '" + keyword +"', check: 'false', fileName : '" + fileName + "', divID : '" + fileDivID + "', originFileName : '" + form_dict['originFileName'] + "'};";
script += "$('#' + '" + fileDivID +"').load('/extensions', postArgs, function(data) { });$('#' + '" + fileDivID +"').html('Loading...');"
if len(keyword) > 30:
keyword = keyword[0 : 30] + '..'
html += '<font size="2"><a id="' + fileLinkID + '" href="javascript:void(0);" onclick="' + script + '">' + keyword +'</a></font> '
html += '</div>'
return html
def getAliasList(self, record):
aliasList = []
if record != None and record.get_id().strip() != '':
ret = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'alias'})
if ret != None:
alias = ret.strip()
print 'alias:' + alias
if alias != '':
if alias.find(',') != -1:
aliasList = alias.split(',')
return aliasList
else:
aliasList = [alias.strip()]
return aliasList
def isDir(self, url):
if url.startswith('/User') and url[url.rfind('/') :].find('.') == -1:
return True
return False
def getMatchFiles(self, title, url='', paths=Config.filefinder_dirs):
output = ''
cmd = ''
if url != '' and self.isDir(url):
url = url.replace(' ', '\ ').replace('%20', '\ ')
paths = [url]
for path in paths:
if path != '':
if url != '' and self.isDir(url):
cmd = 'find ' + path + ' -iname "*"'
else:
cmd = 'find ' + path + ' -iname "*' + title.replace('"', '').replace('%20', ' ').replace(' ', '*') + '*"'
print 'cmd ' + cmd
try:
示例6: Edit
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
#.........这里部分代码省略.........
if rID.startswith('loop-h-') or rID.find('plugin') != -1:
editedData = ''
textContent = self.textFormatConvert(textContent)
textContent = textContent.replace(',\n', '+')
textContent = self.utils.removeDoubleSpace(textContent)
textContent = textContent.replace(', ', '+')
textContent = textContent.replace(',', '+')
textContent = textContent.replace('\n', '')
editedData = rTitle + '(' + textContent + ')'
print 'editedData--->' + editedData
#return
historyRecord = None
r = None
print rID
r, historyRecord = self.getRecordByHistory(rID, rTitle, fileName)
if rID.find('plugin') != -1 and historyRecord == None:
pid = rID.replace('custom-plugin-', '')
if pid.find('-pg') != -1:
pid = pid[0 : pid.find('-pg')]
r = self.utils.getRecord(pid, path=fileName, use_cache=False)
#print historyRecord.line
#return 'error'
if r != None:
editRID = r.get_id().strip()
resourceType = ''
if historyRecord != None and editedData.find('category(') == -1:
resourceType = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', historyRecord.line, {'tag' : 'category'})
if resourceType != None:
resourceType = resourceType.strip()
print 'editRID-->' + editRID
if rID.find(editRID) != -1:
newData = r.edit_desc_field2(self.utils, r, resourceType, rTitle, editedData, self.tag.get_tag_list(library), library=library)
if newData != '':
#print '--->' + newData
result = self.editRecord(editRID, self.utils.removeDoubleSpace(newData), originFileName, library=library, resourceType=resourceType, divID=divID)
return result
return 'error'
else:
textContent = self.utils.removeDoubleSpace(textContent.replace(',\n ', ', ').replace('\n', ' '))
print textContent
return self.editRecord(rID, textContent, originFileName, library=library, divID=divID)
return 'error'
column = str(form_dict['column'])
print fileName
r = None
if rTitle.startswith('library/'):
示例7: Pathways
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
class Pathways(BaseExtension):
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
def excute(self, form_dict):
fileName = form_dict['fileName'].encode('utf8')
column = form_dict['column']
url = form_dict['url'].encode('utf8')
#if fileName.endswith('-library') and url.find(Config.ip_adress) != -1:
print url
#print form_dict
if form_dict.has_key('crossrefQuery') and form_dict['crossrefQuery'].strip() != '':
query = form_dict['crossrefQuery']
if query.startswith('db/') == False:
query = 'db/' + query
if query.find('/filter') != -1:
query = query.replace('/filter', '&filter')
if query.find('filter=') == -1:
query = query + '&filter=%s'
record = self.utils.getRecord(form_dict['rID'], path=fileName, use_cache=False)
queryText = form_dict['rTitle']
if record != None and record.line.find('alias:') != -1:
alias = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'alias'})
if alias != None:
queryText = queryText + '[or]' + alias.replace(', ', '[or]').strip()
if query.find('%s') != -1:
query = query.replace('%s', queryText)
print 'query-->' + query
fileName = query
else:
if url.find(Config.ip_adress) != -1:
fileName = url[url.find('db=') + 3 :]
fileName = 'db/' + fileName
fileName = fileName.replace('&key=', '')
if fileName.find('&column') != -1:
fileName = fileName[0 : fileName.find('&column')]
print fileName
if fileName.find('db/') != -1:
width = '530'
height = '600'
if column == '1':
width = '1400'
height = '600'
elif column == '2':
width = '700'
height = '600'
fileName = fileName[fileName.find('db/') + 3 :]
db = fileName[0 : fileName.rfind('/') + 1]
key = fileName[fileName.rfind('/') + 1 : ]
if key == '':
key = '?'
src = "http://" + Config.ip_adress + '/?db=' + db + '&key=' + key + '&nosearchbox=true&column=1'
print src
return '<iframe width="' + width + '" height="' + height + '" frameborder="0" src="' + src + '"></iframe>'
return 'nothing'
def check(self, form_dict):
#print form_dict
originFileName = form_dict['originFileName'].encode('utf8')
fileName = form_dict['fileName'].encode('utf8')
url = form_dict['url'].encode('utf8')
print fileName
return (form_dict.has_key('crossrefQuery') and form_dict['crossrefQuery'] != '') or (originFileName != fileName and fileName.endswith('-library') == False) or url.find(Config.ip_adress) != -1
示例8: Content
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import reflection_call [as 别名]
#.........这里部分代码省略.........
# print 'xwwwww' + r.line
# return True
#print rID
#print self.getExtensionDataFilePath(self.formatFileName(fileName))
p = self.utils.find_file_by_pattern_path(re.compile(rID, re.I), self.getExtensionDataFilePath(self.formatFileName(fileName)))
print p
if p != '':
return True
self.data_type = 'history-content'
p = self.utils.find_file_by_pattern_path(re.compile(rID, re.I), self.getExtensionDataFilePath(self.formatFileName(form_dict['fileName'].encode('utf8'))))
if p != '':
return True
else:
self.data_type = 'content'
if self.getContentRef(rID, fileName) != '':
return True
return False
#self.loadContent(rID, fileName, self.optional_content)
#self.loadContent(rID, self.getExtensionDataFilePath(self.formatFileName(fileName)), self.datafile_content)
#print self.record_content
#print self.optional_content
#print self.datafile_content
#return self.datafile_content.has_key(rID) or self.optional_content.has_key(rID)
def getContentRef(self, rID, fileName):
record = self.utils.getRecord(rID, path=fileName)
if record != None and record.line.strip() != '':
contentref = self.utils.reflection_call('record', 'WrapRecord', 'get_tag_content', record.line, {'tag' : 'contentref'})
if contentref != None:
return contentref.strip()
return ''
def write(self, html):
f = open('temp/test.html', 'w')
for line in html:
f.write(line)
#print 'write ' + html + ' to file'
f.close
def genContentHtml(self, key, content_divID, defaultLinks, library):
return self.genMetadataHtml(key, content_divID, defaultLinks, library)
def genMetadataHtml(self, key, content_divID, defaultLinks, library):
html = '<div class="ref"><ol>'
if self.form_dict['column'] == '3' and int(self.form_dict['extension_count']) > 10:
html = '<div class="ref"><br><ol>'
count = 0
#print 'key:' + key
#print self.datafile_content
if self.datafile_content.has_key(key):
self.record_content = self.datafile_content
elif self.optional_content.has_key(key):
self.record_content = self.optional_content
if self.record_content.has_key(key):
#print key
for r in self.record_content[key]: