/
opt
/
alt
/
python37
/
lib64
/
python3.7
/
/opt/alt/python37/lib64/python3.7
mkdir
upload
Name
Size
Mode
Actions
asyncio/
-
0755
rm
collections/
-
0755
rm
concurrent/
-
0755
rm
config-3.7m/
-
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
idlelib/
-
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
site-packages/
-
0755
rm
sqlite3/
-
0755
rm
test/
-
0755
rm
unittest/
-
0755
rm
urllib/
-
0755
rm
venv/
-
0755
rm
wsgiref/
-
0755
rm
xml/
-
0755
rm
xmlrpc/
-
0755
rm
__pycache__/
-
0755
rm
abc.py
5580
0644
edit
dl
rm
aifc.py
32814
0644
edit
dl
rm
antigravity.py
477
0644
edit
dl
rm
argparse.py
95372
0644
edit
dl
rm
ast.py
12842
0644
edit
dl
rm
asynchat.py
11328
0644
edit
dl
rm
asyncore.py
20118
0644
edit
dl
rm
base64.py
20393
0755
edit
dl
rm
bdb.py
31730
0644
edit
dl
rm
binhex.py
13954
0644
edit
dl
rm
bisect.py
2557
0644
edit
dl
rm
bz2.py
12410
0644
edit
dl
rm
calendar.py
24826
0644
edit
dl
rm
cgi.py
35050
0755
edit
dl
rm
cgitb.py
12018
0644
edit
dl
rm
chunk.py
5435
0644
edit
dl
rm
cmd.py
14860
0644
edit
dl
rm
code.py
10622
0644
edit
dl
rm
codecs.py
36615
0644
edit
dl
rm
codeop.py
6275
0644
edit
dl
rm
colorsys.py
4064
0644
edit
dl
rm
compileall.py
13788
0644
edit
dl
rm
configparser.py
54283
0644
edit
dl
rm
contextlib.py
24763
0644
edit
dl
rm
contextvars.py
129
0644
edit
dl
rm
copy.py
8856
0644
edit
dl
rm
copyreg.py
7017
0644
edit
dl
rm
cProfile.py
6253
0755
edit
dl
rm
crypt.py
3346
0644
edit
dl
rm
csv.py
16180
0644
edit
dl
rm
dataclasses.py
49520
0644
edit
dl
rm
datetime.py
86544
0644
edit
dl
rm
decimal.py
320
0644
edit
dl
rm
difflib.py
84393
0644
edit
dl
rm
dis.py
19888
0644
edit
dl
rm
doctest.py
104560
0644
edit
dl
rm
dummy_threading.py
2815
0644
edit
dl
rm
enum.py
35043
0644
edit
dl
rm
filecmp.py
9830
0644
edit
dl
rm
fileinput.py
14625
0644
edit
dl
rm
fnmatch.py
4056
0644
edit
dl
rm
formatter.py
15143
0644
edit
dl
rm
fractions.py
23752
0644
edit
dl
rm
ftplib.py
35618
0644
edit
dl
rm
functools.py
32932
0644
edit
dl
rm
genericpath.py
4912
0644
edit
dl
rm
getopt.py
7489
0644
edit
dl
rm
getpass.py
5994
0644
edit
dl
rm
gettext.py
21967
0644
edit
dl
rm
glob.py
5638
0644
edit
dl
rm
gzip.py
20637
0644
edit
dl
rm
hashlib.py
9534
0644
edit
dl
rm
heapq.py
23017
0644
edit
dl
rm
hmac.py
6517
0644
edit
dl
rm
imaplib.py
53292
0644
edit
dl
rm
imghdr.py
3795
0644
edit
dl
rm
imp.py
10536
0644
edit
dl
rm
inspect.py
117635
0644
edit
dl
rm
io.py
3517
0644
edit
dl
rm
ipaddress.py
73578
0644
edit
dl
rm
keyword.py
2256
0755
edit
dl
rm
linecache.py
5330
0644
edit
dl
rm
locale.py
78191
0644
edit
dl
rm
lzma.py
12983
0644
edit
dl
rm
macpath.py
6123
0644
edit
dl
rm
mailbox.py
78654
0644
edit
dl
rm
mailcap.py
9067
0644
edit
dl
rm
mimetypes.py
21496
0644
edit
dl
rm
modulefinder.py
23035
0644
edit
dl
rm
netrc.py
5566
0644
edit
dl
rm
nntplib.py
43087
0644
edit
dl
rm
ntpath.py
22340
0644
edit
dl
rm
nturl2path.py
2584
0644
edit
dl
rm
numbers.py
10244
0644
edit
dl
rm
opcode.py
5824
0644
edit
dl
rm
operator.py
10863
0644
edit
dl
rm
optparse.py
60371
0644
edit
dl
rm
os.py
37901
0644
edit
dl
rm
pathlib.py
50329
0644
edit
dl
rm
pdb.py
62505
0755
edit
dl
rm
pickle.py
57994
0644
edit
dl
rm
pickletools.py
91220
0644
edit
dl
rm
pipes.py
8916
0644
edit
dl
rm
pkgutil.py
21461
0644
edit
dl
rm
platform.py
46994
0755
edit
dl
rm
plistlib.py
30709
0644
edit
dl
rm
poplib.py
14964
0644
edit
dl
rm
posixpath.py
15771
0644
edit
dl
rm
pprint.py
20884
0644
edit
dl
rm
profile.py
22494
0755
edit
dl
rm
pstats.py
27315
0644
edit
dl
rm
pty.py
4763
0644
edit
dl
rm
pyclbr.py
15137
0644
edit
dl
rm
pydoc.py
105876
0644
edit
dl
rm
py_compile.py
8001
0644
edit
dl
rm
queue.py
11359
0644
edit
dl
rm
quopri.py
7265
0755
edit
dl
rm
random.py
27557
0644
edit
dl
rm
re.py
15306
0644
edit
dl
rm
reprlib.py
5267
0644
edit
dl
rm
rlcompleter.py
7097
0644
edit
dl
rm
runpy.py
11959
0644
edit
dl
rm
sched.py
6442
0644
edit
dl
rm
secrets.py
2038
0644
edit
dl
rm
selectors.py
18561
0644
edit
dl
rm
shelve.py
8527
0644
edit
dl
rm
shlex.py
13100
0644
edit
dl
rm
shutil.py
41950
0644
edit
dl
rm
signal.py
2123
0644
edit
dl
rm
site.py
21575
0644
edit
dl
rm
smtpd.py
34722
0755
edit
dl
rm
smtplib.py
44443
0755
edit
dl
rm
sndhdr.py
7086
0644
edit
dl
rm
socket.py
27469
0644
edit
dl
rm
socketserver.py
26923
0644
edit
dl
rm
sre_compile.py
26872
0644
edit
dl
rm
sre_constants.py
7177
0644
edit
dl
rm
sre_parse.py
39156
0644
edit
dl
rm
ssl.py
45495
0644
edit
dl
rm
stat.py
5391
0644
edit
dl
rm
statistics.py
20651
0644
edit
dl
rm
string.py
11564
0644
edit
dl
rm
stringprep.py
12917
0644
edit
dl
rm
struct.py
257
0644
edit
dl
rm
subprocess.py
72649
0644
edit
dl
rm
sunau.py
18375
0644
edit
dl
rm
symbol.py
2142
0755
edit
dl
rm
symtable.py
7279
0644
edit
dl
rm
sysconfig.py
24440
0644
edit
dl
rm
tabnanny.py
11419
0755
edit
dl
rm
tarfile.py
92675
0755
edit
dl
rm
telnetlib.py
23135
0644
edit
dl
rm
tempfile.py
26730
0644
edit
dl
rm
textwrap.py
19407
0644
edit
dl
rm
this.py
1003
0644
edit
dl
rm
threading.py
49284
0644
edit
dl
rm
timeit.py
13493
0755
edit
dl
rm
token.py
3763
0644
edit
dl
rm
tokenize.py
27031
0644
edit
dl
rm
trace.py
28903
0755
edit
dl
rm
traceback.py
23437
0644
edit
dl
rm
tracemalloc.py
17076
0644
edit
dl
rm
tty.py
879
0644
edit
dl
rm
types.py
9897
0644
edit
dl
rm
typing.py
56438
0644
edit
dl
rm
uu.py
7277
0644
edit
dl
rm
uuid.py
29518
0644
edit
dl
rm
warnings.py
20080
0644
edit
dl
rm
wave.py
18230
0644
edit
dl
rm
weakref.py
21508
0644
edit
dl
rm
webbrowser.py
23715
0755
edit
dl
rm
xdrlib.py
5913
0644
edit
dl
rm
zipapp.py
7535
0644
edit
dl
rm
zipfile.py
81094
0644
edit
dl
rm
_bootlocale.py
1801
0644
edit
dl
rm
_collections_abc.py
26424
0644
edit
dl
rm
_compat_pickle.py
8749
0644
edit
dl
rm
_compression.py
5340
0644
edit
dl
rm
_dummy_thread.py
6027
0644
edit
dl
rm
_markupbase.py
14598
0644
edit
dl
rm
_osx_support.py
19600
0644
edit
dl
rm
_pydecimal.py
228690
0644
edit
dl
rm
_pyio.py
91616
0644
edit
dl
rm
_py_abc.py
6186
0644
edit
dl
rm
_sitebuiltins.py
3115
0644
edit
dl
rm
_strptime.py
25504
0644
edit
dl
rm
_sysconfigdata_dm_linux_x86_64-linux-gnu.py
29786
0644
edit
dl
rm
_sysconfigdata_m_linux_x86_64-linux-gnu.py
28651
0644
edit
dl
rm
_threading_local.py
7214
0644
edit
dl
rm
_weakrefset.py
5679
0644
edit
dl
rm
__future__.py
5101
0644
edit
dl
rm
__phello__.foo.py
64
0644
edit
dl
rm
Edit:
/opt/alt/python37/lib64/python3.7/asynchat.py
(11328B)
# -*- 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 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 as why: 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