bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def url_norm (url): """ Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return: (normed url, idna flag) @rtype: tuple of length two """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # mailto: urlsplit ... | def url_norm (url): """ Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return: (normed url, idna flag) @rtype: tuple of length two """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # mailto: urlsplit ... | 15,400 |
def create_conf_file (self, data, directory=None): """create local config file from given data (list of lines) in the directory (or current directory if not given) """ data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.g... | def create_conf_file (self, data, directory=None): """create local config file from given data (list of lines) in the directory (or current directory if not given) """ data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.g... | 15,401 |
def create_conf_file (self, data, directory=None): """create local config file from given data (list of lines) in the directory (or current directory if not given) """ data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.g... | def scripts = [ 'webcleaner', 'webcleaner-certificates', ] if os.name=='nt' or win_cross_compiling: scripts.append('install-webcleaner.py') create_conf_file scripts = [ 'webcleaner', 'webcleaner-certificates', ] if os.name=='nt' or win_cross_compiling: scripts.append('install-webcleaner.py') (self, scripts = [ 'web... | 15,402 |
def create_conf_file (self, data, directory=None): """create local config file from given data (list of lines) in the directory (or current directory if not given) """ data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.g... | def create_conf_file (self, data, directory=None): """create local config file from given data (list of lines) in the directory (or current directory if not given) """ data.insert(0, "# this file is automatically created by setup.py") data.insert(0, "# -*- coding: iso-8859-1 -*-") if directory is None: directory = os.g... | 15,403 |
def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re.... | def process_headers (self): # Headers are terminated by a blank line .. now in the regexp, # we want to say it's either a newline at the beginning of # the document, or it's a lot of headers followed by two newlines. # The cleaner alternative would be to read one line at a time # until we get to a blank line... m = re.... | 15,404 |
def process_content (self): data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we're done self.bytes_remaining -= len(data) debug(PROXY, "%s %d bytes remaining", str(self), self.bytes_remaining) is_closed = Fal... | def process_content (self): data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we're done self.bytes_remaining -= len(data) debug(PROXY, "%s %d bytes remaining", str(self), self.bytes_remaining) is_closed = Fal... | 15,405 |
def process_content (self): data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we're done self.bytes_remaining -= len(data) debug(PROXY, "%s %d bytes remaining", str(self), self.bytes_remaining) is_closed = Fal... | def process_content (self): data = self.read(self.bytes_remaining) if self.bytes_remaining is not None: # If we do know how many bytes we're dealing with, # we'll close the connection when we're done self.bytes_remaining -= len(data) debug(PROXY, "%s %d bytes remaining", str(self), self.bytes_remaining) is_closed = Fal... | 15,406 |
def flush (self): """flush data of decoders (if any) and filters""" debug(PROXY, "%s flushing", str(self)) self.flushing = True data = "" while self.decoders: data = self.decoders[0].flush() del self.decoders[0] for decoder in self.decoders: data = decoder.decode(data) try: for i in [FILTER_RESPONSE_DECODE, FILTER_RESP... | def flush (self): """flush data of decoders (if any) and filters""" debug(PROXY, "%s flushing", str(self)) self.flushing = True data = "" while self.decoders: data = self.decoders[0].flush() del self.decoders[0] for decoder in self.decoders: data = decoder.decode(data) try: for i in _response_filters: data = applyfilte... | 15,407 |
def get_file_list (self): super(MySdist, self).get_file_list() self.filelist.append("MANIFEST") | def get_file_list (self): super(MySdist, self).get_file_list() self.filelist.append("MANIFEST") | 15,408 |
def getAttrs (self, headers, url): # weed out the rules that dont apply to this url rules = filter(lambda r, u=url: r.appliesTo(u), self.rules) if not rules: return {} return {'buf': Buf(rules)} | def getAttrs (self, headers, url): # weed out the rules that dont apply to this url rules = filter(lambda r, u=url: r.appliesTo(u), self.rules) if not rules: return {} return {'buf': Buf(rules)} | 15,409 |
def __init__ (self, rules): self.buf = "" self.rules = rules | def __init__ (self, rules): self.buf = "" self.rules = rules | 15,410 |
def replace (self, data): data = self.buf + data for rule in self.rules: data = rule.search.sub(rule.replace, data) self.buf = data[-BUF_SIZE:] return data[:-BUF_SIZE] | def replace (self, data): self.buf += data if len(self.buf) > 512: self._replace() if len(self.buf) > 256: data = self.buf self.buf = self.buf[-256:] return data[:-256] return "" def _replace (self): for rule in self.rules: data = rule.search.sub(rule.replace, data) self.buf = data[-BUF_SIZE:] return data[:-BUF_SIZE] | 15,411 |
def replace (self, data): data = self.buf + data for rule in self.rules: data = rule.search.sub(rule.replace, data) self.buf = data[-BUF_SIZE:] return data[:-BUF_SIZE] | def replace (self, data): data = self.buf + data for rule in self.rules: data = rule.search.sub(rule.replace, data) self.buf = data[-BUF_SIZE:] return data[:-BUF_SIZE] | 15,412 |
def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | 15,413 |
def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | 15,414 |
def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | 15,415 |
def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | def __init__ (self, parent, rule, index): """initialize pics rule display frame""" FXRuleFrame.__init__(self, parent, rule, index) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_URL,FXPicsRuleFrame.onCmdUrl) FXMAPFUNC(self,SEL_COMMAND,FXPicsRuleFrame.ID_SERVICE,FXPicsRuleFrame.onCmdService) FXMAPFUNC(self,SEL_COMMAND,FX... | 15,416 |
def create_message1 (flags=0xb203): "" # overall lenght = 48 bytes protocol = 'NTLMSSP\000' #name type = '\001\000' #type 1 zeros1 = '\000\000' flags = utils.hex2str(flags) zeros2 = '\000\000\000\000\000\000\000\000\000' zeros3 = '\000\000\000\000\000\000\000\000\000\000\000' smthg1 = '0\000\000\000\... | def create_message1 (flags="\xb2\x03"): # overall lenght = 48 bytes protocol = 'NTLMSSP\000' #name type = '\001\000' #type 1 zeros1 = '\000\000' flags = utils.hex2str(flags) zeros2 = '\000\000\000\000\000\000\000\000\000' zeros3 = '\000\000\000\000\000\000\000\000\000\000\000' smthg1 = '0\000\000\000... | 15,417 |
def create_message1 (flags=0xb203): "" # overall lenght = 48 bytes protocol = 'NTLMSSP\000' #name type = '\001\000' #type 1 zeros1 = '\000\000' flags = utils.hex2str(flags) zeros2 = '\000\000\000\000\000\000\000\000\000' zeros3 = '\000\000\000\000\000\000\000\000\000\000\000' smthg1 = '0\000\000\000\... | def create_message1 (flags=0xb203): "" # overall lenght = 48 bytes protocol = 'NTLMSSP\000' #name type = '\001\000' #type 1 zeros1 = '\000\000' flags = utils.hex2str(flags) zeros2 = '\000\000\000\000\000\000\000\000\000' zeros3 = '\000\000\000\000\000\000\000\000\000\000\000' smthg1 = '0\000\000\000\... | 15,418 |
def create_message2 (flags=0x8201): "" protocol = 'NTLMSSP\x00' #name type = '\x02' msglen = '\x28' flags = utils.hex2str(flags) nonce = "%08f" % (random.random()*10) assert nonce not in nonces nonces[nonce] = None zero2 = '\x00' * 2 zero7 = '\x00' * 7 zero8 = '\x00' * 8 return "%(protocol)s%(type)s%(zero7)s%(msglen... | def create_message2 (flags=0x8201): "" protocol = 'NTLMSSP\x00' #name type = '\x02' msglen = '\x28' nonce = "%08f" % (random.random()*10) assert nonce not in nonces nonces[nonce] = None zero2 = '\x00' * 2 zero7 = '\x00' * 7 zero8 = '\x00' * 8 return "%(protocol)s%(type)s%(zero7)s%(msglen)s%(zero2)s%(nonce)s%(zero8)s... | 15,419 |
def create_message2 (flags=0x8201): "" protocol = 'NTLMSSP\x00' #name type = '\x02' msglen = '\x28' flags = utils.hex2str(flags) nonce = "%08f" % (random.random()*10) assert nonce not in nonces nonces[nonce] = None zero2 = '\x00' * 2 zero7 = '\x00' * 7 zero8 = '\x00' * 8 return "%(protocol)s%(type)s%(zero7)s%(msglen... | def create_message2 (flags=0x8201): "" protocol = 'NTLMSSP\x00' #name type = '\x02' msglen = '\x28' flags = utils.hex2str(flags) nonce = "%08f" % (random.random()*10) assert nonce not in nonces nonces[nonce] = None zero2 = '\x00' * 2 zero7 = '\x00' * 7 zero8 = '\x00' * 8 return "%(protocol)s%(type)s%(zero7)s%(msglen... | 15,420 |
def create_message3 (nonce, domain, username, host, flags=0x8201, lm_hashed_pw=None, nt_hashed_pw=None, ntlm_mode=0): "" flags = utils.hex2str(flags) protocol = 'NTLMSSP\000' #name type = '\003\000' #type 3 head = protocol + type + '\000\000' domain_rec = record(domain) user_rec = record(... | def create_message3 (nonce, domain, username, host, flags=0x8201, lm_hashed_pw=None, nt_hashed_pw=None, ntlm_mode=0): protocol = 'NTLMSSP\000' #name type = '\003\000' #type 3 head = protocol + type + '\000\000' domain_rec = record(domain) user_rec = record(username) host_rec = record(host)... | 15,421 |
def create_message3 (nonce, domain, username, host, flags=0x8201, lm_hashed_pw=None, nt_hashed_pw=None, ntlm_mode=0): "" flags = utils.hex2str(flags) protocol = 'NTLMSSP\000' #name type = '\003\000' #type 3 head = protocol + type + '\000\000' domain_rec = record(domain) user_rec = record(... | def create_message3 (nonce, domain, username, host, flags=0x8201, lm_hashed_pw=None, nt_hashed_pw=None, ntlm_mode=0): "" flags = utils.hex2str(flags) protocol = 'NTLMSSP\000' #name type = '\003\000' #type 3 head = protocol + type + '\000\000' domain_rec = record(domain) user_rec = record(... | 15,422 |
def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | def error(self, code, msg, txt=''): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | 15,423 |
def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': 'WebCleaner Proxy Error %d %s' % (code, msg), 'header': 'Bummer!', 'content': 'WebCleaner Proxy Error %d %s<br>%s<br>' % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | 15,424 |
def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' http_ver = '... | 15,425 |
def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | def error(self, code, msg, txt=""): content = wc.proxy.HTML_TEMPLATE % \ {'title': "WebCleaner Proxy Error %d %s" % (code, msg), 'header': "Bummer!", 'content': "WebCleaner Proxy Error %d %s<br>%s<br>" % \ (code, msg, txt), } if config['proxyuser']: auth = 'Proxy-Authenticate: Basic realm="WebCleaner"\r\n' else: auth =... | 15,426 |
def __init__(self, client, request, headers, content, nofilter): self.client = client self.request = request self.headers = headers if config["proxyuser"]: if not self.headers.has_key("Proxy-Authorization"): self.error(407, _("Proxy Authentication Required")) return auth = self.headers['Proxy-Authorization'] # XXX more... | def __init__(self, client, request, headers, content, nofilter): self.client = client self.request = request self.headers = headers if config["proxyuser"]: if not self.check_proxy_auth(): self.error(407, _("Proxy Authentication Required")) return auth = self.headers['Proxy-Authorization'] # XXX more self.content = cont... | 15,427 |
def __init__(self, client, request, headers, content, nofilter): self.client = client self.request = request self.headers = headers if config["proxyuser"]: if not self.headers.has_key("Proxy-Authorization"): self.error(407, _("Proxy Authentication Required")) return auth = self.headers['Proxy-Authorization'] # XXX more... | def __init__(self, client, request, headers, content, nofilter): self.client = client self.request = request self.headers = headers if config["proxyuser"]: if not self.headers.has_key("Proxy-Authorization"): self.error(407, _("Proxy Authentication Required")) return auth = self.headers['Proxy-Authorization'] # XXX more... | 15,428 |
def run (self): if self.all: # remove share directory directory = os.path.join("build", "share") if os.path.exists(directory): remove_tree(directory, dry_run=self.dry_run) else: distutils.log.warn("'%s' does not exist -- can't clean it", directory) clean.run(self) | def run (self): if self.all: # remove share directory directory = os.path.join("build", "share") if os.path.exists(directory): remove_tree(directory, dry_run=self.dry_run) else: distutils.log.warn("'%s' does not exist -- can't clean it", directory) clean.run(self) | 15,429 |
def valid_mail (address): """return cleaned up mail, or an empty string on errors""" return email.parseaddr(address)[1] | def valid_mail (address): """return cleaned up mail, or an empty string on errors""" cleaned = parseaddr(address) if not cleaned[0]: return cleaned[1] return '%s <%s>'%cleaned | 15,430 |
def handle_dns (self, hostname, answer): assert self.state == 'dns' debug(PROXY, "%s handle dns", self) if not self.client.connected: warn(PROXY, "%s client closed after DNS", self) # The browser has already closed this connection, so abort return if answer.isFound(): self.ipaddr = answer.data[0] self.state = 'server' ... | def handle_dns (self, hostname, answer): assert self.state == 'dns' debug(PROXY, "%s handle dns", self) if not self.client.connected: warn(PROXY, "%s client closed after DNS", self) # The browser has already closed this connection, so abort return if answer.isFound(): self.ipaddr = answer.data[0] self.state = 'server' ... | 15,431 |
def get_root_handler (): """return a handler for basic logging""" if os.name=="nt": from logging.handlers import NTEventLogHandler return set_format(NTEventLogHandler(Name)) logfile = get_log_file("%s.err"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = WcRotatingF... | def get_root_handler (): """return a handler for basic logging""" if os.name=="nt": from logging.handlers import NTEventLogHandler return set_format(NTEventLogHandler(Name)) logfile = get_log_file("%s.err"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = RotatingFil... | 15,432 |
def get_wc_handler (): """return a handler for webcleaner logging""" if os.name=="nt": from logging.handlers import NTEventLogHandler return set_format(NTEventLogHandler(Name)) logfile = get_log_file("%s.log"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = WcRotati... | def get_wc_handler (): """return a handler for webcleaner logging""" if os.name=="nt": from logging.handlers import NTEventLogHandler return set_format(NTEventLogHandler(Name)) logfile = get_log_file("%s.log"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = Rotating... | 15,433 |
def get_access_handler (): """return a handler for access logging""" logfile = get_log_file("%s-access.log"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = WcRotatingFileHandler(logfile, mode, maxBytes, backupCount) # log only the message handler.setFormatter(loggi... | def get_access_handler (): """return a handler for access logging""" logfile = get_log_file("%s-access.log"%Name) mode = 'a' maxBytes = 1024*1024*2 # 2 MB backupCount = 5 # number of files to generate handler = RotatingFileHandler(logfile, mode, maxBytes, backupCount) # log only the message handler.setFormatter(logging... | 15,434 |
def get_last_word_boundary (s, width): """Get maximal index i of a whitespace char in s with 0 < i < width. Note: if s contains no whitespace this returns width-1""" match = re.compile(".*\s").match(s[0:width]) if match: return match.end() return width-1 | def get_last_word_boundary (s, width): """Get maximal index i of a whitespace char in s with 0 < i < width. Note: if s contains no whitespace this returns width-1""" match = re.compile(".*\s").match(s[0:width]) if match: return match.end() return width-1 | 15,435 |
def map2hosts (hostmap): ret = hostmap[0].copy() for net, mask in hostmap[1]: ret.add("%s/%d" % (net, mask2suffix(mask))) return ret | def map2hosts (hostmap): ret = hostmap[0].copy() for net, mask in hostmap[1]: ret.add("%s/%d" % (num2dq(net), mask2suffix(mask))) return ret | 15,436 |
def _test (): hosts, nets = hosts2map(["192.168.1.1/16"]) for net, mask in nets: print num2dq(net), mask2suffix(mask) | def _test (): hosts = ["192.168.1.1/16"] hostmap = hosts2map(hosts) print hostmap print map2hosts(hostmap) | 15,437 |
def classify (fp, magicdir=wc.ConfigDir): """ Classify a file. """ global _magic if _magic is None: # initialize mime data magicfile = os.path.join(magicdir, "magic.mime") assert os.path.exists(magicfile) magiccache = magicfile+".mgc" _magic = Magic(magicfile, magiccache) pos = fp.tell() mime = _magic.classify(fp) fp.s... | def classify (fp, magicdir=wc.ConfigDir): """ Classify a file. """ global _magic if _magic is None: # initialize mime data magicfile = os.path.join(magicdir, "magic.mime") assert os.path.exists(magicfile) magiccache = magicfile + ".mgc" _magic = Magic(magicfile, magiccache) pos = fp.tell() mime = _magic.classify(fp) fp... | 15,438 |
def classify (self, f): if not self.entries: raise StandardError("Not initialised properly") # Are we still looking for the ruleset to apply or are we in a rule found_rule = False # If we failed part of the rule there is no point looking for # higher level subrule allow_next = 0 # String provided by the successfull rul... | def classify (self, f): if not self.entries: raise StandardError("Not initialised properly") # Are we still looking for the ruleset to apply or are we in a rule found_rule = False # If we failed part of the rule there is no point looking for # higher level subrule allow_next = 0 # String provided by the successfull rul... | 15,439 |
def __repr__ (self): """return listener class and address""" return '<Listener:%s>' % self.addr | def __repr__ (self): """return listener class and address""" return '<Listener:%s>' % self.addr | 15,440 |
def fill_attrs (self, attrs, name): if name=='pics': UrlRule.fill_attrs(self, attrs, name) elif name=='service': self.service = unxmlify(attrs.get('name')).encode('iso8859-1') self.ratings[service] = {} elif name=='category': assert self.service self.category = unxmlify(attrs.get('name')).encode('iso8859-1') else: rais... | def fill_attrs (self, attrs, name): if name=='pics': UrlRule.fill_attrs(self, attrs, name) elif name=='service': self.service = unxmlify(attrs.get('name')).encode('iso8859-1') self.ratings[self.service] = {} elif name=='category': assert self.service self.category = unxmlify(attrs.get('name')).encode('iso8859-1') else:... | 15,441 |
def status (pidfile): if os.path.exists(pidfile): pid = ing(file(pidfile).read()) return i18n._("WebCleaner is running (PID %d)")%pid, 0 else: return i18n._("WebCleaner is not running (no lock file found)"), 3 | def status (pidfile): if os.path.exists(pidfile): pid = int(file(pidfile).read()) return i18n._("WebCleaner is running (PID %d)")%pid, 0 else: return i18n._("WebCleaner is not running (no lock file found)"), 3 | 15,442 |
def onCmdConfUpdate (self, sender, sel, ptr): """download files from http://webcleaner.sourceforge.net/zapper/ and copy them over the existing config""" # base url for all files from wc import BaseUrl dialog = FXMessageBox(self,i18n._("Update Help"),UpdateHelp % BaseUrl,None,MBOX_OK_CANCEL) if self.getApp().doShow(dial... | def onCmdConfUpdate (self, sender, sel, ptr): """download files from http://webcleaner.sourceforge.net/zapper/ and copy them over the existing config""" # base url for all filesdoreload = False from wc import update, BaseUrl, Configuration dialog = FXMessageBox(self,i18n._("Update Help"),UpdateHelp % BaseUrl,None,MBOX_... | 15,443 |
def onCmdConfUpdate (self, sender, sel, ptr): """download files from http://webcleaner.sourceforge.net/zapper/ and copy them over the existing config""" # base url for all files from wc import BaseUrl dialog = FXMessageBox(self,i18n._("Update Help"),UpdateHelp % BaseUrl,None,MBOX_OK_CANCEL) if self.getApp().doShow(dial... | def onCmdConfUpdate (self, sender, sel, ptr): """download files from http://webcleaner.sourceforge.net/zapper/ and copy them over the existing config""" # base url for all files from wc import BaseUrl dialog = FXMessageBox(self,i18n._("Update Help"),UpdateHelp % BaseUrl,None,MBOX_OK_CANCEL) if self.getApp().doShow(dial... | 15,444 |
def SvcDoRun (self): """start this service""" import servicemanager # Log a "started" message to the event log. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '')) wc.wstartfunc(handle=self.hWaitStop, confdir=self.configdir, filelogs=self.filelogs)... | def SvcDoRun (self): """start this service""" import servicemanager # Log a "started" message to the event log. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '')) wc.start.wstartfunc(handle=self.hWaitStop, confdir=self.configdir, filelogs=self.fil... | 15,445 |
def filterEndElement (self, tag): # remember: self.rulestack[-1][1] is the rulelist that # matched for a start tag. and if the first one ([0]) # matches, all other match too if self.rulestack and self.rulestack[-1][1][0].match_tag(tag): pos, rulelist = self.rulestack.pop() for rule in rulelist: if rule.match_complete(p... | def filterEndElement (self, tag): # remember: self.rulestack[-1][1] is the rulelist that # matched for a start tag. and if the first one ([0]) # matches, all other match too if self.rulestack and self.rulestack[-1][1][0].match_tag(tag) and \ self.stackcount[-1][0]==tag and self.stackcount[-1][1]<=0: del self.stackcount... | 15,446 |
def doit (self, data, **args): debug(FILTER, "block filter working on %s", `data`) splitted = data.split() if len(splitted)!=3: error(FILTER, "invalid request: %s", `data`) return data method,url,protocol = splitted urlTuple = list(urlparse.urlparse(url)) netloc = urlTuple[1] s = netloc.split(":") if len(s)==2: urlTupl... | def doit (self, data, **args): debug(FILTER, "block filter working on %s", `data`) splitted = data.split() if len(splitted)!=3: error(FILTER, "invalid request: %s", `data`) return data method,url,protocol = splitted urlTuple = list(urlparse.urlparse(url)) netloc = urlTuple[1] s = netloc.split(":") if len(s)==2: urlTupl... | 15,447 |
def doit (self, data, **args): debug(FILTER, "block filter working on %s", `data`) splitted = data.split() if len(splitted)!=3: error(FILTER, "invalid request: %s", `data`) return data method,url,protocol = splitted urlTuple = list(urlparse.urlparse(url)) netloc = urlTuple[1] s = netloc.split(":") if len(s)==2: urlTupl... | def doit (self, data, **args): debug(FILTER, "block filter working on %s", `data`) splitted = data.split() if len(splitted)!=3: error(FILTER, "invalid request: %s", `data`) return data method,url,protocol = splitted urlTuple = list(urlparse.urlparse(url)) netloc = urlTuple[1] s = netloc.split(":") if len(s)==2: urlTupl... | 15,448 |
def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" rulelist = [] filtered = 0 # default data tobuffer = (STARTTAG, tag, attrs) # look for filter rules which apply for rule in self.rules: if rule.match_tag(tag) and r... | def startElement (self, tag, attrs): """We get a new start tag. New rules could be appended to the pending rules. No rules can be removed from the list.""" rulelist = [] filtered = 0 # default data tobuffer = (STARTTAG, tag, attrs) # look for filter rules which apply for rule in self.rules: if rule.match_tag(tag) and r... | 15,449 |
def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = attrs[name] if not val: return self.jsEnv.attachListener(self) self.jsEnv.executeScriptAsFunction(val) self.jsEnv.detachListener(self) return self.popup_counter | def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" val = attrs[name] if not val: return self.jsEnv.attachListener(self) self.jsEnv.executeScriptAsFunction(val, 0.0) self.jsEnv.detachListener(self) return self.popup_counter | 15,450 |
def processData (self, data): # XXX pass | def processData (self, data): # XXX pass | 15,451 |
def jsEndElement (self, tag): """parse generated html for scripts""" if tag!='script': return # XXX | defif not self.buffer: print >>sys.stderr, "empty buffer on </script>" return last = self.buffer[-1] if last[0]!=DATA: print >>sys.stderr, "missing body for </script>", last return script = last[1].strip() if script.startswith("<!--"): script = script[4:].strip() self.jsEnv.attachListener(self) self.jsEnv.executeScript... | 15,452 |
def text_headers (): return "\n".join(HEADERS.getall()) or "-" | def text_headers (): return "\n".join(wc.proxy.HEADERS.getall()) or "-" | 15,453 |
def handle_read (self): assert self.connected | def handle_read (self): assert self.connected | 15,454 |
def rating_allow (self, url): """ Asks cache if the rule allows the rating data for given url Looks up cache to find rating data, if not returns a MISSING message. """ klass = wc.filter.rating.storage.pickle.PickleStorage rating_store = wc.filter.rating.storage.get_rating_store(klass) # sanitize url url = wc.filter.rat... | def rating_allow (self, url): """ Asks cache if the rule allows the rating data for given url Looks up cache to find rating data, if not returns a MISSING message. """ rating_store = wc.filter.rating.get_ratings() # sanitize url url = wc.filter.rating.make_safe_url(url) if url in rating_store: return self.check_against... | 15,455 |
def create_batch_file(self, directory, data, filename): filename = os.path.join(directory, filename) # write the batch file util.execute(write_file, (filename, data), "creating %s" % filename, self.verbose>=1, self.dry_run) | defif os.name=='nt': macros = [('YY_NO_UNISTD_H', None)] else: macros = [] create_batch_file(self,if os.name=='nt': macros = [('YY_NO_UNISTD_H', None)] else: macros = [] directory,if os.name=='nt': macros = [('YY_NO_UNISTD_H', None)] else: macros = [] data,if os.name=='nt': macros = [('YY_NO_UNISTD_H', None)] else: mac... | 15,456 |
def get_wc_config (): """ Get WebCleaner configuration object. """ global _wc_config if _wc_config is None: import wc _wc_config = wc.configuration.init() return _wc_config | def get_wc_config (): """ Get WebCleaner configuration object. """ global _wc_config if _wc_config is None: import wc.configuration _wc_config = wc.configuration.init() return _wc_config | 15,457 |
def reserve_server (self, addr): for server,status in self.map.get(addr, {}).items(): if status[0] == 'available': # Let's reuse this one self.map[addr][server] = ('busy', ) debug(PROXY, 'Proxy: reserve_server %s %s', str(addr), str(server)) return server return None | def reserve_server (self, addr): for server,status in self.map.get(addr, {}).items(): if status[0] == 'available': # Let's reuse this one self.map[addr][server] = ('busy', ) debug(PROXY, 'pool reserve %s %s', str(addr), str(server)) return server return None | 15,458 |
def process_read (self): # Assume that the entire answer comes in one packet if self.conntype == 'tcp': if len(self.recv_buffer) < 2: return header = self.recv_buffer[:2] count = dnslib.Lib.unpack16bit(header) if len(self.recv_buffer) < 2+count: return self.read(2) # header data = self.read(count) self.socket.shutdown(... | def process_read (self): # Assume that the entire answer comes in one packet if self.conntype == 'tcp': if len(self.recv_buffer) < 2: return header = self.recv_buffer[:2] count = dnslib.Lib.unpack16bit(header) if len(self.recv_buffer) < 2+count: return self.read(2) # header data = self.read(count) self.socket.shutdown(... | 15,459 |
def _main (): """USAGE: test/run.sh test/getssl.py <https url>""" if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) import wc wc.configuration.config = wc.configuration.init() port = config['port'] sslport = config['sslport'] request(sys.argv[1], sslport) #rawrequest(sys.argv[1], sslport) #rawrequest2(sys.argv[1], s... | def _main (): """USAGE: test/run.sh test/getssl.py <https url>""" if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) import wc.configuration wc.configuration.config = wc.configuration.init() port = config['port'] sslport = config['sslport'] request(sys.argv[1], sslport) #rawrequest(sys.argv[1], sslport) #rawrequest2(... | 15,460 |
def _main (): """USAGE: test/run.sh test/getssl.py <https url>""" if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) import wc wc.configuration.config = wc.configuration.init() port = config['port'] sslport = config['sslport'] request(sys.argv[1], sslport) #rawrequest(sys.argv[1], sslport) #rawrequest2(sys.argv[1], s... | def _main (): """USAGE: test/run.sh test/getssl.py <https url>""" if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) import wc wc.configuration.config = wc.configuration.init() port = wc.configuration.config['port'] sslport = wc.configuration.config['sslport'] request(sys.argv[1], sslport) #rawrequest(sys.argv[1], ss... | 15,461 |
def get_ntlm_challenge (**attrs): """return initial challenge token for ntlm authentication""" ctype = attrs.get('type', 0) if ctype not in (0, 2): raise IOError("Invalid NTLM challenge type") if ctype==0: # initial challenge return "NTLM" if ctype==2: # after getting first credentials return "NTLM %s" % base64.encodes... | def get_ntlm_challenge (**attrs): """return initial challenge token for ntlm authentication""" ctype = attrs.get('type', 0) if ctype==0: # initial challenge return "NTLM" if ctype==2: # after getting first credentials return "NTLM %s" % base64.encodestring(create_message2()).strip() | 15,462 |
def get_ntlm_challenge (**attrs): """return initial challenge token for ntlm authentication""" ctype = attrs.get('type', 0) if ctype not in (0, 2): raise IOError("Invalid NTLM challenge type") if ctype==0: # initial challenge return "NTLM" if ctype==2: # after getting first credentials return "NTLM %s" % base64.encodes... | def get_ntlm_challenge (**attrs): """return initial challenge token for ntlm authentication""" ctype = attrs.get('type', 0) if ctype not in (0, 2): raise IOError("Invalid NTLM challenge type") if ctype==0: # initial challenge return "NTLM" elif ctype==2: # after getting first credentials return "NTLM %s" % base64.encod... | 15,463 |
def get_ntlm_credentials (challenge, **attrs): ctype = attrs.get('type', 1) if ctype not in (1, 3): raise IOError("Invalid NTLM credentials type") if ctype==1: msg = create_message1() elif ctype==3: nonce = attrs['nonce'] domain = attrs['domain'] username = attrs['username'] host = attrs['host'] msg = create_message3(n... | def get_ntlm_credentials (challenge, **attrs): ctype = attrs.get('type', 1) if ctype==1: msg = create_message1() elif ctype==3: nonce = attrs['nonce'] domain = attrs['domain'] username = attrs['username'] host = attrs['host'] msg = create_message3(nonce, domain, username, host) return "NTLM %s" % base64.encodestring(ms... | 15,464 |
def get_ntlm_type3_message (**attrs): # extract the required attributes | def get_ntlm_type3_message (**attrs): # extract the required attributes | 15,465 |
def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] name = frame.f_globals["__name__"] line = linecache.getline(filename, lineno) info... | def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": name = frame.f_globals["__name__"] line = linecache.getline(filename, lineno) info(tracelog, "%s:%s: %s", name, lineno, line.rstrip()) return _traceit | 15,466 |
def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] name = frame.f_globals["__name__"] line = linecache.getline(filename, lineno) info... | def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] name = frame.f_globals["__name__"] if name not in _trace_ignore: lineno = frame.f_... | 15,467 |
def make_safe_url (url): """Remove unsafe parts of url for rating cache check.""" parts = wc.filter.rating.split_url(url) pathparts = [make_safe_part(x) for x in parts[2:]] pathparts[0:2] = parts[0:2] return "".join(pathparts) | def make_safe_url (url): """Remove unsafe parts of url for rating cache check.""" parts = split_url(url) pathparts = [make_safe_part(x) for x in parts[2:]] pathparts[0:2] = parts[0:2] return "".join(pathparts) | 15,468 |
def check_url (self, url): """If url is not safe raise a ValueError.""" if not wc.url.is_safe_url(url): raise ValueError("Invalid rating url %r." % url) | def check_url (self, url): """If url is not safe raise a ValueError.""" if not wc.url.is_safe_url(url): raise ValueError("Invalid rating url %r." % url) | 15,469 |
def __setitem__ (self, url, rating): """Add rating for given url.""" self.check_url(url) self.cache[url] = rating | def __setitem__ (self, url, rating): """Add rating for given url.""" url = self.check_url(url) self.cache[url] = rating | 15,470 |
def __getitem__ (self, url): """Get rating for given url.""" self.check_url(url) # use a specialized form of longest prefix matching: # split the url in parts and the longest matching part wins parts = split_url(url) # the range selects from all parts (full url) down to the first two parts for i in range(len(parts), 1,... | def __getitem__ (self, url): """Get rating for given url.""" url = self.check_url(url) # use a specialized form of longest prefix matching: # split the url in parts and the longest matching part wins parts = split_url(url) # the range selects from all parts (full url) down to the first two parts for i in range(len(part... | 15,471 |
def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | 15,472 |
def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | 15,473 |
def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | def url_norm (url): """Normalize the given URL which must be quoted. Supports unicode hostnames (IDNA encoding) according to RFC 3490. @return (normed url, idna flag) """ urlparts = list(urlparse.urlsplit(url)) # scheme urlparts[0] = urllib.unquote(urlparts[0]).lower() # host (with path or query side effects) is_idn =... | 15,474 |
def match_url (url, domainlist): """return True if host part of url matches an entry in given domain list""" if not url: return False return match_host(spliturl(url)[1], domainlist) | def match_url (url, domainlist): """return True if host part of url matches an entry in given domain list""" if not url: return False return match_host(url_split(url)[1], domainlist) | 15,475 |
def test_wrap (self): """test line wrapping""" s = "11%(sep)s22%(sep)s33%(sep)s44%(sep)s55" % {'sep': os.linesep} # testing width <= 0 self.assertEquals(wc.strformat.wrap(s, -1), s) self.assertEquals(wc.strformat.wrap(s, 0), s) s2 = "11 22%(sep)s33 44%(sep)s55" % {'sep': os.linesep} # splitting lines self.assertEquals(... | def test_wrap (self): """test line wrapping""" s = "11%(sep)s22%(sep)s33%(sep)s44%(sep)s55" % {'sep': os.linesep} # testing width <= 0 self.assertEquals(wc.strformat.wrap(s, -1), s) self.assertEquals(wc.strformat.wrap(s, 0), s) l = len(os.linesep) gap = " "*l s2 = "11%(gap)s22%(sep)s33%(gap)s44%(sep)s55" % \ {'sep': os... | 15,476 |
def test_wrap (self): """test line wrapping""" s = "11%(sep)s22%(sep)s33%(sep)s44%(sep)s55" % {'sep': os.linesep} # testing width <= 0 self.assertEquals(wc.strformat.wrap(s, -1), s) self.assertEquals(wc.strformat.wrap(s, 0), s) s2 = "11 22%(sep)s33 44%(sep)s55" % {'sep': os.linesep} # splitting lines self.assertEquals(... | def test_wrap (self): """test line wrapping""" s = "11%(sep)s22%(sep)s33%(sep)s44%(sep)s55" % {'sep': os.linesep} # testing width <= 0 self.assertEquals(wc.strformat.wrap(s, -1), s) self.assertEquals(wc.strformat.wrap(s, 0), s) s2 = "11 22%(sep)s33 44%(sep)s55" % {'sep': os.linesep} # splitting lines self.assertEquals(... | 15,477 |
def p (path): """norm a path name to platform specific notation""" return os.path.normpath(path) | def normpath (path): """norm a path name to platform specific notation""" return os.path.normpath(path) | 15,478 |
def run (self): super(MyInstall, self).run() # we have to write a configuration file because we need the # <install_data> directory (and other stuff like author, url, ...) data = [] for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']: attr = 'install_%s'%d if self.root: # cut off root path prefix cutof... | def run (self): super(MyInstall, self).run() # we have to write a configuration file because we need the # <install_data> directory (and other stuff like author, url, ...) data = [] for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']: attr = 'install_%s'%d if self.root: # cut off root path prefix cutof... | 15,479 |
def run (self): super(MyInstall, self).run() # we have to write a configuration file because we need the # <install_data> directory (and other stuff like author, url, ...) data = [] for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']: attr = 'install_%s'%d if self.root: # cut off root path prefix cutof... | def run (self): super(MyInstall, self).run() # we have to write a configuration file because we need the # <install_data> directory (and other stuff like author, url, ...) data = [] for d in ['purelib', 'platlib', 'lib', 'headers', 'scripts', 'data']: attr = 'install_%s'%d if self.root: # cut off root path prefix cutof... | 15,480 |
def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | 15,481 |
def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | 15,482 |
def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | 15,483 |
def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | 15,484 |
def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | def get_exe_bytes (self): if win_cross_compiling: bv = "7.1" # wininst-x.y.exe is in the same directory as bdist_wininst directory = os.path.dirname(distutils.command.__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. filename = os.path.join(directory, "wininst-%s.exe" % bv) ret... | 15,485 |
def __init__ (self, headers): """ Initialize internal buffers and flags. """ self.headers = headers self.buf = '' self.bytes_remaining = None self.closed = False | def __init__ (self): """ Initialize internal buffers and flags. """ self.headers = headers self.buf = '' self.bytes_remaining = None self.closed = False | 15,486 |
def __init__ (self, headers): """ Initialize internal buffers and flags. """ self.headers = headers self.buf = '' self.bytes_remaining = None self.closed = False | def __init__ (self, headers): """ Initialize internal buffers and flags. """ self.buf = '' self.bytes_remaining = None self.closed = False | 15,487 |
def read_footers (self): i = self.buf.find('\r\n\r\n') if i > 0: fp = StringIO.StringIO(self.buf[:i]) self.buf = self.buf[i+4:] msg = wc.http.header.WcMessage(fp) fp.close() for name in msg: for value in msg.getheaders(name): self.headers.addheader(name, value) | def read_footers (self): i = self.buf.find('\r\n\r\n') if i >= 0: fp = StringIO.StringIO(self.buf[:i]) self.buf = self.buf[i+4:] msg = wc.http.header.WcMessage(fp) fp.close() for name in msg: for value in msg.getheaders(name): self.headers.addheader(name, value) | 15,488 |
def read_footers (self): i = self.buf.find('\r\n\r\n') if i > 0: fp = StringIO.StringIO(self.buf[:i]) self.buf = self.buf[i+4:] msg = wc.http.header.WcMessage(fp) fp.close() for name in msg: for value in msg.getheaders(name): self.headers.addheader(name, value) | def read_footers (self): i = self.buf.find('\r\n\r\n') if i > 0: fp = StringIO.StringIO(self.buf[:i]) self.buf = self.buf[i+4:] msg = wc.http.header.WcMessage(fp) fp.close() for name in msg: for value in msg.getheaders(name): self.headers.addheader(name, value) | 15,489 |
def set_proxy_headers (headers): remove_hop_by_hop_headers(headers) set_via_header(headers) set_date_header(headers) remove_old_warning_headers(headers) | def set_proxy_headers (headers): remove_hop_by_hop_headers(headers) set_via_header(headers) set_date_header(headers) remove_warning_headers(headers) | 15,490 |
def end_element (self, name): self.cmode = None if self.rule: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name=='folder': if self.compile_data: self.folder.compile_data() | def end_element (self, name): self.cmode = None if self.rule is None: self.folder.end_data(name) else: self.rule.end_data(name) if name in rulenames: if self.compile_data: self.rule.compile_data() elif name=='folder': if self.compile_data: self.folder.compile_data() | 15,491 |
def __getattr__ (self, name): """delegate unknown attrs to self.parser""" return getattr(self.parser, name) | def __getattr__ (self, name): """delegate attrs to self.parser""" return getattr(self.parser, name) | 15,492 |
def pi (self, data): self.buffer_append_data([DATA; "<?%s?>"%data]) | def pi (self, data): self.buffer_append_data([DATA; "<?%s?>"%data]) | 15,493 |
def trace (log): """ Start tracing of the current thread (and the current thread only). """ global tracelog tracelog = log sys.settrace(_traceit) | def trace (log): """ Start tracing of the current thread (and the current thread only). """ global tracelog if tracelog is None: tracelog = log sys.settrace(_traceit) | 15,494 |
def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] name = frame.f_globals["__name__"] line = linecache.getline(filename, lineno) debu... | def _traceit (frame, event, arg): """ Print current executed line. """ if event == "line": lineno = frame.f_lineno filename = frame.f_globals["__file__"] if filename.endswith(".pyc") or filename.endswith(".pyo"): filename = filename[:-1] name = frame.f_globals["__name__"] line = linecache.getline(filename, lineno) info... | 15,495 |
def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() s.write('Traceback:') s.write(os.linesep) for frame, fname, lineno, method, lines, i in reversed(stack): s.write(' File %r, line %d, in %s' % (fname, lineno, method)) s.write(... | 15,496 |
def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | 15,497 |
def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | 15,498 |
def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | def _stack_format (stack): """ Format a stack trace to a message. @return: formatted stack message @rtype: string """ s = StringIO.StringIO() traceback.print_stack(stack, file=s) if PRINT_LOCALVARS: s.write("Locals by frame, innermost last%s" % os.linesep) for frame in stack: s.write(os.linesep) s.write("Frame %s in %... | 15,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.