def load_from(cls, filepath): from openalea.secondnature.data import DataFactoryManager dataMgr = DataFactoryManager() dataFactories = dataMgr.gather_items() docs = dict() name = "" with zipfile.ZipFile(filepath, "r") as z: manifest = z.read("manifest.txt") print manifest lines = manifest.split("\n") name = lines[0].split("=")[1] filesAndFactories = [f.split(":") for f in lines[1:]] ctr = 0 for f, facName, type_ in filesAndFactories: df = dataFactories.get(facName) if not df: continue bytes = z.read(f) stream = io.BytesIO(initial_bytes=bytes) try: upk = df.data_from_stream(f, stream, type_) except Exception, e: print "couldn't read", f, " : ", e traceback.print_exc() else: docs[ctr] = upk ctr += 1
def init(cls): from openalea.secondnature.layouts import LayoutManager from openalea.secondnature.applets import AppletFactoryManager from openalea.secondnature.data import DataFactoryManager lm = LayoutManager() am = AppletFactoryManager() dm = DataFactoryManager() lm.init_sources() am.init_sources() dm.init_sources() lm.gather_items(refresh=True) am.gather_items(refresh=True) dm.gather_items(refresh=True)
def init(cls): from openalea.secondnature.layouts import LayoutManager from openalea.secondnature.applets import AppletFactoryManager from openalea.secondnature.data import DataFactoryManager lm = LayoutManager() am = AppletFactoryManager() dm = DataFactoryManager() lm.init_sources() am.init_sources() dm.init_sources() lm.gather_items(refresh=True) am.gather_items(refresh=True) dm.gather_items(refresh=True)
def load_from(cls, filepath): from openalea.secondnature.data import DataFactoryManager dataMgr = DataFactoryManager() dataFactories = dataMgr.gather_items() docs = dict() name = "" with zipfile.ZipFile(filepath, "r") as z: manifest = z.read("manifest.txt") print manifest lines = manifest.split("\n") name = lines[0].split("=")[1] filesAndFactories = [f.split(":") for f in lines[1:]] ctr = 0 for f, facName, type_ in filesAndFactories: df = dataFactories.get(facName) if not df: continue bytes = z.read(f) stream = io.BytesIO(initial_bytes=bytes) try: upk = df.data_from_stream(f, stream, type_) except Exception, e: print "couldn't read", f, " : ", e traceback.print_exc() else: docs[ctr] = upk ctr+=1