rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
NOTE: this function assumes it is runner as the logged-in user: | NOTE: this function assumes it runs as the logged-in user: | def _setAttrs(self, path, attrs): """ NOTE: this function assumes it is runner as the logged-in user: i.e. under _runAsUser() """ if attrs.has_key("uid") and attrs.has_key("gid"): os.lchown(path, attrs["uid"], attrs["gid"]) if attrs.has_key("permissions"): os.chmod(path, attrs["permissions"]) if attrs.has_key("atime") ... |
text = escapingRE.sub(r'\\\1{}', text.replace('\\', '$\\backslash$')) | text = escapingRE.sub(lambda x: (x.group()=='\\' and '$\\backslash$') or '\\'+x.group(), text) | def latexEscape(text): text = escapingRE.sub(r'\\\1{}', text.replace('\\', '$\\backslash$')) return text.replace('\n', ' ') |
if resolv: | if resolv and os.path.exists(resolv): | def __init__(self, resolv = None, servers = None, timeout = 10): """ @type servers: C{list} of C{(str, int)} or C{None} @param servers: If not None, interpreted as a list of addresses of domain name servers to attempt to use for this lookup. Addresses should be in dotted-quad form. If specified, overrides C{resolv}. ... |
match = re.match(self.fileLinePattern, line) | match = self.fileLinePattern.match(line) | def lineReceived(self, line): match = re.match(self.fileLinePattern, line) if match: dict = match.groupdict() dict['size'] = int(dict['size']) self.files.append(dict) |
def __init__(self,page,event): self.page=page self.event=event def getFormFields(self,request): text=string.replace(self.event.data,"<br>\n","\n") return [ ["string","Title","title",self.event.title], ["text","Data","data",text]] def process(self,write,request,title,data): self.event.title=title self.event.data=strin... | def __init__(self,page,event): self.page=page self.event=event def getFormFields(self,request): text=string.replace(self.event.data,"<br>\n","\n") return [ ["string","Title","title",self.event.title], ["text","Data","data",text]] def process(self,write,request,title,data): self.event.title=title self.event.data=strin... | def __init__(self,page,event): self.page=page self.event=event |
def render(self, request): | def _rewrite(self, request): | def render(self, request): for rewriteRule in self.rewriteRules: rewriteRule(request) resource = self.resource.getChildForRequest(request) return resource.render(request) |
resource = self.resource.getChildForRequest(request) return resource.render(request) | def getChild(self, path, request): request.postpath.insert(0, path) self._rewrite(request) path = request.postpath.pop(0) return self.resource.getChildWithDefault(path, request) def render(self, request): self._rewrite(request) return self.resource.render(request) | def render(self, request): for rewriteRule in self.rewriteRules: rewriteRule(request) resource = self.resource.getChildForRequest(request) return resource.render(request) |
except MailboxError, m: | except MailboxException, m: | def auth_SUBSCRIBE(self, tag, args): name = self._parseMbox(args) try: self.account.subscribe(name) except MailboxError, m: self.sendNegativeResponse(tag, str(m)) else: self.sendPositiveResponse(tag, 'Subscribed') |
except MailboxError, m: | except MailboxException, m: | def auth_UNSUBSCRIBE(self, tag, args): name = self._parseMbox(args) try: self.account.unsubscribe(name) except MailboxError, m: self.sendNegativeResponse(tag, str(m)) else: self.sendPositiveResponse(tag, 'Unsubscribed') |
raise MailboxError, "Not currently subscribed to " + name | raise MailboxException, "Not currently subscribed to " + name | def unsubscribe(self, name): name = name.upper() if name not in self.subscriptions: raise MailboxError, "Not currently subscribed to " + name self.subscriptions.remove(name) |
host, port, url = _parse(l[0]) self.factory.host = host | host, port, url = _parse(l[0], defaultPort=self.transport.addr[1]) if host: self.factory.host = host self.factory.port = port | def handleStatus_301(self): l = self.headers.get('location') if not l: self.handleStatusDefault() host, port, url = _parse(l[0]) self.factory.host = host self.factory.url = url |
def _parse(url): | def _parse(url, defaultPort=80): | def _parse(url): parsed = urlparse.urlparse(url) url = urlparse.urlunparse(('','')+parsed[2:]) host, port = parsed[1], 80 if ':' in host: host, port = host.split(':') port = int(port) return host, port, url |
host, port = parsed[1], 80 | host, port = parsed[1], defaultPort | def _parse(url): parsed = urlparse.urlparse(url) url = urlparse.urlunparse(('','')+parsed[2:]) host, port = parsed[1], 80 if ':' in host: host, port = host.split(':') port = int(port) return host, port, url |
Mailboxes which do not intent to do any special processing to | Mailboxes which do not intend to do any special processing to | def requestStatus(self, names): """Return status information about this mailbox. |
i1 = self.preferredOrder.index(x) i2 = self.preferredOrder.index(y) if i1 < 0: return 1 if i2 < 0: return -1 | try: i1 = self.preferredOrder.index(x) except ValueError: return 1 try: i2 = self.preferredOrder.index(y) except ValueError: return -1 | def _(x, y): i1 = self.preferredOrder.index(x) i2 = self.preferredOrder.index(y) if i1 < 0: return 1 if i2 < 0: return -1 return cmp(i1, i2) |
self.transport.write('%3.3d-%s\r\n' % (code, line)) self.transport.write('%3.3d %s\r\n' % (code, lastline and lastline[0] or '')) | self.sendLine('%3.3d-%s' % (code, line)) self.sendLine('%3.3d %s' % (code, lastline and lastline[0] or '')) | def sendCode(self, code, message=''): "Send an SMTP code with a message." lines = message.splitlines() lastline = lines[-1:] for line in lines[:-1]: self.transport.write('%3.3d-%s\r\n' % (code, line)) self.transport.write('%3.3d %s\r\n' % (code, lastline and lastline[0] or '')) |
self.sendCode(550, 'Cannot receive for specified address') | self.sendCode(failure.value.code, 'Cannot receive for specified address %s: %s' % (repr(str(failure.value.addr)), failure.value.resp)) | def _ebFromValidate(self, failure): if failure.check(SMTPBadSender): self.sendCode(550, 'Cannot receive for specified address') elif failure.check(SMTPServerError): self.sendCode(failure.value.code, failure.value.resp) else: log.err(failure) self.sendCode( 451, 'Requested action aborted: local error in processing' ) |
self.sendCode(550, 'Cannot receive for specified address') | self.sendCode(failure.value.code, failure.value.resp) | def _ebToValidate(self, failure): if failure.check(SMTPBadRcpt): self.sendCode(550, 'Cannot receive for specified address') elif failure.check(SMTPServerError): self.sendCode(failure.value.code, failure.value.resp) else: log.err(failure) self.sendCode( 451, 'Requested action aborted: local error in processing' ) |
self.parent.removeService(self) | d = self.parent.removeService(self) | def disownServiceParent(self): self.parent.removeService(self) self.parent = None |
service.stopService() | return service.stopService() else: return None | def removeService(self, service): if service.name: del self.namedServices[service.name] self.services.remove(service) if self.running: service.stopService() |
@type portType: type which implements C{IListeningPort} | @type portType: type which implements L{IListeningPort} | def listenWith(self, portType, *args, **kw): """Start an instance of the given C{portType} listening. |
@type connectorType: type which implements C{IConnector} | @type connectorType: type which implements L{IConnector} | def connectWith(self, connectorType, *args, **kw): """ Start an instance of the given C{connectorType} connecting. |
@param factory: a twisted.internet.protocol.ServerFactory instance | @param factory: a L{twisted.internet.protocol.ServerFactory} instance | def listenTCP(self, port, factory, backlog=5, interface=''): """Connects a given protocol factory to the given numeric TCP/IP port. |
@raise CannotListenError: as defined in twisted.internet.error, if it | @raise CannotListenError: as defined here L{twisted.internet.error.CannotListenError}, if it | def listenTCP(self, port, factory, backlog=5, interface=''): """Connects a given protocol factory to the given numeric TCP/IP port. |
@param factory: a twisted.internet.protocol.ClientFactory instance | @param factory: a L{twisted.internet.protocol.ClientFactory} instance | def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): """Connect a TCP client. |
@returns: An object implementing IConnector. This connector will call | @returns: An object implementing L{IConnector}. This connector will call | def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): """Connect a TCP client. |
failed, or lost - see ClientFactory docs for details. | failed, or lost - see L{ClientFactory<twisted.internet.protocol.ServerFactory>} docs for details. | def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): """Connect a TCP client. |
"""Connects a given DatagramProtocol to the given numeric UDP port. @returns: object conforming to IListeningPort. | """Connects a given L{DatagramProtocol<twisted.internet.protocol.DatagramProtocol>} to the given numeric UDP port. @returns: object conforming to L{IListeningPort}. | def listenMulticast(self, port, protocol, interface='', maxPacketSize=8192): """Connects a given DatagramProtocol to the given numeric UDP port. |
"""Connects a ConnectedDatagramProtocol instance to a UDP port. | """Connects a L{ConnectedDatagramProtocol<twisted.internet.protocol.ConnectedDatagramProtocol>} instance to a UDP port. | def connectMulticast(self, remotehost, remoteport, protocol, localport=0, interface='', maxPacketSize=8192): """Connects a ConnectedDatagramProtocol instance to a UDP port. """ |
@see: C{twisted.internet.protocol.ProcessProtocol} | @see: L{twisted.internet.protocol.ProcessProtocol} | def spawnProcess(self, processProtocol, executable, args=(), env={}, path=None, uid=None, gid=None, usePTY=0): """Spawn a process, with a process protocol. |
@type resolver: An object implementing the C{IResolverSimple} interface | @type resolver: An object implementing the L{IResolverSimple} interface | def installResolver(self, resolver): """Set the internal resolver to use to for name lookups. |
"""Implement me to be able to use FileDescriptor type resources. | """Implement me to be able to use L{FileDescriptor<twisted.internet.abstract.FileDescriptor>} type resources. | def installResolver(self, resolver): """Set the internal resolver to use to for name lookups. |
@raise CannotListenError: as defined in C{twisted.internet.error}, | @raise CannotListenError: as defined here L{twisted.internet.error.CannotListenError}, | def startListening(self): """Start listening on this port. |
"""I am a FileDescriptor that can both read and write. | """I am a L{FileDescriptor<twisted.internet.abstract.FileDescriptor>} that can both read and write. | def doWrite(self): """Some data is available for reading on your descriptor. """ |
to resumeProducing(). A producer should implement the IProducer | to resumeProducing(). A producer should implement the L{IProducer} | def registerProducer(self, producer, streaming): """Register to receive data from a producer. |
"""Return an object implementing IProtocol, or None. | """Return an object implementing L{IProtocol}, or None. | def buildProtocol(self, addr): """Return an object implementing IProtocol, or None. |
Once TLS mode is started the transport will implement ISSLTransport. | Once TLS mode is started the transport will implement L{ISSLTransport}. | def getPeer(self): """Returns tuple ('INET', host, port).""" |
@param contextFactory: A context factory (see ssl.py) | @param contextFactory: A context factory (see L{ssl.py<twisted.internet.ssl>}) | def startTLS(self, contextFactory): """Initiate TLS negotiation. @param contextFactory: A context factory (see ssl.py) """ |
Might raise error.ConnectionRefusedError. | Might raise L{ConnectionRefusedError<twisted.internet.error.ConnectionRefusedError>}. | def write(self, packet, (host, port)): """Write packet to given address. |
Might raise error.ConnectionRefusedError. | Might raise L{ConnectionRefusedError<twisted.internet.error.ConnectionRefusedError>}. | def write(self, packet): """Write packet to address we are connected to. |
Might raise error.ConnectionRefusedError. | Might raise L{ConnectionRefusedError<twisted.internet.error.ConnectionRefusedError>}. | def write(self, packet, address): """Write packet to given address. |
class InetdFactory(ServerFactory): protocol = InetdProtocol service = None def __init__(self, service): self.service = service | class InvalidServicesConfError(InvalidConfError): """Invalid services file""" | def connectionLost(self, reason): self.process.transport.loseConnection() |
class InetdOptions(usage.Options): optParameters = [['file', 'f', '/etc/inetd.conf'],] | class UnknownService(Exception): """Unknown service name""" | def __init__(self, service): self.service = service |
def main(options=None): if not options: options = InetdOptions() options.parseOptions() | class SimpleConfFile: """Simple configuration file parser superclass. Filters out comments and empty lines (which includes lines that only contain comments). """ | def main(options=None): if not options: options = InetdOptions() options.parseOptions() conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/proto... |
conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) | commentChar = ' | def main(options=None): if not options: options = InetdOptions() options.parseOptions() conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/proto... |
app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/protocol: %s/%s' % (service.socketType, service.protocol)) continue | def parseFile(self, file): """Parse a configuration file""" for line in file.readlines(): comment = line.find(self.commentChar) if comment != -1: line = line[:comment] | def main(options=None): if not options: options = InetdOptions() options.parseOptions() conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/proto... |
print 'Adding service:', service.name, service.port, service.protocol factory = InetdFactory(service) app.listenTCP(service.port, factory) app.run(save=0) | line = line.strip() if not line: continue self.parseLine(line) def parseLine(self, line): """Override this.""" | def main(options=None): if not options: options = InetdOptions() options.parseOptions() conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/proto... |
if __name__ == '__main__': main() | class InetdService: name = None port = None socketType = None protocol = None wait = None user = None group = None program = None programArgs = None def __init__(self, name, port, socketType, protocol, wait, user, group, program, programArgs): self.name = name self.port = port self.socketType = socketType self.protoco... | def main(options=None): if not options: options = InetdOptions() options.parseOptions() conf = inetdconf.InetdConf() conf.parseFile(open(options['file'])) app = Application('tinetd') for service in conf.services: if service.protocol != 'tcp' or service.socketType != 'stream': log.msg('Skipping unsupported type/proto... |
request.prepath = [] | prefixLen = 3+request.isSecure()+4+len(path)+len(request.prepath[-3]) | def getChild(self, path, request): if ':' in path: host, port = path.split(':', 1) port = int(port) else: host, port = path, 80 request.setHost(host, port) request.prepath = [] request.path = '/'+'/'.join(request.postpath) return request.site.getResourceFor(request) |
class ISSHUser: | class ISSHUser(components.Interface): | def requestAvatar(self, username, mind, *interfaces): return interfaces[0], UnixSSHUser(username), lambda: None |
for i in range(self.numberAccepts): | if os.name == "posix": numAccepts = self.numberAccepts else: numAccepts = 1 for i in range(numAccepts): | def doRead(self): """Called when my socket is ready for reading. |
def encrypt(passphrase, data): | def _encrypt(passphrase, data): | def encrypt(passphrase, data): from Crypto.Cipher import AES as cipher leftover = len(data) % cipher.block_size if leftover: data += ' '*(cipher.block_size - leftover) return cipher.new(md5.new(passphrase).digest()[:16]).encrypt(data) |
def decrypt(passphrase, data): | def _decrypt(passphrase, data): | def decrypt(passphrase, data): from Crypto.Cipher import AES return AES.new(md5.new(passphrase).digest()[:16]).decrypt(data) |
def setPassword(self, password): pass | def setPassword(self, password): pass | |
f.write(encrypt(passphrase, s.getvalue())) | f.write(_encrypt(passphrase, s.getvalue())) | def _saveTemp(self, filename, passphrase, dumpFunc): f = open(filename, 'wb') if passphrase is None: dumpFunc(self, f) else: s = StringIO.StringIO() dumpFunc(self, s) f.write(encrypt(passphrase, s.getvalue())) f.close() |
fp = StringIO.StringIO(open(filename, 'rb').read()) | fp = StringIO.StringIO(_decrypt(open(filename, 'rb').read())) | def load(filename, style, passphrase=None): mode = 'r' if style=='source' from twisted.persisted.marmalade import unjellyFromXML as load elif style=='xml': from twisted.persisted.aot import unjellyFromSource as load else: from cPickle import load mode = 'rb' if passphrase: fp = StringIO.StringIO(open(filename, 'rb').re... |
entry.set_position(oldpos+len(result[0])-len(word)-1) | entry.set_position(oldpos+len(result[0])-len(word)) | def handle_key_press_event(self, entry, event): stopSignal = False # ASSUMPTION: Assume Meta == mod4 isMeta = event.state & gtk.GDK.MOD4_MASK |
usedFiles = [] | def isInKnownHosts(host, pubKey, options): """checks to see if host is in the known_hosts file for the user. returns 0 if it isn't, 1 if it is and is the same, 2 if it's changed. """ keyType = common.getNS(pubKey)[0] retVal = 0 if not options['known-hosts'] and not os.path.exists(os.path.expanduser('~/.ssh/')): print ... | |
except KeyboardInterrupt, e: | except (KeyboardInterrupt, IOError): | def getPassword(self, prompt = None): if not prompt: prompt = "%s@%s's password: " % (self.user, self.transport.transport.getPeer().host) try: oldout, oldin = sys.stdout, sys.stdin sys.stdin = sys.stdout = open('/dev/tty','r+') p=getpass.getpass(prompt) sys.stdout,sys.stdin=oldout,oldin return defer.succeed(p) except K... |
"wcfactory_ instead", DeprecationWarning) | "wvfactory_ instead", DeprecationWarning) | def getNodeView(self, request, node, submodel, model): namespaces = [] view = None viewName = node.getAttribute('view') |
If there is no buffered data this tries to write this data immediately, otherwise this adds data to be written the next time this file descriptor is ready for writing. | The data is buffered until his file descriptor is ready for writing. | def write(self, data): """Reliably write some data. |
reactor.callLater(10, self.timeOut) | self.id = reactor.callLater(10, self.timeOut) | def runClient(self): pb.connect("localhost", PORTNO, "guest", "guest", "pbfailure", "guest", 30).addCallbacks(self.connected, self.notConnected) reactor.callLater(10, self.timeOut) |
reactor.stop() | self.stopReactor() | def notConnected(self, fail): reactor.stop() raise pb.Error("There's probably something wrong with your environment" "(is port 54321 free?), because I couldn't connect to myself.") |
if self.total == 3: self.stopReactor() | def success(self, result): if result in [42, 420, 4200]: self.total = self.total + 1 | |
if self.total != 3: raise TimeoutError("Never got all three failures!") | raise TimeoutError("Never got all three failures!") | def timeOut(self): reactor.stop() if self.total != 3: raise TimeoutError("Never got all three failures!") |
_setUpLogging(self) | def postOptions(self): self['_origdir'] = os.getcwd() # Want to do this stuff as early as possible _setUpTestdir() _setUpLogging(self) if self['suppresswarnings']: warnings.warn('--suppresswarnings deprecated. Is a no-op', category=DeprecationWarning) if not self.has_key('tbformat'): self['tbformat'] = 'default' if sel... | |
def __init__(self, methodName=None): | def __init__(self, methodName): | def __init__(self, methodName=None): super(TestCase, self).__init__(methodName) self._testMethodName = methodName testMethod = getattr(self, methodName) self._parents = [testMethod, self] self._parents.extend(util.getPythonContainers(testMethod)) self._shared = (hasattr(self, 'setUpClass') or hasattr(self, 'tearDownCla... |
df = lambda file, linkrel: self.doFile[0](file, linkrel, d['ext'], | df = lambda file, linkrel: self.doFile[0](file, linkrel, ext, | def generate_html(self, d): n = htmlDefault.copy() n.update(d) d = n if d['ext'] == "None": ext = "" else: ext = d['ext'] try: fp = open(d['template']) templ = microdom.parse(fp) except IOError, e: raise process.NoProcessorError(e.filename+": "+e.strerror) except sux.ParseError, e: raise process.NoProcessorError(str(e)... |
import thread | def preWait(self, key): import thread global ioThread if thread.get_ident() == ioThread: return _Waiter.preWait(self, key) import thread import threading cond = self.conditions[key] = threading.Condition() cond.acquire() | |
if thread.get_ident() == ioThread: | if threadmodule.get_ident() == ioThread: | def preWait(self, key): import thread global ioThread if thread.get_ident() == ioThread: return _Waiter.preWait(self, key) import thread import threading cond = self.conditions[key] = threading.Condition() cond.acquire() |
import thread import threading cond = self.conditions[key] = threading.Condition() | cond = self.conditions[key] = threadingmodule.Condition() | def preWait(self, key): import thread global ioThread if thread.get_ident() == ioThread: return _Waiter.preWait(self, key) import thread import threading cond = self.conditions[key] = threading.Condition() cond.acquire() |
import thread | def wait(self, key): import thread global ioThread if thread.get_ident() == ioThread: return _Waiter.wait(self, key) cond = self.conditions[key] cond.wait() # ... r, is_ok = self.results[key] del self.conditions[key] del self.results[key] cond.release() if is_ok: return r else: raise r | |
if thread.get_ident() == ioThread: | if threadmodule.get_ident() == ioThread: | def wait(self, key): import thread global ioThread if thread.get_ident() == ioThread: return _Waiter.wait(self, key) cond = self.conditions[key] cond.wait() # ... r, is_ok = self.results[key] del self.conditions[key] del self.results[key] cond.release() if is_ok: return r else: raise r |
import thread self.block = thread.allocate_lock() | self.block = threadmodule.allocate_lock() | def __init__(self): assert threaded,\ "Locks may not be allocated in an unthreaded environment!" import thread self.block = thread.allocate_lock() self.count = 0 self.owner = 0 |
import thread current = thread.get_ident() | current = threadmodule.get_ident() | def acquire(self): import thread current = thread.get_ident() if self.owner == current: self.count = self.count + 1 return 1 self.block.acquire() self.owner = current self.count = 1 |
import thread current = thread.get_ident() | current = threadmodule.get_ident() | def release(self): import thread current = thread.get_ident() if self.owner != current: raise "Release of unacquired lock." self.count = self.count - 1 if self.count == 0: self.owner = None self.block.release() |
import thread if (ioThread == thread.get_ident()): | if (ioThread == threadmodule.get_ident()): | def isInIOThread(): """Are we in the thread responsable for I/O requests (the event loop)? """ global threaded global ioThread if threaded: import thread if (ioThread == thread.get_ident()): return 1 else: return 0 return 1 |
self.assertIdentical(1._connection, None) | self.assertIdentical(t._connection, None) | def testVolatile(self): if not interfaces.IReactorUNIX(reactor, None): raise unittest.SkipTest, "This reactor does not support UNIX domain sockets" factory = protocol.ServerFactory() factory.protocol = wire.Echo t = internet.UNIXServer('echo.skt', factory) t.startService() self.failIfIdentical(t._port, None) t1 = copy.... |
return '"' + _cmdLineQuoteRe.sub(r'\1\1\\"', s) + '"' | quote = ((" " in s) or ("\t" in s) or ('"' in s)) and '"' or '' return quote + _cmdLineQuoteRe2.sub(r"\1\1", _cmdLineQuoteRe.sub(r'\1\1\\"', s)) + quote | def _cmdLineQuote(s): return '"' + _cmdLineQuoteRe.sub(r'\1\1\\"', s) + '"' |
self.suffix = '\x00' * self.bytes + readPrecisely(strio, 16 - self.bytes) | self.suffix = '\x00' * (16 - self.bytes) + readPrecisely(strio, self.bytes) | def decode(self, strio, length = None): self.prefixLen = struct.unpack('!B', readPrecisely(strio, 1))[0] self.bytes = int(self.prefixLen / 8.0) if self.prefixLen != 128: self.suffix = '\x00' * self.bytes + readPrecisely(strio, 16 - self.bytes) if self.prefixLen != 0: self.prefix.decode(strio) |
self._parseError("Invalid intial attribute value: %r" % byte) | self._parseError("Invalid initial attribute value: %r" % byte) | def do_beforeattrval(self, byte): if byte in '"\'': return 'attrval' elif byte.isspace(): return elif self.beExtremelyLenient: if byte in lenientIdentChars or byte.isalnum(): return 'messyattr' if byte == '>': self.attrval = 'True' self.tagAttributes[self.attrname] = self.attrval self.gotTagStart(self.tagName, self.tag... |
p = [p.type for p in p.result] | p = [str(p).lower() for p in p.result] | def testFetchParserMacros(self): cases = [ ['ALL', (4, ['flags', 'internaldate', 'rfc822.size', 'envelope'])], ['FULL', (5, ['flags', 'internaldate', 'rfc822.size', 'envelope', 'body'])], ['FAST', (3, ['flags', 'internaldate', 'rfc822.size'])], ] |
modified_since = stringToDatetime(modified_since) | modified_since = stringToDatetime(modified_since.split(';', 1)[0]) | def setLastModified(self, when): """Set the X{Last-Modified} time for the response to this request. |
os.setgid(gid) | def __init__(self, reactor, command, args, environment, path, proto, uid=None, gid=None): """Spawn an operating-system process. | |
stderr = os.fdopen(fd, 'w') stderr.write("Upon execvpe %s %s in environment %s\n:" % | stderr = os.fdopen(1, 'w') stderr.write("Upon execvpe %s %s in environment %s:\n" % | def __init__(self, reactor, command, args, environment, path, proto, uid=None, gid=None): """Spawn an operating-system process. |
tk.Label(statusFrame, textvariable=self.statusVar).pack(side=tk.LEFT) | tk.Label(statusFrame, textvariable=self.statusVar, width=80, anchor="w").pack(side=tk.LEFT) | def createWidgets(self): """Creates and packs the various widgets. |
dump(compiledTemplate, open(compiledTemplateName, 'wb'), 1) | dump(compiledTemplate, open(compiledTemplatePath, 'wb'), 1) | def lookupTemplate(self, request): """ Use acquisition to look up the template named by self.templateFile, located anywhere above this object in the heirarchy, and use it as the template. The first time the template is used it is cached for speed. """ if not self.templateDirectory: self.templateDirectory = os.path.spli... |
if not reason.check(error.UserError): | if not reason.check(error.UserError) or reason.check(TimeoutError): | def clientConnectionFailed(self, connector, reason): if self.continueTrying: self.connector = connector if not reason.check(error.UserError): self.retry() |
if not os.path.exists(path) or hasattr(self, 'lastPublicKey'): | if not os.path.exists(path) or self.lastPublicKey: | def getPublicKey(self): path = os.path.expanduser('~/.ssh/id_dsa') # this works with rsa too # just change the name here and in getPrivateKey if not os.path.exists(path) or hasattr(self, 'lastPublicKey'): # the file doesn't exist, or we've tried a public key return return keys.getPublicKeyString(path+'.pub') |
"useranonymous": [types.StringType, "Anonymous Username", "Username for anonymous users, typically 'username'."], "otp": ["boolean", "OTP", "Use One time passwords."], | "useranonymous": [types.StringType, "Anonymous Username", "Username for anonymous users, typically 'anonymous'."], "otp": ["boolean", "OTP", "Use One Time Passwords."], | def getNameType(self): return "Username" |
"thirdparty": ["boolean", "Allow 3rd-party Transfers", "Allow A to forward data to B. May be a security risk"], | "thirdparty": ["boolean", "Allow 3rd-party Transfers", "Allow A to forward data to B. May be a security risk."], | def getNameType(self): return "Username" |
print 'adding', str(port[0]), port[1] | def listStaticEntities(self): ret = [] for port in getattr(self.app, '%sPorts' % self.ptype): print 'adding', str(port[0]), port[1] ret.append((str(port[0]), port[1])) return ret | |
print "?", port[0] | def getStaticEntity(self, name): idx = int(name) #for port in self.ports: for port in getattr(self.app, '%sPorts' % self.ptype): print "?", port[0] if port[0] == idx: print "ret",port[1] return port[1] raise KeyError, "No such entity %s" % (name,) | |
print "ret",port[1] | def getStaticEntity(self, name): idx = int(name) #for port in self.ports: for port in getattr(self.app, '%sPorts' % self.ptype): print "?", port[0] if port[0] == idx: print "ret",port[1] return port[1] raise KeyError, "No such entity %s" % (name,) | |
reactor.iterate() reactor.iterate() | def setUp(self): self.f = f = MyServerFactory() self.p = p = reactor.listenTCP(0, f, interface="127.0.0.1") reactor.iterate() reactor.iterate() # XXX we don't test server side yet since we don't do it yet d = protocol.ClientCreator(reactor, MyProtocol).connectTCP( p.getHost().host, p.getHost().port) d.addCallback(self.... | |
__implements__ = (Referenceable.__implements__, IUsernameHashedPassword, IUsernameMD5Password) | implements(IUsernameHashedPassword, IUsernameMD5Password) | def remote_login(self, username): """Start of username/password login.""" c = challenge() return c, _PortalAuthChallenger(self, username, c) |
if se.args[0] in (EWOULDBLOCK, EALREADY, EINPROGRESS): | print "SR DEBUG:", se.args[0], EWOULDBLOCK, EALREADY, EINPROGRESS if se.args[0] == EMYSTERY: | def doConnect(self): """I connect the socket. Then, call the protocol's makeConnection, and start waiting for data. """ try: self.socket.connect(self.addr) except socket.error, se: if se.args[0] in (EWOULDBLOCK, EALREADY, EINPROGRESS): self.startWriting() else: self.protocol.connectionFailed() self.stopWriting() retur... |
path = self.filename | path = os.path.basename(self.filename) | def visitNode_a_href(self, node): supported_schemes=['http', 'https', 'ftp', 'mailto'] self.visitNodeDefault(node) href = node.getAttribute('href') if urlparse.urlparse(href)[0] in supported_schemes: text = domhelpers.getNodeText(node) if text != href: self.writer('\\footnote{%s}' % latexEscape(href)) else: path, fragi... |
self.writer('\\label{%sHASH%s}' % (self.filename, | self.writer('\\label{%sHASH%s}' % (os.path.basename(self.filename), | def visitNode_a_name(self, node): self.writer('\\label{%sHASH%s}' % (self.filename, node.getAttribute('name'))) self.visitNodeDefault(node) |
self.writer('\\label{%s}}\n' % self.filename) | self.writer('\\label{%s}}\n' % os.path.basename(self.filename)) | def visitNode_title(self, node): self.writer('\\section{') self.visitNodeDefault(node) self.writer('\\label{%s}}\n' % self.filename) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.