mirror of
https://github.com/python/cpython.git
synced 2025-09-20 15:40:32 +00:00
String method conversion.
(This one was trivial -- no actual string. references in it!)
This commit is contained in:
parent
c95bf69fce
commit
19e6d6218e
1 changed files with 4 additions and 8 deletions
|
@ -1,7 +1,5 @@
|
||||||
"""Gopher protocol client interface."""
|
"""Gopher protocol client interface."""
|
||||||
|
|
||||||
import string
|
|
||||||
|
|
||||||
__all__ = ["send_selector","send_query"]
|
__all__ = ["send_selector","send_query"]
|
||||||
|
|
||||||
# Default selector, host and port
|
# Default selector, host and port
|
||||||
|
@ -58,15 +56,14 @@ TAB = '\t'
|
||||||
def send_selector(selector, host, port = 0):
|
def send_selector(selector, host, port = 0):
|
||||||
"""Send a selector to a given host and port, return a file with the reply."""
|
"""Send a selector to a given host and port, return a file with the reply."""
|
||||||
import socket
|
import socket
|
||||||
import string
|
|
||||||
if not port:
|
if not port:
|
||||||
i = string.find(host, ':')
|
i = host.find(':')
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
host, port = host[:i], string.atoi(host[i+1:])
|
host, port = host[:i], int(host[i+1:])
|
||||||
if not port:
|
if not port:
|
||||||
port = DEF_PORT
|
port = DEF_PORT
|
||||||
elif type(port) == type(''):
|
elif type(port) == type(''):
|
||||||
port = string.atoi(port)
|
port = int(port)
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.connect((host, port))
|
s.connect((host, port))
|
||||||
s.send(selector + CRLF)
|
s.send(selector + CRLF)
|
||||||
|
@ -98,7 +95,6 @@ def path_to_datatype_name(path):
|
||||||
|
|
||||||
def get_directory(f):
|
def get_directory(f):
|
||||||
"""Get a directory in the form of a list of entries."""
|
"""Get a directory in the form of a list of entries."""
|
||||||
import string
|
|
||||||
list = []
|
list = []
|
||||||
while 1:
|
while 1:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
|
@ -115,7 +111,7 @@ def get_directory(f):
|
||||||
print '(Empty line from server)'
|
print '(Empty line from server)'
|
||||||
continue
|
continue
|
||||||
gtype = line[0]
|
gtype = line[0]
|
||||||
parts = string.splitfields(line[1:], TAB)
|
parts = line[1:].split(TAB)
|
||||||
if len(parts) < 4:
|
if len(parts) < 4:
|
||||||
print '(Bad line from server:', `line`, ')'
|
print '(Bad line from server:', `line`, ')'
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue