mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Use string methods where possible, and remove import string
This commit is contained in:
		
							parent
							
								
									05ab2e693c
								
							
						
					
					
						commit
						7ce734cd72
					
				
					 3 changed files with 11 additions and 13 deletions
				
			
		|  | @ -36,7 +36,6 @@ | ||||||
| 
 | 
 | ||||||
| import os | import os | ||||||
| import sys | import sys | ||||||
| import string |  | ||||||
| 
 | 
 | ||||||
| # Import SOCKS module if it exists, else standard socket module socket | # Import SOCKS module if it exists, else standard socket module socket | ||||||
| try: | try: | ||||||
|  | @ -266,7 +265,7 @@ def sendeprt(self, host, port): | ||||||
|         if af == 0: |         if af == 0: | ||||||
|             raise error_proto, 'unsupported address family' |             raise error_proto, 'unsupported address family' | ||||||
|         fields = ['', `af`, host, `port`, ''] |         fields = ['', `af`, host, `port`, ''] | ||||||
|         cmd = 'EPRT ' + string.joinfields(fields, '|') |         cmd = 'EPRT ' + '|'.join(fields) | ||||||
|         return self.voidcmd(cmd) |         return self.voidcmd(cmd) | ||||||
| 
 | 
 | ||||||
|     def makeport(self): |     def makeport(self): | ||||||
|  | @ -585,18 +584,18 @@ def parse229(resp, peer): | ||||||
| 
 | 
 | ||||||
|     if resp[:3] <> '229': |     if resp[:3] <> '229': | ||||||
|         raise error_reply, resp |         raise error_reply, resp | ||||||
|     left = string.find(resp, '(') |     left = resp.find('(') | ||||||
|     if left < 0: raise error_proto, resp |     if left < 0: raise error_proto, resp | ||||||
|     right = string.find(resp, ')', left + 1) |     right = resp.find(')', left + 1) | ||||||
|     if right < 0: |     if right < 0: | ||||||
|         raise error_proto, resp # should contain '(|||port|)' |         raise error_proto, resp # should contain '(|||port|)' | ||||||
|     if resp[left + 1] <> resp[right - 1]: |     if resp[left + 1] <> resp[right - 1]: | ||||||
|         raise error_proto, resp |         raise error_proto, resp | ||||||
|     parts = string.split(resp[left + 1:right], resp[left+1]) |     parts = resp[left+1].split(resp[left + 1:right]) | ||||||
|     if len(parts) <> 5: |     if len(parts) <> 5: | ||||||
|         raise error_proto, resp |         raise error_proto, resp | ||||||
|     host = peer[0] |     host = peer[0] | ||||||
|     port = string.atoi(parts[3]) |     port = int(parts[3]) | ||||||
|     return host, port |     return host, port | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -38,10 +38,10 @@ def updatepos(self, i, j): | ||||||
|         if i >= j: |         if i >= j: | ||||||
|             return j |             return j | ||||||
|         rawdata = self.rawdata |         rawdata = self.rawdata | ||||||
|         nlines = string.count(rawdata, "\n", i, j) |         nlines = rawdata.count("\n", i, j) | ||||||
|         if nlines: |         if nlines: | ||||||
|             self.lineno = self.lineno + nlines |             self.lineno = self.lineno + nlines | ||||||
|             pos = string.rindex(rawdata, "\n", i, j) # Should not fail |             pos = rawdata.rindex("\n", i, j) # Should not fail | ||||||
|             self.offset = j-(pos+1) |             self.offset = j-(pos+1) | ||||||
|         else: |         else: | ||||||
|             self.offset = self.offset + j-i |             self.offset = self.offset + j-i | ||||||
|  | @ -176,7 +176,7 @@ def _parse_doctype_element(self, i, declstartpos): | ||||||
|         # style content model; just skip until '>' |         # style content model; just skip until '>' | ||||||
|         rawdata = self.rawdata |         rawdata = self.rawdata | ||||||
|         if '>' in rawdata[j:]: |         if '>' in rawdata[j:]: | ||||||
|             return string.find(rawdata, ">", j) + 1 |             return rawdata.find(">", j) + 1 | ||||||
|         return -1 |         return -1 | ||||||
| 
 | 
 | ||||||
|     # Internal -- scan past <!ATTLIST declarations |     # Internal -- scan past <!ATTLIST declarations | ||||||
|  | @ -200,7 +200,7 @@ def _parse_doctype_attlist(self, i, declstartpos): | ||||||
|             if c == "(": |             if c == "(": | ||||||
|                 # an enumerated type; look for ')' |                 # an enumerated type; look for ')' | ||||||
|                 if ")" in rawdata[j:]: |                 if ")" in rawdata[j:]: | ||||||
|                     j = string.find(rawdata, ")", j) + 1 |                     j = rawdata.find(")", j) + 1 | ||||||
|                 else: |                 else: | ||||||
|                     return -1 |                     return -1 | ||||||
|                 while rawdata[j:j+1] in string.whitespace: |                 while rawdata[j:j+1] in string.whitespace: | ||||||
|  | @ -307,7 +307,7 @@ def _scan_name(self, i, declstartpos): | ||||||
|             name = s.strip() |             name = s.strip() | ||||||
|             if (i + len(s)) == n: |             if (i + len(s)) == n: | ||||||
|                 return None, -1  # end of buffer |                 return None, -1  # end of buffer | ||||||
|             return string.lower(name), m.end() |             return name.lower(), m.end() | ||||||
|         else: |         else: | ||||||
|             self.updatepos(declstartpos, i) |             self.updatepos(declstartpos, i) | ||||||
|             self.error("expected name token") |             self.error("expected name token") | ||||||
|  |  | ||||||
|  | @ -261,12 +261,11 @@ def not_less_witness(self, other): | ||||||
|         return a |         return a | ||||||
| 
 | 
 | ||||||
| def format_witnesses(w): | def format_witnesses(w): | ||||||
|     import string |  | ||||||
|     firsts = map(lambda tup: str(tup[0]), w) |     firsts = map(lambda tup: str(tup[0]), w) | ||||||
|     prefix = "at tab size" |     prefix = "at tab size" | ||||||
|     if len(w) > 1: |     if len(w) > 1: | ||||||
|         prefix = prefix + "s" |         prefix = prefix + "s" | ||||||
|     return prefix + " " + string.join(firsts, ', ') |     return prefix + " " + ', '.join(firsts) | ||||||
| 
 | 
 | ||||||
| def process_tokens(tokens): | def process_tokens(tokens): | ||||||
|     INDENT = tokenize.INDENT |     INDENT = tokenize.INDENT | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Neal Norwitz
						Neal Norwitz