Example #1
0
def main():
    from shutil import copyfile
    from os.path import exists

    def usage():
        sys.stdout.write(
            "Usage: python %s <existing_file> <new_file>\n" % sys.argv[0])
        sys.stdout.write("  Creates a new py3k-compatible file ")
        sys.stdout.write("from an existing FileStorage file.\n")
        raise SystemExit

    if len(sys.argv) != 3:
        usage()
    infile = sys.argv[1]
    outfile = sys.argv[2]
    if not exists(infile):
        usage()
    if exists(outfile):
        if input('overwrite %r? [y/N] ' % outfile).strip().lower() != 'y':
            raise SystemExit
    copyfile(infile, outfile)

    # monkey patch pickler class, must be done before importing durus stuff
    patch_pickler()

    from durus.__main__ import get_storage_class
    from durus.connection import Connection

    storage_class = get_storage_class(outfile)
    storage = storage_class(outfile)
    connection = Connection(storage)
    print ("Converting %s for use with py3k." % outfile)
    for j, x in enumerate(connection.get_crawler()):
        x._p_note_change()
        if j > 0 and j % 10000 == 0:
            print(j)
            connection.commit()
    print(j)
    connection.commit()
    connection.pack()
Example #2
0
def main():
    from shutil import copyfile
    from os.path import exists

    def usage():
        sys.stdout.write("Usage: python %s <existing_file> <new_file>\n" %
                         sys.argv[0])
        sys.stdout.write("  Creates a new py3k-compatible file ")
        sys.stdout.write("from an existing FileStorage file.\n")
        raise SystemExit

    if len(sys.argv) != 3:
        usage()
    infile = sys.argv[1]
    outfile = sys.argv[2]
    if not exists(infile):
        usage()
    if exists(outfile):
        if input('overwrite %r? [y/N] ' % outfile).strip().lower() != 'y':
            raise SystemExit
    copyfile(infile, outfile)

    # monkey patch pickler class, must be done before importing durus stuff
    patch_pickler()

    from durus.__main__ import get_storage_class
    from durus.connection import Connection

    storage_class = get_storage_class(outfile)
    storage = storage_class(outfile)
    connection = Connection(storage)
    print("Converting %s for use with py3k." % outfile)
    for j, x in enumerate(connection.get_crawler()):
        x._p_note_change()
        if j > 0 and j % 10000 == 0:
            print(j)
            connection.commit()
    print(j)
    connection.commit()
    connection.pack()
Example #3
0
    from durus.connection import Connection
    from durus.file_storage import FileStorage
    from shutil import copyfile

    def usage():
        sys.stdout.write(
            "Usage: python %s <existing_file> <new_file>\n" % sys.argv[0])
        sys.stdout.write("  Creates a new py3k-compatible file ")
        sys.stdout.write("from an existing FileStorage file.\n")
        raise SystemExit

    if len(sys.argv) != 3:
        usage()
    from os.path import exists
    if not exists(sys.argv[1]):
        usage()
    if exists(sys.argv[2]):
        usage()
    copyfile(sys.argv[1], sys.argv[2])
    storage = FileStorage(sys.argv[2])
    connection = Connection(storage)
    print ("Converting %s for use with py3k." % sys.argv[2])
    for j, x in enumerate(connection.get_crawler()):
        x._p_note_change()
        if j > 0 and j % 10000 == 0:
            print(j)
            connection.commit()
    print(j)
    connection.commit()
    connection.pack()
Example #4
0
    from durus.connection import Connection
    from durus.file_storage import FileStorage
    from shutil import copyfile

    def usage():
        sys.stdout.write("Usage: python %s <existing_file> <new_file>\n" %
                         sys.argv[0])
        sys.stdout.write("  Creates a new py3k-compatible file ")
        sys.stdout.write("from an existing FileStorage file.\n")
        raise SystemExit

    if len(sys.argv) != 3:
        usage()
    from os.path import exists
    if not exists(sys.argv[1]):
        usage()
    if exists(sys.argv[2]):
        usage()
    copyfile(sys.argv[1], sys.argv[2])
    storage = FileStorage(sys.argv[2])
    connection = Connection(storage)
    print("Converting %s for use with py3k." % sys.argv[2])
    for j, x in enumerate(connection.get_crawler()):
        x._p_note_change()
        if j > 0 and j % 10000 == 0:
            print(j)
            connection.commit()
    print(j)
    connection.commit()
    connection.pack()