mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
just moving some stuff around, not foreshadowing
This commit is contained in:
parent
9d32564c68
commit
4f1eb89382
|
@ -53,13 +53,13 @@ from .util import (
|
|||
PYFTPD_VER,
|
||||
RAM_AVAIL,
|
||||
RAM_TOTAL,
|
||||
RE_ANSI,
|
||||
SQLITE_VER,
|
||||
UNPLICATIONS,
|
||||
URL_BUG,
|
||||
URL_PRJ,
|
||||
Daemon,
|
||||
align_tab,
|
||||
ansi_re,
|
||||
b64enc,
|
||||
dedent,
|
||||
has_resource,
|
||||
|
@ -167,7 +167,7 @@ def lprint(*a: Any, **ka: Any) -> None:
|
|||
txt: str = " ".join(unicode(x) for x in a) + eol
|
||||
printed.append(txt)
|
||||
if not VT100:
|
||||
txt = ansi_re.sub("", txt)
|
||||
txt = RE_ANSI.sub("", txt)
|
||||
|
||||
print(txt, end="", **ka)
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ from .util import (
|
|||
HAVE_PSUTIL,
|
||||
HAVE_SQLITE3,
|
||||
HAVE_ZMQ,
|
||||
RE_ANSI,
|
||||
URL_BUG,
|
||||
UTC,
|
||||
VERSIONS,
|
||||
|
@ -60,7 +61,6 @@ from .util import (
|
|||
HMaccas,
|
||||
ODict,
|
||||
alltrace,
|
||||
ansi_re,
|
||||
build_netmap,
|
||||
expat_ver,
|
||||
gzip,
|
||||
|
@ -1409,9 +1409,9 @@ class SvcHub(object):
|
|||
if self.no_ansi:
|
||||
fmt = "%s %-21s %s\n"
|
||||
if "\033" in msg:
|
||||
msg = ansi_re.sub("", msg)
|
||||
msg = RE_ANSI.sub("", msg)
|
||||
if "\033" in src:
|
||||
src = ansi_re.sub("", src)
|
||||
src = RE_ANSI.sub("", src)
|
||||
elif c:
|
||||
if isinstance(c, int):
|
||||
msg = "\033[3%sm%s\033[0m" % (c, msg)
|
||||
|
|
|
@ -243,7 +243,17 @@ except:
|
|||
BITNESS = struct.calcsize("P") * 8
|
||||
|
||||
|
||||
ansi_re = re.compile("\033\\[[^mK]*[mK]")
|
||||
RE_ANSI = re.compile("\033\\[[^mK]*[mK]")
|
||||
RE_CTYPE = re.compile(r"^content-type: *([^; ]+)", re.IGNORECASE)
|
||||
RE_CDISP = re.compile(r"^content-disposition: *([^; ]+)", re.IGNORECASE)
|
||||
RE_CDISP_FIELD = re.compile(
|
||||
r'^content-disposition:(?: *|.*; *)name="([^"]+)"', re.IGNORECASE
|
||||
)
|
||||
RE_CDISP_FILE = re.compile(
|
||||
r'^content-disposition:(?: *|.*; *)filename="(.*)"', re.IGNORECASE
|
||||
)
|
||||
RE_MEMTOTAL = re.compile("^MemTotal:.* kB")
|
||||
RE_MEMAVAIL = re.compile("^MemAvailable:.* kB")
|
||||
|
||||
|
||||
BOS_SEP = ("%s" % (os.sep,)).encode("ascii")
|
||||
|
@ -488,11 +498,11 @@ def read_ram() -> tuple[float, float]:
|
|||
with open("/proc/meminfo", "rb", 0x10000) as f:
|
||||
zsl = f.read(0x10000).decode("ascii", "replace").split("\n")
|
||||
|
||||
p = re.compile("^MemTotal:.* kB")
|
||||
p = RE_MEMTOTAL
|
||||
zs = next((x for x in zsl if p.match(x)))
|
||||
a = int((int(zs.split()[1]) / 0x100000) * 100) / 100
|
||||
|
||||
p = re.compile("^MemAvailable:.* kB")
|
||||
p = RE_MEMAVAIL
|
||||
zs = next((x for x in zsl if p.match(x)))
|
||||
b = int((int(zs.split()[1]) / 0x100000) * 100) / 100
|
||||
except:
|
||||
|
@ -1698,14 +1708,10 @@ class MultipartParser(object):
|
|||
self.args = args
|
||||
self.headers = http_headers
|
||||
|
||||
self.re_ctype = re.compile(r"^content-type: *([^; ]+)", re.IGNORECASE)
|
||||
self.re_cdisp = re.compile(r"^content-disposition: *([^; ]+)", re.IGNORECASE)
|
||||
self.re_cdisp_field = re.compile(
|
||||
r'^content-disposition:(?: *|.*; *)name="([^"]+)"', re.IGNORECASE
|
||||
)
|
||||
self.re_cdisp_file = re.compile(
|
||||
r'^content-disposition:(?: *|.*; *)filename="(.*)"', re.IGNORECASE
|
||||
)
|
||||
self.re_ctype = RE_CTYPE
|
||||
self.re_cdisp = RE_CDISP
|
||||
self.re_cdisp_field = RE_CDISP_FIELD
|
||||
self.re_cdisp_file = RE_CDISP_FILE
|
||||
|
||||
self.boundary = b""
|
||||
self.gen: Optional[
|
||||
|
|
Loading…
Reference in a new issue