当前位置: 首页>>代码示例>>Python>>正文


Python Record.get_title方法代码示例

本文整理汇总了Python中record.Record.get_title方法的典型用法代码示例。如果您正苦于以下问题:Python Record.get_title方法的具体用法?Python Record.get_title怎么用?Python Record.get_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在record.Record的用法示例。


在下文中一共展示了Record.get_title方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getRecord

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [as 别名]
    def getRecord(self, keyword, use_subject='', path='', return_all=False):
        subject = default_subject;
        if use_subject != "":
            subject = use_subject
        if path == '':
            path = self.getPath(subject)

        print 'searching %s'%keyword + " in " + subject
        record_list = []
        for file_name in self.find_file_by_pattern(".*", path):
            f = open(file_name)
            for line in f.readlines():
                record = Record(line)
                record.set_path(file_name)
                if record.get_id().lower().strip() == keyword.lower().strip():
                    print "found " + record.get_id() + ' ' + record.get_title() + ' ' + record.get_url() + ' in ' + self.shortFileName(file_name)
                    if return_all:
                        record_list.append(record)
                    else:
                        return record
        if return_all:
            if len(record_list) > 0:
                return record_list
            else:
                print "no record found in " + subject +" db"
                return record_list.append(Record(''))
        else:
            print "no record found in " + subject +" db"
            return Record('')
开发者ID:fahimkhan,项目名称:slma.link,代码行数:31,代码来源:utils.py

示例2: getStartupPorjects

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [as 别名]
 def getStartupPorjects(self, path):
     data = {}
     if os.path.exists(path):
         f = open(path, 'rU')
         for line in f.readlines():
             record = Record(line)
             key = record.get_title().replace(' ', '').replace('.', '').strip()
             url = 'https://github.com/' + key
             data[key.lower()] = url 
               
     if len(data) > 0:
         self.getProjectByDict(data, 'eecs/projects/github/organization/')
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:14,代码来源:update_github.py

示例3: getUrl

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [as 别名]
    def getUrl(self, keyword, use_subject='', engin=''):
        urls = []
        url = ""
        subject = default_subject;
        if use_subject != "":
            subject = use_subject
        print 'searching %s'%keyword + " in " + subject

        for file_name in self.find_file_by_pattern(".*", self.getPath(subject)):
            f = open(file_name)
            for line in f.readlines():
                record = Record(line)
                if record.get_id().lower().strip() == keyword.lower().strip():
                    print "found " + record.get_id() + ' ' + record.get_title() + ' ' + record.get_url() + ' in ' + self.shortFileName(file_name)
                    title = record.get_title().strip()
                    if engin != "" and self.validEngin(engin) == True:
                        urls.append(self.getEnginUrl(engin.lower()) + title)
                    else:
                        urls.append(record.get_url().strip())

            f.close()


        if len(urls) > 1:
            for u in urls:
                if self.isEnginUrl(u) == False:
                    url = u
                    break
                if url == "":
                    url = urls[0]
        elif len(urls) == 1:
            url = urls[0]
        else:
            print "no url found in " + subject +" db"

        return url
开发者ID:fahimkhan,项目名称:slma.link,代码行数:38,代码来源:utils.py

示例4: getLines

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [as 别名]
def getLines(file_name):
    all_lines = []
    if os.path.exists(file_name):
        f = open(file_name,'rU')
        all_lines = f.readlines()
        if filter_keyword != "":
            filter_result = []
            for line in all_lines:
                record = Record(line)
                data = record.get_id() + record.get_title()
                keyword = filter_keyword
                if includeDesc(filter_keyword):
                    keyword, data = getKeywordAndData(filter_keyword, line)

                if filter(keyword, data):
                    filter_result.append(line)
            all_lines = filter_result[:]
    return all_lines
开发者ID:Django-27,项目名称:deep_em,代码行数:20,代码来源:list.py

