rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
self._debug(NIGHTMARE, "JS: document.write", `data`) | def jsProcessData (self, data): """process data produced by document.write() JavaScript""" self._debug(NIGHTMARE, "JS: document.write", `data`) self.js_output += 1 # parse recursively self.js_html.feed(data) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: popup") | def jsProcessPopup (self): """process javascript popup""" self._debug(NIGHTMARE, "JS: popup") self.js_popup += 1 | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "buf_append_data") | 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[... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "flushbuf") | def flushbuf (self): """clear and return the output buffer""" self._debug(NIGHTMARE, "flushbuf") data = self.outbuf.getvalue() self.outbuf.close() self.outbuf = StringIO() return data | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "self.outbuf", `self.outbuf.getvalue()`) self._debug(NIGHTMARE, "self.buf", `self.buf`) self._debug(NIGHTMARE, "self.waitbuf", `self.waitbuf`) self._debug(NIGHTMARE, "self.inbuf", `self.inbuf.getvalue()`) | def _debugbuf (self): """print debugging information about data buffer status""" self._debug(NIGHTMARE, "self.outbuf", `self.outbuf.getvalue()`) self._debug(NIGHTMARE, "self.buf", `self.buf`) self._debug(NIGHTMARE, "self.waitbuf", `self.waitbuf`) self._debug(NIGHTMARE, "self.inbuf", `self.inbuf.getvalue()`) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "feed", `data`) | def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO()... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "feed") | def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO()... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "wait") | def feed (self, data): """feed some data to the parser""" if self.state=='parse': # look if we must replay something if self.waited: self.waited = 0 waitbuf, self.waitbuf = self.waitbuf, [] self.replay(waitbuf) if self.state!='parse': return data = self.inbuf.getvalue() + data self.inbuf.close() self.inbuf = StringIO()... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(HURT_ME_PLENTY, "flush") | def flush (self): self._debug(HURT_ME_PLENTY, "flush") # flushing in wait state raises a filter exception if self.state=='wait': raise FilterWait("HtmlParser[%d]: waiting for data"%self.level) self.parser.flush() | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "replay", waitbuf) | def replay (self, waitbuf): """call the handler functions again with buffer data""" self._debug(NIGHTMARE, "replay", waitbuf) for item in waitbuf: if item[0]==DATA: self._data(item[1]) elif item[0]==STARTTAG: self.startElement(item[1], item[2]) elif item[0]==ENDTAG: self.endElement(item[1]) elif item[0]==COMMENT: self.... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "cdata", `data`) | def cdata (self, data): """character data""" self._debug(NIGHTMARE, "cdata", `data`) return self._data(data) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "characters", `data`) | def characters (self, data): """characters""" self._debug(NIGHTMARE, "characters", `data`) return self._data(data) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "comment", `data`) | def comment (self, data): """a comment; accept only non-empty comments""" self._debug(NIGHTMARE, "comment", `data`) item = [COMMENT, data] if self.state=='wait': return self.waitbuf.append(item) if self.comments and data: self.buf.append(item) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "doctype", `data`) | def doctype (self, data): self._debug(NIGHTMARE, "doctype", `data`) return self._data("<!DOCTYPE%s>"%data) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "pi", `data`) | def pi (self, data): self._debug(NIGHTMARE, "pi", `data`) return self._data("<?%s?>"%data) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "startElement", `tag`) | 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.""" # default data self._debug(NIGHTMARE, "startElement", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.wa... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "matched rule %s on tag %s" % (`rule.title`, `tag`)) | 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.""" # default data self._debug(NIGHTMARE, "startElement", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.wa... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "put on buffer") | 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.""" # default data self._debug(NIGHTMARE, "startElement", `tag`) tag = check_spelling(tag, self.url) item = [STARTTAG, tag, attrs] if self.state=='wait': return self.wa... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "endElement", `tag`) | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: del", `name`, "from", `tag`) | def jsStartElement (self, tag, attrs): """Check popups for onmouseout and onmouseover. Inline extern javascript sources""" changed = 0 self.js_src = None self.js_output = 0 self.js_popup = 0 for name in ('onmouseover', 'onmouseout'): if attrs.has_key(name) and self.jsPopup(attrs, name): self._debug(NIGHTMARE, "JS: del"... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: jsPopup") | def jsPopup (self, attrs, name): """check if attrs[name] javascript opens a popup window""" self._debug(NIGHTMARE, "JS: jsPopup") val = resolve_html_entities(attrs[name]) if not val: return self.js_env.attachListener(self) try: self.js_env.executeScriptAsFunction(val, 0.0) except jslib.error, msg: pass self.js_env.deta... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(HURT_ME_PLENTY, "jsForm", `name`, `action`, `target`) | def jsForm (self, name, action, target): """when hitting a (named) form, notify the JS engine about that""" if not name: return self._debug(HURT_ME_PLENTY, "jsForm", `name`, `action`, `target`) self.js_env.addForm(name, action, target) | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "switching back to parse with") | def jsScriptData (self, data, url, ver): """Callback for loading <script src=""> data in the background If downloading is finished, data is None""" assert self.state=='wait' if data is None: if not self.js_script: print >> sys.stderr, "HtmlParser[%d]: empty JS src"%self.level, url else: self.buf.append([STARTTAG, "scri... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(HURT_ME_PLENTY, "JS read", len(data), "<=", url) | def jsScriptData (self, data, url, ver): """Callback for loading <script src=""> data in the background If downloading is finished, data is None""" assert self.state=='wait' if data is None: if not self.js_script: print >> sys.stderr, "HtmlParser[%d]: empty JS src"%self.level, url else: self.buf.append([STARTTAG, "scri... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(HURT_ME_PLENTY, "JS jsScriptSrc", `url`, `ver`) | def jsScriptSrc (self, url, language): """Start a background download for <script src=""> tags""" assert self.state=='parse' ver = 0.0 if language: mo = re.search(r'(?i)javascript(?P<num>\d\.\d)', language) if mo: ver = float(mo.group('num')) url = urlparse.urljoin(self.url, url) self._debug(HURT_ME_PLENTY, "JS jsScrip... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: jsScript", ver, `script`) | def jsScript (self, script, ver, item): """execute given script with javascript version ver""" self._debug(NIGHTMARE, "JS: jsScript", ver, `script`) assert self.state == 'parse' assert len(self.buf) >= 2 self.js_output = 0 self.js_env.attachListener(self) # start recursive html filter (used by jsProcessData) self.js_ht... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: endScript") | def jsEndScript (self, item): self._debug(NIGHTMARE, "JS: endScript") assert len(self.buf) >= 2 if self.js_output: try: self.js_html.feed('') self.js_html.flush() except FilterWait: self.state = 'wait' self.waited = 'True' make_timer(0.1, lambda : self.jsEndScript(item)) return self.js_html._debugbuf() assert not self.... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
self._debug(NIGHTMARE, "JS: switching back to parse with") | def jsEndScript (self, item): self._debug(NIGHTMARE, "JS: endScript") assert len(self.buf) >= 2 if self.js_output: try: self.js_html.feed('') self.js_html.flush() except FilterWait: self.state = 'wait' self.waited = 'True' make_timer(0.1, lambda : self.jsEndScript(item)) return self.js_html._debugbuf() assert not self.... | 2235a065dd104f9a4252037ab7cb36681acd5b89 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/2235a065dd104f9a4252037ab7cb36681acd5b89/HtmlParser.py | |
if self.addr[0] not in config['allowed_hosts']: | if not config['allowedhosts'].has_key(self.addr[0]): | def __init__ (self, socket, addr): Connection.__init__(self, socket) self.addr = addr self.state = 'request' self.server = None self.request = '' self.headers = None self.bytes_remaining = None # for content only self.content = '' if self.addr[0] not in config['allowed_hosts']: self.close() | 867e53561cb3cce104da8b9c721509c7f19ca606 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/867e53561cb3cce104da8b9c721509c7f19ca606/HttpClient.py |
if self.enclosed and self.tag in NO_CLOSE_TAGS: raise ValueError, "reading rule %r: tag %r has no end tag, " \ "so specifying an enclose value is invalid." % \ (self.titles['en'], tag) | def __init__ (self, sid=None, titles=None, descriptions=None, disable=0, tag=u"a", attrs=None, enclosed=u"", part=wc.filter.html.COMPLETE, replacement=u""): """ Initialize rule data. """ super(HtmlrewriteRule, self).__init__(sid=sid, titles=titles, descriptions=descriptions, disable=disable) self.tag = tag self.tag_ro ... | 5df9a57bb2b61cf160c233fd653800d8acb18754 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5df9a57bb2b61cf160c233fd653800d8acb18754/HtmlrewriteRule.py | |
if self.tag in NO_CLOSE_TAGS: return True | for tag in NO_CLOSE_TAGS: if self.match_tag(tag): return True | def matches_starttag (self): """ See if this rule matches start tags. """ if self.tag in NO_CLOSE_TAGS: return True return self.part not in [ wc.filter.html.ENCLOSED, wc.filter.html.COMPLETE, ] | 5df9a57bb2b61cf160c233fd653800d8acb18754 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5df9a57bb2b61cf160c233fd653800d8acb18754/HtmlrewriteRule.py |
if self.tag in NO_CLOSE_TAGS: return False | for tag in NO_CLOSE_TAGS: if self.match_tag(tag): return False | def matches_endtag (self): """ See if this rule matches end tags. """ if self.tag in NO_CLOSE_TAGS: return False return self.part not in [ wc.filter.html.ATTR, wc.filter.html.ATTRVAL, wc.filter.html.ATTRNAME, ] | 5df9a57bb2b61cf160c233fd653800d8acb18754 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5df9a57bb2b61cf160c233fd653800d8acb18754/HtmlrewriteRule.py |
def XtestScriptSrc1 (self): | def testScriptSrc1 (self): | def XtestScriptSrc1 (self): self.filt( | b49dd87fac36792099044bb63fbf6476f7b83c01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b49dd87fac36792099044bb63fbf6476f7b83c01/TestScriptSrc.py |
def XtestScriptSrc2 (self): | def testScriptSrc2 (self): | def XtestScriptSrc2 (self): self.filt( | b49dd87fac36792099044bb63fbf6476f7b83c01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b49dd87fac36792099044bb63fbf6476f7b83c01/TestScriptSrc.py |
def XtestScriptSrc3 (self): | def testScriptSrc3 (self): | def XtestScriptSrc3 (self): """missing </script>""" self.filt( | b49dd87fac36792099044bb63fbf6476f7b83c01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/b49dd87fac36792099044bb63fbf6476f7b83c01/TestScriptSrc.py |
print "line", `l` | def parse_headers (): headers = [] try: s = get_data("/headers/") #debug(BRING_IT_ON, "headers data", s) except (IOError, ValueError): print >> sys.stderr, _("WebCleaner is not running") return headers if s=="-": return headers lines = s.split("\n") for l in lines: print "line", `l` # strip off paranthesis l = l[1:-1] ... | 47761498dc644faabb60e83c0bebe297ee674e10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/47761498dc644faabb60e83c0bebe297ee674e10/HeaderWindow.py | |
print >>sys.stderr, "JS:", data | self.jsfilter.feed(data) | def processData (self, data): print >>sys.stderr, "JS:", data # XXX parse recursively | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
self.buffer.append((ENDTAG, tag)) | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py | |
if not filtered and self.javascript: | if not filtered and self.javascript and tag=='script': | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
if tag!='script': return if not self.buffer: print >>sys.stderr, "empty buffer on </script>" | if len(self.buffer)<2: print >>sys.stderr, "short buffer on </script>", self.buffer | def jsEndElement (self, tag): """parse generated html for scripts""" if tag!='script': return if 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("<... | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
last = self.buffer[-1] if last[0]!=DATA: print >>sys.stderr, "missing body for </script>", last | if self.buffer[-1][0]!=DATA or self.buffer[-2][0]!=STARTTAG: print >>sys.stderr, "missing tags for </script>", self.buffer[-2:] | def jsEndElement (self, tag): """parse generated html for scripts""" if tag!='script': return if 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("<... | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
script = last[1].strip() | script = self.buffer[-1][1].strip() self.buffer[-2:] = [] | def jsEndElement (self, tag): """parse generated html for scripts""" if tag!='script': return if 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("<... | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
self.jsEnv.executeScriptAsFunction(val, 0.0) | self.jsfilter = HtmlFilter(self.rules, self.document, comments=self.comments, javascript=self.javascript) self.jsEnv.executeScriptAsFunction(script, 0.0) | def jsEndElement (self, tag): """parse generated html for scripts""" if tag!='script': return if 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("<... | 35fc60315c55232a57ddd202478a1748ebc7468a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/35fc60315c55232a57ddd202478a1748ebc7468a/Rewriter.py |
if attrs.get('imgreducer_convert'): img = img.convert() | if img.mode not in ('RGB', 'L'): img.draft("RGB", img.size) img = img.convert("RGB") | def finish (self, data, attrs): """ Feed image data to buffer, then convert it and return result. """ if self.init_image_reducer: self.set_ctype_header(attrs) self.init_image_reducer = False if not attrs.has_key('imgreducer_buf'): return data p = attrs['imgreducer_buf'] if data: p.write(data) p.seek(0) try: img = Image... | 13b8aa23c835eaed0a2ae53aa82e5260107086cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/13b8aa23c835eaed0a2ae53aa82e5260107086cf/ImageReducer.py |
"I/O error reading image data: %s", str(msg)) | "I/O error reading image data %r: %s", attrs['url'], str(msg)) | def finish (self, data, attrs): """ Feed image data to buffer, then convert it and return result. """ if self.init_image_reducer: self.set_ctype_header(attrs) self.init_image_reducer = False if not attrs.has_key('imgreducer_buf'): return data p = attrs['imgreducer_buf'] if data: p.write(data) p.seek(0) try: img = Image... | 13b8aa23c835eaed0a2ae53aa82e5260107086cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/13b8aa23c835eaed0a2ae53aa82e5260107086cf/ImageReducer.py |
d['imgreducer_convert'] = convert(ctype) | def get_attrs (self, url, localhost, stages, headers): """ Initialize image reducer buffer and flags. """ if not self.applies_to_stages(stages): return {} # don't filter tiny images d = super(ImageReducer, self).get_attrs(url, localhost, stages, headers) # weed out the rules that don't apply to this url rules = [ rule ... | 13b8aa23c835eaed0a2ae53aa82e5260107086cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/13b8aa23c835eaed0a2ae53aa82e5260107086cf/ImageReducer.py | |
def convert (ctype): """ Return True if an image has to be convert()ed before saving. """ return ctype in ('image/gif',) | def get_attrs (self, url, localhost, stages, headers): """ Initialize image reducer buffer and flags. """ if not self.applies_to_stages(stages): return {} # don't filter tiny images d = super(ImageReducer, self).get_attrs(url, localhost, stages, headers) # weed out the rules that don't apply to this url rules = [ rule ... | 13b8aa23c835eaed0a2ae53aa82e5260107086cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/13b8aa23c835eaed0a2ae53aa82e5260107086cf/ImageReducer.py | |
data += content | data += request.content | def construct_request_data (self, request): """ Construct valid HTTP request data string. """ lines = [] version = "HTTP/%d.%d" % request.version lines.append("%s %s %s" % (request.method, request.uri, version)) lines.extend(request.headers) # an empty line ends the headers lines.extend(("", "")) data = "\r\n".join(lin... | 51ab489f74ddf9b36d79a2707841ec7b0704a4b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/51ab489f74ddf9b36d79a2707841ec7b0704a4b6/__init__.py |
if subkey.get('EnableDHCP')==1: ip = subkey.get('DhcpIPAddress') | if subkey.get('EnableDHCP'): ip = subkey.get('DhcpIPAddress', '') | def get_localaddrs (): """all active interfaces' ip addresses""" addrs = sets.Set() try: # search interfaces key = wc.winreg.key_handle(wc.winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces") for subkey in key.subkeys(): if subkey.get('EnableDHCP')==1: ip = subkey.get('DhcpIPAddr... | 46e6c1670e7d231539bdadf3e56d95da49100694 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/46e6c1670e7d231539bdadf3e56d95da49100694/nt.py |
ip = subkey.get('IPAddress') if ip: addrs.add(ip) | ip = subkey.get('IPAddress', '') if not (isinstance(ip, basestring) and ip): continue addrs.add(str(ip)) | def get_localaddrs (): """all active interfaces' ip addresses""" addrs = sets.Set() try: # search interfaces key = wc.winreg.key_handle(wc.winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces") for subkey in key.subkeys(): if subkey.get('EnableDHCP')==1: ip = subkey.get('DhcpIPAddr... | 46e6c1670e7d231539bdadf3e56d95da49100694 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/46e6c1670e7d231539bdadf3e56d95da49100694/nt.py |
p.debug(1) | def _main (): """USAGE: test/run.sh test/parsefile.py test.html""" import sys if len(sys.argv)!=2: print _main.__doc__ sys.exit(1) if sys.argv[1]=='-': f = sys.stdin else: f = file(sys.argv[1]) from wc.parser.htmllib import HtmlPrinter from wc.parser import htmlsax p = htmlsax.parser(HtmlPrinter()) p.debug(1) size = 10... | cd253a6cdf23fbc9d8c7e42879bd4883bca11cb0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/cd253a6cdf23fbc9d8c7e42879bd4883bca11cb0/parsefile.py | |
""" % fname("example") | """ % fname("example", sep="/") | def fname (name): return os.path.join("wc", "dns", "tests", name) | 9f0b5ca04367d9257ac9c86c3a391f1d3f26e70b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9f0b5ca04367d9257ac9c86c3a391f1d3f26e70b/test_zone.py |
translator = gettext.translation(Name, LocaleDir, [lang]) | if lang!='en': translator = gettext.translation(Name, LocaleDir, [lang]) else: translator = None | def __init__ (self, client, url, form, protocol, status=200, msg=i18n._('Ok'), context={}, headers={'Content-Type': 'text/html'}): self.client = client # we pretend to be the server self.connected = True try: lang = i18n.get_headers_lang(headers) # get the template filename path, dirs, lang = get_template_url(url, lang... | ae419adf110b72b6c3e74a036a832d0229454dda /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/ae419adf110b72b6c3e74a036a832d0229454dda/__init__.py |
"""return True if given file is writable""" if os.path.isdir(fname) or os.path.islink(fname): return False try: if os.path.exists(fname): open(fname, 'a').close() return True else: open(fname, 'w').close() os.remove(fname) return True except IOError: pass return False def get_log_file (name, logname, trydirs=[]): """... | """return True if given file is writable""" if os.path.isdir(fname) or os.path.islink(fname): return False try: if os.path.exists(fname): open(fname, 'a').close() return True else: open(fname, 'w').close() os.remove(fname) return True except IOError: pass return False def get_log_file (name, logname, trydirs=None): "... | def iswritable (fname): """return True if given file is writable""" if os.path.isdir(fname) or os.path.islink(fname): return False try: if os.path.exists(fname): open(fname, 'a').close() return True else: open(fname, 'w').close() os.remove(fname) return True except IOError: pass return False | 208101be0a66da6c9dc5cf88658d5acfe1c68647 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/208101be0a66da6c9dc5cf88658d5acfe1c68647/__init__.py |
p.feed("""<a b="c"><""") p.feed("""d>""") | s = """<h1>bla</h1>""" for c in s: p.feed(c) p.flush() | def _broken (): p = HtmlPrinter() p.feed("""<a b="c"><""") p.feed("""d>""") | 25e8ed57c6acfdfe71d03c14a622ec92b468c27e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/25e8ed57c6acfdfe71d03c14a622ec92b468c27e/htmllib.py |
return (mo.group(1), mo.group(2)) if __name__=='__main__': for url in ['', 'a', 'a/b', 'http://imadoofus.com', 'http://imadoofus.com//', 'http://imadoofus.com/?q=a', 'http://imadoofus.com/?q=a 'http://imadoofus.com/a/b//c', 'http://imadoofus.com/forum', 'http://imadoofus.com/forum/', ]: print rating_split_url(url) pr... | vmin, vmax = mo.group(1), mo.group(2) if vmin=="": vmin = None else: vmin = int(vmin) if vmax=="": vmax = None else: vmax = int(vmax) return (vmin, vmax) | def rating_range (value): """parse value as range; return tuple (rmin, rmax) or None on error""" mo = _range_re.match(value) if not mo: return None return (mo.group(1), mo.group(2)) | 9accbce77dae1b724f1f1ad6ba3ab59b899732cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/9accbce77dae1b724f1f1ad6ba3ab59b899732cb/Rating.py |
def server_response (self, response, statuscode, headers): | def server_response (self, response, statuscode, status, headers): | def server_response (self, response, statuscode, headers): """the server got a response""" # Okay, transfer control over to the real client if self.client.connected: config['requests']['valid'] += 1 self.server.client = self.client self.client.server_response(self.server, response, statuscode, headers) else: self.serve... | 5aaaf0f8c7cbeb35466459a95e5888072c287921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5aaaf0f8c7cbeb35466459a95e5888072c287921/ClientServerMatchmaker.py |
self.client.server_response(self.server, response, statuscode, headers) | self.client.server_response(self.server, response, status, headers) | def server_response (self, response, statuscode, headers): """the server got a response""" # Okay, transfer control over to the real client if self.client.connected: config['requests']['valid'] += 1 self.server.client = self.client self.client.server_response(self.server, response, statuscode, headers) else: self.serve... | 5aaaf0f8c7cbeb35466459a95e5888072c287921 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5aaaf0f8c7cbeb35466459a95e5888072c287921/ClientServerMatchmaker.py |
elif not ct.startswith(gm[0]) and \ gm[0] in _fix_content_types: warn(PROXY, i18n._("change Content-Type from %s to %s in %s"), `ct`, `gm[0]`, `self.url`) self.headers['Content-Type'] = "%s\r"%gm[0] if gm[1] and gm[1] in _fix_content_encodings: ce = self.headers.get('Content-Encoding', None) if ce is None: self.heade... | def check_headers (self): """add missing content-type and/or encoding headers""" # 304 Not Modified does not send any type or encoding info, # because this info was cached if self.statuscode == '304': return # check content-type against our own guess i = self.document.find('?') if i>0: document = self.document[:i] else... | 7cad4003033d1bd964b8222c220ae1bfd6bbf463 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/7cad4003033d1bd964b8222c220ae1bfd6bbf463/HttpServer.py | |
headers.append("Content-Length: %d" % len(content)-5) | headers.append("Content-Length: %d" % (len(content)-5)) | def get_request_headers (self, content): port = self.server.socket.getsockname()[1] headers = [ "Host: localhost:%d" % port, "Proxy-Connection: close", ] if content: headers.append("Content-Length: %d" % len(content)) headers.append("Content-Length: %d" % len(content)-5) return headers | 4178632fd0e93a2cc5b75e213dd7b89be7a0e06b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4178632fd0e93a2cc5b75e213dd7b89be7a0e06b/test_multiheader.py |
"Content-Length: %d" % len(content)-5, | "Content-Length: %d" % (len(content)-5), | def get_response_headers (self, content): return [ "Content-Type: text/plain", "Content-Length: %d" % len(content), "Content-Length: %d" % len(content)-5, ] | 4178632fd0e93a2cc5b75e213dd7b89be7a0e06b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4178632fd0e93a2cc5b75e213dd7b89be7a0e06b/test_multiheader.py |
def generate_sids (): | def generate_sids (prefix="wc"): | def generate_sids (): for rule in _rules_without_sid: rule.sid = generate_unique_sid("wc") del _rules_without_sid[:] | 6af989e0d472cc03f4c8722380321c1aa0df7ec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/6af989e0d472cc03f4c8722380321c1aa0df7ec1/__init__.py |
rule.sid = generate_unique_sid("wc") | rule.sid = generate_unique_sid(prefix) | def generate_sids (): for rule in _rules_without_sid: rule.sid = generate_unique_sid("wc") del _rules_without_sid[:] | 6af989e0d472cc03f4c8722380321c1aa0df7ec1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/6af989e0d472cc03f4c8722380321c1aa0df7ec1/__init__.py |
hosts = sort_seq(ip.map2hosts(self['nofilterhosts'])) | hosts = self['nofilterhosts'] | def write_proxyconf (self): """write proxy configuration""" f = file(self['configfile'], 'w') f.write("""<?xml version="1.0" encoding="%s"?> | 047dfe1a215752fc10b3c7fa9191f5799f3347da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/047dfe1a215752fc10b3c7fa9191f5799f3347da/__init__.py |
'HTTP/1.0 %d Use different host\r\n', | 'HTTP/1.0 %d %s\r\n', 'Server: WebCleaner Proxy\r\n' | def error(self, code, msg): ServerHandleDirectly( self.client, 'HTTP/1.0 %d Use different host\r\n', 'Content-type: text/html\r\n' 'Location: http://%s\r\n' '\r\n' % (code, new_url), msg) | d689ab4b5238b9e82a92e3c41d9f0c47782b391e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d689ab4b5238b9e82a92e3c41d9f0c47782b391e/ClientServerMatchmaker.py |
'Location: http://%s\r\n' '\r\n' % (code, new_url), | '\r\n' '<html><head>' '<title>WebCleaner Proxy Error %d %s</title>' '</head><body bgcolor=" 'WebCleaner Proxy Error %d %s<br>' '%s<br></center></body></html>' % (code, msg, code, msg), | def error(self, code, msg): ServerHandleDirectly( self.client, 'HTTP/1.0 %d Use different host\r\n', 'Content-type: text/html\r\n' 'Location: http://%s\r\n' '\r\n' % (code, new_url), msg) | d689ab4b5238b9e82a92e3c41d9f0c47782b391e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d689ab4b5238b9e82a92e3c41d9f0c47782b391e/ClientServerMatchmaker.py |
assert self.state == 'dns' if answer.isError(): self.error(400, _(answer.data)) return self.state = 'server' self.ipaddr = socket.gethostbyname(self.hostname) self.find_server() def _handle_dns(self, hostname, answer): | def handle_dns(self, hostname, answer): assert self.state == 'dns' if answer.isError(): self.error(400, _(answer.data)) return self.state = 'server' self.ipaddr = socket.gethostbyname(self.hostname) | d689ab4b5238b9e82a92e3c41d9f0c47782b391e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/d689ab4b5238b9e82a92e3c41d9f0c47782b391e/ClientServerMatchmaker.py | |
print "X", repr(file_length) print "X", repr(offset) | 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... | 687536303ff11effe11421562bee57b974b1a0bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/687536303ff11effe11421562bee57b974b1a0bb/magic.py | |
debug(PROXY, '%s <= read %d', self, len(data)) debug(CONNECTION, 'data %r', data) | def handle_read (self): """read data from connection, put it into recv_buffer and call process_read""" assert self.connected debug(PROXY, '%s handle_read', self) | 07041c45cdc133cb738a13fb1405dec85759d43c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/07041c45cdc133cb738a13fb1405dec85759d43c/Connection.py | |
debug(HURT_ME_PLENTY, "request", `self.request`) | def __init__ (self, client, request, headers, content, nofilter,compress): self.client = client self.request = request self.headers = headers self.compress = compress self.content = content self.nofilter = nofilter debug(HURT_ME_PLENTY, "request", `self.request`) self.method, self.url, protocol = self.request.split() s... | de023d7b994a3cb75dfc854df0807d6ae5f19339 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/de023d7b994a3cb75dfc854df0807d6ae5f19339/ClientServerMatchmaker.py | |
url = baseurl+filename+".gz" | url = baseurl+filename | 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_... | c11acc76c9ac079636774d74a38c7a44f6e1ecbc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/c11acc76c9ac079636774d74a38c7a44f6e1ecbc/update.py |
if encoding in ('gzip', 'x-gzip', 'deflate') and rewrite: | if encoding in ('gzip', 'x-gzip', 'deflate'): | 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.... | 02280af01cffb8e7abeb5cea52943ce090adfb45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/02280af01cffb8e7abeb5cea52943ce090adfb45/HttpServer.py |
elif encoding and encoding!='identity' and rewrite: | elif encoding and encoding!='identity': | 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.... | 02280af01cffb8e7abeb5cea52943ce090adfb45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/02280af01cffb8e7abeb5cea52943ce090adfb45/HttpServer.py |
self.attrs = initStateObjects(self.headers, self.url) if self.headers.get('Content-Length') is None: self.headers['Connection'] = 'close' wc.proxy.HEADERS.append((self.url, 1, self.headers.headers)) self.client.server_response(self.response, self.headers) self.attrs['nofilter'] = self.nofilter['nofilter'] if ((respon... | 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.... | 02280af01cffb8e7abeb5cea52943ce090adfb45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/02280af01cffb8e7abeb5cea52943ce090adfb45/HttpServer.py | |
if self.document.endswith(".bz2") or \ self.document.endswith(".tgz") or \ self.document.endswith(".gz"): gm = mimetypes.guess_type(self.document, False) if gm[1]: self.headers['Content-Encoding'] = gm[1] if gm[0]: self.headers['Content-Type'] = gm[0] | 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.... | c7a765614b330c8ca260a7b155f31d0a0b59bd6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/c7a765614b330c8ca260a7b155f31d0a0b59bd6c/HttpServer.py | |
p.feed("""<a><t""") p.feed("""r>""") | p.feed("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META NAME="Description" CONTENT="Obsession Development: Products"> <META NAME="Resource-Type" CONTENT="document"> <META NAME="Content-Type" CONTENT="text/html, charset=iso-8859-1"> <META HTTP-EQUIV="Content-Style-Type... | def _broken (): p = HtmlPrinter() p.feed("""<a><t""") p.feed("""r>""") p.flush() | 5b39040dd85d5381c8f17f797f74aad71815bfd8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/5b39040dd85d5381c8f17f797f74aad71815bfd8/htmllib.py |
if not category.valid_value(value): | if category.iterable: realvalue = value else: realvalue = _intrange_from_string(value) if not category.valid_value(realvalue): | def _form_ratings (form): """Check category value validity""" for catname, value in _get_prefix_vals(form, 'category_'): category = _get_category(catname) if category is None: # unknown category error['categoryvalue'] = True return False if not category.valid_value(value): error['categoryvalue'] = True return False if ... | a4c18f8b00dd11d6673142806f476a8ab23a0a0f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/a4c18f8b00dd11d6673142806f476a8ab23a0a0f/rating_html.py |
p = wc.configuration.ZapperParser(filename) | p = wc.configuration.confparse.ZapperParser(filename) | def read_ids (filename, ids): p = wc.configuration.ZapperParser(filename) p.parse() ids['folder']['sid'] = str(p.folder.sid) ids['folder']['oid'] = p.folder.oid ids['folder']['configversion'] = str(p.folder.configversion) for rule in p.folder.rules: for ftype in ('domains', 'urls'): if rule.name.endswith(ftype): ids[ft... | 3465b5ee3ef1c0df3638f47dce4d547cf4c2df9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/3465b5ee3ef1c0df3638f47dce4d547cf4c2df9c/bl2wc.py |
fname = "extracted/"+fname[:-3] | fname = os.path.join(extract_to, fname[:-3]) | def blacklist (fname, extract_to="extracted"): source = os.path.join("downloads", fname) # extract tar if fname.endswith(".tar.gz") or fname.endswith(".tgz"): print "extracting archive", fname f = tarfile.TarFile.gzopen(source) for m in f: a, b = os.path.split(m.name) a = os.path.basename(a) if b in myfiles and a in my... | 3465b5ee3ef1c0df3638f47dce4d547cf4c2df9c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/3465b5ee3ef1c0df3638f47dce4d547cf4c2df9c/bl2wc.py |
self.js_script += data | self.js_script += data.decode(self.htmlparser.encoding, "ignore") | def jsScriptData (self, data, url, ver): """Callback for loading <script src=""> data in the background If downloading is finished, data is None""" assert self.htmlparser.state[0] == 'wait', "non-wait state" wc.log.debug(wc.LOG_JS, "%s jsScriptData %r", self, data) if data is None: if not self.js_script: wc.log.warn(wc... | 8ccd48f9e30f773513b3a2077760f5ffc6bb980b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8ccd48f9e30f773513b3a2077760f5ffc6bb980b/JSFilter.py |
res = [None] | def _form_reset (): """reset info/error and global vars""" global filterenabled, filterdisabled filterenabled = u"" filterdisabled = u"" for key in info.keys(): info[key] = False for key in error.keys(): error[key] = False res = [None] | f22f1610959a45b0274edaa01996e69b5de6708c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/f22f1610959a45b0274edaa01996e69b5de6708c/config_html.py | |
def update (wconfig, baseurl, dryrun=False, log=None): | def update (wconfig, dryrun=False, log=None): | def update (wconfig, 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 """ chg = False url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >... | 8342ac908384bd779d9849f21b36dc47ba58d309 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8342ac908384bd779d9849f21b36dc47ba58d309/update.py |
p = wc.ZapperParser(fullname, compile_data=False) p.parse(page, wconfig) | p = wc.ZapperParser(fullname, wconfig, compile_data=False) p.parse(fp=page) | def update (wconfig, 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 """ chg = False url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >... | 8342ac908384bd779d9849f21b36dc47ba58d309 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8342ac908384bd779d9849f21b36dc47ba58d309/update.py |
def _test (): initlog("test/logging.conf") baseurl = "http://localhost/~calvin/webcleaner.sf.net/htdocs/test/" update(wc.Configuration(), baseurl, dryrun=True) if __name__=='__main__': _test() | def update (wconfig, 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 """ chg = False url = baseurl+"filter-md5sums.txt" try: page = open_url(url) except IOError, msg: print >... | 8342ac908384bd779d9849f21b36dc47ba58d309 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/8342ac908384bd779d9849f21b36dc47ba58d309/update.py | |
def new_instance (self, opts): | def new_instance (self, **opts): | def new_instance (self, opts): return HtmlFilter(self.rules, self.ratings, self.url, **opts) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("cdata %r", data) | debug(FILTER, "%s cdata %r", self, data) | def cdata (self, data): """character data""" self._debug("cdata %r", data) return self._data(data) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("characters %r", data) | debug(FILTER, "%s characters %r", self, data) | def characters (self, data): """characters""" self._debug("characters %r", data) return self._data(data) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("comment %r", data) | debug(FILTER, "%s comment %r", self, data) | def comment (self, data): """a comment; accept only non-empty comments""" if not (self.comments and data): return self._debug("comment %r", data) item = [COMMENT, data] self.htmlparser.tagbuf.append(item) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("doctype %r", data) | debug(FILTER, "%s doctype %r", self, data) | def doctype (self, data): self._debug("doctype %r", data) return self._data("<!DOCTYPE%s>"%data) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("pi %r", data) | debug(FILTER, "%s pi %r", self, data) | def pi (self, data): self._debug("pi %r", data) return self._data("<?%s?>"%data) | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("startElement %r", tag) | debug(FILTER, "%s startElement %r", self, tag) if self._is_waiting([STARTTAG, tag, attrs]): return | 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.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("using base url %r", self.base_url) | debug(FILTER, "%s using base url %r", self, self.base_url) | 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.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._filterStartElement(tag, attrs) | self.filterStartElement(tag, attrs) | 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.""" # default data self._debug("startElement %r", tag) tag = check_spelling(tag, self.url) if self.stackcount: if self.stackcount[-1][0]==tag: self.stackcount[-1][1] +=... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
def _filterStartElement (self, tag, attrs): | def filterStartElement (self, tag, attrs): | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("matched rule %r on tag %r", rule.title, tag) | debug(FILTER, "%s matched rule %r on tag %r", self, rule.title, tag) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("put on buffer") | debug(FILTER, "%s put rule %r on buffer", self, rule.title) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._jsStartElement(tag, attrs) | self.jsStartElement(tag, attrs) | def _filterStartElement (self, tag, attrs): """filter the start element according to filter rules""" rulelist = [] filtered = False item = [STARTTAG, tag, attrs] for rule in self.rules: if rule.match_tag(tag) and rule.match_attrs(attrs): self._debug("matched rule %r on tag %r", rule.title, tag) if rule.start_sufficient... | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
self._debug("endElement %r", tag) | debug(FILTER, "%s endElement %r", self, tag) if self._is_waiting([ENDTAG, tag]): return | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py | ||
if not self._filterEndElement(tag): | if not self.filterEndElement(tag): | def endElement (self, tag): """We know the following: if a rule matches, it must be the one on the top of the stack. So we look only at the top rule. | 4a1c178ba0dd448a42795b2c19afac8cb1126130 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3948/4a1c178ba0dd448a42795b2c19afac8cb1126130/HtmlFilter.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.