コード例 #1
0
ファイル: not_in_use.py プロジェクト: rzjfr/LTCrawler
def find_work_name_2(name):
    """(str)->list
    dsc: returns a list of workid for given user name
    """
    # if we had the information local
    with open('./data/books.json', 'r') as name_repository:
        for line in name_repository:
            record = json.loads(line)
            if name in record.keys():
                return record[name]
    # calculate it
    data = find_json_name(name)
    data = json.loads(data)
    isbns = []
    works = []
    if 'books' in data.keys() and data['books']:
        for book_id in data['books'].keys():
            isbn = data['books'][book_id]['ISBN_cleaned']
            if isbn == '':  # find missing isbn
                print '...'
                work = find_work_bookid(book_id)
                works.append(work)
            else:  # find work id
                isbns.append(isbn)
    else:
        message = 'No book found for %s' % name
        log(message)
    works.extend(find_isbn_work(isbns))
    return works
コード例 #2
0
ファイル: not_in_use.py プロジェクト: rzjfr/LTCrawler
def find_isbn_name(name):
    """(srt) -> list
    dsc: return all isbn list of a given user name (with duplicates)
    >>>find_isbn_name("sds")
    []
    >>>find_isbn_name("rzjfr")
    ['0345453743']
    """
    data = find_json_name(name)
    result = []
    if data:
        data = json.loads(data)
        if 'books' in data.keys() and data['books']:
            for book_id in data['books'].keys():
                isbn = data['books'][book_id]['ISBN_cleaned']
                if isbn == '':  # find missing isbn
                    title = data['books'][book_id]['title']
                    sleep(1)
                    isbn = get_isbn_title(title)
                    result.append(isbn)
                else:
                    result.append(isbn)
        else:
            message = 'No book found for %s' % name
            log(message)
        return result
    else:
        message = 'No data found for %s' % name
        log(message)
コード例 #3
0
ファイル: not_in_use.py プロジェクト: rzjfr/LTCrawler
def find_bookids_name(name):
    """(srt) -> list
    dsc: gets all book ids of given user name from json data
    >>>find_bookids_name('rzjfr')
    ['97711987']
    """
    data = find_json_name(name)
    result = []
    if data:
        data = json.loads(data)
        if 'books' in data.keys() and data['books']:
            for book_id in data['books'].keys():
                    result.append(book_id)
        else:
            log('No data found for %s' % name, 'Error')
        return result
    else:
        log('No data found for %s' % name, 'Error')