示例5: saveIncrementalPapers

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [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"
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:24,代码来源:update_arxiv.py

示例6: excute

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [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
#.........这里部分代码省略.........
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:103,代码来源:history.py

示例7: syncHistory

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [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()
#.........这里部分代码省略.........
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:103,代码来源:history.py

示例8: customPrintFile

# 需要导入模块: from record import Record [as 别名]
# 或者: from record.Record import get_title [as 别名]

#.........这里部分代码省略.........
            
    #elif line[0 : line.find(' ')].strip().find('.') != -1:

    elif line[0 : line.find(' ')].strip().isdigit() and line[0 : line.find(' ')].find('.') == -1:
        sub_sub_pid += 1
        if pid == 0:
	    print  customid + '-' + str(pid) + '.' + str(sub_sub_pid) + ' | ' + line[line.find(' ') : ].strip() + ' | | parentid:' + customid + '-'+ str(pid)
        else:
	    print  customid + '-' + str(pid)+ '.' + str(sub_pid) + '.' + str(sub_sub_pid) + ' | ' + line[line.find(' ') : ].strip() + ' | | parentid:' + customid + '-'+ str(pid) + '.' + str(sub_pid)
    #else:
    #    sub_sub_pid += 1
    #    print  customid + '-' + str(pid)+ '.' + str(sub_pid) + '.' + str(sub_sub_pid) + ' | ' + line.strip() + ' | | parentid:' + customid + '-'+ str(pid) + '.' + str(sub_pid)


    if line.find('.') != -1:
        number = line[0 : line.find(' ')].replace('.', '')
        title = line[line.find(' ') + 1 : ].strip()
        print customid + '-' + number + ' | ' + title + ' | | parentid:' + customid
    else:
        title = line[line.find(' ') + 1 : ].strip()
        #print customid + '-' + line[0 : line.find(' ')].strip() + ' | ' + title + ' | | parentid:' + customid
        #print line[0 : line.find(' ')].strip() + ' | ' + title + ' | | '
	print 'pitt-neurobio-' + str(line_id) + ' | ' + line + ' | | '

    title = line.strip()
    custom = '7.81'
    id = line[0 : line.find(' ')]
    if id.find('.') == -1 and id.find(':') == -1:
        return
    if id.find(':') != -1:
        id = id.replace(':', '')
        print custom + '-' + str(id) + ' | ' + title[title.find(' ') :].strip() + ' | | parentid:' + custom
    else:
        print custom + '-' + str(id) + ' | ' + title[title.find(' ') :].strip() + ' | | parentid:' + custom + '-' + id[0 : id.rfind('.')]

    custom = 'BIO118'
    title = line.strip()
    if id == 'Appendix':
        print custom + '-' + title[0 : title.find(':')].replace(' ', '') + ' | ' + title[title.find(':') + 1 :].strip() + ' | | parentid:' + custom
        return
    #id =id[0 : len(id) - 1]

    if title.startswith('PART') or id == '1':
    #if id.find('.') == -1: 
        unit += 1
        chapter = 0
        sub_chapter = 0
        sub_sub_pid = 0
        print custom + '-' + str(unit) + ' | ' + utils.caseLine(title[title.find(' ', title.find(' ') + 1) :].strip()) + ' | | parentid:' + custom
    #elif title.startswith(' ') == False:
    #elif id.find('.') != -1 and id.find('.', id.find('.') + 1) == -1:
    elif id.isdigit() and id.find('.') == -1:
        chapter += 1
        sub_chapter = 0
        sub_sub_pid = 0
        print custom + '-' + str(unit) + '.' + str(chapter) + ' | ' + title[title.find(' ') :].strip() + ' | | parentid:' + custom  + '-' + str(unit)
    elif id.find('.') != -1:
        sub_chapter += 1
        sub_sub_pid = 0
        if unit == 1:
            print custom + '-' + str(unit) + '.' + str(sub_chapter) + ' | ' + title[title.find(' ') :].strip() + ' | | parentid:' + custom  + '-' + str(unit)
        else:
            print custom + '-' + str(unit) + '.' + str(chapter) + '.' + str(sub_chapter) + ' | ' + title[title.find(' ') :].strip() + ' | | parentid:' + custom  + '-' + str(unit) + '.' + str(chapter)
    else:
        sub_sub_pid += 1
        if unit == 1:
            print custom + '-' + str(unit) + '.' + str(sub_chapter) + '.' + str(sub_sub_pid) + ' | ' + title.strip() + ' | | parentid:' + custom  + '-' + str(unit) + '.' + str(sub_chapter)
        else:
            print custom + '-' + str(unit) + '.' + str(chapter) + '.' + str(sub_chapter) + '.' + str(sub_sub_pid) + ' | ' + title.strip() + ' | | parentid:' + custom  + '-' + str(unit) + '.' + str(chapter) + '.' + str(sub_chapter)

    custom = 'CS334A'
    id = line[0 : line.find(' ')]
    if id.find('.') != -1:
        print custom + '-' + id + ' | ' + line[line.find(' ') :].strip()+ ' | | parentid:' + custom + '-' + id[0 : id.rfind('.')]
    else:
        print custom + '-' + id + ' | ' + line[line.find(' ') :].strip()+ ' | | parentid:' + custom 
    #if title.find('(') != -1:
        #title = title[0 : title.find('(')].strip()
    '''
    #print customid  + '-' + str(line_id) + ' | ' + line.strip()  + ' | | '
    #print customid  +  ' | ' + line.strip()  + ' | | '
    #print line[0 : line.find(' ')].lower() + ' | ' + line[line.find(' ') :].strip()+ ' | | '
    
    r = Record(line)

    title = r.get_title()

    #title = title[title.find(',') + 1 :].strip().lower() +  ' ' + title[0 : title.find(',')].strip().lower()

    #new_title = ''
    #for t in title.split(' '):
    #    new_title += t[0: 1].upper() + t[1:] + ' '


    #print  r.get_id().strip() + customid + ' | ' + title.strip() + ' | ' + r.get_url().strip() + ' | ' + r.get_describe().strip()
    
    if title.find('(') != -1:
        title = title[0: title.find('(')].strip()

    print title.strip() + '(' + r.get_url().strip() + ')'
开发者ID:wowdd1,项目名称:xlinkBook,代码行数:104,代码来源:convert.py


注:本文中的record.Record.get_title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。