/
opt
/
alt
/
python311
/
lib64
/
python3.11
/
/opt/alt/python311/lib64/python3.11
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.11-x86_64-linux-gnu/
-
0755
rm
ctypes/
-
0755
rm
curses/
-
0755
rm
dbm/
-
0755
rm
distutils/
-
0755
rm
email/
-
0755
rm
encodings/
-
0755
rm
ensurepip/
-
0755
rm
html/
-
0755
rm
http/
-
0755
rm
importlib/
-
0755
rm
json/
-
0755
rm
lib-dynload/
-
0755
rm
lib2to3/
-
0755
rm
logging/
-
0755
rm
multiprocessing/
-
0755
rm
pydoc_data/
-
0755
rm
re/
-
0755
rm
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
tomllib/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
zoneinfo/
-
0755
rm
__phello__/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
6538
0644
edit
dl
rm
aifc.py
34211
0644
edit
dl
rm
antigravity.py
500
0644
edit
dl
rm
argparse.py
100283
0644
edit
dl
rm
ast.py
61444
0644
edit
dl
rm
asynchat.py
11570
0644
edit
dl
rm
asyncore.py
20310
0644
edit
dl
rm
base64.py
21041
0755
edit
dl
rm
bdb.py
32463
0644
edit
dl
rm
bisect.py
3135
0644
edit
dl
rm
bz2.py
11847
0644
edit
dl
rm
calendar.py
24731
0644
edit
dl
rm
cgi.py
34432
0755
edit
dl
rm
cgitb.py
12421
0644
edit
dl
rm
chunk.py
5500
0644
edit
dl
rm
cmd.py
14873
0644
edit
dl
rm
code.py
10622
0644
edit
dl
rm
codecs.py
37150
0644
edit
dl
rm
codeop.py
5907
0644
edit
dl
rm
colorsys.py
4062
0644
edit
dl
rm
compileall.py
20252
0644
edit
dl
rm
configparser.py
55660
0644
edit
dl
rm
contextlib.py
27414
0644
edit
dl
rm
contextvars.py
129
0644
edit
dl
rm
copy.py
8681
0644
edit
dl
rm
copyreg.py
7677
0644
edit
dl
rm
cProfile.py
6359
0755
edit
dl
rm
crypt.py
3913
0644
edit
dl
rm
csv.py
16030
0644
edit
dl
rm
dataclasses.py
58472
0644
edit
dl
rm
datetime.py
91832
0644
edit
dl
rm
decimal.py
320
0644
edit
dl
rm
difflib.py
83308
0644
edit
dl
rm
dis.py
28906
0644
edit
dl
rm
doctest.py
106297
0644
edit
dl
rm
enum.py
79583
0644
edit
dl
rm
filecmp.py
10178
0644
edit
dl
rm
fileinput.py
15714
0644
edit
dl
rm
fnmatch.py
5999
0644
edit
dl
rm
fractions.py
28677
0644
edit
dl
rm
ftplib.py
35815
0644
edit
dl
rm
functools.py
38413
0644
edit
dl
rm
genericpath.py
4975
0644
edit
dl
rm
getopt.py
7489
0644
edit
dl
rm
getpass.py
5990
0644
edit
dl
rm
gettext.py
21320
0644
edit
dl
rm
glob.py
8732
0644
edit
dl
rm
graphlib.py
9656
0644
edit
dl
rm
gzip.py
24074
0644
edit
dl
rm
hashlib.py
11765
0644
edit
dl
rm
heapq.py
23024
0644
edit
dl
rm
hmac.py
7716
0644
edit
dl
rm
imaplib.py
55217
0644
edit
dl
rm
imghdr.py
3952
0644
edit
dl
rm
imp.py
10606
0644
edit
dl
rm
inspect.py
123419
0644
edit
dl
rm
io.py
4320
0644
edit
dl
rm
ipaddress.py
79124
0644
edit
dl
rm
keyword.py
1061
0644
edit
dl
rm
LICENSE.txt
13936
0644
edit
dl
rm
linecache.py
5649
0644
edit
dl
rm
locale.py
79095
0644
edit
dl
rm
lzma.py
13277
0644
edit
dl
rm
mailbox.py
78830
0644
edit
dl
rm
mailcap.py
9369
0644
edit
dl
rm
mimetypes.py
22962
0644
edit
dl
rm
modulefinder.py
23699
0644
edit
dl
rm
netrc.py
6929
0644
edit
dl
rm
nntplib.py
41087
0644
edit
dl
rm
ntpath.py
30222
0644
edit
dl
rm
nturl2path.py
2887
0644
edit
dl
rm
numbers.py
10348
0644
edit
dl
rm
opcode.py
10447
0644
edit
dl
rm
operator.py
10965
0644
edit
dl
rm
optparse.py
60369
0644
edit
dl
rm
os.py
39530
0644
edit
dl
rm
pathlib.py
48566
0644
edit
dl
rm
pdb.py
64186
0755
edit
dl
rm
pickle.py
65132
0644
edit
dl
rm
pickletools.py
93861
0644
edit
dl
rm
pipes.py
8978
0644
edit
dl
rm
pkgutil.py
24638
0644
edit
dl
rm
platform.py
42287
0755
edit
dl
rm
plistlib.py
28354
0644
edit
dl
rm
poplib.py
15198
0644
edit
dl
rm
posixpath.py
17013
0644
edit
dl
rm
pprint.py
24583
0644
edit
dl
rm
profile.py
22896
0755
edit
dl
rm
pstats.py
29356
0644
edit
dl
rm
pty.py
6317
0644
edit
dl
rm
pyclbr.py
11396
0644
edit
dl
rm
pydoc.py
112664
0755
edit
dl
rm
py_compile.py
7837
0644
edit
dl
rm
queue.py
11496
0644
edit
dl
rm
quopri.py
7281
0755
edit
dl
rm
random.py
32162
0644
edit
dl
rm
reprlib.py
5437
0644
edit
dl
rm
rlcompleter.py
7827
0644
edit
dl
rm
runpy.py
13159
0644
edit
dl
rm
sched.py
6351
0644
edit
dl
rm
secrets.py
2028
0644
edit
dl
rm
selectors.py
19671
0644
edit
dl
rm
shelve.py
8560
0644
edit
dl
rm
shlex.py
13501
0644
edit
dl
rm
shutil.py
56517
0644
edit
dl
rm
signal.py
2495
0644
edit
dl
rm
site.py
22987
0644
edit
dl
rm
smtpd.py
31175
0755
edit
dl
rm
smtplib.py
45431
0755
edit
dl
rm
sndhdr.py
7448
0644
edit
dl
rm
socket.py
37557
0644
edit
dl
rm
socketserver.py
27586
0644
edit
dl
rm
sre_compile.py
231
0644
edit
dl
rm
sre_constants.py
232
0644
edit
dl
rm
sre_parse.py
229
0644
edit
dl
rm
ssl.py
54305
0644
edit
dl
rm
stat.py
5485
0644
edit
dl
rm
statistics.py
47705
0644
edit
dl
rm
string.py
11786
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
257
0644
edit
dl
rm
subprocess.py
88725
0644
edit
dl
rm
sunau.py
18480
0644
edit
dl
rm
symtable.py
10368
0644
edit
dl
rm
sysconfig.py
30315
0644
edit
dl
rm
tabnanny.py
11312
0755
edit
dl
rm
tarfile.py
107876
0755
edit
dl
rm
telnetlib.py
23301
0644
edit
dl
rm
tempfile.py
31873
0644
edit
dl
rm
textwrap.py
19718
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
58231
0644
edit
dl
rm
timeit.py
13532
0755
edit
dl
rm
token.py
2386
0644
edit
dl
rm
tokenize.py
26336
0644
edit
dl
rm
trace.py
29196
0755
edit
dl
rm
traceback.py
40547
0644
edit
dl
rm
tracemalloc.py
18047
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
types.py
10067
0644
edit
dl
rm
typing.py
120951
0644
edit
dl
rm
uu.py
7341
0644
edit
dl
rm
uuid.py
27597
0644
edit
dl
rm
warnings.py
21110
0644
edit
dl
rm
wave.py
21818
0644
edit
dl
rm
weakref.py
21513
0644
edit
dl
rm
webbrowser.py
25149
0755
edit
dl
rm
xdrlib.py
5977
0644
edit
dl
rm
zipapp.py
7535
0644
edit
dl
rm
zipfile.py
93788
0644
edit
dl
rm
zipimport.py
30897
0644
edit
dl
rm
_aix_support.py
3389
0644
edit
dl
rm
_bootsubprocess.py
2675
0644
edit
dl
rm
_collections_abc.py
30193
0644
edit
dl
rm
_compat_pickle.py
8761
0644
edit
dl
rm
_compression.py
5681
0644
edit
dl
rm
_markupbase.py
14653
0644
edit
dl
rm
_osx_support.py
22023
0644
edit
dl
rm
_pydecimal.py
229202
0644
edit
dl
rm
_pyio.py
94193
0644
edit
dl
rm
_py_abc.py
6189
0644
edit
dl
rm
_sitebuiltins.py
3128
0644
edit
dl
rm
_strptime.py
25175
0644
edit
dl
rm
_sysconfigdata_d_linux_x86_64-linux-gnu.py
58878
0644
edit
dl
rm
_sysconfigdata__linux_x86_64-linux-gnu.py
59645
0644
edit
dl
rm
_threading_local.py
7220
0644
edit
dl
rm
_weakrefset.py
5893
0644
edit
dl
rm
__future__.py
5218
0644
edit
dl
rm
__hello__.py
227
0644
edit
dl
rm
Edit:
/opt/alt/python311/lib64/python3.11/asynchat.py
(11570B)
# -*- Mode: Python; tab-width: 4 -*- # Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp # Author: Sam Rushing <rushing@nightmare.com> # ====================================================================== # Copyright 1996 by Sam Rushing # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of Sam # Rushing not be used in advertising or publicity pertaining to # distribution of the software without specific, written prior # permission. # # SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN # NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # ====================================================================== r"""A class supporting chat-style (command/response) protocols. This class adds support for 'chat' style protocols - where one side sends a 'command', and the other sends a response (examples would be the common internet protocols - smtp, nntp, ftp, etc..). The handle_read() method looks at the input stream for the current 'terminator' (usually '\r\n' for single-line responses, '\r\n.\r\n' for multi-line output), calling self.found_terminator() on its receipt. for example: Say you build an async nntp client using this class. At the start of the connection, you'll have self.terminator set to '\r\n', in order to process the single-line greeting. Just before issuing a 'LIST' command you'll set it to '\r\n.\r\n'. The output of the LIST command will be accumulated (using your own 'collect_incoming_data' method) up to the terminator, and then control will be returned to you - by calling your self.found_terminator() method. """ import asyncore from collections import deque from warnings import _deprecated _DEPRECATION_MSG = ('The {name} module is deprecated and will be removed in ' 'Python {remove}. The recommended replacement is asyncio') _deprecated(__name__, _DEPRECATION_MSG, remove=(3, 12)) class async_chat(asyncore.dispatcher): """This is an abstract class. You must derive from this class, and add the two methods collect_incoming_data() and found_terminator()""" # these are overridable defaults ac_in_buffer_size = 65536 ac_out_buffer_size = 65536 # we don't want to enable the use of encoding by default, because that is a # sign of an application bug that we don't want to pass silently use_encoding = 0 encoding = 'latin-1' def __init__(self, sock=None, map=None): # for string terminator matching self.ac_in_buffer = b'' # we use a list here rather than io.BytesIO for a few reasons... # del lst[:] is faster than bio.truncate(0) # lst = [] is faster than bio.truncate(0) self.incoming = [] # we toss the use of the "simple producer" and replace it with # a pure deque, which the original fifo was a wrapping of self.producer_fifo = deque() asyncore.dispatcher.__init__(self, sock, map) def collect_incoming_data(self, data): raise NotImplementedError("must be implemented in subclass") def _collect_incoming_data(self, data): self.incoming.append(data) def _get_data(self): d = b''.join(self.incoming) del self.incoming[:] return d def found_terminator(self): raise NotImplementedError("must be implemented in subclass") def set_terminator(self, term): """Set the input delimiter. Can be a fixed string of any length, an integer, or None. """ if isinstance(term, str) and self.use_encoding: term = bytes(term, self.encoding) elif isinstance(term, int) and term < 0: raise ValueError('the number of received bytes must be positive') self.terminator = term def get_terminator(self): return self.terminator # grab some more data from the socket, # throw it to the collector method, # check for the terminator, # if found, transition to the next state. def handle_read(self): try: data = self.recv(self.ac_in_buffer_size) except BlockingIOError: return except OSError: self.handle_error() return if isinstance(data, str) and self.use_encoding: data = bytes(str, self.encoding) self.ac_in_buffer = self.ac_in_buffer + data # Continue to search for self.terminator in self.ac_in_buffer, # while calling self.collect_incoming_data. The while loop # is necessary because we might read several data+terminator # combos with a single recv(4096). while self.ac_in_buffer: lb = len(self.ac_in_buffer) terminator = self.get_terminator() if not terminator: # no terminator, collect it all self.collect_incoming_data(self.ac_in_buffer) self.ac_in_buffer = b'' elif isinstance(terminator, int): # numeric terminator n = terminator if lb < n: self.collect_incoming_data(self.ac_in_buffer) self.ac_in_buffer = b'' self.terminator = self.terminator - lb else: self.collect_incoming_data(self.ac_in_buffer[:n]) self.ac_in_buffer = self.ac_in_buffer[n:] self.terminator = 0 self.found_terminator() else: # 3 cases: # 1) end of buffer matches terminator exactly: # collect data, transition # 2) end of buffer matches some prefix: # collect data to the prefix # 3) end of buffer does not match any prefix: # collect data terminator_len = len(terminator) index = self.ac_in_buffer.find(terminator) if index != -1: # we found the terminator if index > 0: # don't bother reporting the empty string # (source of subtle bugs) self.collect_incoming_data(self.ac_in_buffer[:index]) self.ac_in_buffer = self.ac_in_buffer[index+terminator_len:] # This does the Right Thing if the terminator # is changed here. self.found_terminator() else: # check for a prefix of the terminator index = find_prefix_at_end(self.ac_in_buffer, terminator) if index: if index != lb: # we found a prefix, collect up to the prefix self.collect_incoming_data(self.ac_in_buffer[:-index]) self.ac_in_buffer = self.ac_in_buffer[-index:] break else: # no prefix, collect it all self.collect_incoming_data(self.ac_in_buffer) self.ac_in_buffer = b'' def handle_write(self): self.initiate_send() def handle_close(self): self.close() def push(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be byte-ish (%r)', type(data)) sabs = self.ac_out_buffer_size if len(data) > sabs: for i in range(0, len(data), sabs): self.producer_fifo.append(data[i:i+sabs]) else: self.producer_fifo.append(data) self.initiate_send() def push_with_producer(self, producer): self.producer_fifo.append(producer) self.initiate_send() def readable(self): "predicate for inclusion in the readable for select()" # cannot use the old predicate, it violates the claim of the # set_terminator method. # return (len(self.ac_in_buffer) <= self.ac_in_buffer_size) return 1 def writable(self): "predicate for inclusion in the writable for select()" return self.producer_fifo or (not self.connected) def close_when_done(self): "automatically close this channel once the outgoing queue is empty" self.producer_fifo.append(None) def initiate_send(self): while self.producer_fifo and self.connected: first = self.producer_fifo[0] # handle empty string/buffer or None entry if not first: del self.producer_fifo[0] if first is None: self.handle_close() return # handle classic producer behavior obs = self.ac_out_buffer_size try: data = first[:obs] except TypeError: data = first.more() if data: self.producer_fifo.appendleft(data) else: del self.producer_fifo[0] continue if isinstance(data, str) and self.use_encoding: data = bytes(data, self.encoding) # send the data try: num_sent = self.send(data) except OSError: self.handle_error() return if num_sent: if num_sent < len(data) or obs < len(first): self.producer_fifo[0] = first[num_sent:] else: del self.producer_fifo[0] # we tried to send some actual data return def discard_buffers(self): # Emergencies only! self.ac_in_buffer = b'' del self.incoming[:] self.producer_fifo.clear() class simple_producer: def __init__(self, data, buffer_size=512): self.data = data self.buffer_size = buffer_size def more(self): if len(self.data) > self.buffer_size: result = self.data[:self.buffer_size] self.data = self.data[self.buffer_size:] return result else: result = self.data self.data = b'' return result # Given 'haystack', see if any prefix of 'needle' is at its end. This # assumes an exact match has already been checked. Return the number of # characters matched. # for example: # f_p_a_e("qwerty\r", "\r\n") => 1 # f_p_a_e("qwertydkjf", "\r\n") => 0 # f_p_a_e("qwerty\r\n", "\r\n") => <undefined> # this could maybe be made faster with a computed regex? # [answer: no; circa Python-2.0, Jan 2001] # new python: 28961/s # old python: 18307/s # re: 12820/s # regex: 14035/s def find_prefix_at_end(haystack, needle): l = len(needle) - 1 while l and not haystack.endswith(needle[:l]): l -= 1 return l
Save
cmd:
run