From df6124b425912a6a29eea7354491f5225cf3a08a Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Thu, 24 Mar 2011 19:51:33 -0400 Subject: [PATCH] Remove windows-style newlines --- nbt.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/nbt.py b/nbt.py index 52d7545..73730a0 100644 --- a/nbt.py +++ b/nbt.py @@ -34,16 +34,16 @@ def _file_loader(func): def load(fileobj): return NBTFileReader(fileobj).read_all() -def load_from_region(filename, x, y): - nbt = load_region(filename).load_chunk(x, y) - if nbt is None: +def load_from_region(filename, x, y): + nbt = load_region(filename).load_chunk(x, y) + if nbt is None: return None ## return none. I think this is who we should indicate missing chunks - #raise IOError("No such chunk in region: (%i, %i)" % (x, y)) - return nbt.read_all() - -def load_region(filename): - return MCRFileReader(filename) - + #raise IOError("No such chunk in region: (%i, %i)" % (x, y)) + return nbt.read_all() + +def load_region(filename): + return MCRFileReader(filename) + class NBTFileReader(object): def __init__(self, fileobj, is_gzip=True): if is_gzip: @@ -180,9 +180,9 @@ class MCRFileReader(object): chunks (as instances of NBTFileReader), getting chunk timestamps, and for listing chunks contained in the file.""" - def __init__(self, filename): - self._file = None - self._filename = filename + def __init__(self, filename): + self._file = None + self._filename = filename # cache used when the entire header tables are read in get_chunks() self._locations = None self._timestamps = None @@ -252,7 +252,7 @@ class MCRFileReader(object): return timestamp - def get_chunk_info(self,closeFile = True): + def get_chunk_info(self,closeFile = True): """Return a list of all chunks contained in this region file, as a list of (x, y) coordinate tuples. To load these chunks, provide these coordinates to load_chunk().""" @@ -260,7 +260,7 @@ class MCRFileReader(object): if self._chunks: return self._chunks - if self._file is None: + if self._file is None: self._file = open(self._filename,'rb'); self._chunks = [] @@ -283,11 +283,11 @@ class MCRFileReader(object): for x in xrange(32): timestamp = self._read_chunk_timestamp() self._timestamps.append(timestamp) - - if closeFile: - #free the file object since it isn't safe to be reused in child processes (seek point goes wonky!) - self._file.close() - self._file = None + + if closeFile: + #free the file object since it isn't safe to be reused in child processes (seek point goes wonky!) + self._file.close() + self._file = None return self._chunks def get_chunk_timestamp(self, x, y): @@ -320,13 +320,13 @@ class MCRFileReader(object): x = x % 32 y = y % 32 if self._locations is None: - self.get_chunk_info() + self.get_chunk_info() location = self._locations[x + y * 32] if location is None: return None - if self._file is None: + if self._file is None: self._file = open(self._filename,'rb'); # seek to the data self._file.seek(location[0])