mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
partyfuse: normalize naming in parsers
This commit is contained in:
parent
73d05095b5
commit
3dff6cda40
|
@ -390,13 +390,12 @@ class Gateway(object):
|
||||||
|
|
||||||
return r.read()
|
return r.read()
|
||||||
|
|
||||||
def parse_jls(self, datasrc):
|
def parse_jls(self, sck):
|
||||||
rsp = b""
|
rsp = b""
|
||||||
while True:
|
while True:
|
||||||
buf = datasrc.read(1024 * 32)
|
buf = sck.read(1024 * 32)
|
||||||
if not buf:
|
if not buf:
|
||||||
break
|
break
|
||||||
|
|
||||||
rsp += buf
|
rsp += buf
|
||||||
|
|
||||||
rsp = json.loads(rsp.decode("utf-8"))
|
rsp = json.loads(rsp.decode("utf-8"))
|
||||||
|
@ -414,24 +413,24 @@ class Gateway(object):
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def parse_html(self, datasrc):
|
def parse_html(self, sck):
|
||||||
ret = []
|
ret = []
|
||||||
remainder = b""
|
rem = b""
|
||||||
ptn = re.compile(
|
ptn = re.compile(
|
||||||
r'^<tr><td>(-|DIR|<a [^<]+</a>)</td><td><a[^>]* href="([^"]+)"[^>]*>([^<]+)</a></td><td>([^<]+)</td><td>[^<]+</td><td>([^<]+)</td></tr>$'
|
r'^<tr><td>(-|DIR|<a [^<]+</a>)</td><td><a[^>]* href="([^"]+)"[^>]*>([^<]+)</a></td><td>([^<]+)</td><td>[^<]+</td><td>([^<]+)</td></tr>$'
|
||||||
)
|
)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
buf = remainder + datasrc.read(4096)
|
buf = sck.read(4096)
|
||||||
# print('[{}]'.format(buf.decode('utf-8')))
|
|
||||||
if not buf:
|
if not buf:
|
||||||
break
|
break
|
||||||
|
|
||||||
remainder = b""
|
buf = rem + buf
|
||||||
endpos = buf.rfind(b"\n")
|
rem = b""
|
||||||
if endpos >= 0:
|
idx = buf.rfind(b"\n")
|
||||||
remainder = buf[endpos + 1 :]
|
if idx >= 0:
|
||||||
buf = buf[:endpos]
|
rem = buf[idx + 1 :]
|
||||||
|
buf = buf[:idx]
|
||||||
|
|
||||||
lines = buf.decode("utf-8").split("\n")
|
lines = buf.decode("utf-8").split("\n")
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|
Loading…
Reference in a new issue