code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
from ..bookmarks.chromium import parse_bookmark_data for url, name in parse_bookmark_data(url_data.get_content()): url_data.add_url(url, name=name)
def parse_chromium (url_data)
Parse a Chromium or Google Chrome bookmark file.
5.901628
5.346981
1.103731
from ..bookmarks.safari import parse_bookmark_data for url, name in parse_bookmark_data(url_data.get_content()): url_data.add_url(url, name=name)
def parse_safari (url_data)
Parse a Safari bookmark file.
5.186097
4.509822
1.149956
lineno = 0 for line in url_data.get_content().splitlines(): lineno += 1 line = line.strip() if not line or line.startswith('#'): continue url_data.add_url(line, line=lineno)
def parse_text (url_data)
Parse a text file with one url per line; comment and blank lines are ignored.
3.621113
3.10777
1.165181
lineno = 0 linkfinder = linkparse.css_url_re.finditer strip_comments = linkparse.strip_c_comments for line in strip_comments(url_data.get_content()).splitlines(): lineno += 1 for mo in linkfinder(line): column = mo.start("url") url = strformat.unquote(mo.grou...
def parse_css (url_data)
Parse a CSS file for url() patterns.
5.849226
5.435208
1.076173
linkfinder = linkparse.swf_url_re.finditer for mo in linkfinder(url_data.get_content()): url = mo.group() url_data.add_url(url)
def parse_swf (url_data)
Parse a SWF file for URLs.
7.552605
6.408034
1.178615
# construct parser object handler = linkparse.LinkFinder(callback, tags) parser = htmlsax.parser(handler) if url_data.charset: parser.encoding = url_data.charset handler.parser = parser # parse try: parser.feed(url_data.get_content()) parser.flush() except li...
def find_links (url_data, callback, tags)
Parse into content and search for URLs to check. Found URLs are added to the URL queue.
6.254945
6.376316
0.980965
filename = url_data.get_os_filename() for url, name in firefox.parse_bookmark_file(filename): url_data.add_url(url, name=name)
def parse_firefox (url_data)
Parse a Firefox3 bookmark file.
7.073986
5.186873
1.363825
query = url_data.urlparts[3] for k, v, sep in urlutil.parse_qsl(query, keep_blank_values=True): if k == "url": url_data.add_url(v) break
def parse_itms_services(url_data)
Get "url" CGI parameter value as child URL.
5.291306
4.381612
1.207616
if is_frozen(): # find modules in library.zip filename zipname = os.path.dirname(os.path.dirname(__file__)) parentmodule = os.path.basename(os.path.dirname(__file__)) with zipfile.ZipFile(zipname, 'r') as f: prefix = "%s/%s/" % (parentmodule, packagename) ...
def get_package_modules(packagename)
Find all valid modules in the given package which must be a folder in the same directory as this loader.py module. A valid module has a .py extension, and is importable. @return: all loaded valid modules @rtype: iterator of module
3.036187
3.063743
0.991006
if check_writable_by_others(folder): print("ERROR: refuse to load modules from world writable folder %r" % folder) return for filename in get_importable_files(folder): fullname = os.path.join(folder, filename) modname = parentpackage+"."+filename[:-3] try: ...
def get_folder_modules(folder, parentpackage)
.
4.538364
4.488756
1.011052
for fname in os.listdir(folder): if fname.endswith('.py') and not fname.startswith('_'): fullname = os.path.join(folder, fname) if check_writable_by_others(fullname): print("ERROR: refuse to load module from world writable file %r" % fullname) else: ...
def get_importable_files(folder)
Find all module files in the given folder that end with '.py' and don't start with an underscore. @return module names @rtype: iterator of string
6.037879
5.992549
1.007564
for module in modules: for plugin in get_module_plugins(module, classes): yield plugin
def get_plugins(modules, classes)
Find all given (sub-)classes in all modules. @param modules: the modules to search @ptype modules: iterator of modules @return: found classes @rytpe: iterator of class objects
3.614392
5.453264
0.662794
host = self.urlparts[1] addresses = socket.getaddrinfo(host, 80, 0, 0, socket.SOL_TCP) args = {'host': host} if addresses: args['ips'] = [x[4][0] for x in addresses] self.set_result(_('%(host)s resolved to IPs %(ips)s') % args, valid=True) else: ...
def check_connection(self)
Resolve hostname.
3.547076
3.271207
1.084333
lock = threading.Lock() # for thread debugging, use the DebugLock wrapper if debug: lock = DebugLock(lock, name) return lock
def get_lock (name, debug=False)
Get a new lock. @param debug: if True, acquire() and release() will have debug messages @ptype debug: boolean, default is False @return: a lock object @rtype: threading.Lock or DebugLock
6.325112
9.317812
0.678819
if value is None: lock = threading.Semaphore() else: lock = threading.BoundedSemaphore(value) if debug: lock = DebugLock(lock, name) return lock
def get_semaphore(name, value=None, debug=False)
Get a new semaphore. @param value: if not None, a BoundedSemaphore will be used @ptype debug: int or None @param debug: if True, acquire() and release() will have debug messages @ptype debug: boolean, default is False @return: a semaphore object @rtype: threading.Semaphore or threading.BoundedSe...
2.919729
2.731662
1.068847
threadname = threading.currentThread().getName() log.debug(LOG_THREAD, "Acquire %s for %s", self.name, threadname) self.lock.acquire(blocking) log.debug(LOG_THREAD, "...acquired %s for %s", self.name, threadname)
def acquire (self, blocking=1)
Acquire lock.
3.451209
3.105509
1.111318
threadname = threading.currentThread().getName() log.debug(LOG_THREAD, "Release %s for %s", self.name, threadname) self.lock.release()
def release (self)
Release lock.
6.666082
5.214505
1.278373
for line in value.splitlines(): line = line.strip() if not line or line.startswith('#'): continue yield line
def read_multiline (value)
Helper function reading multiline values.
2.698275
2.485982
1.085396
assert isinstance(files, list), "Invalid file list %r" % files try: self.read_ok = super(LCConfigParser, self).read(files) if len(self.read_ok) < len(files): failed_files = set(files) - set(self.read_ok) log.warn(LOG_CHECK, "Could not read...
def read (self, files)
Read settings from given config files. @raises: LinkCheckerError on syntax errors in the config file(s)
5.173792
4.753287
1.088466
if self.has_option(section, option): value = self.get(section, option) if not allowempty and not value: raise LinkCheckerError(_("invalid empty value for %s: %s\n") % (option, value)) self.config[option] = value
def read_string_option (self, section, option, allowempty=False)
Read a string option.
3.738975
3.647083
1.025196
if self.has_option(section, option): self.config[option] = self.getboolean(section, option)
def read_boolean_option(self, section, option)
Read a boolean option.
3.125895
3.008879
1.03889
if self.has_option(section, option): num = self.getint(section, option) if min is not None and num < min: raise LinkCheckerError( _("invalid value for %s: %d must not be less than %d") % (option, num, min)) if max is not None and n...
def read_int_option (self, section, option, key=None, min=None, max=None)
Read an integer option.
2.264665
2.230788
1.015186
section = "output" from ..logger import LoggerClasses for c in LoggerClasses: key = c.LoggerName if self.has_section(key): for opt in self.options(key): self.config[key][opt] = self.get(key, opt) if self.has_opt...
def read_output_config (self)
Read configuration options in section "output".
3.004198
2.951525
1.017846
section = "checking" self.read_int_option(section, "threads", min=-1) self.config['threads'] = max(0, self.config['threads']) self.read_int_option(section, "timeout", min=1) self.read_int_option(section, "aborttimeout", min=1) self.read_int_option(section, "recur...
def read_checking_config (self)
Read configuration options in section "checking".
2.60656
2.508663
1.039024
section = "authentication" password_fields = [] if self.has_option(section, "entry"): for val in read_multiline(self.get(section, "entry")): auth = val.split() if len(auth) == 3: self.config.add_auth(pattern=auth[0], user=a...
def read_authentication_config (self)
Read configuration options in section "authentication".
2.952229
2.876635
1.026279
if not fields: return # The information which of the configuration files # included which option is not available. To avoid false positives, # a warning is only printed if exactly one file has been read. if len(self.read_ok) != 1: return ...
def check_password_readable(self, section, fields)
Check if there is a readable configuration file and print a warning.
6.621227
6.477415
1.022202
section = "filtering" if self.has_option(section, "ignorewarnings"): self.config['ignorewarnings'] = [f.strip().lower() for f in \ self.get(section, 'ignorewarnings').split(',')] if self.has_option(section, "ignore"): for line in read_multiline(s...
def read_filtering_config (self)
Read configuration options in section "filtering".
2.852848
2.726586
1.046308
folders = self.config["pluginfolders"] modules = plugins.get_plugin_modules(folders) for pluginclass in plugins.get_plugin_classes(modules): section = pluginclass.__name__ if self.has_section(section): self.config["enabledplugins"].append(section)...
def read_plugin_config(self)
Read plugin-specific configuration values.
3.926955
3.762444
1.043725
log.debug(LOG_PLUGIN, "checking content for warning regex") content = url_data.get_content() # add warnings for found matches, up to the maximum allowed number match = self.warningregex.search(content) if match: # calculate line number for match l...
def check(self, url_data)
Check content.
6.463083
6.167754
1.047883
config = dict() section = cls.__name__ option = "warningregex" if configparser.has_option(section, option): value = configparser.get(section, option) else: value = None config[option] = value return config
def read_config(cls, configparser)
Read configuration file options.
3.451557
3.305475
1.044194
self.output.seek(where) self.output.truncate() keys_to_delete = [] for k, v in self.compress.iteritems(): if v >= where: keys_to_delete.append(k) for k in keys_to_delete: del self.compress[k]
def _rollback(self, where)
Truncate the output buffer at offset I{where}, and remove any compression table entries that pointed beyond the truncation point. @param where: the offset @type where: int
3.312159
2.508156
1.320556
if self.section != section: if self.section > section: raise dns.exception.FormError self.section = section
def _set_section(self, section)
Set the renderer's current section. Sections must be rendered order: QUESTION, ANSWER, AUTHORITY, ADDITIONAL. Sections may be empty. @param section: the section @type section: int @raises dns.exception.FormError: an attempt was made to set a section value less than the...
7.031178
3.756047
1.871962
self._set_section(QUESTION) before = self.output.tell() qname.to_wire(self.output, self.compress, self.origin) self.output.write(struct.pack("!HH", rdtype, rdclass)) after = self.output.tell() if after >= self.max_size: self._rollback(before) ...
def add_question(self, qname, rdtype, rdclass=dns.rdataclass.IN)
Add a question to the message. @param qname: the question name @type qname: dns.name.Name @param rdtype: the question rdata type @type rdtype: int @param rdclass: the question rdata class @type rdclass: int
3.827318
3.731391
1.025708
self._set_section(section) before = self.output.tell() n = rrset.to_wire(self.output, self.compress, self.origin, **kw) after = self.output.tell() if after >= self.max_size: self._rollback(before) raise dns.exception.TooBig self.counts[se...
def add_rrset(self, section, rrset, **kw)
Add the rrset to the specified section. Any keyword arguments are passed on to the rdataset's to_wire() routine. @param section: the section @type section: int @param rrset: the rrset @type rrset: dns.rrset.RRset object
5.082785
4.478996
1.134805
self._set_section(section) before = self.output.tell() n = rdataset.to_wire(name, self.output, self.compress, self.origin, **kw) after = self.output.tell() if after >= self.max_size: self._rollback(before) raise dns.e...
def add_rdataset(self, section, name, rdataset, **kw)
Add the rdataset to the specified section, using the specified name as the owner name. Any keyword arguments are passed on to the rdataset's to_wire() routine. @param section: the section @type section: int @param name: the owner name @type name: dns.name.Name o...
5.113182
4.883946
1.046937
# make sure the EDNS version in ednsflags agrees with edns ednsflags &= 0xFF00FFFFL ednsflags |= (edns << 16) self._set_section(ADDITIONAL) before = self.output.tell() self.output.write(struct.pack('!BHHIH', 0, dns.rdatatype.OPT, payload, ...
def add_edns(self, edns, ednsflags, payload, options=None)
Add an EDNS OPT record to the message. @param edns: The EDNS level to use. @type edns: int @param ednsflags: EDNS flag values. @type ednsflags: int @param payload: The EDNS sender's payload field, which is the maximum size of UDP datagram the sender can handle. @...
2.805347
2.686178
1.044364
self._set_section(ADDITIONAL) before = self.output.tell() s = self.output.getvalue() (tsig_rdata, self.mac, ctx) = dns.tsig.sign(s, keyname, secret, ...
def add_tsig(self, keyname, secret, fudge, id, tsig_error, other_data, request_mac, algorithm=dns.tsig.default_algorithm)
Add a TSIG signature to the message. @param keyname: the TSIG key name @type keyname: dns.name.Name object @param secret: the secret to use @type secret: string @param fudge: TSIG time fudge @type fudge: int @param id: the message id to encode in the tsig signatu...
3.006441
3.059203
0.982753
self.output.seek(0) self.output.write(struct.pack('!HHHHHH', self.id, self.flags, self.counts[0], self.counts[1], self.counts[2], self.counts[3])) self.output.seek(0, 2)
def write_header(self)
Write the DNS message header. Writing the DNS message header is done asfter all sections have been rendered, but before the optional TSIG signature is added.
3.459235
2.694903
1.283621
cls = get_option_class(otype) return cls.from_wire(otype, wire, current, olen)
def option_from_wire(otype, wire, current, olen)
Build an EDNS option object from wire format @param otype: The option type @type otype: int @param wire: The wire-format message @type wire: string @param current: The offet in wire of the beginning of the rdata. @type current: int @param olen: The length of the wire-format option data ...
3.296449
3.528253
0.934301
self.writeln(s=u"# %s" % s, **args)
def comment (self, s, **args)
Write CSV comment.
12.74456
9.228664
1.380976
super(CSVLogger, self).start_output() row = [] if self.has_part("intro"): self.write_intro() self.flush() else: # write empty string to initialize file output self.write(u"") self.queue = StringIO() self.writer = cs...
def start_output (self)
Write checking start info as csv comment.
4.694788
4.487042
1.046299
row = [] if self.has_part("urlname"): row.append(url_data.base_url) if self.has_part("parentname"): row.append(url_data.parent_url) if self.has_part("baseref"): row.append(url_data.base_ref) if self.has_part("result"): row....
def log_url (self, url_data)
Write csv formatted url check info.
2.168104
2.128354
1.018677
while not urlqueue.empty(): url_data = urlqueue.get() try: check_url(url_data, logger) finally: urlqueue.task_done(url_data)
def check_urls (urlqueue, logger)
Check URLs without threading.
2.687907
2.518851
1.067116
if url_data.has_result: logger.log_url(url_data.to_wire()) else: cache = url_data.aggregate.result_cache key = url_data.cache_url result = cache.get_result(key) if result is None: # check check_start = time.time() try: ...
def check_url(url_data, logger)
Check a single URL with logging.
4.115596
4.0319
1.020758
try: url_data = self.urlqueue.get(timeout=QUEUE_POLL_INTERVALL_SECS) if url_data is not None: try: self.check_url_data(url_data) finally: self.urlqueue.task_done(url_data) self.setName(self.o...
def check_url (self)
Try to get URL data from queue and check it.
4.972669
4.05227
1.227131
if url_data.url is None: url = "" else: url = url_data.url.encode("ascii", "replace") self.setName("CheckThread-%s" % url) check_url(url_data, self.logger)
def check_url_data (self, url_data)
Check one URL data instance.
6.173841
5.516529
1.119153
event_mask = 0 if readable: event_mask |= select.POLLIN if writable: event_mask |= select.POLLOUT if error: event_mask |= select.POLLERR pollable = select.poll() pollable.register(fd, event_mask) if timeout: event_list = pollable.poll(long(timeout * 100...
def _poll_for(fd, readable, writable, error, timeout)
@param fd: File descriptor (int). @param readable: Whether to wait for readability (bool). @param writable: Whether to wait for writability (bool). @param expiration: Deadline timeout (expiration time, in seconds (float)). @return True on success, False on timeout
1.933514
2.236139
0.864666
rset, wset, xset = [], [], [] if readable: rset = [fd] if writable: wset = [fd] if error: xset = [fd] if timeout is None: (rcount, wcount, xcount) = select.select(rset, wset, xset) else: (rcount, wcount, xcount) = select.select(rset, wset, xset, tim...
def _select_for(fd, readable, writable, error, timeout)
@param fd: File descriptor (int). @param readable: Whether to wait for readability (bool). @param writable: Whether to wait for writability (bool). @param expiration: Deadline timeout (expiration time, in seconds (float)). @return True on success, False on timeout
1.910568
2.349208
0.813282
wire = q.to_wire() if af is None: try: af = dns.inet.af_for_address(where) except Exception: af = dns.inet.AF_INET if af == dns.inet.AF_INET: destination = (where, port) if source is not None: source = (source, source_port) elif a...
def udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, ignore_unexpected=False, one_rr_per_rrset=False)
Return the response obtained after sending a query via UDP. @param q: the query @type q: dns.message.Message @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, the defa...
2.31418
2.243356
1.031571
s = '' while count > 0: _wait_for_readable(sock, expiration) n = sock.recv(count) if n == '': raise EOFError count = count - len(n) s = s + n return s
def _net_read(sock, count, expiration)
Read the specified number of bytes from sock. Keep trying until we either get the desired amount, or we hit EOF. A Timeout exception will be raised if the operation is not completed by the expiration time.
2.712743
2.710095
1.000977
current = 0 l = len(data) while current < l: _wait_for_writable(sock, expiration) current += sock.send(data[current:])
def _net_write(sock, data, expiration)
Write the specified data to the socket. A Timeout exception will be raised if the operation is not completed by the expiration time.
4.318645
3.995133
1.080977
wire = q.to_wire() if af is None: try: af = dns.inet.af_for_address(where) except Exception: af = dns.inet.AF_INET if af == dns.inet.AF_INET: destination = (where, port) if source is not None: source = (source, source_port) elif a...
def tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0, one_rr_per_rrset=False)
Return the response obtained after sending a query via TCP. @param q: the query @type q: dns.message.Message object @param where: where to send the message @type where: string containing an IPv4 or IPv6 address @param timeout: The number of seconds to wait before the query times out. If None, t...
2.722839
2.657742
1.024493
if os.name == 'nt': if "LOCALAPPDATA" in os.environ: basedir = unicode(os.environ["LOCALAPPDATA"], nt_filename_encoding) else: # read local appdata directory from registry from ..winutil import get_shell_folder try: basedir = get_s...
def get_profile_dir ()
Return path where all profiles of current user are stored.
2.516158
2.495997
1.008077
value = _by_text.get(text.upper()) if value is None: match = _unknown_type_pattern.match(text) if match == None: raise UnknownRdatatype value = int(match.group(1)) if value < 0 or value > 65535: raise ValueError("type must be between >= 0 and <= 6553...
def from_text(text)
Convert text into a DNS rdata type value. @param text: the text @type text: string @raises dns.rdatatype.UnknownRdatatype: the type is unknown @raises ValueError: the rdata type value is not >= 0 and <= 65535 @rtype: int
4.435846
2.86849
1.546404
if rdtype >= TKEY and rdtype <= ANY or rdtype in _metatypes: return True return False
def is_metatype(rdtype)
True if the type is a metatype. @param rdtype: the type @type rdtype: int @rtype: bool
12.041276
12.291009
0.979682
self.start_time = time.time() self.setName("Status") # the first status should be after a second wait_seconds = 1 first_wait = True while not self.stopped(wait_seconds): self.log_status() if first_wait: wait_seconds = self....
def run_checked (self)
Print periodic status messages.
6.433473
5.734974
1.121796
duration = time.time() - self.start_time checked, in_progress, queue = self.aggregator.urlqueue.status() num_urls = len(self.aggregator.result_cache) self.logger.log_status(checked, in_progress, queue, duration, num_urls)
def log_status (self)
Log a status message.
6.03424
6.106846
0.988111
global mimedb try: mimedb = mimetypes.MimeTypes(strict=False) except Exception as msg: log.error(LOG_CHECK, "could not initialize MIME database: %s" % msg) return # For Opera bookmark files (opera6.adr) add_mimetype(mimedb, 'text/plain', '.adr') # To recognize PHP fi...
def init_mimedb()
Initialize the local MIME database.
5.850696
5.853901
0.999452
# If extension is already a common type, strict=True must be used. strict = extension in mimedb.types_map[True] mimedb.add_type(mimetype, extension, strict=strict)
def add_mimetype(mimedb, mimetype, extension)
Add or replace a mimetype to be used with the given extension.
9.150406
10.106567
0.905392
mime, encoding = None, None if mimedb: mime, encoding = mimedb.guess_type(filename, strict=False) basename = os.path.basename(filename) # Special case for Safari Bookmark files if not mime and basename == 'Bookmarks.plist': return 'application/x-plist+safari' # Special case ...
def guess_mimetype (filename, read=None)
Return MIME type of file, or 'application/octet-stream' if it could not be determined.
4.377406
4.239268
1.032585
mime = None try: data = read()[:70] except Exception: pass else: for cmime, ro in PARSE_CONTENTS.items(): if ro.search(data): mime = cmime break return mime
def guess_mimetype_read(read)
Try to read some content and do a poor man's file(1).
6.885401
6.570303
1.047958
handler = FormFinder() parser = htmlsax.parser(handler) handler.parser = parser parser.encoding = encoding # parse parser.feed(content) parser.flush() # break cyclic dependencies handler.parser = None parser.handler = None log.debug(LOG_CHECK, "Found forms %s", handler.f...
def search_form(content, cgiuser, cgipassword, encoding='utf-8')
Search for a HTML form in the given HTML content that has the given CGI fields. If no form is found return None.
5.642369
5.466477
1.032176
if tag == u'form': if u'action' in attrs: url = attrs['action'] self.form = Form(url) elif tag == u'input': if self.form: if 'name' in attrs: key = attrs['name'] value = attrs.get('va...
def start_element(self, tag, attrs)
Does nothing, override in a subclass.
3.366673
3.402418
0.989494
if tag == u'form': self.forms.append(self.form) self.form = None
def end_element(self, tag)
search for ending form values.
4.689536
3.651921
1.284129
log.debug(LOG_CHECK, "Link pattern %r strict=%s", arg, strict) if arg.startswith('!'): pattern = arg[1:] negate = True else: pattern = arg negate = False try: regex = re.compile(pattern) except re.error as msg: log.warn(LOG_CHECK, "invalid regular...
def get_link_pat (arg, strict=False)
Get a link pattern matcher for intern/extern links. Returns a compiled pattern and a negate and strict option. @param arg: pattern from config @type arg: string @param strict: if pattern is to be handled strict @type strict: bool @return: dictionary with keys 'pattern', 'negate' and 'strict' ...
3.033092
2.679732
1.131864
if 'LOCPATH' in os.environ: locdir = os.environ['LOCPATH'] else: locdir = os.path.join(get_install_data(), 'share', 'locale') i18n.init(configdata.name.lower(), locdir, loc=loc) # install translated log level names import logging logging.addLevelName(logging.CRITICAL, _('CRI...
def init_i18n (loc=None)
Initialize i18n with the configured locale dir. The environment variable LOCPATH can also specify a locale dir. @return: None
2.642814
2.620414
1.008548
if os.name != 'posix': return if os.geteuid() == 0: log.warn(LOG_CHECK, _("Running as root user; " "dropping privileges by changing user to nobody.")) import pwd os.seteuid(pwd.getpwnam('nobody')[3])
def drop_privileges ()
Make sure to drop root privileges on POSIX systems.
6.364394
5.742398
1.108316
parent = os.path.dirname(os.path.dirname(__file__)) third_party = os.path.join(parent, "third_party") if os.path.isdir(third_party): sys.path.append(os.path.join(third_party, "dnspython"))
def find_third_party_modules ()
Find third party modules and add them to the python path.
2.398868
2.186355
1.097199
basedir = unicode(os.environ["HOME"]) return os.path.join(basedir, u"Library", u"Safari")
def get_profile_dir ()
Return path where all profiles of current user are stored.
6.198197
6.041986
1.025854
if sys.platform != 'darwin': return u"" try: dirname = get_profile_dir() if os.path.isdir(dirname): fname = os.path.join(dirname, u"Bookmarks.plist") if os.path.isfile(fname): return fname except Exception: pass return u""
def find_bookmark_file ()
Return the bookmark file of the Default profile. Returns absolute filename if found, or empty string if no bookmark file could be found.
2.718706
2.610961
1.041266
if has_biplist: return biplist.readPlist(filename) # fall back to normal plistlist try: return plistlib.readPlist(filename) except Exception: # not parseable (eg. not well-formed, or binary) return {}
def get_plist_data_from_file (filename)
Parse plist data for a file. Tries biplist, falling back to plistlib.
6.695741
5.655591
1.183915
if has_biplist: return biplist.readPlistFromString(data) # fall back to normal plistlist try: return plistlib.readPlistFromString(data) except Exception: # not parseable (eg. not well-formed, or binary) return {}
def get_plist_data_from_string (data)
Parse plist data for a string. Tries biplist, falling back to plistlib.
6.27466
5.196077
1.207576
if is_leaf(entry): url = entry[KEY_URLSTRING] title = entry[KEY_URIDICTIONARY].get('title', url) yield (url, title) elif has_children(entry): for child in entry[KEY_CHILDREN]: for item in parse_plist(child): yield item
def parse_plist(entry)
Parse a XML dictionary entry.
5.016313
5.059456
0.991473
value = _algorithm_by_text.get(text.upper()) if value is None: value = int(text) return value
def algorithm_from_text(text)
Convert text into a DNSSEC algorithm value @rtype: int
5.31371
4.545407
1.169028
text = _algorithm_by_value.get(value) if text is None: text = str(value) return text
def algorithm_to_text(value)
Convert a DNSSEC algorithm value to text @rtype: string
4.832938
5.054038
0.956253
if isinstance(origin, (str, unicode)): origin = dns.name.from_text(origin, dns.name.root) if isinstance(rrset, tuple): rrname = rrset[0] else: rrname = rrset.name if isinstance(rrsigset, tuple): rrsigname = rrsigset[0] rrsigrdataset = rrsigset[1] else:...
def _validate(rrset, rrsigset, keys, origin=None, now=None)
Validate an RRset @param rrset: The RRset to validate @type rrset: dns.rrset.RRset or (dns.name.Name, dns.rdataset.Rdataset) tuple @param rrsigset: The signature RRset @type rrsigset: dns.rrset.RRset or (dns.name.Name, dns.rdataset.Rdataset) tuple @param keys: The key dictionary. @type ...
2.361093
2.217956
1.064536
roboturl = url_data.get_robots_txt_url() with self.get_lock(roboturl): return self._allows_url(url_data, roboturl)
def allows_url (self, url_data)
Ask robots.txt allowance.
6.866424
4.920315
1.395525
with cache_lock: if roboturl in self.cache: self.hits += 1 rp = self.cache[roboturl] return rp.can_fetch(self.useragent, url_data.url) self.misses += 1 kwargs = dict(auth=url_data.auth, session=url_data.session) if ...
def _allows_url (self, url_data, roboturl)
Ask robots.txt allowance. Assumes only single thread per robots.txt URL calls this function.
2.861888
2.707528
1.057011
if not rp.sitemap_urls or not url_data.allows_simple_recursion(): return for sitemap_url, line in rp.sitemap_urls: url_data.add_url(sitemap_url, line=line)
def add_sitemap_urls(self, rp, url_data, roboturl)
Add sitemap URLs to queue.
4.965552
4.735077
1.048674
super(HtmlLogger, self).start_output() header = { "encoding": self.get_charset_encoding(), "title": configuration.App, "body": self.colorbackground, "link": self.colorlink, "vlink": self.colorlink, "alink": self.colorlink, ...
def start_output (self)
Write start of checking info.
6.077316
5.865136
1.036177
self.writeln(u"<tr>") self.writeln(u'<td>%s</td>' % self.part("id")) self.write(u"<td>%d</td></tr>" % self.stats.number)
def write_id (self)
Write ID for current URL.
7.010284
5.805058
1.207617
self.writeln(u"<tr>") self.writeln(u'<td class="url">%s</td>' % self.part("url")) self.write(u'<td class="url">') self.write(u"`%s'" % cgi.escape(url_data.base_url)) self.writeln(u"</td></tr>")
def write_url (self, url_data)
Write url_data.base_url.
4.694301
3.96612
1.1836
args = (self.part("name"), cgi.escape(url_data.name)) self.writeln(u"<tr><td>%s</td><td>`%s'</td></tr>" % args)
def write_name (self, url_data)
Write url_data.name.
6.782964
5.596804
1.211935
self.write(u"<tr><td>"+self.part("parenturl")+ u'</td><td><a target="top" href="'+ url_data.parent_url+u'">'+ cgi.escape(url_data.parent_url)+u"</a>") if url_data.line > 0: self.write(_(", line %d") % url_data.line) if...
def write_parent (self, url_data)
Write url_data.parent_url.
3.298412
3.174894
1.038905
self.writeln(u"<tr><td>"+self.part("base")+u"</td><td>"+ cgi.escape(url_data.base_ref)+u"</td></tr>")
def write_base (self, url_data)
Write url_data.base_ref.
7.861429
5.435753
1.446245
self.writeln("<tr><td>"+self.part("realurl")+u"</td><td>"+ u'<a target="top" href="'+url_data.url+ u'">'+cgi.escape(url_data.url)+u"</a></td></tr>")
def write_real (self, url_data)
Write url_data.url.
6.700099
5.917916
1.132172
self.writeln(u"<tr><td>"+self.part("dltime")+u"</td><td>"+ (_("%.3f seconds") % url_data.dltime)+ u"</td></tr>")
def write_dltime (self, url_data)
Write url_data.dltime.
8.70029
7.328852
1.187129
self.writeln(u"<tr><td>"+self.part("dlsize")+u"</td><td>"+ strformat.strsize(url_data.size)+ u"</td></tr>")
def write_size (self, url_data)
Write url_data.size.
12.213604
10.415935
1.172588
self.writeln(u"<tr><td>"+self.part("checktime")+u"</td><td>"+ (_("%.3f seconds") % url_data.checktime)+u"</td></tr>")
def write_checktime (self, url_data)
Write url_data.checktime.
8.288295
7.065318
1.173096
sep = u"<br/>"+os.linesep text = sep.join(cgi.escape(x) for x in url_data.info) self.writeln(u'<tr><td valign="top">' + self.part("info")+ u"</td><td>"+text+u"</td></tr>")
def write_info (self, url_data)
Write url_data.info.
7.085035
6.150916
1.151867
text = cgi.escape(self.format_modified(url_data.modified)) self.writeln(u'<tr><td valign="top">' + self.part("modified") + u"</td><td>"+text+u"</td></tr>")
def write_modified(self, url_data)
Write url_data.modified.
5.89593
5.008875
1.177097
sep = u"<br/>"+os.linesep text = sep.join(cgi.escape(x[1]) for x in url_data.warnings) self.writeln(u'<tr><td class="warning" '+ u'valign="top">' + self.part("warning") + u'</td><td class="warning">' + text + u"</td></tr>")
def write_warning (self, url_data)
Write url_data.warnings.
6.112685
5.375752
1.137084
if url_data.valid: self.write(u'<tr><td class="valid">') self.write(self.part("result")) self.write(u'</td><td class="valid">') self.write(cgi.escape(_("Valid"))) else: self.write(u'<tr><td class="error">') self.write(self....
def write_result (self, url_data)
Write url_data.result.
2.661689
2.486894
1.070287
self.writeln(u'<br/><i>%s</i><br/>' % _("Statistics")) if self.stats.number > 0: self.writeln(_( "Content types: %(image)d image, %(text)d text, %(video)d video, " "%(audio)d audio, %(application)d application, %(mail)d mail" " and %(other)d...
def write_stats (self)
Write check statistic infos.
3.464424
3.27668
1.057297
self.writeln(u"<br/>") self.write(_("That's it.")+" ") if self.stats.number >= 0: self.write(_n("%d link checked.", "%d links checked.", self.stats.number) % self.stats.number) self.write(u" ") self.write(_n("%d warning found", "%d ...
def write_outro (self)
Write end of check message.
3.118504
3.049702
1.02256
if self.has_part("stats"): self.write_stats() if self.has_part("outro"): self.write_outro() self.close_fileoutput()
def end_output (self, **kwargs)
Write end of checking info as HTML.
6.527017
5.866997
1.112497
i = ip.find("::") prefix = ip[:i] suffix = ip[i + 2:] count = prefix.count(":") + suffix.count(":") if prefix: count += 1 prefix = prefix + ":" if suffix: count += 1 suffix = ":" + suffix if count >= num: raise ValueError("invalid ipv6 number: %s"...
def expand_ipv6 (ip, num)
Expand an IPv6 address with included :: to num octets. @raise: ValueError on invalid IP addresses
3.321344
3.461462
0.959521
if _ipv4_re.match(ip) or \ _ipv6_re.match(ip) or \ _ipv6_ipv4_re.match(ip): return (ip, 1) if _ipv6_abbr_re.match(ip): return (expand_ipv6(ip, 8), 1) if _ipv6_ipv4_abbr_re.match(ip): i = ip.rfind(":") + 1 return (expand_ipv6(ip[:i], 6) + ip[i:], 1) retu...
def expand_ip (ip)
ipv6 addresses are expanded to full 8 octets, all other addresses are left untouched return a tuple (ip, num) where num==1 if ip is a numeric ip, 0 otherwise.
2.350438
2.338351
1.005169
if not _ipv4_re.match(ip): return False a, b, c, d = [int(i) for i in ip.split(".")] return a <= 255 and b <= 255 and c <= 255 and d <= 255
def is_valid_ipv4 (ip)
Return True if given ip is a valid IPv4 address.
1.916217
1.918021
0.999059
# XXX this is not complete: check ipv6 and ipv4 semantics too here if not (_ipv6_re.match(ip) or _ipv6_ipv4_re.match(ip) or _ipv6_abbr_re.match(ip) or _ipv6_ipv4_abbr_re.match(ip)): return False return True
def is_valid_ipv6 (ip)
Return True if given ip is a valid IPv6 address.
4.201476
4.110026
1.02225