rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
try: m = getattr(obj, 'set' + key.capitalize()) except AttributeError: pass else: m(value) return try: m = getattr(obj, 'set_' + key) except AttributeError: pass else: m(value) return | aBase = 'set' + keyCaps(key) for accessor in (aBase + '_', aBase, 'set_' + key): m = getattr(obj, accessor, None) if m is None: continue try: m(value) return except TypeError: pass | def setKey(obj, key, value): """ Set the attribute referenced by 'key' to 'value'. The key is used to build the name of an attribute, or attribute accessor method. The following attributes and accessors are tried (in this order): - Accessor 'setKey' - Accessor 'set_key' - Attribute '_key' - Attribute 'key' Raises Key... |
return nil | return None | def dataRepresentationOfType_(self, aType): # return an NSData containing the document's data represented as # the type identified by aType. return nil |
import traceback | def unexpectedErrorAlert(): import traceback exceptionInfo = traceback.format_exception_only( *sys.exc_info()[:2])[0].strip() return NSRunAlertPanel("An unexpected error has occurred", "(%s)" % exceptionInfo, "Continue", "Quit", None) | |
tag = 0 | self._tag = 0 | def init(self): self = super(ProgressCell, self).init() if self is None: return None |
cellFrame, controlView) | cellFrame, view) | def drawInteriorWithFrame_inView_(self, cellFrame, view): super(ProgressCell, self).drawInteriorWithFrame_inView_( cellFrame, controlView) self.setControlView_(view) NSColor.controlColor().set() NSRectFill(cellFrame) |
"-DPYOBJC_NEW_INITIALIZER_PATTERN", | def IfFrameWork(name, packages, extensions, headername=None): """ Return the packages and extensions if the framework exists, or two empty lists if not. """ for pth in ('/System/Library/Frameworks', '/Library/Frameworks'): basedir = os.path.join(pth, name) if os.path.exists(basedir): if (headername is None) or os.path.... | |
runtasks("Generating wrappers & stubs", [sys.executable, "Scripts/CodeGenerators/cocoa_generator.py"]) | def run(self): # Save self.compiler, we need to reset it when we have to rebuild # the extensions. compiler_saved = self.compiler | |
execdir=$(dirname ${0}) | execdir=$(dirname "${0}") | def __load(): import imp, sys, os for p in sys.path: path = os.path.join(p, "%(filename)s") if os.path.exists(path): break else: assert 0, "file not found: %(filename)s" mod = imp.load_dynamic("%(name)s", path) |
resdir=$(dirname ${execdir})/Resources | resdir=$(dirname "${execdir}")/Resources | def __load(): import imp, sys, os for p in sys.path: path = os.path.join(p, "%(filename)s") if os.path.exists(path): break else: assert 0, "file not found: %(filename)s" mod = imp.load_dynamic("%(name)s", path) |
exec ${executable} ${main} ${1} | exec "${executable}" "${main}" "${1}" | def __load(): import imp, sys, os for p in sys.path: path = os.path.join(p, "%(filename)s") if os.path.exists(path): break else: assert 0, "file not found: %(filename)s" mod = imp.load_dynamic("%(name)s", path) |
os.environ['DYLD_BIND_AT_LAUNCH'] = '1' | def runTestCase(self): os.environ['DYLD_BIND_AT_LAUNCH'] = '1' fp = os.popen('/tmp/test.bin', 'r') del os.environ['DYLD_BIND_AT_LAUNCH'] data = fp.read() xit = fp.close() if xit != None: self.fail("Running failed[%s]"%(xit,)) return data | |
del os.environ['DYLD_BIND_AT_LAUNCH'] | def runTestCase(self): os.environ['DYLD_BIND_AT_LAUNCH'] = '1' fp = os.popen('/tmp/test.bin', 'r') del os.environ['DYLD_BIND_AT_LAUNCH'] data = fp.read() xit = fp.close() if xit != None: self.fail("Running failed[%s]"%(xit,)) return data | |
if convertedValue: | if convertedValue is not None: | def propertyListFromPythonCollection(aPyCollection, conversionHelper=None): """Convert a Python collection (dictionary, array, tuple, string) into an Objective-C collection. If conversionHelper is defined, it must be a callable. It will be called for any object encountered for which propertyListFromPythonCollection()... |
os.unlink(os.path.join(self.build_lib, '_AppKit.so')) | os.unlink(os.path.join(self.build_lib, 'AppKit', '_AppKit.so')) | def run(self): task_build_libffi() |
os.unlink(os.path.join(self.build_lib, '_Foundation.so')) | os.unlink(os.path.join(self.build_lib, 'Foundation', '_Foundation.so')) | def run(self): task_build_libffi() |
if HAS_KVO and '__useKVO__' not in type_dict: if not ( 'willChangeValueForKey_' in type_dict or 'didChangeValueForKey_' in type_dict): useKVO = issubclass(super_class, NSObject) type_dict['__useKVO__'] = useKVO if useKVO and HAS_PANTHER_KVO: type_dict['__pyobjc_kvo_stack__'] = ivar('__pyobjc_kvo_stack__') | if (HAS_KVO and '__useKVO__' not in type_dict and isNative(type_dict.get('willChangeValueForKey_')) and isNative(type_dict.get('didChangeValueForKey_'))): useKVO = issubclass(super_class, NSObject) type_dict['__useKVO__'] = useKVO | def bundleForClass(cls): return cb |
def init(self): self = super(PyObjCDebuggingDelegate, self).init() self.setVerbosity_(DEFAULTVERBOSITY) return self | verbosity = objc.ivar('verbosity', 'i') | def init(self): self = super(PyObjCDebuggingDelegate, self).init() self.setVerbosity_(DEFAULTVERBOSITY) return self |
self.setVerbosity_(verbosity) | self.verbosity = verbosity | def initWithVerbosity_(self, verbosity): self = self.init() self.setVerbosity_(verbosity) return self |
def setVerbosity_(self, verbosity): self._verbosity = verbosity def verbosity(self): return self._verbosity | def initWithVerbosity_(self, verbosity): self = self.init() self.setVerbosity_(verbosity) return self | |
if self.verbosity() & LOGSTACKTRACE: | if self.verbosity & LOGSTACKTRACE: | def exceptionHandler_shouldLogException_mask_(self, sender, exception, aMask): try: if isPythonException(exception): if self.verbosity() & LOGSTACKTRACE: nsLogObjCException(exception) return nsLogPythonException(exception) elif self.verbosity() & LOGSTACKTRACE: return nsLogObjCException(exception) else: return False ex... |
elif self.verbosity() & LOGSTACKTRACE: | elif self.verbosity & LOGSTACKTRACE: | def exceptionHandler_shouldLogException_mask_(self, sender, exception, aMask): try: if isPythonException(exception): if self.verbosity() & LOGSTACKTRACE: nsLogObjCException(exception) return nsLogPythonException(exception) elif self.verbosity() & LOGSTACKTRACE: return nsLogObjCException(exception) else: return False ex... |
for key in graphic.class__.keysForNonBoundsProperties(): | for key in graphic.class__().keysForNonBoundsProperties(): | def stopObservingGraphics_(self, graphics): if graphics is None: return for graphic in graphics: for key in graphic.class__.keysForNonBoundsProperties(): graphic.removeObserver_forKeyPath_(self, key) graphic.removeObserver_forKeyPath_(self, u"drawingBounds") |
for obj in [ ['a',], 'hello', 2, ]: self.assertEquals(repr(obj), PyObjC_TestClass4.fetchObjectDescription_(obj)) | TESTS = ['a'], 'hello', 2 EXPECTS = u'(a)', u'hello', u'2' for obj,expect in zip(TESTS, EXPECTS): self.assertEquals(expect, PyObjC_TestClass4.fetchObjectDescription_(obj)) | def testSimple(self): for obj in [ ['a',], 'hello', 2, ]: self.assertEquals(repr(obj), PyObjC_TestClass4.fetchObjectDescription_(obj)) |
if minArgs == maxArgs: | if selArgs == 3 and (minArgs <= 2 <= maxArgs) and funcName.startswith('validate') and funcName.endswith('_error_'): return selector(func, signature='c@:N^@o^@') elif minArgs == maxArgs: | def accessor(func, typeSignature='@'): """ Return an Objective-C method object that is conformant with key-value coding and key-value observing. """ from inspect import getargspec args, varargs, varkw, defaults = getargspec(func) funcName = func.__name__ maxArgs = len(args) minArgs = maxArgs - len(defaults or ()) # im... |
elif funcName.startswith('validate') and funcName.endswith('_error_'): return selector(func, signature='c@:N^@o^@') | def accessor(func, typeSignature='@'): """ Return an Objective-C method object that is conformant with key-value coding and key-value observing. """ from inspect import getargspec args, varargs, varkw, defaults = getargspec(func) funcName = func.__name__ maxArgs = len(args) minArgs = maxArgs - len(defaults or ()) # im... | |
if k in ('__doc__', '__slots__', '__bases__', '__module__'): continue | def add_convenience_methods(super_class, name, type_dict): """ Add additional methods to the type-dict of subclass 'name' of 'super_class'. CONVENIENCE_METHODS is a global variable containing a mapping from an Objective-C selector to a Python method name and implementation. CLASS_METHODS is a global variable containi... | |
makeDir(basedir, 'Library', 'Developer', 'ProjectBuilder Extras', 'Project Templates', 'Application') templateDestination = os.path.join(basedir, 'Library', 'Developer', 'ProjectBuilder Extras', | makeDir(basedir, 'Developer', 'ProjectBuilder Extras', 'Project Templates', 'Application') templateDestination = os.path.join(basedir, 'Developer', 'ProjectBuilder Extras', | def killNasties(irrelevant, dirName, names): for aName in names: if aName in nastyFiles: os.remove( os.path.join(dirName, aName) ) if dirName.find(".pbproj") > 0: for aName in names: if aName.find(".pbxuser") > 0: os.remove( os.path.join(dirName, aName) ) if dirName[-3:] == 'CVS': while len(names): del names[0] shutil.... |
makeDir(basedir, 'Library', 'Developer', 'ProjectBuilder Extras') pbxSpecificationsDestination = os.path.join(basedir, 'Library', 'Developer', 'ProjectBuilder Extras', 'Specifications') | makeDir(basedir, 'Developer', 'ProjectBuilder Extras') pbxSpecificationsDestination = os.path.join(basedir, 'Developer', 'ProjectBuilder Extras', 'Specifications') | def killNasties(irrelevant, dirName, names): for aName in names: if aName in nastyFiles: os.remove( os.path.join(dirName, aName) ) if dirName.find(".pbproj") > 0: for aName in names: if aName.find(".pbxuser") > 0: os.remove( os.path.join(dirName, aName) ) if dirName[-3:] == 'CVS': while len(names): del names[0] shutil.... |
base, ext = os.path.splitext(fn) | ext = os.path.splitext(fn)[1] | def _xcodeFiles(base): for fn in os.listdir(base): base, ext = os.path.splitext(fn) if ext == '.xcode': yield XCODE_20, os.path.join(base, fn, 'project.pbxproj') elif ext == '.xcodeproj': yield XCODE_21, os.path.join(base, fn, 'project.pbxproj') |
('__setattr__', lambda self, name, value: self.setValue_forKey_(name, value)), | ('__setattr__', lambda self, name, value: self.setValue_forKey_(value, name)), | def NSMutableData__setitem__(self, item, value): self.mutableBytes()[item] = value |
%(EOL)s | typedef baz wibble fun* SomethingGreat; | |
ignore_files=[]) | ignore_files=[], emit_imports=0, emit_footer=0) enum_generator.generate( DISCRECORDING2_HDRS, 'build/codegen/_DiscRecording2_Enum.inc', ignore_files=[], emit_imports=0, emit_footer=0, emit_header=0) enum_generator.generate( DISCRECORDING3_HDRS, 'build/codegen/_DiscRecording3_Enum.inc', ignore_files=[], emit_imports=0, ... | fd.write('typedef void* PYOBJC_VOIDPTR;\n') |
ignore=()) | ignore=(), emit_footer=0) strconst_generator.generate(DISCRECORDING2_HDRS, 'build/codegen/_DiscRecording2_Str.inc', ignore=(), emit_footer=0, emit_header=0) strconst_generator.generate(DISCRECORDING3_HDRS, 'build/codegen/_DiscRecording3_Str.inc', ignore=(), emit_header=0) | fd.write('typedef void* PYOBJC_VOIDPTR;\n') |
url = NSURL.fileURLWithPath_(__file__) | filePath = __file__ if filePath[-1] == 'c': filePath = filePath[:-1] url = NSURL.fileURLWithPath_(filePath) | def testInitWithURL(self): url = NSURL.fileURLWithPath_(__file__) |
self.assertEquals(strval.string(), open(__file__, 'rb').read()) | self.assertEquals(strval.string(), open(filePath, 'rb').read()) | def testInitWithURL(self): url = NSURL.fileURLWithPath_(__file__) |
while (nextObject is not None): | while nextObject is not None: | def enumeratorGenerator(anEnumerator): nextObject = anEnumerator.nextObject() while (nextObject is not None): yield nextObject nextObject = anEnumerator.nextObject() |
if self.nibname is None: raise bundlebuilder.BundleBuilderError, ("must specify 'nibname'" " when building a plugin bundle") | def setup(self): | |
if self.nibname: | if self.nibname is not None: | def setup(self): |
e.nodes = [e.nodes[x] for x in swapcorners[refinenode]] e.nodcoord = [e.nodcoord[x] for x in swapcorners[refinenode]] | elem.nodes = [elem.nodes[x] for x in swapcorners[refinenode]] elem.nodcoord = [elem.nodcoord[x] for x in swapcorners[refinenode]] | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setCoordinate(elem.name+'_71', coord) | model.setCoordinate(elename+'_71', coord) | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setCoordinate(elem.name+'_72', coord) | model.setCoordinate(elename+'_72', coord) | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setCoordinate(elem.name+'_73', coord) | model.setCoordinate(elename+'_73', coord) | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setCoordinate(elem.name+'_74', coord) | model.setCoordinate(elename+'_74', coord) | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setCoordinate(elem.name+'_%d' % n, coord) nodenames = [elem.name+'_%d' % n for n in corners] | model.setCoordinate(elename+'_%d' % n, coord) nodenames = [elename+'_%d' % n for n in corners] | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
for n, nn in zip(elem.nodes, [elem.name+'_%d' % n for n in cornerlist]): | for n, nn in zip(elem.nodes, [elename+'_%d' % n for n in cornerlist]): | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
m.setElement(elem.name + '_%s' % i, 'Hex8', nodenames) m.removeElement(e.name) | model.setElement(elename + '_%s' % i, 'Hex8', nodenames) model.removeElement(elem.name) | def subdivideHex(model, elem, refinenodes): """subdivide a Hex8 element |elem| around the nodes |lnodes| remove |elem| from the model |model| and insert the subelements """ assert(elem.shape.name == 'Hex8') # swap the element corners depending on the refine node / edge swapcorners = [ [0, 1, 2, 3, 4, 5, 6, 7], # u 0... |
os.remove(os.path.join(root, name)) | def removeDir(topDir) | |
os.rmdir(os.path.join(root, name)) | def removeDir(topDir) | |
def __init__(self, project, workDir = null, startRevision = null, endRevision = null): | def __init__(self, project, workDir = None, startRevision = None, endRevision = None): | def __init__(self, project, workDir = null, startRevision = null, endRevision = null): self.project = project if workDir == null: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
if workDir == null: | if workDir == None: | def __init__(self, project, workDir = null, startRevision = null, endRevision = null): self.project = project if workDir == null: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
if startRevision == null: | if startRevision == None: | def __init__(self, project, workDir = null, startRevision = null, endRevision = null): self.project = project if workDir == null: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
if endRevision == null: | if endRevision == None: | def __init__(self, project, workDir = null, startRevision = null, endRevision = null): self.project = project if workDir == null: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
def extract_revision_data(self, revision) | def extract_revision_data(self, revision): | def extract_revision_data(self, revision) destDir = os.path.join(self.workDir, revision) project.repository.export(destDir, revision) filename = os.path.join(self.workDir, "stats.%s" % revision) sys.execlp("sloccount --duplicates --autogen --addlangall %s > %s" % (destDir, filename)) removeDir(destDir) |
def collectMetrics(self) | def collectMetrics(self): | def collectMetrics(self) metrics = MetricsCollector(self) metrics.run() print "\n\nData is available at %" % (metrics.workDir) |
def build_re_list(self, expressions_list): | def build_re_list(expressions_list): | def build_re_list(self, expressions_list): re_list = [] for expression in expressions_list: re_list.append(re.compile(expression)) return re_list |
def string_matches_re_list(self, string, re_list): | def string_matches_re_list(string, re_list): | def string_matches_re_list(self, string, re_list): for expression in re_list: if expression.match(string): return True return False |
assert(core.SVN_VER_MAJOR, core.SVN_VER_MINOR) >= (1, 3), "Subversion 1.3 or later required" | assert(svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR) >= (1, 3), "Subversion 1.3 or later required" | def __init__(self, url): assert(core.SVN_VER_MAJOR, core.SVN_VER_MINOR) >= (1, 3), "Subversion 1.3 or later required" self.url = url |
startRevision = convertRevisionStringToInt(startRevision) | startRevision = self.convertRevisionStringToInt(startRevision) | def getRevisionRange(self, startRevision, endRevision): if type(startRevision) == str: startRevision = convertRevisionStringToInt(startRevision) if type(endRevision) == str: endRevision = convertRevisionStringToInt(endRevision) return range(startRevision, endRevision) |
endRevision = convertRevisionStringToInt(endRevision) | endRevision = self.convertRevisionStringToInt(endRevision) | def getRevisionRange(self, startRevision, endRevision): if type(startRevision) == str: startRevision = convertRevisionStringToInt(startRevision) if type(endRevision) == str: endRevision = convertRevisionStringToInt(endRevision) return range(startRevision, endRevision) |
self.workDir = tempfile.mkstemp() | self.workDir = tempfile.mkdtemp() | def __init__(self, project, workDir = None, startRevision = None, endRevision = None): self.project = project if workDir == None: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
self.ignoreDirs = build_re_list(project.tagXfiles["VendorCode"]) | self.ignoreDirs = build_re_list(project.getFilesTaggedAs("VendorCode")) | def __init__(self, project, workDir = None, startRevision = None, endRevision = None): self.project = project if workDir == None: self.workDir = tempfile.mkstemp() else: self.workDir = workDir |
for revision in project.repository.getRevisionRange(self.startRevision, self.endRevision): | for revision in self.project.repository.getRevisionRange(self.startRevision, self.endRevision): | def collectData(self): locHistory = {} |
for i in self.project.tagXfile["VendorCode"]: | for i in self.project.getFilesTaggedAs("VendorCode"): | def run(self): print "Compiling data for project %s, from version %s to %s" % (self.project.name, self.startRevision, self.endRevision) print "Directories to be ignored: ", for i in self.project.tagXfile["VendorCode"]: print i, print "" |
gnuplotData = file(output_file, "w+") | gnuplotData = file(outputFile, "w+") | def run(self): print "Compiling data for project %s, from version %s to %s" % (self.project.name, self.startRevision, self.endRevision) print "Directories to be ignored: ", for i in self.project.tagXfile["VendorCode"]: print i, print "" |
self.repository(repository) | self.repository = repository | def setRepository(self, repository): self.repository(repository) |
print "\n\nData is available at %" % (metrics.workDir) | print "\n\nData is available at %s" % (metrics.workDir) | def collectMetrics(self): metrics = MetricsCollector(self) metrics.run() print "\n\nData is available at %" % (metrics.workDir) |
self.exposure_length = self.config.getint("camera","exposure") | def setup(self): # setup new config parser and parse config self.config = SafeConfigParser() self.config.read(self.config_filename) # accuracy is really the timeout before it gives up and waits for the next time period self.accuracy = 3 # get details from config file self.cameraname = self.config.get("camera","name") s... | |
is_bulbspeed = subprocess.check_output("gphoto2 --port "+self.camera_port+" --get-config shutterspeed", shell=True).splitlines() bulb = is_bulbspeed[3][is_bulbspeed[3].find("Current: ")+9: len(is_bulbspeed[3])] if bulb.find("bulb") != -1: cmd = ["gphoto2 --port "+ self.camera_port+" --set-config capturetarget=sdram --s... | cmd = ["gphoto2 --port "+self.camera_port+" --set-config capturetarget=sdram --capture-image-and-download --filename='"+os.path.join(self.spool_directory, os.path.splitext(raw_image)[0])+".%C'"] | def run(self): # set the next capture time to now just because self.next_capture = datetime.datetime.now() # this is to test and see if the config has been modified self.last_config_modify_time = None while (True): # testing for the config modification if os.stat(self.config_filename).st_mtime!=self.last_config_modify_... |
configlist = | def detect_cameras(type): try: a = subprocess.check_output("gphoto2 --auto-detect", shell=True) cams = {} for port in re.finditer("usb:", a): cmdret = subprocess.check_output('gphoto2 --port "'+a[port.start():port.end()+7]+'" --get-config serialnumber', shell=True) cams[a[port.start():port.end()+7]] = cmdret[cmdret.fin... | |
self.mainViewModel.clear() self.bilds=[] for k, item in self.Backend.listBilder({}).iteritems(): | try: self.mainViewModel.clear() self.bilds=[] for k, item in self.Backend.listBilder({}).iteritems(): | def getBilds(self): self.mainViewModel.clear() self.bilds=[] for k, item in self.Backend.listBilder({}).iteritems(): self.bilds.append(item) tmp = gtk.gdk.PixbufLoader() bildbin = item.getBildBin() if bildbin != None: tmp.write(bildbin) pbuf = tmp.get_pixbuf().scale_simple(100, 100 ,gtk.gdk.INTERP_NEAREST) self.mainVie... |
]) | ]) tmp.close() except gobject.GError, error: print "gobject.GError: %s: %s" % (item.Path, error) | def getBilds(self): self.mainViewModel.clear() self.bilds=[] for k, item in self.Backend.listBilder({}).iteritems(): self.bilds.append(item) tmp = gtk.gdk.PixbufLoader() bildbin = item.getBildBin() if bildbin != None: tmp.write(bildbin) pbuf = tmp.get_pixbuf().scale_simple(100, 100 ,gtk.gdk.INTERP_NEAREST) self.mainVie... |
self.Data = pickle.load(self.pPath) | self.Data = pickle.load(open(self.pPath)) | def __init__(self, pPath): self.pPath = pPath self.Data = pickle.load(self.pPath) |
if type(url) != type("string"): | if type(url) not in [type("string"), type(u'unicode')]: | def replace_link(match): flags = sets.Set(["loose", "check-neighboring-spaces"]) path = match.group(1)[1:-1].split('][') url = lookup(path, namespace_url, flags) if type(url) != type("string"): return '<font color="red">%s</a>' % url img = False for extension in image_extensions: if url.endswith(extension): img = True ... |
command_word, name, target = text.split(None) junk, form_name = command_word.split("-", 1) aliaslist[name] = (uli.forms_by_name[form_name], target) | name, form_name, target = m.group(1), m.group(2), m.group(3) form_func = uli.forms_by_name[form_name] aliaslist[name] = (form_func, target) | def f_uliAlias(m, origin, (cmd, channel), text, p=p): if debug: p.msg(origin.sender, 'alias accepted') command_word, name, target = text.split(None) junk, form_name = command_word.split("-", 1) aliaslist[name] = (uli.forms_by_name[form_name], target) save() |
p.rule(f_uliAlias, 'ulialias', "uli-[-_a-zA-Z]+ [a-zA-Z]+ http://.+$" ) | p.msg(origin.sender, "added alias %r for %s to %s" % (name, uli.form_names[form_func], target)) p.rule(f_uliAlias, 'alias', "^%s?alias ([^\s]+) ([^\s]+) (http://[^\s]+)$" % address_pattern) | def f_uliAlias(m, origin, (cmd, channel), text, p=p): if debug: p.msg(origin.sender, 'alias accepted') command_word, name, target = text.split(None) junk, form_name = command_word.split("-", 1) aliaslist[name] = (uli.forms_by_name[form_name], target) save() |
p.rule(f_uliListAliases, 'ulilistaliases', "uli-list-aliases") | p.rule(f_uliListAliases, 'list-aliases', "^%s?list[- ]?aliases" % address_pattern) | def f_uliListAliases(m,origin, (cmd, channel), text, p=p): p.msg(origin.sender, "the current list of bindings:") for binding in aliaslist: p.msg(origin.sender, "Alias: %s Function: %s Url: %s" % (binding,uli.form_names[aliaslist[binding][0]], aliaslist[binding][1]) ) |
allsplitup = text.split(None,1) alias = allsplitup[0] | alias = m.group(1) | def f_uliAliasCommand(m, origin, (cmd, channel), text, p=p): allsplitup = text.split(None,1) alias = allsplitup[0] if aliaslist.has_key(alias): if debug: p.msg(origin.sender, "interpreting %s as an alias." "sending %s as command..." % (alias, allsplitup[1])) f_uliCommand(alias, allsplitup[1], origin) |
allsplitup[1])) f_uliCommand(alias, allsplitup[1], origin) p.rule(f_uliAliasCommand, 'ulialiascommand', "[a-zA-Z]+ ([a-zA-Z]+)*" ) | m.group(2))) f_uliCommand(alias, m.group(2), origin) p.rule(f_uliAliasCommand, 'aliases', "^%s?([a-zA-Z]+) (.*)$" % address_pattern) | def f_uliAliasCommand(m, origin, (cmd, channel), text, p=p): allsplitup = text.split(None,1) alias = allsplitup[0] if aliaslist.has_key(alias): if debug: p.msg(origin.sender, "interpreting %s as an alias." "sending %s as command..." % (alias, allsplitup[1])) f_uliCommand(alias, allsplitup[1], origin) |
listoflines = f_chop_by_length( line , 80 ) | listoflines = f_chop_by_length( line , 400 ) | def f_uliCommand(alias, command, origin): response = aliaslist[alias][0]( aliaslist[alias][1] , command ) for line in response.splitlines(): listoflines = f_chop_by_length( line , 80 ) for littleline in listoflines: p.msg(origin.sender, littleline ) |
p.msg(origin.sender, "uli-list-aliases, uli-<form> <alias> <url>, " "<existing-alias> <command-string>, help %s, " "debug toggle %s, remove alias <alias>" % (p.nick,p.nick)) p.rule(f_uliBotHelp, 'ulibothelp', "help %s" % p.nick ) | p.msg(origin.sender, "list aliases, alias <form> <alias> <url>, " "<existing-alias> <command-string>, help, " "debug toggle, remove alias <alias>") p.rule(f_uliBotHelp, 'commands', "^%s(help|commands)$" % address_pattern) p.rule(f_uliBotHelp, 'commands', "^(help|commands) %s$" % p.nick) | def f_uliBotHelp(m, origin, (cmd, channel), text, p=p): p.msg(origin.sender, "Commands I understand:") p.msg(origin.sender, "uli-list-aliases, uli-<form> <alias> <url>, " "<existing-alias> <command-string>, help %s, " "debug toggle %s, remove alias <alias>" % (p.nick,p.nick)) |
p.rule(f_uliBotDebugMode, 'ulibotdebugmode', "debug toggle %s" % p.nick ) | p.rule(f_uliBotDebugMode, 'debug', "^%s?debug toggle" % address_pattern ) | def f_uliBotDebugMode(m, origin, (cmd, channel), text, p=p): global debug debug = not debug |
allsplitup = text.split(" ") alias = allsplitup[2] | alias = m.group(1) | def f_uliRemoveAlias(m, origin, (cmd, channel), text, p=p): allsplitup = text.split(" ") alias = allsplitup[2] if aliaslist.has_key(alias): del aliaslist[alias] |
p.rule(f_uliRemoveAlias, 'uliremovealias', "remove alias [a-zA-Z]+" ) | p.msg(origin.sender, "removed alias %r whis was %s to %s" % (alias, uli.form_names[data[0]], data[1])) save() else: p.msg(origin.sender, "no such alias %r" % alias) p.rule(f_uliRemoveAlias, 'remove', "^%s?remove[- ]alias ([^\s]+)$" % address_pattern) | def f_uliRemoveAlias(m, origin, (cmd, channel), text, p=p): allsplitup = text.split(" ") alias = allsplitup[2] if aliaslist.has_key(alias): del aliaslist[alias] |
redir_lookup_flags) | redirect_lookup_flags) | def do_GET(self): if self.path.startswith("/?"): args = cgi.parse_qs( self.path[2:] ) else: args = {} |
if len(args["namespace"] == 1): | if len(args["namespace"]) == 1: | def do_GET(self): if self.path.startswith("/?"): args = cgi.parse_qs( self.path[2:] ) else: args = {} |
if not load.has_key( "RECEIVED-TIME" ): | if not load.has_key( "RESERVED-RECEIVED-TIME" ): | def _match(s, load, pattern): op = pattern[0].upper() if op == "ALL": return True elif op == "NOT": return not s._match(load, pattern[1]) elif op == "AND": return _custom_reduce(lambda x, y: x and y, pattern[1:], False, load) elif op == "OR": return _custom_reduce(lambda x, y: x or y, pattern[1:], True, load) elif op =... |
return load["RECEIVED-TIME"] > time_ago | return load["RESERVED-RECEIVED-TIME"] > time_ago | def _match(s, load, pattern): op = pattern[0].upper() if op == "ALL": return True elif op == "NOT": return not s._match(load, pattern[1]) elif op == "AND": return _custom_reduce(lambda x, y: x and y, pattern[1:], False, load) elif op == "OR": return _custom_reduce(lambda x, y: x or y, pattern[1:], True, load) elif op =... |
server.notify( load, Cpw ) | server.notify( s._stripped_copy(load), Cpw ) | def _ding(s, client_info, Cpw, load): xmlrpc_url = client_info.get( "CLIENT-XMLRPC", None ) if xmlrpc_url: try: server=xmlrpclib.ServerProxy( xmlrpc_url ) print time.asctime(),"-- notify %s" % xmlrpc_url server.notify( load, Cpw ) return True # success except httplib.socket.error: pass except xmlrpclib.Fault, f: pass p... |
load["RECEIVED-TIME"] = time.time() | load["RESERVED-RECEIVED-TIME"] = time.time() | def _stampload(s,load): """ Timestamp a load, with whatever value we like. (Reserved for server use.) """ load["RECEIVED-TIME"] = time.time() |
def get_logs( s, pattern ): | def get_logs( s, ptrn ): | def get_logs( s, pattern ): """ The server is not obligated to keep logs for any set period of time. |
log = pickle.load( open( LOGS_PICKLE, "r" ) ) | try: log = pickle.load( open( LOGS_PICKLE, "r" ) ) except IOError: log = [] | def get_logs( s, pattern ): """ The server is not obligated to keep logs for any set period of time. |
for load in logs: | for load in log: | def get_logs( s, pattern ): """ The server is not obligated to keep logs for any set period of time. |
to_return.append( load ) | to_return.append( s._stripped_copy(load) ) | def get_logs( s, pattern ): """ The server is not obligated to keep logs for any set period of time. |
full = link_names('<html>' + xhtml_fragment + '</html>', dictionary) | full = link_names('<html>' + xhtml_fragment + '</html>', collected_names) | def link_names_in_fragment(xhtml_fragment, collected_names): """Link Local Names found in XHTML fragment. collected_names can be a dictionary or a CollectedNames instance. The fragment must contain no errors. This is a convenience function. It's also something of a hack. If anyone knows the proper solution, I'd lov... |
code_info.SPACE_KEY, space_name ) | code_info.SPACE_KEY, space_name.upper() ) | def edit_key( space_name ): import code_info return "index.cgi?%s=%s&%s=%s" % ( code_info.PAGE_KEY, code_info.PAGE_EDITNAMES, code_info.SPACE_KEY, space_name ) |
code_info.SPACE_KEY, space_name ) | code_info.SPACE_KEY, space_name.upper() ) | def description_key( space_name ): import code_info return "index.cgi?%s=%s&%s=%s" % ( code_info.PAGE_KEY, code_info.PAGE_DESCRIPTION, code_info.SPACE_KEY, space_name ) |
uli_xmlrpc( XMLRPC_LN_SERVER, "dump-cache %s" % (conf.URL_DOMAIN_NAME+conf.URL_DIRECTORY_BASE+description_key( space_name )) ) | uli_xmlrpc( XMLRPC_LN_SERVER, "dump-cache http://%s" % (conf.URL_DOMAIN_NAME+conf.URL_DIRECTORY_BASE+description_key( space_name )) ) | def tell_dump(s, space_name): import conf uli_xmlrpc( XMLRPC_LN_SERVER, "dump-cache %s" % (conf.URL_DOMAIN_NAME+conf.URL_DIRECTORY_BASE+description_key( space_name )) ) |
return (localnames.replace_text(data, url), contentType) | return ({"data": xmlrpclib.Binary(localnames.replace_text(data.encode("utf-8"), url)), "contentType": contentType}) | def xmlrpc_filterData(self, data, contentType, params): data = data.decode("utf-8", "replace") url = params["namespace"] return (localnames.replace_text(data, url), contentType) |
httpd = BaseHTTPServer.HTTPServer(("localhost", 9000), LocalNamesHandler) | httpd = BaseHTTPServer.HTTPServer(("services.taoriver.net", 9090), LocalNamesHandler) | def xmlrpc_render(self, format, url): if type(url) == type([]): ns = localnames.aggregate(url) else: ns = localnames.get_namespace(url) if format in ["XML-RPC", "XML-RPC-text"]: ns2 = {} for k in ["LN", "X", "NS", "PATTERN"]: ns2[k] = un_unicode_dict(ns[k]) if format == "XML-RPC": return ns2 else: return xmlrpclib.dump... |
Goes 1 level deep into defaults, match's against 0 depths pattern if nothing found, returns None if there is no 0 depth pattern. | (1) Follows connections chain. (2) Looks for name, and checks 1 level into defaults, too. (3) Returns against last connection's pattern, if nothing found. | def lookup_tuple( s, tup ): """ Goes 1 level deep into defaults, match's against 0 depths pattern if nothing found, returns None if there is no 0 depth pattern. Doesn't check defaults on Connections. returns URL or None tup: tuple where first items are connection names, and last item is the name of an item """ space... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.