bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def iswriteable (fname): if os.path.isdir(fname) or os.path.islink(fname): return False try: if os.path.exists(fname): f = file(fname, 'a') f.close() return True else: f = file(fname, 'w') f.close() os.remove(fname) return True except IOError, msg: pass return False
def iswriteable (fname): if os.path.isdir(fname) or os.path.islink(fname): return False try: if os.path.exists(fname): f = file(fname, 'a') f.close() return True else: f = file(fname, 'w') f.close() os.remove(fname) return True except IOError: pass return False
16,400
def startfunc (handle=None): # init logging initlog(os.path.join(ConfigDir, "logging.conf")) # we run single-threaded, decrease check interval sys.setcheckinterval(500) # support reload on posix systems if os.name=='posix': import signal signal.signal(signal.SIGHUP, reload_config) # drop privileges os.chdir("/") # for ...
def startfunc (handle=None): # init logging initlog(os.path.join(ConfigDir, "logging.conf")) # we run single-threaded, decrease check interval sys.setcheckinterval(500) # support reload on posix systems if os.name=='posix': import signal signal.signal(signal.SIGHUP, reload_config) # drop privileges os.chdir("/") # for ...
16,401
def parse (self, fp, config): self.config = config super(WConfigParser, self).parse(fp) self.config['configfile'] = self.filename self.config['filters'].sort()
def parse (self, fp, _config): self.config = _config super(WConfigParser, self).parse(fp) self.config['configfile'] = self.filename self.config['filters'].sort()
16,402
def reset (self): """Reset to default values""" self['port'] = 8080 self['proxyuser'] = "" self['proxypass'] = "" self['parentproxy'] = "" self['parentproxyport'] = 3128 self['parentproxyuser'] = "" self['parentproxypass'] = "" self['logfile'] = "" self['strict_whitelist'] = 0 self['debuglevel'] = 0 self['rules'] = [] ...
def reset (self): """Reset to default values""" self['port'] = 8080 self['proxyuser'] = "" self['proxypass'] = "" self['parentproxy'] = "" self['parentproxyport'] = 3128 self['parentproxyuser'] = "" self['parentproxypass'] = "" self['logfile'] = "" self['strict_whitelist'] = 0 self['debuglevel'] = 0 self['rules'] = [] ...
16,403
def esc_ansicolor (color): """convert a named color definition to an escaped ANSI color""" control = '' if ";" in color: control, color = color.split(";", 1) control = AnsiControl.get(ctype, '')+";" cnum = AnsiColor.get(color, '0') return AnsiEsc % (control+cnum)
def esc_ansicolor (color): """convert a named color definition to an escaped ANSI color""" control = '' if ";" in color: control, color = color.split(";", 1) control = AnsiControl.get(control, '')+";" cnum = AnsiColor.get(color, '0') return AnsiEsc % (control+cnum)
16,404
def addr2bin (addr): if type(addr) == type(0): return addr bytes = addr.split('.') if len(bytes) != 4: raise ValueError, 'bad IP address' n = 0 for byte in bytes: n = n<<8 | int(byte) return n
def addr2bin (addr): if type(addr) == type(0): return addr bytes = addr.split('.') if len(bytes) != 4: raise ValueError, 'bad IP address' n = 0L for byte in bytes: n = n<<8 | int(byte) return n
16,405
def js_process_error (self, msg): """ Process javascript syntax error. """ wc.log.error(wc.LOG_JS, "JS error at %s", self.url) wc.log.error(wc.LOG_JS, msg)
def js_process_error (self, msg): """ Process javascript syntax error. """ wc.log.error(wc.LOG_JS, "JS error at %s", self.url) wc.log.error(wc.LOG_JS, msg)
16,406
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
def update_filter (wconfig, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+"filter-md5sums.txt" try: page = open_...
16,407
def create_conf_file(self, directory, data=[]): data.insert(0, "# this file is automatically created by setup.py") filename = os.path.join(directory, self.config_file) # add metadata metanames = dir(self.metadata) + \ ['fullname', 'contact', 'contact_email'] for name in metanames: method = "get_" + name cmd = "%s = %s"...
def create_conf_file(self, directory, data=[]): data.insert(0, "# this file is automatically created by setup.py") filename = os.path.join(directory, self.config_file) # add metadata metanames = dir(self.metadata) + \ ['fullname', 'contact', 'contact_email'] for name in metanames: method = "get_" + name cmd = "%s = %s"...
16,408
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 val =...
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...
16,409
def translate (self, domain, msgid, mapping=None, """Interpolates and translate TAL expression.""" context=None, target_language=None, default=None): _msg = self.gettext(msgid) wc.log.debug(wc.LOG_TAL, "TRANSLATED %r %r", msgid, _msg) return wc.webgui.TAL.TALInterpreter.interpolate(_msg, mapping)
def translate (self, domain, msgid, mapping=None, """Interpolates and translate TAL expression.""" _msg = self.gettext(msgid) wc.log.debug(wc.LOG_TAL, "TRANSLATED %r %r", msgid, _msg) return wc.webgui.TAL.TALInterpreter.interpolate(_msg, mapping)
16,410
def create_conf_file(self, directory, data=[]): data.insert(0, "# this file is automatically created by setup.py") filename = os.path.join(directory, self.config_file) # add metadata metanames = dir(self.metadata) + \ ['fullname', 'contact', 'contact_email'] for name in metanames: method = "get_" + name cmd = "%s = %s"...
def create_conf_file(self, directory, data=[]): data.insert(0, "# this file is automatically created by setup.py") filename = os.path.join(directory, self.config_file) # add metadata metanames = dir(self.metadata) + \ ['fullname', 'contact', 'contact_email'] for name in metanames: method = "get_" + name cmd = "%s = %s"...
16,411
def get_context (): # init and return TALES context context = simpleTALES.Context() context.addGlobal("parameter", "hullabulla") return context
def get_context (): # init and return TALES context context = simpleTALES.Context() context.addGlobal("parameter", "hullabulla") return context
16,412
def get_wc_client_headers (host): """ Get default webcleaner proxy request headers. """ headers = WcMessage() headers['Host'] = '%s\r' % host headers['Accept-Encoding'] = 'gzip;q=1.0, deflate;q=0.9, identity;q=0.5\r' headers['Connection'] = 'Keep-Alive\r' headers['Keep-Alive'] = 'timeout=300\r' headers['User-Agent'] = ...
def get_wc_client_headers (host): """ Get default webcleaner proxy request headers. """ headers = wc.http.header.WcMessage() headers['Host'] = '%s\r' % host headers['Accept-Encoding'] = 'gzip;q=1.0, deflate;q=0.9, identity;q=0.5\r' headers['Connection'] = 'Keep-Alive\r' headers['Keep-Alive'] = 'timeout=300\r' headers['...
16,413
def check_nonces (): # deprecate old nonces for key, value in nonces.items(): noncetime = time.time() - value if noncetime > max_noncesecs: del nonces[nonce]
def check_nonces (): # deprecate old nonces for nonce, value in nonces.items(): noncetime = time.time() - value if noncetime > max_noncesecs: del nonces[nonce]
16,414
def parse_ntlm_challenge (challenge): """parse both type0 and type2 challenges""" if "," in challenge: chal, remainder = challenge.split(",", 1) else: chal, remainder = challenge, "" chal = chal.strip() reaminder = remainder.strip() if not chal: # empty challenge (type0) encountered res = {'type': NTLMSSP_INIT} else: m...
def parse_ntlm_challenge (challenge): """parse both type0 and type2 challenges""" if "," in challenge: chal, remainder = challenge.split(",", 1) else: chal, remainder = challenge, "" chal = chal.strip() remainder = remainder.strip() if not chal: # empty challenge (type0) encountered res = {'type': NTLMSSP_INIT} else: m...
16,415
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
16,416
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
16,417
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
def _kind (self,full_type,endian): if endian == 'local': kind = full_type else: kind = full_type[2:]
16,418
def _data (self,kind,result): pos = 0 data = list('') while pos < len(result): if convert.is_c_escape(result[pos:]): # \0 is not a number it is the null string if result[pos+1] == '0': data.append(result[pos]) data.append(0L) # \rnt are special else: data.append(result[pos:pos+2]) pos +=2 elif kind == "string" and (res...
def _data (self,kind,result): pos = 0 data = list('') while pos < len(result): if convert.is_c_escape(result[pos:]): # \0 is not a number it is the null string if result[pos+1] == '0': data.append(result[pos]) data.append(0L) # \rnt are special else: data.append(result[pos:pos+2]) pos +=2 else: base = convert.which_bas...
16,419
def _data (self,kind,result): pos = 0 data = list('') while pos < len(result): if convert.is_c_escape(result[pos:]): # \0 is not a number it is the null string if result[pos+1] == '0': data.append(result[pos]) data.append(0L) # \rnt are special else: data.append(result[pos:pos+2]) pos +=2 elif kind == "string" and (res...
def_data(self,kind,result):pos=0data=list('')whilepos<len(result):ifconvert.is_c_escape(result[pos:]):#\0isnotanumberitisthenullstringifresult[pos+1]=='0':data.append(result[pos])data.append(0L)#\rntarespecialelse:data.append(result[pos:pos+2])pos+=2elifkind=="string"and(result[pos]instring.ascii_lettersorresult[pos]in...
16,420
def _length (self, kind, data): # Calculate the size of the data to read in the file if kind == "string": replace = "" for i in data: # except: Too lazy to handle the '\r' and co otherwise try: replace += chr(i) except: replace+='*' # This is for "\0" replace = replace.replace('*\0','*') # This is for two "\" replace =...
def _length (self, kind, data): # Calculate the size of the data to read in the file if kind.startswith("string"): replace = "" for i in data: # except: Too lazy to handle the '\r' and co otherwise try: replace += chr(i) except: replace+='*' # This is for "\0" replace = replace.replace('*\0','*') # This is for two "\" ...
16,421
def read_magic (self, magic_file): self.magic = []
def read_magic (self, magic_file): self.magic = []
16,422
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 # When we found the rule, what is the level that we successfull passed in_level = 0 # If we failed part of the rule there is no point lookin...
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 # When we found the rule, what is the level that we successfull passed in_level = 0 # If we failed part of the rule there is no point lookin...
16,423
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 # When we found the rule, what is the level that we successfull passed in_level = 0 # If we failed part of the rule there is no point lookin...
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 # When we found the rule, what is the level that we successfull passed in_level = 0 # If we failed part of the rule there is no point lookin...
16,424
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
16,425
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
16,426
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
def body(self, master): d = {"appname": wc.AppName} msg = _("""The administrator password protects the web
16,427
def apply(self): password = self.pass_entry.get() if password: save_adminpassword(password) else: print _("Not saving empty password.")
def apply(self): password = self.pass_entry.get() if password: save_adminpassword(password) else: print _("Not saving empty password.")
16,428
def handle_timeout (self): # The DNS server hasn't responded to us, or we've lost the # packet somewhere, so let's try it again, unless the retry # count is too large. Each time we retry, we increase the # timeout (see send_dns_request). if not self.callback: return # It's already handled, so ignore this wc.log.warn(w...
defwc.log.debug(wc.LOG_DNS, "%s switching to TCP", self) handle_timeoutwc.log.debug(wc.LOG_DNS, "%s switching to TCP", self) (self):wc.log.debug(wc.LOG_DNS, "%s switching to TCP", self) #wc.log.debug(wc.LOG_DNS, "%s switching to TCP", self) Thewc.log.debug(wc.LOG_DNS, "%s switching to TCP", self) DNSwc.log.debug(wc.LOG...
16,429
def process_read (self): if not self.callback: self.close() # Assume that the entire answer comes in one packet if self.tcp: if len(self.recv_buffer) < 2: return header = self.recv_buffer[:2] (l,) = struct.unpack("!H", header) if len(self.recv_buffer) < 2+l: return self.read(2) # header wire = self.read(l) try: self.so...
def process_read (self): if not self.callback: self.close() # Assume that the entire answer comes in one packet if self.tcp: if len(self.recv_buffer) < 2: return header = self.recv_buffer[:2] (l,) = struct.unpack("!H", header) if len(self.recv_buffer) < 2+l: return self.read(2) # header wire = self.read(l) try: self.so...
16,430
def convert_adzapper_pattern (pattern): pattern = pattern.replace(".", "\\.") pattern = pattern.replace("?", "\\?") pattern = pattern.replace("**", ".*?") pattern = re.sub(r"([^.])\*([^?])", r"\1[^/]*\2", pattern) return pattern
def convert_adzapper_pattern (pattern): pattern = pattern.replace(".", "\\.") pattern = pattern.replace("?", "\\?") pattern = pattern.replace("**", ".*?") pattern = re.sub(r"([^.])\*([^?]|$)", r"\1[^/]*\2", pattern) return pattern
16,431
def write_allow (zapfile, adclass, pattern): #print "%s allow %s" % (adclass, `pattern`) d = get_rule_dict(adclass, pattern) zapfile.write("""<allow title="%(title)s" desc="%(desc)s" url="%(url)s"
def write_allow (zapfile, adclass, pattern): #print "%s allow %s" % (adclass, `pattern`) d = get_rule_dict(adclass, pattern) zapfile.write("""<allow title="%(title)s" desc="%(desc)s" url="%(url)s"
16,432
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s" """ % d) if replacement is not None: zapfile.write(">%s</block>" % xmlify(replacemen...
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s""" % d) if replacement is not None: zapfile.write(">%s</block>" % xmlify(replacement)...
16,433
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s" """ % d) if replacement is not None: zapfile.write(">%s</block>" % xmlify(replacemen...
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s" """ % d) if replacement is not None: zapfile.write("\">%s</block>" % xmlify(replacem...
16,434
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s" """ % d) if replacement is not None: zapfile.write(">%s</block>" % xmlify(replacemen...
def write_block (zapfile, adclass, pattern, replacement=None): #print "%s block %s => %s" % (adclass, `pattern`, `replacement`) d = get_rule_dict(adclass, pattern) zapfile.write("""<block title="%(title)s" desc="%(desc)s" url="%(url)s" """ % d) if replacement is not None: zapfile.write(">%s</block>" % xmlify(replacemen...
16,435
def newfunc (*args, **kwargs): """ Print deprecated warning and execute original function. """ warnings.warn("Call to deprecated function %s." % func.__name__, category=DeprecationWarning) return func(*args, **kwargs)
def newfunc (*args, **kwargs): """ Print deprecated warning and execute original function. """ warnings.warn("Call to deprecated function %s." % func.__name__, category=DeprecationWarning) return func(*args, **kwargs)
16,436
def newfunc (*args, **kwargs): """ Execute function synchronized. """ lock.acquire(True) # blocking try: return func(*args, **kwargs) finally: lock.release()
def newfunc (*args, **kwargs): """ Execute function synchronized. """ lock.acquire(True) # blocking try: return func(*args, **kwargs) finally: lock.release()
16,437
def newfunc (*args, **kwargs): """ Raise NotImplementedError """ raise NotImplementedError("%s not implemented" % func.__name__)
def newfunc (*args, **kwargs): """ Raise NotImplementedError """ raise NotImplementedError("%s not implemented" % func.__name__)
16,438
def add_blockdomains (self, rule): print "blockdomains", rule.file lines = get_file_data(rule.file) for line in lines: line = line.strip() if not line or line[0]=='#': continue self.blocked_domains.append(line)
def add_blockdomains (self, rule): print "blockdomains", rule.file lines = self.get_file_data(rule.file) for line in lines: line = line.strip() if not line or line[0]=='#': continue self.blocked_domains.append(line)
16,439
def add_blockurls (self, rule): print "blockurls", rule.file lines = get_file_data(rule.file) for line in lines: line = line.strip() if not line or line[0]=='#': continue self.blocked_urls.append(line.split("/", 1))
def add_blockurls (self, rule): print "blockurls", rule.file lines = self.get_file_data(rule.file) for line in lines: line = line.strip() if not line or line[0]=='#': continue self.blocked_urls.append(line.split("/", 1))
16,440
def blocked (self, urlTuple): # check blocked domains for _block in self.blocked_domains: debug(NIGHTMARE, "block domain", _block) if urltuple[1] == _block: return 0 # check blocked urls for _block in self.blocked_urls: debug(NIGHTMARE, "block url", _block) if urlTuple[1]==_block[0] and urlTuple[2].startswith(_block[1]...
def blocked (self, urlTuple): # check blocked domains for _block in self.blocked_domains: debug(NIGHTMARE, "block domain", _block) if urlTuple[1] == _block: return 0 # check blocked urls for _block in self.blocked_urls: debug(NIGHTMARE, "block url", _block) if urlTuple[1]==_block[0] and urlTuple[2].startswith(_block[1]...
16,441
def update_filter (wconfig, dryrun=False, log=None): """ Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing. @raise: IOError """ print >> log, _("updating filters"), "..." chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+...
def update_filter (wconfig, dryrun=False, log=None): """ Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing. @raise: IOError """ print >> log, _("updating filters"), "..." chg = False baseurl = wconfig['baseurl']+"filter/" url = baseurl+...
16,442
def __init__ (self): self.in_winhelp = False # inside object tag calling WinHelp # running on MacOS or MacOSX self.macintosh = os.name == 'mac' or \ (os.name == 'posix' and sys.platform.startswith('darwin'))
def __init__ (self): self.in_winhelp = False # inside object tag calling WinHelp # running on MacOS or MacOSX self.macintosh = os.name == 'mac' or \ (os.name == 'posix' and sys.platform.startswith('darwin'))
16,443
def meta_start (self, attrs, htmlfilter): """ Check <meta> start tag. """ if attrs.has_key('content') and self.macintosh: # prevent CVE-2002-0153 if attrs.get('http-equiv', '').lower() == 'refresh': url = attrs['content'].lower() if ";" in url: url = url.split(";", 1)[1] if url.startswith('url='): url = url[4:] if url....
def meta_start (self, attrs, htmlfilter): """ Check <meta> start tag. """ if attrs.has_key('content') and self.macintosh: # prevent CVE-2002-0153 if attrs.get('http-equiv', '').lower() == 'refresh': url = attrs['content'].lower() if ";" in url: url = url.split(";", 1)[1] if url.startswith('url='): url = url[4:] if url....
16,444
def meta_start (self, attrs, htmlfilter): """ Check <meta> start tag. """ if attrs.has_key('content') and self.macintosh: # prevent CVE-2002-0153 if attrs.get('http-equiv', '').lower() == 'refresh': url = attrs['content'].lower() if ";" in url: url = url.split(";", 1)[1] if url.startswith('url='): url = url[4:] if url....
def meta_start (self, attrs, htmlfilter): """ Check <meta> start tag. """ if attrs.has_key('content') and self.macintosh: # prevent CVE-2002-0153 if attrs.get('http-equiv', '').lower() == 'refresh': url = attrs['content'].lower() if ";" in url: url = url.split(";", 1)[1] if url.startswith('url='): url = url[4:] if url....
16,445
def onCmdTitle (self, sender, sel, ptr): title = sender.getText().strip() if not title: error(i18n._("empty title")) sender.setText(self.rule.title) return 1 self.rule.title = title self.getApp().dirty = 1 if self.rule.get_name()!="folder": title = "[%s] %s" % (self.rule.get_name(), title) sender.setText(title) debug(B...
def onCmdTitle (self, sender, sel, ptr): title = sender.getText().strip() if not title: error(i18n._("empty title")) sender.setText(self.rule.title) return 1 self.rule.title = title self.getApp().dirty = 1 if self.rule.get_name()!="folder": tmptitle = "[%s] %s" % (self.rule.get_name(), title) else: tmptitle = title sen...
16,446
def doit (self, data, attrs): """ Investigate request data for a block.
def doit (self, data, attrs): """ Investigate request data for a block.
16,447
def doit (self, data, attrs): """ Investigate request data for a block.
def doit (self, data, attrs): """ Investigate request data for a block.
16,448
def ignorableWhitespace(self, d): """handler for ignorable whitespace""" self.buffer_append_data([DATA, d])
def ignorableWhitespace(self, d): """handler for ignorable whitespace""" self.buffer_append_data([DATA, d])
16,449
def buffer2data(self): """Append all tags of the buffer to the data""" for n in self.buffer: if n[0]==DATA: self.data += n[1] elif n[0]==COMMENT: self.data += "<!--%s-->"%n[1] elif n[0]==STARTTAG: s = "<"+n[1] for name,val in n[2].items(): if '"' in val: s += " %s='%s'"%(name,val) else: s += ' %s="%s"'%(name,val) self....
def buffer2data(self): """Append all tags of the buffer to the data""" for n in self.buffer: if n[0]==DATA: self.data += n[1] elif n[0]==COMMENT: self.data += "<!--%s-->"%n[1] elif n[0]==STARTTAG: s = "<"+n[1] for name,val in n[2].items(): s += ' %s'%name if val: if val.find('"')!=-1: s += "='%s'"%val else: s += '="%s"...
16,450
def add_i18n_context (context, lang): # language and i18n context_add(context, "lang", lang) try: translator = wc.get_translator(lang, translatorklass=Translator) except IOError, msg: print "XXX", lang, msg translator = NullTranslator() context_add(context, "i18n", translator)
def add_i18n_context (context, lang): # language and i18n context_add(context, "lang", lang) try: translator = wc.get_translator(lang, translatorklass=Translator) except IOError, msg: translator = NullTranslator() context_add(context, "i18n", translator)
16,451
def translate (self, domain, msgid, mapping=None, context=None, target_language=None, default=None): _msg = self.gettext(msgid) wc.log.debug(wc.LOG_TAL, "TRANSLATE %s %s %s %s", msgid, _msg, mapping, context) _msg = TALInterpreter.interpolate(_msg, mapping) return _msg
def translate (self, domain, msgid, mapping=None, context=None, target_language=None, default=None): _msg = self.gettext(msgid) wc.log.debug(wc.LOG_TAL, "TRANSLATE %s %s %s %s", msgid, _msg, mapping, context) _msg = TALInterpreter.interpolate(_msg, mapping) return _msg
16,452
def _buf_append_data (self, data): """we have to make sure that we have no two following DATA things in the tag buffer. Why? To be 100% sure that an ENCLOSED match really matches enclosed data. """ #self._debug(NIGHTMARE, "buf_append_data") if data[0]==DATA and self.buf and self.buf[-1][0]==DATA: self.buf[-1][1] += dat...
def buf_append_data (self, data): """we have to make sure that we have no two following DATA things in the tag buffer. Why? To be 100% sure that an ENCLOSED match really matches enclosed data. """ #self._debug(NIGHTMARE, "buf_append_data") if data[0]==DATA and self.buf and self.buf[-1][0]==DATA: self.buf[-1][1] += data...
16,453
def testScriptSrc4 (self): self.filt(
def testScriptSrc4 (self): self.filt(
16,454
def put_response (self, data, protocol, status, msg, headers): response = "%s %d %s"%(protocol, status, msg) self.client.server_response(self, response, status, headers) self.client.server_content(data) self.client.server_close()
def put_response (self, data, protocol, status, msg, headers): response = "%s %d %s"%(protocol, status, msg) self.client.server_response(self, response, status, headers) self.client.server_content(data) self.client.server_close()
16,455
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.m...
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.m...
16,456
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.m...
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.m...
16,457
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.m...
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.m...
16,458
def _calc_ratings_display (): """ Calculate current set of ratings to display. """ global ratings_display, rating_modified urls = rating_store.keys() urls.sort() ratings_display = urls[curindex:curindex+_entries_per_page] rating_modified.clear() for _url in ratings_display: t = _strtime(rating_store[_url].modified) rat...
def _calc_ratings_display (): """ Calculate current set of ratings to display. """ global ratings_display, rating_modified urls = rating_store.keys() urls.sort() ratings_display = urls[curindex:curindex+_entries_per_page] rating_modified.clear() for _url in ratings_display: t = _strtime(rating_store[_url].modified) rat...
16,459
def _form_apply (): """ Store changed ratings. """ if url in rating_store: rating = rating_store[url] else: rating = _Rating(url, generic) rating.remove_categories() for catname, value in values.items(): category = _get_category(catname) if category.iterable: value = [x for x in value if value[x]][0] else: value = _int...
def _form_apply (): """ Store changed ratings. """ rating = _Rating(url, generic) rating.remove_categories() for catname, value in values.items(): category = _get_category(catname) if category.iterable: value = [x for x in value if value[x]][0] else: value = _intrange_from_string(value) if value is None: error['ratingu...
16,460
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,461
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,462
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,463
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,464
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,465
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
def handle_read (self): """read data from SSL connection, put it into recv_buffer and call process_read""" assert self.connected wc.log.debug(wc.LOG_PROXY, '%s SslConnection.handle_read', self) if len(self.recv_buffer) > wc.proxy.Connection.MAX_BUFSIZE: wc.log.warn(wc.LOG_PROXY, '%s read buffer full', self) return try:...
16,466
def _debugbuf (self): """print debugging information about data buffer status""" debug(FILTER, "self.outbuf %r", self.outbuf.getvalue()) debug(FILTER, "self.tagbuf %r", self.tagbuf) debug(FILTER, "self.waitbuf %r", self.waitbuf) debug(FILTER, "self.inbuf %r", self.inbuf.getvalue())
def __str__ (self): return "%s in state %s"%(self.__class__.__name__, str(self.state)) def debugbuf (self): """print debugging information about buffered data""" debug(FILTER, "self.outbuf %r", self.outbuf.getvalue()) debug(FILTER, "self.tagbuf %r", self.tagbuf) debug(FILTER, "self.waitbuf %r", self.waitbuf) debug(FI...
16,467
def tagbuf2data (self): """Append all tags of the tag buffer to the output buffer""" tagbuf2data(self.tagbuf, self.outbuf) self.tagbuf = []
def tagbuf2data (self): """append serialized tag items of the tag buffer to the output buffer and clear the tag buffer""" debug(FILTER, "%s tagbuf2data", self) tagbuf2data(self.tagbuf, self.outbuf) self.tagbuf = []
16,468
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 if self.waitbuf: waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]=='wait': self.inbuf.write(data) return data = self.inbuf.getvalue() ...
16,469
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
16,470
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
16,471
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
def feed (self, data): """feed some data to the parser""" if self.state[0]=='parse': # look if we must replay something if self.waited > 0: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state[0]!='parse': self.inbuf.write(data) return data = self.inbuf.getvalue() + data self.inbu...
16,472
def flush (self, finish=False): """flush pending data and return the flushed output buffer""" debug(FILTER, "parser flush finish=%s", str(finish)) if self.waited > 100: error(FILTER, "waited too long for %s"%self.state[1]) # tell recursive background downloaders to stop if hasattr(self.handler, "finish"): self.handler....
def flush (self): """flush pending data""" debug(FILTER, "%s flush", self) if self.waited > 100: error(FILTER, "waited too long for %s"%self.state[1]) # tell recursive background downloaders to stop if hasattr(self.handler, "finish"): self.handler.finish() # switch back to parse self.state = ('parse',) # feeding an emp...
16,473
def flush (self, finish=False): """flush pending data and return the flushed output buffer""" debug(FILTER, "parser flush finish=%s", str(finish)) if self.waited > 100: error(FILTER, "waited too long for %s"%self.state[1]) # tell recursive background downloaders to stop if hasattr(self.handler, "finish"): self.handler....
def flush (self, finish=False): """flush pending data and return the flushed output buffer""" debug(FILTER, "parser flush finish=%s", str(finish)) if self.waited > 100: assert self.state[0]=='wait', 'parser %s has waited flag set in non-wait state' % str(self) error(FILTER, "%s waited too long", self) # tell recursive ...
16,474
def flush (self, finish=False): """flush pending data and return the flushed output buffer""" debug(FILTER, "parser flush finish=%s", str(finish)) if self.waited > 100: error(FILTER, "waited too long for %s"%self.state[1]) # tell recursive background downloaders to stop if hasattr(self.handler, "finish"): self.handler....
def flush (self, finish=False): """flush pending data and return the flushed output buffer""" debug(FILTER, "parser flush finish=%s", str(finish)) if self.waited > 100: error(FILTER, "waited too long for %s"%self.state[1]) # tell recursive background downloaders to stop if hasattr(self.handler, "finish"): self.handler....
16,475
def filter_tag (self, tag, attrs): #debug(NIGHTMARE, "rule %s filter_tag" % self.title) part = self.replace[0] #debug(NIGHTMARE, "original tag", tag, "attrs", attrs) #debug(NIGHTMARE, "replace", num_part(part), "with", self.replace[1]) if part==TAGNAME: return (STARTTAG, self.replace[1], attrs) if part==TAG: return (DA...
def filter_tag (self, tag, attrs): #debug(NIGHTMARE, "rule %s filter_tag" % self.title) part = self.replace[0] #debug(NIGHTMARE, "original tag", tag, "attrs", attrs) #debug(NIGHTMARE, "replace", num_part(part), "with", self.replace[1]) if part==TAGNAME: return (STARTTAG, self.replace[1], attrs) if part==TAG: return (DA...
16,476
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,477
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,478
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,479
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,480
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,481
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,482
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,483
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,484
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
def update (config, baseurl, dryrun=False, log=None): """Update the given configuration object with .zap files found at baseurl. If dryrun is True, only print out the changes but do nothing throws IOError on error """ url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >>log, "error ...
16,485
def _test (): # read local configuration config = Configuration() # test base url for all files baseurl = "http://localhost/~calvin/webcleaner.sf.net/htdocs/test/" update(config, baseurl, dryrun=True)
def _test (): # read local configuration# test base url for all files baseurl = "http://localhost/~calvin/webcleaner.sf.net/htdocs/test/" update(config, baseurl, dryrun=True)
16,486
def _test (): # read local configuration config = Configuration() # test base url for all files baseurl = "http://localhost/~calvin/webcleaner.sf.net/htdocs/test/" update(config, baseurl, dryrun=True)
def _test (): # read local configuration config = Configuration() # test base url for all files baseurl = "http://localhost/~calvin/webcleaner.sf.net/htdocs/test/" update(wc.Configuration(), baseurl, dryrun=True)
16,487
def _main (): """USAGE: test/run.sh test/filterfile.py <.html file>""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) from test import initlog, disable_rating_rules initlog("test/logging.conf") import wc wc.config = wc.Configuration...
def _main (): """USAGE: test/run.sh test/filterfile.py <.html file>""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) fname = sys.argv[1] if fname=="-": f = sys.stdin else: f = file(fname) from test import initlog, disable_rating_rules initlog("test/logging.conf") import wc wc.config = wc.Configuration...
16,488
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
16,489
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
16,490
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
16,491
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
def __init__ (self, client, request, headers, content, nofilter, compress, mime=None): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter self.mime = mime debug(BRING_IT_ON, "Proxy:", `self.request`) self.method, self.url, protocol...
16,492
def set_via_header (headers): """ Set "Via:" header. """ headers.addheader("Via", "1.1 unknown")
def set_via_header (headers): """ Set "Via:" header. """ headers.addheader("Via", "1.1 unknown\r")
16,493
def remove_warning_headers (headers): """ Remove old warning headers. """ if "Warning" not in headers: return tokeep = [] date = wc.http.date.parse_http_date(headers['Date']) for warning in headers.getheaders("Warning"): warncode, warnagent, warntext, warndate = \ wc.http.parse_http_warning(warning) if warndate is None...
def remove_warning_headers (headers): """ Remove old warning headers. """ if "Warning" not in headers: return tokeep = [] date = wc.http.date.parse_http_date(headers['Date']) for warning in headers.getheaders("Warning"): warncode, warnagent, warntext, warndate = \ wc.http.parse_http_warning(warning) if warndate is None...
16,494
def check_trailer_headers (headers): """ Message header fields listed in the Trailer header field MUST NOT include the following header fields: . Transfer-Encoding . Content-Length . Trailer """ if "Trailer" not in headers: return tokeep = [] for trailer in headers.getheaders("Trailer"): if trailer.lower() not in forbi...
def check_trailer_headers (headers): """ Message header fields listed in the Trailer header field MUST NOT include the following header fields: . Transfer-Encoding . Content-Length . Trailer """ if "Trailer" not in headers: return tokeep = [] for trailer in headers.getheaders("Trailer"): if trailer.lower() not in forbi...
16,495
def norm_url (url): """replace empty paths with / and normalize them""" url = urllib.unquote(url) urlparts = list(urlparse.urlparse(url)) path = urlparts[2].replace('\\', '/') if not path or path=='/': urlparts[2] = '/' else: # XXX this works only under windows and posix?? # collapse redundant path segments urlparts[2]...
def norm_url (url): """replace empty paths with / and normalize them""" url = urllib.unquote(url) urlparts = list(urlparse.urlparse(url)) path = urlparts[2].replace('\\', '/') if not path or path=='/': urlparts[2] = '/' else: # XXX this works only under windows and posix?? # collapse redundant path segments urlparts[2]...
16,496
def _form_rule_delmatchurls (form): toremove = _getlist(form, 'rule_matchurls') if toremove: for matchurl in toremove: currule.matchurls.remove(matchurl) currule.compile_matchurls() info['rulematchurl'] = True
def _form_rule_delmatchurls (form): toremove = [u for u in _getlist(form, 'rule_matchurls') if u in currule.matchurls] if toremove: for matchurl in toremove: currule.matchurls.remove(matchurl) currule.compile_matchurls() info['rulematchurl'] = True
16,497
def _form_rule_delnomatchurls (form): toremove = _getlist(form, 'rule_nomatchurls') if toremove: for nomatchurl in toremove: currule.nomatchurls.remove(nomatchurl) currule.compile_nomatchurls() info['rulenomatchurl'] = True
def _form_rule_delnomatchurls (form): toremove = [u for u in _getlist(form, 'rule_nomatchurls') if u in currule.nomatchurls] if toremove: for nomatchurl in toremove: currule.nomatchurls.remove(nomatchurl) currule.compile_nomatchurls() info['rulenomatchurl'] = True
16,498
def write_folder (cat, ftype, data, f): print "write", cat, "folder" d = { "charset": wc.ConfigCharset, "title_en": wc.XmlUtils.xmlquote("%s %s" % (ftype.capitalize(), cat)), "title_de": wc.XmlUtils.xmlquote("%s %s" % (transtypes[ftype]['de'].capitalize(), transcats[cat]['de'].capitalize())), "desc_en": wc.XmlUtils.xml...
def write_folder (cat, ftype, data, f): print "write", cat, "folder" d = { "charset": wc.configuration.ConfigCharset, "title_en": wc.XmlUtils.xmlquote("%s %s" % (ftype.capitalize(), cat)), "title_de": wc.XmlUtils.xmlquote("%s %s" % (transtypes[ftype]['de'].capitalize(), transcats[cat]['de'].capitalize())), "desc_en": w...
16,499