MCPcopy Index your code
hub / github.com/python/cpython / parse229

Function parse229

Lib/ftplib.py:831–849  ·  view source on GitHub ↗

Parse the '229' response for an EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.

(resp, peer)

Source from the content-addressed store, hash-verified

829
830
831def parse229(resp, peer):
832 '''Parse the '229' response for an EPSV request.
833 Raises error_proto if it does not contain '(|||port|)'
834 Return ('host.addr.as.numbers', port#) tuple.'''
835 if resp[:3] != '229':
836 raise error_reply(resp)
837 left = resp.find('(')
838 if left < 0: raise error_proto(resp)
839 right = resp.find(')', left + 1)
840 if right < 0:
841 raise error_proto(resp) # should contain '(|||port|)'
842 if resp[left + 1] != resp[right - 1]:
843 raise error_proto(resp)
844 parts = resp[left + 1:right].split(resp[left+1])
845 if len(parts) != 5:
846 raise error_proto(resp)
847 host = peer[0]
848 port = int(parts[3])
849 return host, port
850
851
852def parse257(resp):

Callers 1

makepasvMethod · 0.85

Calls 4

error_replyClass · 0.85
error_protoClass · 0.70
findMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…