From a48077fe54199b1e88953dcac2fd55c83c4cd89e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 15 Jan 2012 19:10:14 -0500 Subject: [PATCH] removed unused imports in world.py. More docstrings Also added __getstate__ and __setstate__ for pickling RegionSet --- overviewer_core/world.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/overviewer_core/world.py b/overviewer_core/world.py index 0c196e2..06cfa3c 100644 --- a/overviewer_core/world.py +++ b/overviewer_core/world.py @@ -17,20 +17,12 @@ import functools import os import os.path from glob import glob -import multiprocessing -import Queue -import sys import logging -import cPickle import collections -import itertools -import time import numpy import nbt -import textures -import util """ This module has routines for extracting information about available worlds @@ -218,7 +210,16 @@ class RegionSet(object): """ - def __init__(self, regiondir): + def __init__(self, regiondir, cachesize=16): + """Initialize a new RegionSet to access the region files in the given + directory. + + regiondir is a path to a directory containing region files. + + cachesize, if specified, is the number of chunks to keep parsed and + in-memory. + + """ #self.world = worldobj self.regiondir = regiondir @@ -234,6 +235,11 @@ class RegionSet(object): self.empty_chunk = [None,None] logging.debug("Done scanning regions") + # Re-initialize upon unpickling + def __getstate__(self): + return self.regiondir + __setstate__ = __init__ + def __repr__(self): return "" % self.regiondir