예제 #1
0
def searchisbnmeta_fileindex(fileindx):
    fileindxMeta = {}

    newBooks = {}

    path = '/home/eltonr/Downloads/'
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    console = logging.StreamHandler()
    console.setLevel(logging.DEBUG)
    console.setFormatter(formatter)
    logger.addHandler(console)
    logger.setLevel(logging.DEBUG)
    t = time.time()
    logname = datetime.datetime.fromtimestamp(t).strftime('%Y_%m_%d_%H_%M_%S')
    fh = logging.FileHandler(logname + '.log')
    fh.setLevel(logging.DEBUG)
    logger.addHandler(fh)
    recorder = open(logname + '_Rename.log', 'w')
    logging.debug('filesystemencoding = ' + sys.getfilesystemencoding())
    newBooks = dicBooks = pickle.load(open('saveLibrayISBNnew.pkl','rb'))
    keysFnames = dicBooks.viewkeys()
    # i = 0

    for i in range(keysFnames.__len__(),fileindx.__len__()):
        filename = fileindx[i]
        logger.debug('====== ====== ====== ====== ====== ======')
        logger.debug('Processing ' + filename)
        bookmeta = BookMeta(filename, recorder, 'goob', 'Publisher:Author:Year:Title:Language:ISBN-13')
        #i=i+1
        newName,isbn = bookmeta.rename()
        print newName
        newBooks[filename] = [newName,isbn]

        if ((i%100)==0):
            pickle.dump(newBooks, open("saveLibrayISBNnew.pkl", "wb"))

    recorder.close()

    return newBooks
예제 #2
0
        console.setLevel(logging.DEBUG)
        console.setFormatter(formatter)
        logger.addHandler(console)
        logger.setLevel(logging.DEBUG)
        t = time.time()
        logname = datetime.datetime.fromtimestamp(t).strftime(
            '%Y_%m_%d_%H_%M_%S')
        fh = logging.FileHandler(logname + '.log')
        fh.setLevel(logging.DEBUG)
        logger.addHandler(fh)
        recorder = open(logname + '_Rename.log', 'w')
        logging.debug('filesystemencoding = ' + sys.getfilesystemencoding())
        for root, dirs, files in os.walk(
                unicode(sys.argv[1], sys.getfilesystemencoding())):
            for f in files:
                if f.endswith(
                    ('.pdf', '.epub'
                     )) and not f.startswith('EMANER_') and not f.startswith(
                         'DELIAF_'
                     ) and not f.startswith('NRAW_') and not f.startswith(
                         'TSIXE-NUM') and not f.startswith(
                             'RORREPTTH_') and not f.startswith('YNAMOOT_'):
                    filename = os.path.join(root, f)
                    logger.debug('====== ====== ====== ====== ====== ======')
                    logger.debug('Processing ' + filename)
                    bookmata = BookMeta(
                        filename, recorder, 'goob',
                        'Publisher:Author:Year:Title:Language:ISBN-13')
                    bookmata.rename()
        recorder.close()
예제 #3
0
IGNORE_PREFIX = ['EMANER_', 'DELIAF_', 'NRAW_', 'TSIXE-NUM', 'RORREPTTH_', 'YNAMOOT_']

if __name__ == '__main__':
    # print("argv number = " + str(len(sys.argv)))
    if len(sys.argv) > 1:
        # logging.basicConfig(level=logging.DEBUG)
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        console = logging.StreamHandler()
        console.setLevel(logging.DEBUG)
        console.setFormatter(formatter)
        logger.addHandler(console)
        logger.setLevel(logging.DEBUG)
        t = time.time()
        logname = datetime.datetime.fromtimestamp(t).strftime('%Y_%m_%d_%H_%M_%S')
        fh = logging.FileHandler(logname + '.log')
        fh.setLevel(logging.DEBUG)
        logger.addHandler(fh)
        recorder = open(logname + '_Rename.log', 'w')
        logging.debug('filesystemencoding = ' + sys.getfilesystemencoding())
        for root, dirs, files in os.walk(unicode(sys.argv[1], sys.getfilesystemencoding())):
            for f in files:
                if f.endswith(('.pdf', '.epub')) and not f.startswith('EMANER_') and not f.startswith(
                        'DELIAF_') and not f.startswith('NRAW_') and not f.startswith('TSIXE-NUM') and not f.startswith(
                        'RORREPTTH_') and not f.startswith('YNAMOOT_'):
                    filename = os.path.join(root, f)
                    logger.debug('====== ====== ====== ====== ====== ======')
                    logger.debug('Processing ' + filename)
                    bookmata = BookMeta(filename, recorder, 'goob', 'Publisher:Author:Year:Title:Language:ISBN-13')
                    bookmata.rename()
        recorder.close()