index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
5,341
semantic_version.base
__str__
null
def __str__(self): version = '%d' % self.major if self.minor is not None: version = '%s.%d' % (version, self.minor) if self.patch is not None: version = '%s.%d' % (version, self.patch) if self.prerelease or (self.partial and self.prerelease == () and self.build is None): version ...
(self)
5,342
semantic_version.base
next_major
null
def next_major(self): if self.prerelease and self.minor is 0 and self.patch is 0: return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) else: return Version('.'.join(str(x) for x in [self.major + 1, 0, 0]))
(self)
5,343
semantic_version.base
next_minor
null
def next_minor(self): if self.prerelease and self.patch is 0: return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) else: return Version( '.'.join(str(x) for x in [self.major, self.minor + 1, 0]))
(self)
5,344
semantic_version.base
next_patch
null
def next_patch(self): if self.prerelease: return Version('.'.join(str(x) for x in [self.major, self.minor, self.patch])) else: return Version( '.'.join(str(x) for x in [self.major, self.minor, self.patch + 1]))
(self)
5,345
releases
_log
Log debug output if debug setting is on. Intended to be partial'd w/ config at top of functions. Meh.
def _log(txt, config): """ Log debug output if debug setting is on. Intended to be partial'd w/ config at top of functions. Meh. """ if config.releases_debug: print(txt, file=sys.stderr, flush=True)
(txt, config)
5,347
releases
add_role
null
def add_role(app, name, role_obj): # This (introspecting docutils.parser.rst.roles._roles) is the same trick # Sphinx uses to emit warnings about double-registering; it's a PITA to try # and configure the app early on so it doesn't emit those warnings, so we # instead just...don't double-register. Meh. ...
(app, name, role_obj)
5,348
releases
append_unreleased_entries
Generate new abstract 'releases' for unreleased issues. There's one for each combination of bug-vs-feature & major release line. When only one major release line exists, that dimension is ignored.
def append_unreleased_entries(app, manager, releases): """ Generate new abstract 'releases' for unreleased issues. There's one for each combination of bug-vs-feature & major release line. When only one major release line exists, that dimension is ignored. """ for family, lines in manager.items...
(app, manager, releases)
5,349
releases
construct_entry_with_release
Releases 'eat' the entries in their line's list and get added to the final data structure. They also inform new release-line 'buffers'. Release lines, once the release obj is removed, should be empty or a comma-separated list of issue numbers.
def construct_entry_with_release(focus, issues, manager, log, releases, rest): """ Releases 'eat' the entries in their line's list and get added to the final data structure. They also inform new release-line 'buffers'. Release lines, once the release obj is removed, should be empty or a comma-separa...
(focus, issues, manager, log, releases, rest)
5,350
releases
construct_entry_without_release
null
def construct_entry_without_release(focus, issues, manager, log, rest): # Handle rare-but-valid non-issue-attached line items, which are # always bugs. (They are their own description.) if not isinstance(focus, Issue): # First, sanity check for potential mistakes resulting in an issue node #...
(focus, issues, manager, log, rest)
5,351
releases
construct_nodes
null
def construct_nodes(releases): result = [] # Reverse the list again so the final display is newest on top for d in reversed(releases): if not d["entries"]: continue obj = d["obj"] entries = [] for entry in d["entries"]: # Use nodes.Node.deepcopy to dee...
(releases)
5,352
releases
construct_releases
null
def construct_releases(entries, app): log = partial(_log, config=app.config) # Walk from back to front, consuming entries & copying them into # per-release buckets as releases are encountered. Store releases in order. releases = [] # Release lines, to be organized by major releases, then by major+mi...
(entries, app)
5,353
releases
generate_changelog
null
def generate_changelog(app, doctree, docname): desired_docnames = app.config.releases_document_name # Ensure we still work mostly-correctly in singlehtml builder situations # (must use name substring test as RTD's singlehtml builder doesn't # actually inherit from Sphinx's own!) is_singlepage = "sin...
(app, doctree, docname)
5,354
releases
generate_unreleased_entry
null
def generate_unreleased_entry(header, line, issues, manager, app): log = partial(_log, config=app.config) nodelist = [ release_nodes( header, app.config.releases_development_branch, None, app.config, ) ] log(f"Creating {line!r} faux-release...
(header, line, issues, manager, app)
5,355
releases
handle_first_release_line
Set up initial line-manager entry for first encountered release line. To be called at start of overall process; afterwards, subsequent major lines are generated by `handle_upcoming_major_release`.
def handle_first_release_line(entries, manager): """ Set up initial line-manager entry for first encountered release line. To be called at start of overall process; afterwards, subsequent major lines are generated by `handle_upcoming_major_release`. """ # It's remotely possible the changelog is...
(entries, manager)
5,356
releases
handle_upcoming_major_release
null
def handle_upcoming_major_release(entries, manager): # Short-circuit if the future holds nothing for us if not entries: return # Short-circuit if we're in the middle of a block of releases, only the # last release before a bunch of issues, should be taking any action. if isinstance(entries[0...
(entries, manager)
5,357
releases
interpolate
null
def interpolate(text, number): if "%s" in text: return text % number return text.format(number=number)
(text, number)
5,358
releases
issue_nodelist
null
def issue_nodelist(name, identifier=None): which = f'[<span style="color: #{ISSUE_TYPES[name]};">{name.capitalize()}</span>]' # noqa signifier = [nodes.raw(text=which, format="html")] id_nodelist = [nodes.inline(text=" "), identifier] if identifier else [] trail = [] if identifier else [nodes.inline(te...
(name, identifier=None)
5,359
releases
issues_role
Use: :issue|bug|feature|support:`ticket_number` When invoked as :issue:, turns into just a "#NN" hyperlink to `releases_issue_uri`. When invoked otherwise, turns into "[Type] <#NN hyperlink>: ". Spaces present in the "ticket number" are used as fields for keywords (major, backported) and/or ...
def issues_role(name, rawtext, text, lineno, inliner, options={}, content=[]): """ Use: :issue|bug|feature|support:`ticket_number` When invoked as :issue:, turns into just a "#NN" hyperlink to `releases_issue_uri`. When invoked otherwise, turns into "[Type] <#NN hyperlink>: ". Spaces present ...
(name, rawtext, text, lineno, inliner, options={}, content=[])
5,364
functools
partial
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.
class partial: """New function with partial application of the given arguments and keywords. """ __slots__ = "func", "args", "keywords", "__dict__", "__weakref__" def __new__(cls, func, /, *args, **keywords): if not callable(func): raise TypeError("the first argument must be ca...
null
5,366
releases
release_nodes
null
def release_nodes(text, slug, date, config): # Doesn't seem possible to do this "cleanly" (i.e. just say "make me a # title and give it these HTML attributes during render time) so...fuckit. # We were already doing fully raw elements elsewhere anyway. And who cares # about a PDF of a changelog? :x u...
(text, slug, date, config)
5,367
releases
release_role
Invoked as :release:`N.N.N <YYYY-MM-DD>`. Turns into useful release header + link to GH tree for the tag.
def release_role(name, rawtext, text, lineno, inliner, options={}, content=[]): """ Invoked as :release:`N.N.N <YYYY-MM-DD>`. Turns into useful release header + link to GH tree for the tag. """ # Make sure year has been specified match = year_arg_re.match(text) if not match: msg = i...
(name, rawtext, text, lineno, inliner, options={}, content=[])
5,368
releases
reorder_release_entries
Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc.
def reorder_release_entries(releases): """ Mutate ``releases`` so the entrylist in each is ordered by feature/bug/etc. """ order = {"feature": 0, "bug": 1, "support": 2} for release in releases: entries = release["entries"].copy() release["entries"] = sorted(entries, key=lambda x: or...
(releases)
5,370
releases
scan_for_spec
Attempt to return some sort of Spec from given keyword value. Returns None if one could not be derived.
def scan_for_spec(keyword): """ Attempt to return some sort of Spec from given keyword value. Returns None if one could not be derived. """ # Both 'spec' formats are wrapped in parens, discard keyword = keyword.lstrip("(").rstrip(")") # First, test for intermediate '1.2+' style matches ...
(keyword)
5,371
releases
setup
null
def setup(app): for key, default in ( # Issue base URI setting: releases_issue_uri # E.g. 'https://github.com/fabric/fabric/issues/' ("issue_uri", None), # Release-tag base URI setting: releases_release_uri # E.g. 'https://github.com/fabric/fabric/tree/' ("release_uri...
(app)
5,374
credis.base
AuthenticationError
null
from credis.base import AuthenticationError
null
5,375
credis.base
Connection
Manages TCP communication to and from a Redis server
from credis.base import Connection
null
5,376
credis.base
ConnectionError
null
from credis.base import ConnectionError
null
5,377
credis.base
RedisProtocolError
null
from credis.base import RedisProtocolError
null
5,378
credis.base
RedisReplyError
null
from credis.base import RedisReplyError
null
5,380
notifications_python_client.notifications
NotificationsAPIClient
null
class NotificationsAPIClient(BaseAPIClient): def send_sms_notification( self, phone_number, template_id, personalisation=None, reference=None, sms_sender_id=None ): notification = {"phone_number": phone_number, "template_id": template_id} if personalisation: notification.upda...
(api_key, base_url='https://api.notifications.service.gov.uk', timeout=30)
5,381
notifications_python_client.base
__init__
Initialise the client Error if either of base_url or secret missing :param base_url - base URL of GOV.UK Notify API: :param secret - application secret - used to sign the request: :param timeout - request timeout on the client :return:
def __init__(self, api_key, base_url="https://api.notifications.service.gov.uk", timeout=30): """ Initialise the client Error if either of base_url or secret missing :param base_url - base URL of GOV.UK Notify API: :param secret - application secret - used to sign the request: :param timeout - r...
(self, api_key, base_url='https://api.notifications.service.gov.uk', timeout=30)
5,382
notifications_python_client.base
_create_request_objects
null
def _create_request_objects(self, url, data, params): api_token = create_jwt_token(self.api_key, self.service_id) kwargs = {"headers": self.generate_headers(api_token), "timeout": self.timeout} if data is not None: kwargs.update(data=self._serialize_data(data)) if params is not None: kwa...
(self, url, data, params)
5,383
notifications_python_client.base
_extended_json_encoder
null
def _extended_json_encoder(self, obj): if isinstance(obj, set): return list(obj) raise TypeError
(self, obj)
5,384
notifications_python_client.base
_perform_request
null
def _perform_request(self, method, url, kwargs): start_time = time.monotonic() try: response = self.request_session.request(method, url, **kwargs) response.raise_for_status() return response except requests.RequestException as e: api_error = HTTPError.create(e) logger...
(self, method, url, kwargs)
5,385
notifications_python_client.base
_process_json_response
null
def _process_json_response(self, response): try: if response.status_code == 204: return return response.json() except ValueError as e: raise InvalidResponse(response, message="No JSON response object could be decoded") from e
(self, response)
5,386
notifications_python_client.base
_serialize_data
null
def _serialize_data(self, data): return json.dumps(data, default=self._extended_json_encoder)
(self, data)
5,387
notifications_python_client.base
delete
null
def delete(self, url, data=None): return self.request("DELETE", url, data=data)
(self, url, data=None)
5,388
notifications_python_client.base
generate_headers
null
def generate_headers(self, api_token): return { "Content-type": "application/json", "Authorization": "Bearer {}".format(api_token), "User-agent": "NOTIFY-API-PYTHON-CLIENT/{}".format(__version__), }
(self, api_token)
5,389
notifications_python_client.base
get
null
def get(self, url, params=None): return self.request("GET", url, params=params)
(self, url, params=None)
5,390
notifications_python_client.notifications
get_all_notifications
null
def get_all_notifications( self, status=None, template_type=None, reference=None, older_than=None, include_jobs=None ): data = {} if status: data.update({"status": status}) if template_type: data.update({"template_type": template_type}) if reference: data.update({"reference":...
(self, status=None, template_type=None, reference=None, older_than=None, include_jobs=None)
5,391
notifications_python_client.notifications
get_all_notifications_iterator
null
def get_all_notifications_iterator(self, status=None, template_type=None, reference=None, older_than=None): result = self.get_all_notifications(status, template_type, reference, older_than) notifications = result.get("notifications") while notifications: for notification in notifications: ...
(self, status=None, template_type=None, reference=None, older_than=None)
5,392
notifications_python_client.notifications
get_all_template_versions
null
def get_all_template_versions(self, template_id): return self.get("service/{}/template/{}/versions".format(self.service_id, template_id))
(self, template_id)
5,393
notifications_python_client.notifications
get_all_templates
null
def get_all_templates(self, template_type=None): _template_type = "?type={}".format(template_type) if template_type else "" return self.get("/v2/templates{}".format(_template_type))
(self, template_type=None)
5,394
notifications_python_client.notifications
get_notification_by_id
null
def get_notification_by_id(self, id): return self.get("/v2/notifications/{}".format(id))
(self, id)
5,395
notifications_python_client.notifications
get_pdf_for_letter
null
def get_pdf_for_letter(self, id): url = "/v2/notifications/{}/pdf".format(id) logger.debug("API request %s %s", "GET", url) url, kwargs = self._create_request_objects(url, data=None, params=None) response = self._perform_request("GET", url, kwargs) return BytesIO(response.content)
(self, id)
5,396
notifications_python_client.notifications
get_received_texts
null
def get_received_texts(self, older_than=None): if older_than: query_string = "?older_than={}".format(older_than) else: query_string = "" return self.get("/v2/received-text-messages{}".format(query_string))
(self, older_than=None)
5,397
notifications_python_client.notifications
get_received_texts_iterator
null
def get_received_texts_iterator(self, older_than=None): result = self.get_received_texts(older_than=older_than) received_texts = result.get("received_text_messages") while received_texts: for received_text in received_texts: yield received_text next_link = result["links"].get("ne...
(self, older_than=None)
5,398
notifications_python_client.notifications
get_template
null
def get_template(self, template_id): return self.get("/v2/template/{}".format(template_id))
(self, template_id)
5,399
notifications_python_client.notifications
get_template_version
null
def get_template_version(self, template_id, version): return self.get("/v2/template/{}/version/{}".format(template_id, version))
(self, template_id, version)
5,400
notifications_python_client.base
post
null
def post(self, url, data): return self.request("POST", url, data=data)
(self, url, data)
5,401
notifications_python_client.notifications
post_template_preview
null
def post_template_preview(self, template_id, personalisation): template = {"personalisation": personalisation} return self.post("/v2/template/{}/preview".format(template_id), data=template)
(self, template_id, personalisation)
5,402
notifications_python_client.base
put
null
def put(self, url, data): return self.request("PUT", url, data=data)
(self, url, data)
5,403
notifications_python_client.base
request
null
def request(self, method, url, data=None, params=None): logger.debug("API request %s %s", method, url) url, kwargs = self._create_request_objects(url, data, params) response = self._perform_request(method, url, kwargs) return self._process_json_response(response)
(self, method, url, data=None, params=None)
5,404
notifications_python_client.notifications
send_email_notification
null
def send_email_notification( self, email_address, template_id, personalisation=None, reference=None, email_reply_to_id=None ): notification = {"email_address": email_address, "template_id": template_id} if personalisation: notification.update({"personalisation": personalisation}) if reference: ...
(self, email_address, template_id, personalisation=None, reference=None, email_reply_to_id=None)
5,405
notifications_python_client.notifications
send_letter_notification
null
def send_letter_notification(self, template_id, personalisation, reference=None): notification = {"template_id": template_id, "personalisation": personalisation} if reference: notification.update({"reference": reference}) return self.post("/v2/notifications/letter", data=notification)
(self, template_id, personalisation, reference=None)
5,406
notifications_python_client.notifications
send_precompiled_letter_notification
null
def send_precompiled_letter_notification(self, reference, pdf_file, postage=None): content = base64.b64encode(pdf_file.read()).decode("utf-8") notification = {"reference": reference, "content": content} if postage: notification["postage"] = postage return self.post("/v2/notifications/letter", da...
(self, reference, pdf_file, postage=None)
5,407
notifications_python_client.notifications
send_sms_notification
null
def send_sms_notification( self, phone_number, template_id, personalisation=None, reference=None, sms_sender_id=None ): notification = {"phone_number": phone_number, "template_id": template_id} if personalisation: notification.update({"personalisation": personalisation}) if reference: no...
(self, phone_number, template_id, personalisation=None, reference=None, sms_sender_id=None)
5,412
notifications_python_client.utils
prepare_upload
null
def prepare_upload(f, filename=None, confirm_email_before_download=None, retention_period=None): contents = f.read() if len(contents) > DOCUMENT_UPLOAD_SIZE_LIMIT: raise ValueError("File is larger than 2MB") file_data = { "file": base64.b64encode(contents).decode("ascii"), "filenam...
(f, filename=None, confirm_email_before_download=None, retention_period=None)
5,415
ascon._ascon
ascon_decrypt
Ascon decryption. key: a bytes object of size 16 (for Ascon-128, Ascon-128a; 128-bit security) or 20 (for Ascon-80pq; 128-bit security) nonce: a bytes object of size 16 (must not repeat for the same key!) associateddata: a bytes object of arbitrary length ciphertext: a bytes object of arbitrary len...
def ascon_decrypt(key, nonce, associateddata, ciphertext, variant="Ascon-128"): """ Ascon decryption. key: a bytes object of size 16 (for Ascon-128, Ascon-128a; 128-bit security) or 20 (for Ascon-80pq; 128-bit security) nonce: a bytes object of size 16 (must not repeat for the same key!) associatedd...
(key, nonce, associateddata, ciphertext, variant='Ascon-128')
5,416
ascon._ascon
ascon_encrypt
Ascon encryption. key: a bytes object of size 16 (for Ascon-128, Ascon-128a; 128-bit security) or 20 (for Ascon-80pq; 128-bit security) nonce: a bytes object of size 16 (must not repeat for the same key!) associateddata: a bytes object of arbitrary length plaintext: a bytes object of arbitrary leng...
def ascon_encrypt(key, nonce, associateddata, plaintext, variant="Ascon-128"): """ Ascon encryption. key: a bytes object of size 16 (for Ascon-128, Ascon-128a; 128-bit security) or 20 (for Ascon-80pq; 128-bit security) nonce: a bytes object of size 16 (must not repeat for the same key!) associatedd...
(key, nonce, associateddata, plaintext, variant='Ascon-128')
5,417
ascon._ascon
ascon_hash
Ascon hash function and extendable-output function. message: a bytes object of arbitrary length variant: "Ascon-Hash", "Ascon-Hasha" (both with 256-bit output for 128-bit security), "Ascon-Xof", or "Ascon-Xofa" (both with arbitrary output length, security=min(128, bitlen/2)) hashlength: the requested o...
def ascon_hash(message, variant="Ascon-Hash", hashlength=32): """ Ascon hash function and extendable-output function. message: a bytes object of arbitrary length variant: "Ascon-Hash", "Ascon-Hasha" (both with 256-bit output for 128-bit security), "Ascon-Xof", or "Ascon-Xofa" (both with arbitrary outpu...
(message, variant='Ascon-Hash', hashlength=32)
5,418
ascon._ascon
ascon_mac
Ascon message authentication code (MAC) and pseudorandom function (PRF). key: a bytes object of size 16 message: a bytes object of arbitrary length (<= 16 for "Ascon-PrfShort") variant: "Ascon-Mac", "Ascon-Maca" (both 128-bit output, arbitrarily long input), "Ascon-Prf", "Ascon-Prfa" (both arbitrarily ...
def ascon_mac(key, message, variant="Ascon-Mac", taglength=16): """ Ascon message authentication code (MAC) and pseudorandom function (PRF). key: a bytes object of size 16 message: a bytes object of arbitrary length (<= 16 for "Ascon-PrfShort") variant: "Ascon-Mac", "Ascon-Maca" (both 128-bit outpu...
(key, message, variant='Ascon-Mac', taglength=16)
5,419
xml.etree.ElementTree
Comment
Comment element factory. This function creates a special element which the standard serializer serializes as an XML comment. *text* is a string containing the comment string.
def Comment(text=None): """Comment element factory. This function creates a special element which the standard serializer serializes as an XML comment. *text* is a string containing the comment string. """ element = Element(Comment) element.text = text return element
(text=None)
5,421
meld3
HTMLMeldParser
A mostly-cut-and-paste of ElementTree's HTMLTreeBuilder that does special meld3 things (like preserve comments and munge meld ids). Subclassing is not possible due to private attributes. :-(
class HTMLMeldParser(HTMLParser): """ A mostly-cut-and-paste of ElementTree's HTMLTreeBuilder that does special meld3 things (like preserve comments and munge meld ids). Subclassing is not possible due to private attributes. :-(""" def __init__(self, builder=None, encoding=None): self.__stack ...
(builder=None, encoding=None)
5,422
meld3
__init__
null
def __init__(self, builder=None, encoding=None): self.__stack = [] if builder is None: builder = MeldTreeBuilder() self.builder = builder self.encoding = encoding or "iso-8859-1" try: # ``convert_charrefs`` was added in Python 3.4. Set it to avoid # "DeprecationWarning: The ...
(self, builder=None, encoding=None)
5,423
_markupbase
_parse_doctype_attlist
null
def _parse_doctype_attlist(self, i, declstartpos): rawdata = self.rawdata name, j = self._scan_name(i, declstartpos) c = rawdata[j:j+1] if c == "": return -1 if c == ">": return j + 1 while 1: # scan a series of attribute descriptions; simplified: # name type [v...
(self, i, declstartpos)
5,424
_markupbase
_parse_doctype_element
null
def _parse_doctype_element(self, i, declstartpos): name, j = self._scan_name(i, declstartpos) if j == -1: return -1 # style content model; just skip until '>' rawdata = self.rawdata if '>' in rawdata[j:]: return rawdata.find(">", j) + 1 return -1
(self, i, declstartpos)
5,425
_markupbase
_parse_doctype_entity
null
def _parse_doctype_entity(self, i, declstartpos): rawdata = self.rawdata if rawdata[i:i+1] == "%": j = i + 1 while 1: c = rawdata[j:j+1] if not c: return -1 if c.isspace(): j = j + 1 else: break e...
(self, i, declstartpos)
5,426
_markupbase
_parse_doctype_notation
null
def _parse_doctype_notation(self, i, declstartpos): name, j = self._scan_name(i, declstartpos) if j < 0: return j rawdata = self.rawdata while 1: c = rawdata[j:j+1] if not c: # end of buffer; incomplete return -1 if c == '>': return j +...
(self, i, declstartpos)
5,427
_markupbase
_parse_doctype_subset
null
def _parse_doctype_subset(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) j = i while j < n: c = rawdata[j] if c == "<": s = rawdata[j:j+2] if s == "<": # end of buffer; incomplete return -1 if s != "<!":...
(self, i, declstartpos)
5,428
_markupbase
_scan_name
null
def _scan_name(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) if i == n: return None, -1 m = _declname_match(rawdata, i) if m: s = m.group() name = s.strip() if (i + len(s)) == n: return None, -1 # end of buffer return name.lower(...
(self, i, declstartpos)
5,429
html.parser
check_for_whole_start_tag
null
def check_for_whole_start_tag(self, i): rawdata = self.rawdata m = locatestarttagend_tolerant.match(rawdata, i) if m: j = m.end() next = rawdata[j:j+1] if next == ">": return j + 1 if next == "/": if rawdata.startswith("/>", j): return ...
(self, i)
5,430
html.parser
clear_cdata_mode
null
def clear_cdata_mode(self): self.interesting = interesting_normal self.cdata_elem = None
(self)
5,431
meld3
close
null
def close(self): HTMLParser.close(self) self.meldids = {} return self.builder.close()
(self)
5,432
html.parser
feed
Feed data to the parser. Call this as often as you want, with as little or as much text as you want (may include '\n').
def feed(self, data): r"""Feed data to the parser. Call this as often as you want, with as little or as much text as you want (may include '\n'). """ self.rawdata = self.rawdata + data self.goahead(0)
(self, data)
5,433
html.parser
get_starttag_text
Return full source of start tag: '<...>'.
def get_starttag_text(self): """Return full source of start tag: '<...>'.""" return self.__starttag_text
(self)
5,434
_markupbase
getpos
Return current line number and offset.
def getpos(self): """Return current line number and offset.""" return self.lineno, self.offset
(self)
5,435
html.parser
goahead
null
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if self.convert_charrefs and not self.cdata_elem: j = rawdata.find('<', i) if j < 0: # if we can't find the next <, either we are at the end # or there's mor...
(self, end)
5,436
meld3
handle_charref
null
def handle_charref(self, char): if char[:1] == "x": char = int(char[1:], 16) else: char = int(char) self.builder.data(unichr(char))
(self, char)
5,437
meld3
handle_comment
null
def handle_comment(self, data): self.builder.start(Comment, {}) self.builder.data(data) self.builder.end(Comment)
(self, data)
5,438
meld3
handle_data
null
def handle_data(self, data): if isinstance(data, bytes): data = _u(data, self.encoding) self.builder.data(data)
(self, data)
5,439
html.parser
handle_decl
null
def handle_decl(self, decl): pass
(self, decl)
5,440
meld3
handle_endtag
null
def handle_endtag(self, tag): if tag in IGNOREEND: return lasttag = self.__stack.pop() if tag != lasttag and lasttag in AUTOCLOSE: self.handle_endtag(lasttag) self.builder.end(tag)
(self, tag)
5,441
meld3
handle_entityref
null
def handle_entityref(self, name): entity = htmlentitydefs.entitydefs.get(name) if entity: if len(entity) == 1: entity = ord(entity) else: entity = int(entity[2:-1]) self.builder.data(unichr(entity)) else: self.unknown_entityref(name)
(self, name)
5,442
html.parser
handle_pi
null
def handle_pi(self, data): pass
(self, data)
5,443
html.parser
handle_startendtag
null
def handle_startendtag(self, tag, attrs): self.handle_starttag(tag, attrs) self.handle_endtag(tag)
(self, tag, attrs)
5,444
meld3
handle_starttag
null
def handle_starttag(self, tag, attrs): if tag == "meta": # look for encoding directives http_equiv = content = None for k, v in attrs: if k == "http-equiv": http_equiv = v.lower() elif k == "content": content = v if http_equiv =...
(self, tag, attrs)
5,445
html.parser
parse_bogus_comment
null
def parse_bogus_comment(self, i, report=1): rawdata = self.rawdata assert rawdata[i:i+2] in ('<!', '</'), ('unexpected call to ' 'parse_comment()') pos = rawdata.find('>', i+2) if pos == -1: return -1 if report: self.handle_comment(rawdata[...
(self, i, report=1)
5,446
_markupbase
parse_comment
null
def parse_comment(self, i, report=1): rawdata = self.rawdata if rawdata[i:i+4] != '<!--': raise AssertionError('unexpected call to parse_comment()') match = _commentclose.search(rawdata, i+4) if not match: return -1 if report: j = match.start(0) self.handle_comment(ra...
(self, i, report=1)
5,447
_markupbase
parse_declaration
null
def parse_declaration(self, i): # This is some sort of declaration; in "HTML as # deployed," this should only be the document type # declaration ("<!DOCTYPE html...>"). # ISO 8879:1986, however, has more complex # declaration syntax for elements in <!...>, including: # --comment-- # [marked ...
(self, i)
5,448
html.parser
parse_endtag
null
def parse_endtag(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag" match = endendtag.search(rawdata, i+1) # > if not match: return -1 gtpos = match.end() match = endtagfind.match(rawdata, i) # </ + tag + > if not match: if self....
(self, i)
5,449
html.parser
parse_html_declaration
null
def parse_html_declaration(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == '<!', ('unexpected call to ' 'parse_html_declaration()') if rawdata[i:i+4] == '<!--': # this case is actually already handled in goahead() return self.parse_comment(i) ...
(self, i)
5,450
_markupbase
parse_marked_section
null
def parse_marked_section(self, i, report=1): rawdata= self.rawdata assert rawdata[i:i+3] == '<![', "unexpected call to parse_marked_section()" sectName, j = self._scan_name( i+3, i ) if j < 0: return j if sectName in {"temp", "cdata", "ignore", "include", "rcdata"}: # look for standa...
(self, i, report=1)
5,451
html.parser
parse_pi
null
def parse_pi(self, i): rawdata = self.rawdata assert rawdata[i:i+2] == '<?', 'unexpected call to parse_pi()' match = piclose.search(rawdata, i+2) # > if not match: return -1 j = match.start() self.handle_pi(rawdata[i+2: j]) j = match.end() return j
(self, i)
5,452
html.parser
parse_starttag
null
def parse_starttag(self, i): self.__starttag_text = None endpos = self.check_for_whole_start_tag(i) if endpos < 0: return endpos rawdata = self.rawdata self.__starttag_text = rawdata[i:endpos] # Now parse the data between i+1 and j into a tag and attrs attrs = [] match = tagfind_...
(self, i)
5,453
html.parser
reset
Reset this instance. Loses all unprocessed data.
def reset(self): """Reset this instance. Loses all unprocessed data.""" self.rawdata = '' self.lasttag = '???' self.interesting = interesting_normal self.cdata_elem = None _markupbase.ParserBase.reset(self)
(self)
5,454
html.parser
set_cdata_mode
null
def set_cdata_mode(self, elem): self.cdata_elem = elem.lower() self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
(self, elem)
5,455
html.parser
unknown_decl
null
def unknown_decl(self, data): pass
(self, data)
5,456
meld3
unknown_entityref
null
def unknown_entityref(self, name): pass # ignore by default; override if necessary
(self, name)
5,457
_markupbase
updatepos
null
def updatepos(self, i, j): if i >= j: return j rawdata = self.rawdata nlines = rawdata.count("\n", i, j) if nlines: self.lineno = self.lineno + nlines pos = rawdata.rindex("\n", i, j) # Should not fail self.offset = j-(pos+1) else: self.offset = self.offset + ...
(self, i, j)