__init__.py

来自「Ming is a library for generating Macrome」· Python 代码 · 共 79 行

PY
79
字号
## A base hack to allow ming use in Zope.#from AccessControl import allow_module, allow_class, allow_typefrom AccessControl import ModuleSecurityInfo, ClassSecurityInfofrom Globals import InitializeClassfrom thread import allocate_lockZMingLock = allocate_lock()allow_module('ming')import setFlags__allow_access_to_unprotected_subobjects__=1import osZWIFF_DEBUG = os.environ.get('ZWIFF_DEBUG',0) and 1class MingLocker:   debug = ZWIFF_DEBUG   def __init__(self):      if self.debug:          print "attempting to get lock.. "                ZMingLock.acquire()            if self.debug:          print "got lock.. "   def __del__(self):      if self.debug:          print "attempting to release lock.. "         ZMingLock.release()      if self.debug:          print "lock released.. "import tempfileimport osclass dumbBuffer:    __allow_access_to_unprotected_subobjects__=1    debug = ZWIFF_DEBUG        def __init__(self, ext='', tmpdir=''):        self.f = None        if tmpdir:            tempfile.tempdir=tmpdir                self.tmpfile = tempfile.mktemp()        if ext:            self.tmpfile = self.tmpfile + ext            def filename(self):        return self.tmpfile            def write(self, s):        f = open(self.tmpfile,'w')        f.write(s)        f.close()        def read(self):        f = open(self.tmpfile)        s = f.read()        f.close()        return s        def __del__(self):       if not ZWIFF_DEBUG:          os.unlink(self.tmpfile)                      

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?