Exemple #1
0
	gpxindex = Index()
	for file in sys.argv[1:]:
		small_files = 0

		print "Checking:",file
		z = zipfile.ZipFile(file, "r")

		#Build up a reference-index
		for filename in z.namelist():
			if( filename.startswith("data/") and filename.endswith(".gpx") ):
				p = GpxParser()
				text = z.read(filename)
				file_index = FileIndex()
				file_index.cachelist = p.ParseText(text)
				info = z.getinfo(filename)
				file_index.crc = crc32(text)
				if( file_index.crc < 0 ):
					#crc32, depending on py version will either return
					#signed 32 bit or unsigned 32 bit, so we adjust if needed
					file_index.crc = long(file_index.crc)
					file_index.crc += 2**32

				if( file_index.crc != info.CRC ):
					print "Error:CRC failure in ",filename
					print "\tGPX crc:",str(file_index.crc)
					print "\tZIP crc:",str(info.CRC)
				if( len(text) < 100*1024 ):
					small_files = small_files + 1
					if( small_files == 2 ):
						print "Warning:multiple small files(<100KiB) in archive"
						print "\tThese should be combined"
Exemple #2
0
            if (small_files == 2):
                print "Warning:packing multiple small files(<100KiB)"
                print "\tThese should be combined"
        if (sz > 5 * 1024 * 1024):
            print "Warning:large file(>5Mib):", basefile
            print "\tGPX size:", sz
            print "\tThis should be split into smaller files"

        parse_time = time.time()
        print "\tParsing XML into cachelist"
        p = GpxParser()
        f = open(file, "rb")
        text = f.read()
        f.close()
        file_index.cachelist = p.ParseText(text)
        file_index.crc = crc32(text)
        file_index.name = os.path.basename(file)
        print "\tFound %i caches" % (len(file_index.cachelist))
        total_caches = total_caches + len(file_index.cachelist)
        parse_time = time.time() - parse_time

        print "\tZipping"
        zip_time = zip_time - time.time()
        z.write(file, "data/" + basefile)
        zip_time = zip_time + time.time()

        index.filelist.append(file_index)

    print "\tCreating indexes for %i caches" % total_caches

    index_xml_time = time.time()
Exemple #3
0
			if( small_files == 2 ):
				print "Warning:packing multiple small files(<100KiB)"
				print "\tThese should be combined"
		if( sz > 5*1024*1024 ):
			print "Warning:large file(>5Mib):",basefile
			print "\tGPX size:",sz
			print "\tThis should be split into smaller files"

		parse_time = time.time()
		print "\tParsing XML into cachelist"
		p = GpxParser()
		f = open( file, "rb" )
		text = f.read()
		f.close()
		file_index.cachelist = p.ParseText(text)
		file_index.crc = crc32(text)
		file_index.name = os.path.basename(file)
		print "\tFound %i caches" % ( len(file_index.cachelist) )
		total_caches = total_caches + len(file_index.cachelist)
		parse_time = time.time() - parse_time

		print "\tZipping"
		zip_time = zip_time - time.time()
		z.write(file,"data/" + basefile )
		zip_time = zip_time + time.time()

		index.filelist.append( file_index )

	print "\tCreating indexes for %i caches" % total_caches

	index_xml_time = time.time()