コード例 #1
0
ファイル: db.py プロジェクト: HexColors60/16k-mudd
def getclass(path):
    # check cache
    if ccache.has_key(path):
        return ccache[path]

    try:
        # Remember our namespace; this will become the iclass' namespace on
        # success since execfile() modifies it.

        ccache[path] = None  # dummy value to avoid recursion

        ns = namespace.get()  # restricted execution environment
        execfile(dpath(path) + '.py', ns)
    except IOError, e:
        del ccache[path]

        if e[0] != ENOENT: raise

        # missing file.
        raise NoSuchClass, path
コード例 #2
0
ファイル: db.py プロジェクト: ap0ught/16k-mudd
def getclass(path):
    # check cache
    if ccache.has_key(path):
        return ccache[path]

    try:
        # Remember our namespace; this will become the iclass' namespace on
        # success since execfile() modifies it.

        ccache[path] = None # dummy value to avoid recursion
        
        ns = namespace.get() # restricted execution environment
        execfile(dpath(path) + '.py', ns)
    except IOError, e:
        del ccache[path]
        
        if e[0] != ENOENT: raise

        # missing file.
        raise NoSuchClass, path
コード例 #3
0
ファイル: db.py プロジェクト: HexColors60/16k-mudd
        except:
            util.log_exc()


def getcode(path):
    try:
        f = open(dpath(path) + '.py')
    except IOError:
        raise NoSuchObject, path
    try:
        return f.read()
    finally:
        f.close()


# Load compressed data
def load_gz():
    global gzcache
    if gzcache is None:
        gzcache = {}
        try:
            f = gzip.open('data.gz', 'r')
            gzcache = pickle.Unpickler(f).load()
            f.close()
        except:
            pass


# Shorthand for softcode.sys
soft_sys = namespace.get()['sys']
コード例 #4
0
ファイル: db.py プロジェクト: ap0ught/16k-mudd
    # Completed ok. Clean up backup
    try: os.unlink(oldfname)
    except: pass
    # return None

# Sync cache -- write all dirty objects
def sync():
    for i in ocache.keys():
        try: ocache[i].save()
        except: util.log_exc()

def getcode(path):
    try: f = open(dpath(path) + '.py')
    except IOError: raise NoSuchObject, path
    try: return f.read()
    finally: f.close()

# Load compressed data
def load_gz():
    global gzcache
    if gzcache is None:
        gzcache = {}
        try:
            f = gzip.open('data.gz', 'r')
            gzcache = pickle.Unpickler(f).load()
            f.close()
        except: pass

# Shorthand for softcode.sys
soft_sys = namespace.get()['sys']