Linux vmi2545633.contaboserver.net 6.1.0-32-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06) x86_64
Apache/2.4.62 (Debian)
Server IP : 127.0.0.1 & Your IP : 127.0.0.1
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
lib /
python3 /
dist-packages /
aptsources /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2023-07-12 09:40
__init__.py
195
B
-rw-r--r--
2023-05-22 14:14
_deb822.py
2.76
KB
-rw-r--r--
2023-05-22 14:14
distinfo.py
15.34
KB
-rw-r--r--
2023-05-22 14:14
distro.py
23.35
KB
-rw-r--r--
2023-05-22 14:14
sourceslist.py
25.41
KB
-rw-r--r--
2023-05-22 14:14
Save
Rename
#!/usr/bin/python3 # -*- coding: utf-8 -*- # # Copyright (C) Canonical Ltd # # SPDX-License-Identifier: GPL-2.0+ """deb822 parser with support for comment headers and footers.""" import io import collections import typing import apt_pkg T = typing.TypeVar("T") class Section: """A single deb822 section, possibly with comments. This represents a single deb822 section. """ def __init__(self, section: str): comments = ["", ""] in_section = False trimmed_section = "" for line in section.split("\n"): if line.startswith("#"): # remove the leading # line = line[1:] comments[in_section] += line + "\n" continue in_section = True trimmed_section += line + "\n" self.tags = collections.OrderedDict(apt_pkg.TagSection(trimmed_section)) self.header, self.footer = comments def __getitem__(self, key: str) -> str: """Get the value of a field.""" return self.tags[key] def __delitem__(self, key: str) -> None: """Delete a field""" del self.tags[key] def __setitem__(self, key: str, val: str) -> None: """Set the value of a field.""" self.tags[key] = val def __bool__(self) -> bool: return bool(self.tags) @typing.overload def get(self, key: str) -> typing.Optional[str]: ... @typing.overload def get(self, key: str, default: T) -> typing.Union[T, str]: ... def get( self, key: str, default: typing.Optional[T] = None ) -> typing.Union[typing.Optional[T], str]: try: return self.tags[key] except KeyError: return default @staticmethod def __comment_lines(content: str) -> str: return ( "\n".join("#" + line for line in content.splitlines()) + "\n" if content else "" ) def __str__(self) -> str: """Canonical string rendering of this section.""" return ( self.__comment_lines(self.header) + "".join(f"{k}: {v}\n" for k, v in self.tags.items()) + self.__comment_lines(self.footer) ) class File: """ Parse a given file object into a list of Section objects. """ def __init__(self, fobj: io.TextIOBase): sections = fobj.read().split("\n\n") self.sections = [Section(s) for s in sections] def __iter__(self) -> typing.Iterator[Section]: return iter(self.sections) def __str__(self) -> str: return "\n\n".join(str(s) for s in self.sections) if __name__ == "__main__": st = """# Header # More header K1: V1 # Inline K2: V2 # not a comment # Footer # More footer """ s = Section(st) print(s)