本文整理汇总了Python中record.Record.get_describe方法的典型用法代码示例。如果您正苦于以下问题:Python Record.get_describe方法的具体用法?Python Record.get_describe怎么用?Python Record.get_describe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类record.Record
的用法示例。
在下文中一共展示了Record.get_describe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveIncrementalPapers
# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_describe [as 别名]
def saveIncrementalPapers(self, fileNumber, lines):
file_name = self.get_file_name("eecs/papers/arxiv/arxiv" + fileNumber, self.school)
file_lines = self.countFileLineNum(file_name)
f = self.open_db(file_name + ".tmp")
self.count = 0
for line in lines:
self.count += 1
record = Record(line)
rawid = self.parse_arxiv_url(record.get_url().strip())[0].replace('.', '-')
self.write_db(f, 'arxiv-' + rawid, record.get_title().strip(), record.get_url().strip(),
record.get_describe().strip())
self.close_db(f)
if file_lines != self.count and self.count > 0:
self.do_upgrade_db(file_name)
print "before lines: " + str(file_lines) + " after update: " + str(self.count) + " \n\n"
else:
self.cancel_upgrade(file_name)
print "no need upgrade\n"
示例2: excute
# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_describe [as 别名]
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('#')]
rTitle = rTitle[rTitle.find('->') + 2 : ]
rID = form_dict['rID'].encode('utf8')
divID = form_dict['divID'].encode('utf8')
self.divID = divID
objID = form_dict['objID'].encode('utf8')
libraryRecord, alias = self.getAlias(rID.strip(), fileName, nocache)
html = ''
quickAccessHistoryFile = ''
if self.existHistoryFile(fileName.strip()):
historyFile = self.getHistoryFileName(fileName)
quickAccessHistoryFile = self.utils.getQuickAccessHistoryFileName()
print historyFile
f = open(historyFile, 'r+')
rDict = {}
all_lines = f.readlines()
if Config.history_enable_quick_access:
quickAccess = self.utils.queryQuickAccess(rID)
if quickAccess != None:
#print 'quickAccess:' + quickAccess.line
all_lines.append(quickAccess.line)
#print all_lines
for line in all_lines:
r = Record(line)
if r.valid(line) == False:
#print r.line
continue
if r.get_url().strip() != '':
#key = r.get_url().strip()
key = r.get_id().strip() + '-' +r.get_title().strip()
if key.find(' - ') != -1:
key = key[0 : key.find(' - ')].strip()
if rDict.has_key(key):
cacheRecord = rDict[key]
desc = self.getClickCount(cacheRecord)
cacheLine = cacheRecord.line
#desc = str(int(newLine[newLine.rfind(':')+1 :].replace('\n', '').strip()))
if line.find('clickcount:') != -1:
desc2 = str(int(self.getClickCount(r)))
#if int(desc2) > int(desc):
# desc = desc2
desc = str(int(desc2) + int(desc))
else:
desc = str(int(desc) + 1)
preStr = cacheLine[0: cacheLine.rfind('clickcount:')].strip()
preStr2 = r.line[0: r.line.rfind('clickcount:')].strip()
newRecord = Record(preStr2)
if newRecord.get_describe().strip() != '':
preStr = preStr2
#print newLine
#print desc
rDict[key] = Record(preStr + ' clickcount:' + desc + '\n')
else:
if line.find('clickcount:') != -1:
rDict[key] = Record(line)
else:
preStr = line[0: line.rfind('clickcount:')].strip()
rDict[key] = Record(preStr + ' clickcount:1' + '\n' )
rList = []
#print rDict
if len(rDict) != len(all_lines):
f.truncate()
f.close()
else:
f.close()
f = None
#.........这里部分代码省略.........
示例3: syncHistory
# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_describe [as 别名]
def syncHistory(self, form):
print '--syncHistory--'
oldLine = form['oldLine']
newLine = form['newLine']
originFileName = form['fileName']
category = form['resourceType']
utils = self.utils
if oldLine != newLine:
oldRecord = Record(oldLine)
newRecord = Record(newLine)
oldID = oldRecord.get_id().strip()
newID = newRecord.get_id().strip()
oldDesc = oldRecord.get_describe()
newDesc = newRecord.get_describe()
historyFileName = self.getHistoryFileName(originFileName)
print historyFileName
all_lines = []
historyRecord = None
count = 0
if oldID != newID and os.path.exists(historyFileName):
print 'id chanage'
f = open(historyFileName, 'rU')
for line in f.readlines():
count += 1
historyRecord = Record(line)
if historyRecord.get_id().strip() == oldID:
print 'match line:' + line
newline = newID + ' | ' + historyRecord.get_title().strip() + ' | ' + historyRecord.get_url().strip() + ' | ' + historyRecord.get_describe().strip() + '\n'
print 'newline:' + newline
all_lines.append(newline)
else:
all_lines.append(line)
f.close()
print 'hislines before:' + str(count) + ' after:' + str(len(all_lines))
utils.write2File(historyFileName, all_lines)
elif oldDesc != newDesc:
print 'desc chanage'
oldDescDict = utils.toDescDict(oldDesc, originFileName)
newDescDict = utils.toDescDict(newDesc, originFileName)
print oldDescDict
print newDescDict
notMatchDict = {}
for k, v in newDescDict.items():
if oldDescDict.has_key(k) == False:
print 'add new tag:' + k
elif oldDescDict[k] != newDescDict[k]:
print 'desc not match:' + k
#print oldDescDict[k]
#print newDescDict[k]
notMatchDict = self.whatNotMacth(oldDescDict[k], newDescDict[k])
for k, v in oldDescDict.items():
if newDescDict.has_key(k) == False:
print 'delete tag:' + k
if os.path.exists(historyFileName):
print 'foud history file:' + historyFileName
f = open(historyFileName, 'rU')
for line in f.readlines():
#print line[0 : line.find('|')].strip()
#print newID
count += 1
historyRecord = Record(line)
if newID != historyRecord.get_id().strip():
all_lines.append(line)
else:
found = False
for k, v in notMatchDict.items():
#print historyRecord.get_title()
#print k
if historyRecord.get_title().find(k) != -1:
print 'matched line:'
print line
found = True
desc = utils.valueText2Desc(v, prefix=False).strip()
print 'new desc:'
print desc
if category != None and category != '' and desc.find('category:') == -1:
desc += ' category:' + category
if line.find('clickcount:') != -1:
clickcount = utils.reflection_call('record', 'WrapRecord', 'get_tag_content', line, {'tag' : 'clickcount'}).strip()
#.........这里部分代码省略.........