#NEWLINE# def process_region_file( filename , start , stop ) : #NEWLINE# #INDENT# 'Given a region filename, return the number of blocks of each ID in that file' #NEWLINE# pieces = filename . split ( '.' ) #NEWLINE# rx = int ( pieces [ ( - 3 ) ] ) #NEWLINE# rz = int ( pieces [ ( - 2 ) ] ) #NEWLINE# block_data_totals = [ ( [ 0 ] * 16 ) for i in range ( 256 ) ] #NEWLINE# if ( start != None ) : #NEWLINE# #INDENT# if ( ( ( ( ( rx + 1 ) * 512 ) - 1 ) < int ( start [ 0 ] ) ) or ( ( ( ( rz + 1 ) * 512 ) - 1 ) < int ( start [ 2 ] ) ) ) : #NEWLINE# #INDENT# return block_data_totals #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( stop != None ) : #NEWLINE# #INDENT# if ( ( ( ( rx * 512 ) - 1 ) > int ( stop [ 0 ] ) ) or ( ( ( rz * 512 ) - 1 ) > int ( stop [ 2 ] ) ) ) : #NEWLINE# #INDENT# return block_data_totals #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# file = RegionFile ( filename ) #NEWLINE# chunks = file . get_chunks ( ) #NEWLINE# print ( ( 'Parsing %s... %d chunks' % ( os . path . basename ( filename ) , len ( chunks ) ) ) ) #NEWLINE# for c in chunks : #NEWLINE# #INDENT# if ( start != None ) : #NEWLINE# #INDENT# if ( ( ( ( ( ( c [ 'x' ] + 1 ) * 16 ) + ( rx * 512 ) ) - 1 ) < int ( start [ 0 ] ) ) or ( ( ( ( ( c [ 'z' ] + 1 ) * 16 ) + ( rz * 512 ) ) - 1 ) < int ( start [ 2 ] ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( stop != None ) : #NEWLINE# #INDENT# if ( ( ( ( ( c [ 'x' ] * 16 ) + ( rx * 512 ) ) - 1 ) > int ( stop [ 0 ] ) ) or ( ( ( ( c [ 'z' ] * 16 ) + ( rz * 512 ) ) - 1 ) > int ( stop [ 2 ] ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# chunk = McRegionChunk ( file . get_chunk ( c [ 'x' ] , c [ 'z' ] ) ) #NEWLINE# assert ( chunk . get_coords ( ) == ( ( c [ 'x' ] + ( rx * 32 ) ) , ( c [ 'z' ] + ( rz * 32 ) ) ) ) #NEWLINE# if ( ( start == None ) and ( stop == None ) ) : #NEWLINE# #INDENT# stats_per_chunk ( chunk , block_data_totals ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bounded_stats_per_chunk ( chunk , block_data_totals , start , stop ) #NEWLINE# #UNINDENT# #UNINDENT# return block_data_totals