PATH: //proc/self/root/proc/thread-self/root/opt/alt/python312/lib64/python3.12
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
π LICENSE.txt
β
X
π __future__.py
β
X
π __hello__.py
β
X
π __pycache__/
X
π _aix_support.py
β
X
π _collections_abc.py
β
X
π _compat_pickle.py
β
X
π _compression.py
β
X
π _markupbase.py
β
X
π _osx_support.py
β
X
π _py_abc.py
β
X
π _pydatetime.py
β
X
π _pydecimal.py
β
X
π _pyio.py
β
X
π _pylong.py
β
X
π _sitebuiltins.py
β
X
π _strptime.py
β
X
π _sysconfigdata__linux_x86_64-linux-gnu.py
β
X
π _sysconfigdata_d_linux_x86_64-linux-gnu.py
β
X
π _threading_local.py
β
X
π _weakrefset.py
β
X
π abc.py
β
X
π aifc.py
β
X
π antigravity.py
β
X
π argparse.py
β
X
π ast.py
β
X
π asyncio/
X
π base64.py
β
X
π bdb.py
β
X
π bisect.py
β
X
π bz2.py
β
X
π cProfile.py
β
X
π calendar.py
β
X
π cgi.py
β
X
π cgitb.py
β
X
π chunk.py
β
X
π cmd.py
β
X
π code.py
β
X
π codecs.py
β
X
π codeop.py
β
X
π collections/
X
π colorsys.py
β
X
π compileall.py
β
X
π concurrent/
X
π config-3.12-x86_64-linux-gnu/
X
π configparser.py
β
X
π contextlib.py
β
X
π contextvars.py
β
X
π copy.py
β
X
π copyreg.py
β
X
π crypt.py
β
X
π csv.py
β
X
π ctypes/
X
π curses/
X
π dataclasses.py
β
X
π datetime.py
β
X
π dbm/
X
π decimal.py
β
X
π difflib.py
β
X
π dis.py
β
X
π doctest.py
β
X
π email/
X
π encodings/
X
π ensurepip/
X
π enum.py
β
X
π filecmp.py
β
X
π fileinput.py
β
X
π fnmatch.py
β
X
π fractions.py
β
X
π ftplib.py
β
X
π functools.py
β
X
π genericpath.py
β
X
π getopt.py
β
X
π getpass.py
β
X
π gettext.py
β
X
π glob.py
β
X
π graphlib.py
β
X
π gzip.py
β
X
π hashlib.py
β
X
π heapq.py
β
X
π hmac.py
β
X
π html/
X
π http/
X
π imaplib.py
β
X
π imghdr.py
β
X
π importlib/
X
π inspect.py
β
X
π io.py
β
X
π ipaddress.py
β
X
π json/
X
π keyword.py
β
X
π lib-dynload/
X
π lib2to3/
X
π linecache.py
β
X
π locale.py
β
X
π logging/
X
π lzma.py
β
X
π mailbox.py
β
X
π mailcap.py
β
X
π mimetypes.py
β
X
π modulefinder.py
β
X
π multiprocessing/
X
π netrc.py
β
X
π nntplib.py
β
X
π ntpath.py
β
X
π nturl2path.py
β
X
π numbers.py
β
X
π opcode.py
β
X
π operator.py
β
X
π optparse.py
β
X
π os.py
β
X
π pathlib.py
β
X
π pdb.py
β
X
π pickle.py
β
X
π pickletools.py
β
X
π pipes.py
β
X
π pkgutil.py
β
X
π platform.py
β
X
π plistlib.py
β
X
π poplib.py
β
X
π posixpath.py
β
X
π pprint.py
β
X
π profile.py
β
X
π pstats.py
β
X
π pty.py
β
X
π py_compile.py
β
X
π pyclbr.py
β
X
π pydoc.py
β
X
π pydoc_data/
X
π queue.py
β
X
π quopri.py
β
X
π random.py
β
X
π re/
X
π reprlib.py
β
X
π rlcompleter.py
β
X
π runpy.py
β
X
π sched.py
β
X
π secrets.py
β
X
π selectors.py
β
X
π shelve.py
β
X
π shlex.py
β
X
π shutil.py
β
X
π signal.py
β
X
π site-packages/
X
π site.py
β
X
π smtplib.py
β
X
π sndhdr.py
β
X
π socket.py
β
X
π socketserver.py
β
X
π sqlite3/
X
π sre_compile.py
β
X
π sre_constants.py
β
X
π sre_parse.py
β
X
π ssl.py
β
X
π stat.py
β
X
π statistics.py
β
X
π string.py
β
X
π stringprep.py
β
X
π struct.py
β
X
π subprocess.py
β
X
π sunau.py
β
X
π symtable.py
β
X
π sysconfig.py
β
X
π tabnanny.py
β
X
π tarfile.py
β
X
π telnetlib.py
β
X
π tempfile.py
β
X
π textwrap.py
β
X
π this.py
β
X
π threading.py
β
X
π timeit.py
β
X
π token.py
β
X
π tokenize.py
β
X
π tomllib/
X
π trace.py
β
X
π traceback.py
β
X
π tracemalloc.py
β
X
π tty.py
β
X
π types.py
β
X
π typing.py
β
X
π unittest/
X
π urllib/
X
π uu.py
β
X
π uuid.py
β
X
π venv/
X
π warnings.py
β
X
π wave.py
β
X
π weakref.py
β
X
π webbrowser.py
β
X
π wsgiref/
X
π xdrlib.py
β
X
π xml/
X
π xmlrpc/
X
π zipapp.py
β
X
π zipfile/
X
π zipimport.py
β
X
π zoneinfo/
X
SAVING...
BERHASIL DIUBAH!
EDITING: _markupbase.py
"""Shared support for scanning document type declarations in HTML and XHTML. This module is used as a foundation for the html.parser module. It has no documented public API and should not be used directly. """ import re _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match _declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match _commentclose = re.compile(r'--\s*>') _markedsectionclose = re.compile(r']\s*]\s*>') # An analysis of the MS-Word extensions is available at # http://www.planetpublish.com/xmlarena/xap/Thursday/WordtoXML.pdf _msmarkedsectionclose = re.compile(r']\s*>') del re class ParserBase: """Parser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.""" def __init__(self): if self.__class__ is ParserBase: raise RuntimeError( "_markupbase.ParserBase must be subclassed") def reset(self): self.lineno = 1 self.offset = 0 def getpos(self): """Return current line number and offset.""" return self.lineno, self.offset # Internal -- update line number and offset. This should be # called for each piece of data exactly once, in order -- in other # words the concatenation of all the input strings to this # function should be exactly the entire input. 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 + j-i return j _decl_otherchars = '' # Internal -- parse declaration (for use by subclasses). 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 section] # name in the following list: ENTITY, DOCTYPE, ELEMENT, # ATTLIST, NOTATION, SHORTREF, USEMAP, # LINKTYPE, LINK, IDLINK, USELINK, SYSTEM rawdata = self.rawdata j = i + 2 assert rawdata[i:j] == "<!", "unexpected call to parse_declaration" if rawdata[j:j+1] == ">": # the empty comment <!> return j + 1 if rawdata[j:j+1] in ("-", ""): # Start of comment followed by buffer boundary, # or just a buffer boundary. return -1 # A simple, practical version could look like: ((name|stringlit) S*) + '>' n = len(rawdata) if rawdata[j:j+2] == '--': #comment # Locate --.*-- as the body of the comment return self.parse_comment(i) elif rawdata[j] == '[': #marked section # Locate [statusWord [...arbitrary SGML...]] as the body of the marked section # Where statusWord is one of TEMP, CDATA, IGNORE, INCLUDE, RCDATA # Note that this is extended by Microsoft Office "Save as Web" function # to include [if...] and [endif]. return self.parse_marked_section(i) else: #all other declaration elements decltype, j = self._scan_name(j, i) if j < 0: return j if decltype == "doctype": self._decl_otherchars = '' while j < n: c = rawdata[j] if c == ">": # end of declaration syntax data = rawdata[i+2:j] if decltype == "doctype": self.handle_decl(data) else: # According to the HTML5 specs sections "8.2.4.44 Bogus # comment state" and "8.2.4.45 Markup declaration open # state", a comment token should be emitted. # Calling unknown_decl provides more flexibility though. self.unknown_decl(data) return j + 1 if c in "\"'": m = _declstringlit_match(rawdata, j) if not m: return -1 # incomplete j = m.end() elif c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": name, j = self._scan_name(j, i) elif c in self._decl_otherchars: j = j + 1 elif c == "[": # this could be handled in a separate doctype parser if decltype == "doctype": j = self._parse_doctype_subset(j + 1, i) elif decltype in {"attlist", "linktype", "link", "element"}: # must tolerate []'d groups in a content model in an element declaration # also in data attribute specifications of attlist declaration # also link type declaration subsets in linktype declarations # also link attribute specification lists in link declarations raise AssertionError("unsupported '[' char in %s declaration" % decltype) else: raise AssertionError("unexpected '[' char in declaration") else: raise AssertionError("unexpected %r char in declaration" % rawdata[j]) if j < 0: return j return -1 # incomplete # Internal -- parse a marked section # Override this to handle MS-word extension syntax <![if word]>content<![endif]> 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 standard ]]> ending match= _markedsectionclose.search(rawdata, i+3) elif sectName in {"if", "else", "endif"}: # look for MS Office ]> ending match= _msmarkedsectionclose.search(rawdata, i+3) else: raise AssertionError( 'unknown status keyword %r in marked section' % rawdata[i+3:j] ) if not match: return -1 if report: j = match.start(0) self.unknown_decl(rawdata[i+3: j]) return match.end(0) # Internal -- parse comment, return length or -1 if not terminated 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(rawdata[i+4: j]) return match.end(0) # Internal -- scan past the internal subset in a <!DOCTYPE declaration, # returning the index just past any whitespace following the trailing ']'. 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.updatepos(declstartpos, j + 1) raise AssertionError( "unexpected char in internal subset (in %r)" % s ) if (j + 2) == n: # end of buffer; incomplete return -1 if (j + 4) > n: # end of buffer; incomplete return -1 if rawdata[j:j+4] == "<!--": j = self.parse_comment(j, report=0) if j < 0: return j continue name, j = self._scan_name(j + 2, declstartpos) if j == -1: return -1 if name not in {"attlist", "element", "entity", "notation"}: self.updatepos(declstartpos, j + 2) raise AssertionError( "unknown declaration %r in internal subset" % name ) # handle the individual names meth = getattr(self, "_parse_doctype_" + name) j = meth(j, declstartpos) if j < 0: return j elif c == "%": # parameter entity reference if (j + 1) == n: # end of buffer; incomplete return -1 s, j = self._scan_name(j + 1, declstartpos) if j < 0: return j if rawdata[j] == ";": j = j + 1 elif c == "]": j = j + 1 while j < n and rawdata[j].isspace(): j = j + 1 if j < n: if rawdata[j] == ">": return j self.updatepos(declstartpos, j) raise AssertionError("unexpected char after internal subset") else: return -1 elif c.isspace(): j = j + 1 else: self.updatepos(declstartpos, j) raise AssertionError("unexpected char %r in internal subset" % c) # end of buffer reached return -1 # Internal -- scan past <!ELEMENT declarations 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 # Internal -- scan past <!ATTLIST declarations 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 [value] [#constraint] name, j = self._scan_name(j, declstartpos) if j < 0: return j c = rawdata[j:j+1] if c == "": return -1 if c == "(": # an enumerated type; look for ')' if ")" in rawdata[j:]: j = rawdata.find(")", j) + 1 else: return -1 while rawdata[j:j+1].isspace(): j = j + 1 if not rawdata[j:]: # end of buffer, incomplete return -1 else: name, j = self._scan_name(j, declstartpos) c = rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 c = rawdata[j:j+1] if not c: return -1 if c == "#": if rawdata[j:] == "#": # end of buffer return -1 name, j = self._scan_name(j + 1, declstartpos) if j < 0: return j c = rawdata[j:j+1] if not c: return -1 if c == '>': # all done return j + 1 # Internal -- scan past <!NOTATION declarations 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 + 1 if c in "'\"": m = _declstringlit_match(rawdata, j) if not m: return -1 j = m.end() else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan past <!ENTITY declarations 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 else: j = i name, j = self._scan_name(j, declstartpos) if j < 0: return j while 1: c = self.rawdata[j:j+1] if not c: return -1 if c in "'\"": m = _declstringlit_match(rawdata, j) if m: j = m.end() else: return -1 # incomplete elif c == ">": return j + 1 else: name, j = self._scan_name(j, declstartpos) if j < 0: return j # Internal -- scan a name token and the new position and the token, or # return -1 if we've reached the end of the buffer. 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(), m.end() else: self.updatepos(declstartpos, i) raise AssertionError( "expected name token at %r" % rawdata[declstartpos:declstartpos+20] ) # To be overridden -- handlers for unknown objects def unknown_decl(self, data): pass
SIMPAN PERUBAHAN