bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _cr_1_1(self,n,repeatRows, cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if sr>=0 and sr>=repeatRows and sr<n and er>=0 and er<n: continue if sr>=repeatRows and sr<n: sr=repeatRows elif sr>=repeatRows and sr>=n: sr=sr+repeatRows-n if er>=repeatRows and er<n: er=repeatRows elif er>=repeatRows and er>=n: er=er+repeatRows-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
def _cr_1_1(self,n,repeatRows, cmds): for c in cmds: c = tuple(c) (sc,sr), (ec,er) = c[1:3] if sr>=0 and sr>=repeatRows and sr<n and er>=0 and er<n: continue if sr>=repeatRows and sr<n: sr=repeatRows elif sr>=repeatRows and sr>=n: sr=sr+repeatRows-n if er>=repeatRows and er<n: er=repeatRows elif er>=repeatRows and er>=n: er=er+repeatRows-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
5,200
def _cr_1_1(self,n,repeatRows, cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if sr>=0 and sr>=repeatRows and sr<n and er>=0 and er<n: continue if sr>=repeatRows and sr<n: sr=repeatRows elif sr>=repeatRows and sr>=n: sr=sr+repeatRows-n if er>=repeatRows and er<n: er=repeatRows elif er>=repeatRows and er>=n: er=er+repeatRows-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
def _cr_1_1(self,n,repeatRows, cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if sr>=0 and sr>=repeatRows and sr<n and er>=0 and er<n: continue if sr>=repeatRows and sr<n: sr=repeatRows elif sr>=repeatRows and sr>=n: sr=sr+repeatRows-n if er>=repeatRows and er<n: er=repeatRows elif er>=repeatRows and er>=n: er=er+repeatRows-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
5,201
def _cr_1_0(self,n,cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if er>=0 and er<n: continue if sr>=0 and sr<n: sr=0 if sr>=n: sr = sr-n if er>=n: er = er-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
def _cr_1_0(self,n,cmds): for c in cmds: c = tuple(c) (sc,sr), (ec,er) = c[1:3] if er>=0 and er<n: continue if sr>=0 and sr<n: sr=0 if sr>=n: sr = sr-n if er>=n: er = er-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
5,202
def _cr_1_0(self,n,cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if er>=0 and er<n: continue if sr>=0 and sr<n: sr=0 if sr>=n: sr = sr-n if er>=n: er = er-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
def _cr_1_0(self,n,cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if er>=0 and er<n: continue if sr>=0 and sr<n: sr=0 if sr>=n: sr = sr-n if er>=n: er = er-n self._addCommand((op, (sc, sr), (ec, er), weight, color))
5,203
def setDash(self, array=[], phase=0): """Two notations. pass two numbers, or an array and phase""" if type(array) == IntType or type(array) == FloatType: self._code.append('[%s %s] 0 d' % (array, phase)) elif type(array) == ListType or type(Array) == TupleType: assert phase <= len(array), "setDash phase must be l.t.e. length of array" textarray = string.join(map(str, array)) self._code.append('[%s] %s d' % (textarray, phase))
def setDash(self, array=[], phase=0): """Two notations. pass two numbers, or an array and phase""" if type(array) == IntType or type(array) == FloatType: self._code.append('[%s %s] 0 d' % (array, phase)) elif type(array) == ListType or type(array) == TupleType: assert phase <= len(array), "setDash phase must be l.t.e. length of array" textarray = string.join(map(str, array)) self._code.append('[%s] %s d' % (textarray, phase))
5,204
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if hasattr(os,'uname'): store.update({ 'uname': os.uname(), 'ctermid': os.ctermid(), 'getgid': os.getgid(), 'getuid': os.getuid(), 'getegid': os.getegid(), 'geteuid': os.geteuid(), 'getlogin': os.getlogin(), 'getgroups': os.getgroups(), 'getpgrp': os.getpgrp(), 'getpid': os.getpid(), 'getppid': os.getppid(), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): store['__script'] = open(fn,'r').read() module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, stdout=None, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if hasattr(os,'uname'): store.update({ 'uname': os.uname(), 'ctermid': os.ctermid(), 'getgid': os.getgid(), 'getuid': os.getuid(), 'getegid': os.getegid(), 'geteuid': os.geteuid(), 'getlogin': os.getlogin(), 'getgroups': os.getgroups(), 'getpgrp': os.getpgrp(), 'getpid': os.getpid(), 'getppid': os.getppid(), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): store['__script'] = open(fn,'r').read() module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
5,205
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if hasattr(os,'uname'): store.update({ 'uname': os.uname(), 'ctermid': os.ctermid(), 'getgid': os.getgid(), 'getuid': os.getuid(), 'getegid': os.getegid(), 'geteuid': os.geteuid(), 'getlogin': os.getlogin(), 'getgroups': os.getgroups(), 'getpgrp': os.getpgrp(), 'getpid': os.getpid(), 'getppid': os.getppid(), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): store['__script'] = open(fn,'r').read() module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): store['__script'] = open(fn,'r').read() module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
5,206
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if hasattr(os,'uname'): store.update({ 'uname': os.uname(), 'ctermid': os.ctermid(), 'getgid': os.getgid(), 'getuid': os.getuid(), 'getegid': os.getegid(), 'geteuid': os.geteuid(), 'getlogin': os.getlogin(), 'getgroups': os.getgroups(), 'getpgrp': os.getpgrp(), 'getpid': os.getpid(), 'getppid': os.getppid(), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): store['__script'] = open(fn,'r').read() module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),capture_traceback=1, **kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if capture_traceback and sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.listdir(cwd) exed = os.path.abspath(os.path.dirname(sys.argv[0])) store.update({ 'gmt': time.asctime(time.gmtime(time.time())), 'platform': sys.platform, 'version': sys.version, 'executable': sys.executable, 'prefix': sys.prefix, 'path': sys.path, 'argv': sys.argv, 'cwd': cwd, 'hostname': socket.gethostname(), 'lcwd': lcwd, }) if exed!=cwd: store.update({'exed': exed, 'lexed': os.listdir(exed), }) if hasattr(os,'uname'): store.update({ 'uname': os.uname(), 'ctermid': os.ctermid(), 'getgid': os.getgid(), 'getuid': os.getuid(), 'getegid': os.getegid(), 'geteuid': os.geteuid(), 'getlogin': os.getlogin(), 'getgroups': os.getgroups(), 'getpgrp': os.getpgrp(), 'getpid': os.getpid(), 'getppid': os.getppid(), }) if getScript: fn = os.path.abspath(sys.argv[0]) if os.path.isfile(fn): try: store['__script'] = (fn,open(fn,'r').read()) except: pass module_versions = {} for n,m in sys.modules.items(): if n=='reportlab' or n=='rlextra' or n[:10]=='reportlab.' or n[:8]=='rlextra.': v = getattr(m,'__version__',None) if v: module_versions[n] = v store['__module_versions'] = module_versions self.store['__payload'] = {} self._add(kw)
5,207
def _show_module_versions(self,k,v): print k[2:] K = v.keys() K.sort() for k in K: vk = v[k] try: m = recursiveImport(k,sys.path[:],1) d = getattr(m,'__version__',None)==vk and 'SAME' or 'DIFFERENT' except: m = None d = '??????unknown??????' print ' %s = %s (%s)' % (k,vk,d)
def _show_module_versions(self,k,v): self._writeln(k[2:]) K = v.keys() K.sort() for k in K: vk = v[k] try: m = recursiveImport(k,sys.path[:],1) d = getattr(m,'__version__',None)==vk and 'SAME' or 'DIFFERENT' except: m = None d = '??????unknown??????' print ' %s = %s (%s)' % (k,vk,d)
5,208
def _show_module_versions(self,k,v): print k[2:] K = v.keys() K.sort() for k in K: vk = v[k] try: m = recursiveImport(k,sys.path[:],1) d = getattr(m,'__version__',None)==vk and 'SAME' or 'DIFFERENT' except: m = None d = '??????unknown??????' print ' %s = %s (%s)' % (k,vk,d)
def _show_module_versions(self,k,v): print k[2:] K = v.keys() K.sort() for k in K: vk = v[k] try: m = recursiveImport(k,sys.path[:],1) d = getattr(m,'__version__',None)==vk and 'SAME' or 'DIFFERENT' except: m = None d = '??????unknown??????' print ' %s = %s (%s)' % (k,vk,d)
5,209
def _banner(self,k,what): print '###################%s %s##################' % (what,k[2:])
def _banner(self,k,what): print '###################%s %s##################' % (what,k[2:])
5,210
def _show_lines(self,k,v): self._start(k) print v self._finish(k)
def _show_lines(self,k,v): self._start(k) self._writeln(v) self._finish(k)
5,211
def _show_payload(self,k,v): if v: import pprint self._start(k) pprint.pprint(v) self._finish(k)
def _show_payload(self,k,v): if v: import pprint self._start(k) pprint.pprint(v,self.stdout) self._finish(k)
5,212
def _show_payload(self,k,v): if v: import pprint self._start(k) pprint.pprint(v) self._finish(k)
def _show_payload(self,k,v): if v: import pprint self._start(k) pprint.pprint(v) self._finish(k)
5,213
def show(self): K = self.store.keys() K.sort() for k in K: if k not in self.specials.keys(): print '%-15s = %s' % (k,self.store[k]) for k in K: if k in self.specials.keys(): apply(self.specials[k],(self,k,self.store[k]))
def show(self): K = self.store.keys() K.sort() for k in K: if k not in self.specials.keys(): self._writeln('%-15s = %s' % (k,self.store[k])) for k in K: if k in self.specials.keys(): apply(self.specials[k],(self,k,self.store[k]))
5,214
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,215
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,216
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,217
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,218
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,219
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,220
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
def save(self, formats=None, verbose=None, fnRoot=None): "Saves copies of self in desired location and formats" ext = '' fnroot = os.path.join(getattr(self,'outDir','.'), fnRoot or (getattr(self,'fileNamePattern',(self.__class__.__name__+'%03d')) % getattr(self,'chartId',0)))
5,221
def buildargs(*args, **kwargs) : """Constructs a printable list of arguments suitable for use in source function calls.""" arguments = "" for arg in args : arguments += "%s, " % repr(arg) for (kw, val) in kwargs.items() : arguments += "%s=%s, " % (kw, repr(val)) if arguments[-2:] == ", " : arguments = arguments[:-2] return arguments
def buildargs(*args, **kwargs) : """Constructs a printable list of arguments suitable for use in source function calls.""" arguments = "" for arg in args : arguments = arguments + ("%s, " % repr(arg)) for (kw, val) in kwargs.items() : arguments += "%s=%s, " % (kw, repr(val)) if arguments[-2:] == ", " : arguments = arguments[:-2] return arguments
5,222
def buildargs(*args, **kwargs) : """Constructs a printable list of arguments suitable for use in source function calls.""" arguments = "" for arg in args : arguments += "%s, " % repr(arg) for (kw, val) in kwargs.items() : arguments += "%s=%s, " % (kw, repr(val)) if arguments[-2:] == ", " : arguments = arguments[:-2] return arguments
def buildargs(*args, **kwargs) : """Constructs a printable list of arguments suitable for use in source function calls.""" arguments = "" for arg in args : arguments += "%s, " % repr(arg) for (kw, val) in kwargs.items() : arguments = arguments+ ("%s=%s, " % (kw, repr(val))) if arguments[-2:] == ", " : arguments = arguments[:-2] return arguments
5,223
def __call__(self, *args, **kwargs) : """The fake method is called, print it then call the real one.""" if not self._parent._parent._in : self._precomment() self._parent._parent._PyWrite(" %s.%s(%s)" % (self._parent._name, self._action, apply(buildargs, args, kwargs))) self._postcomment() self._parent._parent._in += 1 retcode = apply(getattr(self._parent._object, self._action), args, kwargs) self._parent._parent._in -= 1 return retcode
def __call__(self, *args, **kwargs) : """The fake method is called, print it then call the real one.""" if not self._parent._parent._in : self._precomment() self._parent._parent._PyWrite(" %s.%s(%s)" % (self._parent._name, self._action, apply(buildargs, args, kwargs))) self._postcomment() self._parent._parent._in = self._parent._parent._in + 1 retcode = apply(getattr(self._parent._object, self._action), args, kwargs) self._parent._parent._in -= 1 return retcode
5,224
def __call__(self, *args, **kwargs) : """Real object initialisation is made here, because now we've got the arguments.""" if not self._initdone : self.__class__._number += 1 methodname = apply(self._postinit, args, kwargs) self._parent._PyWrite("\n # create PDF%sObject number %i\n %s = %s.%s(%s)" % (methodname[5:], self.__class__._number, self._name, self._parent._name, methodname, apply(buildargs, args, kwargs))) self._initdone = 1 return self
def __call__(self, *args, **kwargs) : """Real object initialisation is made here, because now we've got the arguments.""" if not self._initdone : self.__class__._number = self.__class__._number + 1 methodname = apply(self._postinit, args, kwargs) self._parent._PyWrite("\n # create PDF%sObject number %i\n %s = %s.%s(%s)" % (methodname[5:], self.__class__._number, self._name, self._parent._name, methodname, apply(buildargs, args, kwargs))) self._initdone = 1 return self
5,225
def _precomment(self) : """Outputs comments before the method call.""" if self._action == "showPage" : self._parent._PyWrite("\n # Ends page %i" % self._parent._pagenumber) elif self._action == "saveState" : state = {} d = self._parent._object.__dict__ for name in self._parent._object.STATE_ATTRIBUTES: state[name] = d[name] self._parent._PyWrite("\n # Saves context level %i %s" % (self._parent._contextlevel, state)) self._parent._contextlevel += 1 elif self._action == "restoreState" : self._parent._contextlevel -= 1 self._parent._PyWrite("\n # Restores context level %i %s" % (self._parent._contextlevel, self._parent._object.state_stack[-1])) elif self._action == "beginForm" : self._parent._formnumber += 1 self._parent._PyWrite("\n # Begins form %i" % self._parent._formnumber) elif self._action == "endForm" : self._parent._PyWrite("\n # Ends form %i" % self._parent._formnumber) elif self._action == "save" : self._parent._PyWrite("\n # Saves the PDF document to disk")
def _precomment(self) : """Outputs comments before the method call.""" if self._action == "showPage" : self._parent._PyWrite("\n # Ends page %i" % self._parent._pagenumber) elif self._action == "saveState" : state = {} d = self._parent._object.__dict__ for name in self._parent._object.STATE_ATTRIBUTES: state[name] = d[name] self._parent._PyWrite("\n # Saves context level %i %s" % (self._parent._contextlevel, state)) self._parent._contextlevel = self._parent._contextlevel + 1 elif self._action == "restoreState" : self._parent._contextlevel -= 1 self._parent._PyWrite("\n # Restores context level %i %s" % (self._parent._contextlevel, self._parent._object.state_stack[-1])) elif self._action == "beginForm" : self._parent._formnumber += 1 self._parent._PyWrite("\n # Begins form %i" % self._parent._formnumber) elif self._action == "endForm" : self._parent._PyWrite("\n # Ends form %i" % self._parent._formnumber) elif self._action == "save" : self._parent._PyWrite("\n # Saves the PDF document to disk")
5,226
def _precomment(self) : """Outputs comments before the method call.""" if self._action == "showPage" : self._parent._PyWrite("\n # Ends page %i" % self._parent._pagenumber) elif self._action == "saveState" : state = {} d = self._parent._object.__dict__ for name in self._parent._object.STATE_ATTRIBUTES: state[name] = d[name] self._parent._PyWrite("\n # Saves context level %i %s" % (self._parent._contextlevel, state)) self._parent._contextlevel += 1 elif self._action == "restoreState" : self._parent._contextlevel -= 1 self._parent._PyWrite("\n # Restores context level %i %s" % (self._parent._contextlevel, self._parent._object.state_stack[-1])) elif self._action == "beginForm" : self._parent._formnumber += 1 self._parent._PyWrite("\n # Begins form %i" % self._parent._formnumber) elif self._action == "endForm" : self._parent._PyWrite("\n # Ends form %i" % self._parent._formnumber) elif self._action == "save" : self._parent._PyWrite("\n # Saves the PDF document to disk")
def _precomment(self) : """Outputs comments before the method call.""" if self._action == "showPage" : self._parent._PyWrite("\n # Ends page %i" % self._parent._pagenumber) elif self._action == "saveState" : state = {} d = self._parent._object.__dict__ for name in self._parent._object.STATE_ATTRIBUTES: state[name] = d[name] self._parent._PyWrite("\n # Saves context level %i %s" % (self._parent._contextlevel, state)) self._parent._contextlevel += 1 elif self._action == "restoreState" : self._parent._contextlevel -= 1 self._parent._PyWrite("\n # Restores context level %i %s" % (self._parent._contextlevel, self._parent._object.state_stack[-1])) elif self._action == "beginForm" : self._parent._formnumber = self._parent._formnumber + 1 self._parent._PyWrite("\n # Begins form %i" % self._parent._formnumber) elif self._action == "endForm" : self._parent._PyWrite("\n # Ends form %i" % self._parent._formnumber) elif self._action == "save" : self._parent._PyWrite("\n # Saves the PDF document to disk")
5,227
def _postcomment(self) : """Outputs comments after the method call.""" if self._action == "showPage" : self._parent._pagenumber += 1 self._parent._PyWrite("\n # Begins page %i" % self._parent._pagenumber) elif self._action == "endForm" : self._parent._PyWrite("")
def _postcomment(self) : """Outputs comments after the method call.""" if self._action == "showPage" : self._parent._pagenumber = self._parent._pagenumber + 1 self._parent._PyWrite("\n # Begins page %i" % self._parent._pagenumber) elif self._action == "endForm" : self._parent._PyWrite("")
5,228
def goodTest(x,t,tb=0,**kw): try: P=pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, None = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r = r.replace('\r','\\r') r = r.replace('\n','\\n') print 'Parser(%s)(%s)-->'%(s[2:],repr(x)),r, if r==t and rb==tb: print 'OK' else: print '!!!!!BAD!!!!! should --> ', t
def goodTest(x,t,tb=0,**kw): try: P=_pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, None = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r = r.replace('\r','\\r') r = r.replace('\n','\\n') print 'Parser(%s)(%s)-->'%(s[2:],repr(x)),r, if r==t and rb==tb: print 'OK' else: print '!!!!!BAD!!!!! should --> ', t
5,229
def goodTest(x,t,tb=0,**kw): try: P=pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, None = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r = r.replace('\r','\\r') r = r.replace('\n','\\n') print 'Parser(%s)(%s)-->'%(s[2:],repr(x)),r, if r==t and rb==tb: print 'OK' else: print '!!!!!BAD!!!!! should --> ', t
def goodTest(x,t,tb=0,**kw): try: P=pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, None = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r = r.replace('\r','\\r') r = r.replace('\n','\\n') print '%s.Parser(%s)(%s)-->'%(_pyRXP.__name__,s[2:],repr(x)),r, if r==t and rb==tb: print 'OK' else: print '!!!!!BAD!!!!! should --> ', t
5,230
def failTest(x,t,tb=1,**kw): goodTest(x,t,tb,**kw)
def failTest(x,t,tb=1,**kw): goodTest(x,t,tb,**kw)
5,231
def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) os.environ['CVSROOT']=':pserver:%s@cvs1:/cvsroot/reportlab' % USER if release: do_exec(cvs+' tag %s' % release, 'the tag phase') do_exec(cvs+' co reportlab', 'the download phase')
def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: do_exec(cvs+' tag %s' % release, 'the tag phase') do_exec(cvs+' co reportlab', 'the download phase')
5,232
def _elementWidth(self,v,s): t = type(v) if t in _SeqTypes: w = 0 for e in v: ew = self._elementWidth(e,s) if ew is None: return None w = max(w,ew) return w elif isinstance(v,Flowable) and v._fixedWidth: if hasattr(v, 'width'): return v.width if hasattr(v, 'drawWidth'): return v.drawWidth # Even if something is fixedWidth, the attribute to check is not # necessarily consistent (cf. Image.drawWidth). Therefore, we'll # be extra-careful and fall through to this code if necessary. if hasattr(v, 'minWidth'): return v.minWidth() # should be all flowables if t is not StringType: v = v is not None and str(v) or '' v = string.split(v, "\n") return max(map(lambda a, b=s.fontname, c=s.fontsize,d=pdfmetrics.stringWidth: d(a,b,c), v))
def _elementWidth(self,v,s): t = type(v) if t in _SeqTypes: w = 0 for e in v: ew = self._elementWidth(e,s) if ew is None: return None w = max(w,ew) return w elif isinstance(v,Flowable) and v._fixedWidth: if hasattr(v, 'width'): return v.width if hasattr(v, 'drawWidth'): return v.drawWidth # Even if something is fixedWidth, the attribute to check is not # necessarily consistent (cf. Image.drawWidth). Therefore, we'll # be extra-careful and fall through to this code if necessary. if hasattr(v, 'minWidth'): try: return v.minWidth() except AttributeError: pass # should be all flowables if t is not StringType: v = v is not None and str(v) or '' v = string.split(v, "\n") return max(map(lambda a, b=s.fontname, c=s.fontsize,d=pdfmetrics.stringWidth: d(a,b,c), v))
5,233
def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) recursive_rmdir(cvsdir) recursive_rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%s@cvs.reportlab.sourceforge.net:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst) do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst) do_exec("mv reportlab/demos/py2pdf/idle_print.py %s" % dst) do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt reportlab/pdfgen/test", "reducing size") do_exec("mv %s %s" % (projdir,dst)) do_exec("chmod a+x %s/py2pdf.py %s/idle_print.py" % (dst, dst)) CVS_remove(dst) else: do_exec(cvs+' co docs') dst = os.path.join(d,"reportlab","docs") do_exec("mkdir %s" % dst) P=os.path.join(os.environ['HOME'],'python_stuff','lib') PP=os.path.join(P,'PIL') PP = "%s:%s:%s" % (d,P,PP) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (PP,opp) else: opp = None os.environ['PYTHONPATH']=PP if '-pythonpath' in sys.argv: print 'PYTHONPATH=%s'%os.environ['PYTHONPATH'] os.chdir('docs/reference') do_exec(python + ' ../tools/yaml2pdf.py reference.yml') os.chdir(d) do_exec('cp docs/reference/*.pdf %s' % htmldir) do_exec('mv docs/reference/*.pdf %s' % dst) os.chdir('docs/userguide') do_exec(python + ' genuserguide.py') os.chdir(d) do_exec('cp docs/userguide/*.pdf %s' % htmldir) do_exec('mv docs/userguide/*.pdf %s' % dst) os.chdir('docs/graphguide') do_exec(python + ' gengraphguide.py') os.chdir(d) do_exec('cp docs/graphguide/*.pdf %s' % htmldir) do_exec('mv docs/graphguide/*.pdf %s' % dst) os.chdir('docs/graphguide') do_exec(python + ' gengraphguide.py') os.chdir(d) do_exec('cp docs/graphguide/*.pdf %s' % htmldir) do_exec('mv docs/graphguide/*.pdf %s' % dst) recursive_rmdir('docs') pyc_remove(cvsdir) #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp
def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) recursive_rmdir(cvsdir) recursive_rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%s@cvs.reportlab.sourceforge.net:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst) do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst) do_exec("mv reportlab/demos/py2pdf/idle_print.py %s" % dst) do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt reportlab/pdfgen/test", "reducing size") do_exec("mv %s %s" % (projdir,dst)) do_exec("chmod a+x %s/py2pdf.py %s/idle_print.py" % (dst, dst)) CVS_remove(dst) else: do_exec(cvs+' co docs') dst = os.path.join(d,"reportlab","docs") do_exec("mkdir %s" % dst) P=os.path.join(os.environ['HOME'],'python_stuff','lib') PP=os.path.join(P,'PIL') PP = "%s:%s:%s" % (d,P,PP) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (PP,opp) else: opp = None os.environ['PYTHONPATH']=PP if '-pythonpath' in sys.argv: print 'PYTHONPATH=%s'%os.environ['PYTHONPATH'] os.chdir('docs/reference') do_exec(python + ' ../tools/yaml2pdf.py reference.yml') os.chdir(d) do_exec('cp docs/reference/*.pdf %s' % htmldir) do_exec('mv docs/reference/*.pdf %s' % dst) os.chdir('docs/userguide') do_exec(python + ' genuserguide.py') os.chdir(d) do_exec('cp docs/userguide/*.pdf %s' % htmldir) do_exec('mv docs/userguide/*.pdf %s' % dst) recursive_rmdir('docs') pyc_remove(cvsdir) #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp
5,234
def _getFragWords(frags): ''' given a fragment list return a list of lists [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text del f.text if text!='': S = string.split(text,' ') if W!=[] and text[0] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 if W!=[]: W.insert(0,n) R.append(W) for r in R: f = r[1][0] return R
def _getFragWords(frags): ''' given a fragment list return a list of lists [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text if text!='': S = string.split(text,' ') if W!=[] and text[0] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 if W!=[]: W.insert(0,n) R.append(W) for r in R: f = r[1][0] return R
5,235
def __init__(self, cyan=0, magenta=0, yellow=0, black=0, spotName=None, density=1): """ Initialize with four colors in range [0-1]. the optional spotName and density may be of use to specific renderers. The spotName is intended for use as an identifier to the rendere not client programs. """ self.cyan = cyan self.magenta = magenta self.yellow = yellow self.black = black self.spotName = spotName self.density = max(min(density,1),0) # force into right range
def __init__(self, cyan=0, magenta=0, yellow=0, black=0, spotName=None, density=1): """ Initialize with four colors in range [0-1]. the optional spotName and density may be of use to specific renderers. The spotName is intended for use as an identifier to the rendere not client programs. """ self.cyan = cyan self.magenta = magenta self.yellow = yellow self.black = black self.spotName = spotName self.density = max(min(density,1),0) # force into right range
5,236
def __init__(self, cyan=0, magenta=0, yellow=0, black=0, spotName=None, density=1): """ Initialize with four colors in range [0-1]. the optional spotName and density may be of use to specific renderers. The spotName is intended for use as an identifier to the rendere not client programs. """ self.cyan = cyan self.magenta = magenta self.yellow = yellow self.black = black self.spotName = spotName self.density = max(min(density,1),0) # force into right range
def __init__(self, cyan=0, magenta=0, yellow=0, black=0, spotName=None, density=1): """ Initialize with four colors in range [0-1]. the optional spotName and density may be of use to specific renderers. The spotName is intended for use as an identifier to the rendere not client programs. """ self.cyan = cyan self.magenta = magenta self.yellow = yellow self.black = black self.spotName = spotName self.density = max(min(density,1),0) # force into right range
5,237
def linearlyInterpolatedColor(c0, c1, x0, x1, x): """ Linearly interpolates colors. Can handle RGB, CMYK and PCMYK colors - give ValueError if colours aren't the same. Doesn't currently handle 'Spot Color Interpolation'. """ if c0.__class__ != c1.__class__: raise ValueError, "Color classes must be the same for interpolation!" if x1<x0: x0,x1,c0,c1 = x1,x0,c1,c0 # normalized so x1>x0 if x<x0-1e-8 or x>x1+1e-8: # fudge factor for numerical problems raise ValueError, "Can't interpolate: x=%f is not between %f and %f!" % (x,x0,x1) if x<=x0: return c0 elif x>=x1: return c1 cname = c0.__class__.__name__ dx = float(x1-x0) x = x-x0 if cname is 'Color': # RGB r = c0.red+x*(c1.red - c0.red)/dx g = c0.green+x*(c1.green- c0.green)/dx b = c0.blue+x*(c1.blue - c0.blue)/dx return Color(r,g,b) elif cname is 'CMYKColor': c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return CMYKColor(c,m,y,k, density=d) elif cname is 'PCMYKColor': if cmykDistance(c0,c1)<1e-8: #colors same do density and preserve spotName if any assert c0.spotName == c1.spotName, "Identical cmyk, but different spotName" c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) elif cmykDistance(c0,_CMYK_white)<1e-8: #one of the colours is white c = c1.cyan m = c1.magenta y = c1.yellow k = c1.black d = x*c1.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c1.spotName) elif cmykDistance(c1,_CMYK_white)<1e-8: #one of the colours is white c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = x*c0.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) else: c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100) else: raise ValueError, "Can't interpolate: Unknown color class %s!" % cname
deflinearlyInterpolatedColor(c0,c1,x0,x1,x):"""Linearlyinterpolatescolors.CanhandleRGB,CMYKandPCMYKcolors-giveValueErrorifcoloursaren'tthesame.Doesn'tcurrentlyhandle'SpotColorInterpolation'."""ifc0.__class__!=c1.__class__:raiseValueError,"Colorclassesmustbethesameforinterpolation!"ifx1<x0:x0,x1,c0,c1=x1,x0,c1,c0#normalizedsox1>x0ifx<x0-1e-8orx>x1+1e-8:#fudgefactorfornumericalproblemsraiseValueError,"Can'tinterpolate:x=%fisnotbetween%fand%f!"%(x,x0,x1)ifx<=x0:returnc0elifx>=x1:returnc1cname=c0.__class__.__name__dx=float(x1-x0)x=x-x0ifcnameis'Color':#RGBr=c0.red+x*(c1.red-c0.red)/dxg=c0.green+x*(c1.green-c0.green)/dxb=c0.blue+x*(c1.blue-c0.blue)/dxreturnColor(r,g,b)elifcnameis'CMYKColor':c=c0.cyan+x*(c1.cyan-c0.cyan)/dxm=c0.magenta+x*(c1.magenta-c0.magenta)/dxy=c0.yellow+x*(c1.yellow-c0.yellow)/dxk=c0.black+x*(c1.black-c0.black)/dxd=c0.density+x*(c1.density-c0.density)/dxreturnCMYKColor(c,m,y,k,density=d)elifcnameis'PCMYKColor':ifcmykDistance(c0,c1)<1e-8:#colorssamedodensityandpreservespotNameifanyassertc0.spotName==c1.spotName,"Identicalcmyk,butdifferentspotName"c=c0.cyanm=c0.magentay=c0.yellowk=c0.blackd=c0.density+x*(c1.density-c0.density)/dxreturnPCMYKColor(c*100,m*100,y*100,k*100,density=d*100,spotName=c0.spotName)elifcmykDistance(c0,_CMYK_white)<1e-8:#oneofthecoloursiswhitec=c1.cyanm=c1.magentay=c1.yellowk=c1.blackd=x*c1.density/dxreturnPCMYKColor(c*100,m*100,y*100,k*100,density=d*100,spotName=c1.spotName)elifcmykDistance(c1,_CMYK_white)<1e-8:#oneofthecoloursiswhitec=c0.cyanm=c0.magentay=c0.yellowk=c0.blackd=x*c0.density/dxreturnPCMYKColor(c*100,m*100,y*100,k*100,density=d*100,spotName=c0.spotName)else:c=c0.cyan+x*(c1.cyan-c0.cyan)/dxm=c0.magenta+x*(c1.magenta-c0.magenta)/dxy=c0.yellow+x*(c1.yellow-c0.yellow)/dxk=c0.black+x*(c1.black-c0.black)/dxd=c0.density+x*(c1.density-c0.density)/dxreturnPCMYKColor(c*100,m*100,y*100,k*100,density=d*100)else:raiseValueError,"Can'tinterpolate:Unknowncolorclass%s!"%cname
5,238
def linearlyInterpolatedColor(c0, c1, x0, x1, x): """ Linearly interpolates colors. Can handle RGB, CMYK and PCMYK colors - give ValueError if colours aren't the same. Doesn't currently handle 'Spot Color Interpolation'. """ if c0.__class__ != c1.__class__: raise ValueError, "Color classes must be the same for interpolation!" if x1<x0: x0,x1,c0,c1 = x1,x0,c1,c0 # normalized so x1>x0 if x<x0-1e-8 or x>x1+1e-8: # fudge factor for numerical problems raise ValueError, "Can't interpolate: x=%f is not between %f and %f!" % (x,x0,x1) if x<=x0: return c0 elif x>=x1: return c1 cname = c0.__class__.__name__ dx = float(x1-x0) x = x-x0 if cname is 'Color': # RGB r = c0.red+x*(c1.red - c0.red)/dx g = c0.green+x*(c1.green- c0.green)/dx b = c0.blue+x*(c1.blue - c0.blue)/dx return Color(r,g,b) elif cname is 'CMYKColor': c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return CMYKColor(c,m,y,k, density=d) elif cname is 'PCMYKColor': if cmykDistance(c0,c1)<1e-8: #colors same do density and preserve spotName if any assert c0.spotName == c1.spotName, "Identical cmyk, but different spotName" c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) elif cmykDistance(c0,_CMYK_white)<1e-8: #one of the colours is white c = c1.cyan m = c1.magenta y = c1.yellow k = c1.black d = x*c1.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c1.spotName) elif cmykDistance(c1,_CMYK_white)<1e-8: #one of the colours is white c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = x*c0.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) else: c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100) else: raise ValueError, "Can't interpolate: Unknown color class %s!" % cname
def linearlyInterpolatedColor(c0, c1, x0, x1, x): """ Linearly interpolates colors. Can handle RGB, CMYK and PCMYK colors - give ValueError if colours aren't the same. Doesn't currently handle 'Spot Color Interpolation'. """ if c0.__class__ != c1.__class__: raise ValueError, "Color classes must be the same for interpolation!" if x1<x0: x0,x1,c0,c1 = x1,x0,c1,c0 # normalized so x1>x0 if x<x0-1e-8 or x>x1+1e-8: # fudge factor for numerical problems raise ValueError, "Can't interpolate: x=%f is not between %f and %f!" % (x,x0,x1) if x<=x0: return c0 elif x>=x1: return c1 cname = c0.__class__.__name__ dx = float(x1-x0) x = x-x0 if cname is 'Color': # RGB r = c0.red+x*(c1.red - c0.red)/dx g = c0.green+x*(c1.green- c0.green)/dx b = c0.blue+x*(c1.blue - c0.blue)/dx return Color(r,g,b) elif cname is 'CMYKColor': c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return CMYKColor(c,m,y,k, density=d) elif cname is 'PCMYKColor': if cmykDistance(c0,c1)<1e-8: #colors same do density and preserve spotName if any assert c0.spotName == c1.spotName, "Identical cmyk, but different spotName" c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) elif cmykDistance(c0,_CMYK_white)<1e-8: #one of the colours is white c = c1.cyan m = c1.magenta y = c1.yellow k = c1.black d = x*c1.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c1.spotName) elif cmykDistance(c1,_CMYK_white)<1e-8: #one of the colours is white c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = x*c0.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) else: c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100) else: raise ValueError, "Can't interpolate: Unknown color class %s!" % cname
5,239
def linearlyInterpolatedColor(c0, c1, x0, x1, x): """ Linearly interpolates colors. Can handle RGB, CMYK and PCMYK colors - give ValueError if colours aren't the same. Doesn't currently handle 'Spot Color Interpolation'. """ if c0.__class__ != c1.__class__: raise ValueError, "Color classes must be the same for interpolation!" if x1<x0: x0,x1,c0,c1 = x1,x0,c1,c0 # normalized so x1>x0 if x<x0-1e-8 or x>x1+1e-8: # fudge factor for numerical problems raise ValueError, "Can't interpolate: x=%f is not between %f and %f!" % (x,x0,x1) if x<=x0: return c0 elif x>=x1: return c1 cname = c0.__class__.__name__ dx = float(x1-x0) x = x-x0 if cname is 'Color': # RGB r = c0.red+x*(c1.red - c0.red)/dx g = c0.green+x*(c1.green- c0.green)/dx b = c0.blue+x*(c1.blue - c0.blue)/dx return Color(r,g,b) elif cname is 'CMYKColor': c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return CMYKColor(c,m,y,k, density=d) elif cname is 'PCMYKColor': if cmykDistance(c0,c1)<1e-8: #colors same do density and preserve spotName if any assert c0.spotName == c1.spotName, "Identical cmyk, but different spotName" c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) elif cmykDistance(c0,_CMYK_white)<1e-8: #one of the colours is white c = c1.cyan m = c1.magenta y = c1.yellow k = c1.black d = x*c1.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c1.spotName) elif cmykDistance(c1,_CMYK_white)<1e-8: #one of the colours is white c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = x*c0.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) else: c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100) else: raise ValueError, "Can't interpolate: Unknown color class %s!" % cname
def linearlyInterpolatedColor(c0, c1, x0, x1, x): """ Linearly interpolates colors. Can handle RGB, CMYK and PCMYK colors - give ValueError if colours aren't the same. Doesn't currently handle 'Spot Color Interpolation'. """ if c0.__class__ != c1.__class__: raise ValueError, "Color classes must be the same for interpolation!" if x1<x0: x0,x1,c0,c1 = x1,x0,c1,c0 # normalized so x1>x0 if x<x0-1e-8 or x>x1+1e-8: # fudge factor for numerical problems raise ValueError, "Can't interpolate: x=%f is not between %f and %f!" % (x,x0,x1) if x<=x0: return c0 elif x>=x1: return c1 cname = c0.__class__.__name__ dx = float(x1-x0) x = x-x0 if cname is 'Color': # RGB r = c0.red+x*(c1.red - c0.red)/dx g = c0.green+x*(c1.green- c0.green)/dx b = c0.blue+x*(c1.blue - c0.blue)/dx return Color(r,g,b) elif cname is 'CMYKColor': c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return CMYKColor(c,m,y,k, density=d) elif cname is 'PCMYKColor': if cmykDistance(c0,c1)<1e-8: #colors same do density and preserve spotName if any assert c0.spotName == c1.spotName, "Identical cmyk, but different spotName" c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) elif cmykDistance(c0,_CMYK_white)<1e-8: #one of the colours is white c = c1.cyan m = c1.magenta y = c1.yellow k = c1.black d = x*c1.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c1.spotName) elif cmykDistance(c1,_CMYK_white)<1e-8: #one of the colours is white c = c0.cyan m = c0.magenta y = c0.yellow k = c0.black d = x*c0.density/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100, spotName=c0.spotName) else: c = c0.cyan+x*(c1.cyan - c0.cyan)/dx m = c0.magenta+x*(c1.magenta - c0.magenta)/dx y = c0.yellow+x*(c1.yellow - c0.yellow)/dx k = c0.black+x*(c1.black - c0.black)/dx d = c0.density+x*(c1.density - c0.density)/dx return PCMYKColor(c*100,m*100,y*100,k*100, density=d*100) else: raise ValueError, "Can't interpolate: Unknown color class %s!" % cname
5,240
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
def_getDrawingDimensions(self):#findwidthofboxes+spacerstx=(self.numberOfBoxes*self.boxWidth)ifself.numberOfBoxes>1:tx=tx+((self.numberOfBoxes-1)*self.boxSpacing)#addpaddingtx=tx+self.leftPadding+self.rightPadding#findheightofgrid+trianglesty=self.boxHeight+self.triangleHeight#addpadding(andoffset)ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize#print(tx,ty)return(tx,ty)
5,241
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
5,242
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
def_getDrawingDimensions(self):#findwidthofboxes+spacerstx=(self.numberOfBoxes*self.boxWidth)ifself.numberOfBoxes>1:tx=tx+((self.numberOfBoxes-1)*self.boxSpacing)#addpaddingtx=tx+self.leftPadding+self.rightPadding#findheightofgrid+trianglesty=self.boxHeight+self.triangleHeight#addpadding(andoffset)ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize#print(tx,ty)return(tx,ty)
5,243
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
def_getDrawingDimensions(self):#findwidthofboxes+spacerstx=(self.numberOfBoxes*self.boxWidth)ifself.numberOfBoxes>1:tx=tx+((self.numberOfBoxes-1)*self.boxSpacing)#addpaddingtx=tx+self.leftPadding+self.rightPadding#findheightofgrid+trianglesty=self.boxHeight+self.triangleHeight#addpadding(andoffset)ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize#print(tx,ty)return(tx,ty)
5,244
def _getDrawingDimensions(self): #find width of boxes+spacers tx=(self.numberOfBoxes*self.boxWidth) if self.numberOfBoxes>1: tx=tx+((self.numberOfBoxes-1)*self.boxSpacing) #add padding tx=tx+self.leftPadding+self.rightPadding #find height of grid+triangles ty=self.boxHeight+self.triangleHeight #add padding (and offset) ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize #print (tx, ty) return (tx,ty)
def_getDrawingDimensions(self):#findwidthofboxes+spacerstx=(self.numberOfBoxes*self.boxWidth)ifself.numberOfBoxes>1:tx=tx+((self.numberOfBoxes-1)*self.boxSpacing)#addpaddingtx=tx+self.leftPadding+self.rightPadding#findheightofgrid+trianglesty=self.boxHeight+self.triangleHeight#addpadding(andoffset)ty=ty+self.topPadding+self.bottomPadding+self.sourceLabelOffset+self.sourceLabelFontSize#print(tx,ty)return(tx,ty)
5,245
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
5,246
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
5,247
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
5,248
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
5,249
def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') name = parts[0] if baseDir is None: path = sys.path[:] else: if type(baseDir) not in SeqTypes: path = [baseDir] else: path = list(baseDir) path = filter(None,basDir) if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') name = parts[0] if baseDir is None: path = sys.path[:] else: if type(baseDir) not in SeqTypes: path = [baseDir] else: path = list(baseDir) path = filter(None,path) if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
5,250
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
5,251
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
5,252
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
def _className(self): '''Return a shortened class name''' try: name = self.__class__.__name__ i=string.rfind(name,'.') if i>=0: return name[i+1:] return name except AttributeError: return str(self)
5,253
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list
5,254
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open('libart_lgpl/configure.in','r').readlines(): l = string.split(string.strip(l),'=') if len(l)>1 and string.strip(l[0]) in K: D[string.strip(l[0])] = string.strip(l[1]) if len(D)==3: break return '\\"%s\\"' % string.join(map(lambda k,D=D: D.get(k,'?'),K),'.')
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open('libart_lgpl/configure.in','r').readlines(): l = string.split(string.strip(l),'=') if len(l)>1 and string.strip(l[0]) in K: D[string.strip(l[0])] = string.strip(l[1]) if len(D)==3: break return '\\"%s\\"' % string.join(map(lambda k,D=D: D.get(k,'?'),K),'.')
5,255
def describe(aColor): # finds nearest match to one you provide. Useful when # trying to replicate a web page and you only have the # RGB values namedColors = getAllNamedColors() closest = (10, None, None) #big number, name, color for (name, color) in namedColors.items(): distance = colorDistance(aColor, color) if distance < closest[0]: closest = (distance, name, color) print 'best match is %s, distance %0.4f' % (closest[1], closest[0])
def describe(aColor,mode=0): # finds nearest match to one you provide. Useful when # trying to replicate a web page and you only have the # RGB values namedColors = getAllNamedColors() closest = (10, None, None) #big number, name, color for (name, color) in namedColors.items(): distance = colorDistance(aColor, color) if distance < closest[0]: closest = (distance, name, color) print 'best match is %s, distance %0.4f' % (closest[1], closest[0])
5,256
def describe(aColor): # finds nearest match to one you provide. Useful when # trying to replicate a web page and you only have the # RGB values namedColors = getAllNamedColors() closest = (10, None, None) #big number, name, color for (name, color) in namedColors.items(): distance = colorDistance(aColor, color) if distance < closest[0]: closest = (distance, name, color) print 'best match is %s, distance %0.4f' % (closest[1], closest[0])
def describe(aColor): # finds nearest match to one you provide. Useful when # trying to replicate a web page and you only have the # RGB values namedColors = getAllNamedColors() closest = (10, None, None) #big number, name, color for (name, color) in namedColors.items(): distance = colorDistance(aColor, color) if distance < closest[0]: closest = (distance, name, color) if mode<=1: s = 'best match is %s, distance %0.4f' % (closest[1], closest[0]) if mode==0: print s else: return s elif mode==2: return (closest[1], closest[0]) else: raise ValueError, "Illegal value for mode "+str(mode)
5,257
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # crossbox specific bits box = shapes.Rect(self.x, self.y, s, s, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box) crossLine1 = shapes.Line(self.x+(s*0.15), self.y+(s*0.15), self.x+(s*0.85), self.y+(s*0.85), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine1) crossLine2 = shapes.Line(self.x+(s*0.15), self.y+(s*0.85), self.x+(s*0.85) ,self.y+(s*0.15), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine2)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # crossbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box) crossLine1 = shapes.Line(self.x+(s*0.15), self.y+(s*0.15), self.x+(s*0.85), self.y+(s*0.85), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine1) crossLine2 = shapes.Line(self.x+(s*0.15), self.y+(s*0.85), self.x+(s*0.85) ,self.y+(s*0.15), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine2)
5,258
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # tickbox specific bits box = shapes.Rect(self.x, self.y, s, s, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # tickbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box)
5,259
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
5,260
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
5,261
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
5,262
def sort(self): self._data.sort(_cmpFakeItem) #for t in self._data: print t
def sort(self): self._data.sort(_cmpFakeItem) #for t in self._data: print t
5,263
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount-1)*self.barSpacing else: _3d_depth = self.barWidth _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount+1)*self.barSpacing else: _3d_depth = self.barWidth _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
5,264
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount-1)*self.barSpacing else: _3d_depth = self.barWidth _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount-1)*self.barSpacing else: _3d_depth = self.barWidth + 2*self.barSpacing _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
5,265
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount-1)*self.barSpacing else: _3d_depth = self.barWidth _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
def calcBarPositions(self): VerticalBarChart.calcBarPositions(self) seriesCount = self._seriesCount if self.categoryAxis.style=='parallel_3d': _3d_depth = seriesCount*self.barWidth+(seriesCount-1)*self.barSpacing else: _3d_depth = self.barWidth _3d_depth *= self._normFactor self._3d_dx = self._theta_x*_3d_depth self._3d_dy = self._theta_y*_3d_depth
5,266
def _calc_z0(self,rowNo): if self.categoryAxis.style=='parallel_3d': z0 = self._normFactor*rowNo*(self.barWidth+self.barSpacing) else: z0 = 0 return z0
def _calc_z0(self,rowNo): if self.categoryAxis.style=='parallel_3d': z0 = self._normFactor*(rowNo*(self.barWidth+self.barSpacing)+self.barSpacing) else: z0 = 0 return z0
5,267
def _calc_z0(self,rowNo): if self.categoryAxis.style=='parallel_3d': z0 = self._normFactor*rowNo*(self.barWidth+self.barSpacing) else: z0 = 0 return z0
def _calc_z0(self,rowNo): if self.categoryAxis.style=='parallel_3d': z0 = self._normFactor*rowNo*(self.barWidth+self.barSpacing) else: z0 = self._normFactor*self.barSpacing return z0
5,268
def _makeBar(self,g,x,y,width,height,rowNo,style): z0 = self._calc_z0(rowNo) z1 = z0 + self.barWidth*self._normFactor if height<0: y += height height = -height x += z0*self._theta_x y += z0*self._theta_y g.add((0,z0,z1,x,y,width,height,rowNo,style))
def _makeBar(self,g,x,y,width,height,rowNo,style): z0 = self._calc_z0(rowNo) z1 = z0 + self.barWidth*self._normFactor if height<0: y += height height = -height x += z0*self.theta_x y += z0*self.theta_y g.add((0,z0,z1,x,y,width,height,rowNo,style))
5,269
def _addBarLabel(self, g, rowNo, colNo, x, y, width, height): z0 = self._calc_z0(rowNo) z1 = z0 x += z0*self._theta_x y += z0*self._theta_y g.add((1,z0,z1,x,y,width,height,rowNo,colNo))
def _addBarLabel(self, g, rowNo, colNo, x, y, width, height): z0 = self._calc_z0(rowNo) z1 = z0 x += z0*self.theta_x y += z0*self.theta_y g.add((1,z0,z1,x,y,width,height,rowNo,colNo))
5,270
def makeBars(self): from utils3d import _draw_3d_bar fg = _FakeGroup() self._makeBars(fg,fg) fg.sort() g = Group() theta_x = self._theta_x theta_y = self._theta_y for t in fg.value(): if t[0]==1: z0,z1,x,y,width,height,rowNo,colNo = t[1:] VerticalBarChart._addBarLabel(self,g,rowNo,colNo,x,y,width,height) elif t[0]==0: z0,z1,x,y,width,height,rowNo,style = t[1:] dz = z1 - z0 _draw_3d_bar(g, x, x+width, y, y+height, dz*theta_x, dz*theta_y, fillColor=style.fillColor, fillColorShaded=None, strokeColor=style.strokeColor, strokeWidth=style.strokeWidth, shading=0.1) return g
def makeBars(self): from utils3d import _draw_3d_bar fg = _FakeGroup() self._makeBars(fg,fg) fg.sort() g = Group() theta_x = self.theta_x theta_y = self.theta_y for t in fg.value(): if t[0]==1: z0,z1,x,y,width,height,rowNo,colNo = t[1:] VerticalBarChart._addBarLabel(self,g,rowNo,colNo,x,y,width,height) elif t[0]==0: z0,z1,x,y,width,height,rowNo,style = t[1:] dz = z1 - z0 _draw_3d_bar(g, x, x+width, y, y+height, dz*theta_x, dz*theta_y, fillColor=style.fillColor, fillColorShaded=None, strokeColor=style.strokeColor, strokeWidth=style.strokeWidth, shading=0.1) return g
5,271
def start_image(self, args): self._curImage = pythonpoint.PPImage() self._curImage.filename = self._arg('image',args,'filename') if args['width'] <> 'None': self._curImage.width = self.ceval('image',args,'width') if args['height'] <> 'None': self._curImage.height = self.ceval('image',args,'height')
def start_image(self, args): self._curImage = pythonpoint.PPImage() self._curImage.filename = self._arg('image',args,'filename') self._curImage.width = self.ceval('image',args,'width') self._curImage.height = self.ceval('image',args,'height')
5,272
def calcPositions(self): HorizontalLineChart.calcPositions(self) nSeries = self._seriesCount zSpace = self.zSpace zDepth = self.zDepth if self.categoryAxis.style=='parallel_3d': _3d_depth = nSeries*zDepth+(n+1)*self.zSpace else: _3d_depth = zDepth + 2*zSpace self._3d_dx = self.theta_x*_3d_depth self._3d_dy = self.theta_y*_3d_depth
def calcPositions(self): HorizontalLineChart.calcPositions(self) nSeries = self._seriesCount zSpace = self.zSpace zDepth = self.zDepth if self.categoryAxis.style=='parallel_3d': _3d_depth = nSeries*zDepth+(nSeries+1)*self.zSpace else: _3d_depth = zDepth + 2*zSpace self._3d_dx = self.theta_x*_3d_depth self._3d_dy = self.theta_y*_3d_depth
5,273
def _getConfigureData(self): cA = self.categoryAxis data = self.data if cA.style!='parallel': _data = data data = max(map(len,_data))*[0] for d in _data: for i in xrange(len(d)): data[i] += d[i] or 0 data = _data + [data] self._configureData = data
def _getConfigureData(self): cA = self.categoryAxis data = self.data if cA.style!='parallel': _data = data data = max(map(len,_data))*[0] for d in _data: for i in xrange(len(d)): data[i] += d[i] or 0 data = list(_data) + [data] self._configureData = data
5,274
def getrc(defns,depth=1): from sys import getrefcount, _getframe f = _getframe(depth) G0 = f.f_globals L = f.f_locals if L is not G0: LL = [L] while 1: f = f.f_back G = f.f_globals L = f.f_locals if G is not G0 or G is L: break LL.append(L) L = {} for l in reversed(LL): L.update(l) else: L = L.copy() G0 = G0.copy() return [getrefcount(eval(x,L,G0))-1 for x in defns.split()]
def getrc(defns,depth=1): from sys import getrefcount, _getframe f = _getframe(depth) G0 = f.f_globals L = f.f_locals if L is not G0: LL = [L] while 1: f = f.f_back G = f.f_globals L = f.f_locals if G is not G0 or G is L: break LL.append(L) L = {} for l in reversed(LL): L.update(l) else: L = L.copy() G0 = G0.copy() return ' '.join([str(getrefcount(eval(x,L,G0))-1) for x in defns.split()])
5,275
def checkrc(defns,rcv0): rcv1 = getrc(defns,2) return ' '.join(["%s %d-->%d" % (x,v,w) for x,v,w in zip(defns.split(),rcv0,rcv1) if v!=w])
def checkrc(defns,rcv0): rcv1 = getrc(defns,2) return ' '.join(["%s %s-->%s" % (x,v,w) for x,v,w in zip(defns.split(),rcv0.split(),rcv1.split()) if v!=w])
5,276
eg(""" def __init__(self,filename, pagesize=(595.27,841.89), bottomup = 1, pageCompression=0, encoding=rl_config.defaultEncoding, verbosity=0): """)
eg(""" def __init__(self,filename, pagesize=(595.27,841.89), bottomup = 1, pageCompression=0, encoding=rl_config.defaultEncoding, verbosity=0): """)
5,277
def PIL_imagedata(self): if not zlib: warnOnce('zlib not available') return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size
def PIL_imagedata(self): if not zlib: warnOnce('zlib not available') return image = self.image myimage = image.convert('RGB') imgwidth, imgheight = myimage.size
5,278
def __init__(self): self.fillColor = white self.strokeColor = None self.strokeWidth = 0.1 self.background = ReportLabBlue self.shadow = 0.5 self.height = 86 self.width = 129 self.x = self.y = self.angle = self.skewY = self._dx = 0 self.skewX = 10 self._dy = 35.5 self.showPage = 1
def __init__(self): self.fillColor = white self.strokeColor = None self.strokeWidth = 0.1 self.background = ReportLabBlue self.shadow = 0.5 self.height = 86 self.width = 130 self.x = self.y = self.angle = self.skewY = self._dx = 0 self.skewX = 10 self._dy = 35.5 self.showPage = 1
5,279
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow x, y = self.x, self.y if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) G = Group() G.add(g) _w, _h = 129, 86 w, h = self.width, self.height if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h)) if bg is not None: G.insert(0,Rect(0,0,w,h,fillColor=bg,strokeColor=None))
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow x, y = self.x, self.y if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) G = Group() G.add(g) _w, _h = 130, 86 w, h = self.width, self.height if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h)) if bg is not None: G.insert(0,Rect(0,0,w,h,fillColor=bg,strokeColor=None))
5,280
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow x, y = self.x, self.y if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) G = Group() G.add(g) _w, _h = 129, 86 w, h = self.width, self.height if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h)) if bg is not None: G.insert(0,Rect(0,0,w,h,fillColor=bg,strokeColor=None))
def draw(self): fillColor = self.fillColor strokeColor = self.strokeColor g = Group() bg = self.background shadow = self.shadow x, y = self.x, self.y if bg: shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow) self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow) self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor) g.skew(kx=self.skewX, ky=self.skewY) g.shift(self._dx,self._dy) G = Group() G.add(g) _w, _h = 129, 86 w, h = self.width, self.height if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h)) if bg is not None: G.insert(0,Rect(0,0,w,h,fillColor=bg,strokeColor=None))
5,281
def markfilename(filename,creatorcode=None,filetype=None,ext='PDF'): try: if creatorcode is None or filetype is None and ext is not None: try: creatorcode, filetype = _KNOWN_MAC_EXT[ext] except: return macfs.FSSpec(filename).SetCreatorType(creatorcode,filetype) macostools.touched(filename) except: pass
def markfilename(filename,creatorcode=None,filetype=None,ext='PDF'): try: if creatorcode is None or filetype is None and ext is not None: try: creatorcode, filetype = _KNOWN_MAC_EXT[string.upper(ext)] except: return macfs.FSSpec(filename).SetCreatorType(creatorcode,filetype) macostools.touched(filename) except: pass
5,282
def draw(self): pass
def draw(self): pass
5,283
def __repr__(self): return "PageBreak()"
def __repr__(self): return "PageBreak()"
5,284
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = hx = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,285
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: hx = max(c.getSpaceBefore()-pS,0) h += hx pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,286
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS tHS = tH+max(tSB,pS) if H+tHS>=availHeight-_FUZZ: break i += 1
5,287
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,288
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,289
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,290
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
def split(self, availWidth, availHeight): canv = self.canv C = self._content x = i = H = pS = 0 n = len(C) I2W = {} for x in xrange(n): c = C[x] I = c._ptoinfo if I not in I2W.keys(): T = I.trailer Hdr = I.header tW, tH = _listWrapOn(T, availWidth, self.canv) tSB = T[0].getSpaceBefore() I2W[I] = T,tW,tH,tSB else: T,tW,tH,tSB = I2W[I] _, h = c.wrapOn(canv,availWidth,0xfffffff) if x: h += max(c.getSpaceBefore()-pS,0) pS = c.getSpaceAfter() H += h+pS if H+tH+max(tSB,pS)>=availHeight-_FUZZ: break i += 1
5,291
def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = getattr(self,'preview',1), showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy()
def asString(self, format, verbose=None, preview=0): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = getattr(self,'preview',1), showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy()
5,292
def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = getattr(self,'preview',1), showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy()
def asString(self, format, verbose=None): """Converts to an 8 bit string in given format.""" assert format in ['pdf','ps','eps','gif','png','jpg','jpeg','bmp','ppm','tiff','tif','py','pict','pct'], 'Unknown file format "%s"' % format from reportlab import rl_config #verbose = verbose is not None and (verbose,) or (getattr(self,'verbose',verbose),)[0] if format == 'pdf': from reportlab.graphics import renderPDF return renderPDF.drawToString(self) elif format in ['gif','png','tif','jpg','pct','pict','bmp','ppm']: from reportlab.graphics import renderPM return renderPM.drawToString(self, fmt=format) elif format == 'eps': from rlextra.graphics import renderPS_SEP return renderPS_SEP.drawToString(self, preview = preview, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'ps': from reportlab.graphics import renderPS return renderPS.drawToString(self, showBoundary=getattr(self,'showBorder',rl_config.showBoundary)) elif format == 'py': return self._renderPy()
5,293
def start_seq(self, attr): #if it has a template, use that; otherwise try for id; #otherwise take default sequence if attr.has_key('template'): templ = attr['template'] self.handle_data(templ % self.getSequencer()) return elif attr.has_key('id'): id = attr['id'] else: id = None output = self._seq.nextf(id) self.handle_data(output)
def start_seq(self, attr): #if it has a template, use that; otherwise try for id; #otherwise take default sequence if attr.has_key('template'): templ = attr['template'] self.handle_data(templ % self._seq) return elif attr.has_key('id'): id = attr['id'] else: id = None output = self._seq.nextf(id) self.handle_data(output)
5,294
def __init__(self,verbose=0): # the sequencing stuff presumes access to a sequencer. # this may be set with setSequencer(); if a <seq> tag # is encountered and it has not been set, a default # sequencer will be provided. self._seq = None if _xmllib_newStyle: xmllib.XMLParser.__init__(self,verbose=verbose) else: xmllib.XMLParser.__init__(self) # set up handlers for various tags self.elements = { 'b': (self.start_b, self.end_b), 'u': (self.start_u, self.end_u), 'i': (self.start_i, self.end_i), 'super': (self.start_super, self.end_super), 'sub': (self.start_sub, self.end_sub), 'font': (self.start_font, self.end_font), 'greek': (self.start_greek, self.end_greek), 'para': (self.start_para, self.end_para) }
def __init__(self,verbose=0): # the sequencing stuff presumes access to a sequencer. # this may be set with setSequencer(); if a <seq> tag # is encountered and it has not been set, a default # sequencer will be provided. self._seq = None if _xmllib_newStyle: xmllib.XMLParser.__init__(self,verbose=verbose) else: xmllib.XMLParser.__init__(self) # set up handlers for various tags self.elements = { 'b': (self.start_b, self.end_b), 'u': (self.start_u, self.end_u), 'i': (self.start_i, self.end_i), 'super': (self.start_super, self.end_super), 'sub': (self.start_sub, self.end_sub), 'font': (self.start_font, self.end_font), 'greek': (self.start_greek, self.end_greek), 'para': (self.start_para, self.end_para) }
5,295
def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """
def parse(self, text, style): """Given a formatted string will return a list of ParaFrag objects with their calculated widths. If errors occur None will be returned and the self.errors holds a list of the error messages. """
5,296
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,297
def addStar(x,y,size,angle,g=g,w=s/20,x0=x,y0=y+s/2): s = Star() s.fillColor=colors.yellow s.angle = angle s.size = size*w s.x = x*w+x0 s.y = y*w+y0 g.add(s)
def addStar(x,y,size,angle,g=g,w=s/20,x0=x,y0=y+s/2): s = Star() s.fillColor=colors.yellow s.angle = angle s.size = size*w*2 s.x = x*w+x0 s.y = y*w+y0 g.add(s)
5,298
def addStar(x,y,size,angle,g=g,w=s/20,x0=x,y0=y+s/2): s = Star() s.fillColor=colors.yellow s.angle = angle s.size = size*w s.x = x*w+x0 s.y = y*w+y0 g.add(s)
def addStar(x,y,size,angle,g=g,w=s/20,x0=x,y0=y+s/2): s = Star() s.fillColor=colors.yellow s.angle = angle s.size = size*w s.x = x*w+x0 s.y = y*w+y0 g.add(s)
5,299