3838import StringIO
3939import codecs
4040
41- from string import find , rfind
4241from decimal import Decimal
4342
4443from rdflib .term import URIRef , BNode , Literal , Variable , _XSD_PFX , _unique_id
@@ -81,7 +80,7 @@ def splitFrag(uriref):
8180
8281 """
8382
84- i = rfind (uriref , "#" )
83+ i = uriref . rfind ("#" )
8584 if i >= 0 : return uriref [:i ], uriref [i + 1 :]
8685 else : return uriref , None
8786
@@ -100,7 +99,7 @@ def splitFragP(uriref, punct=0):
10099
101100 """
102101
103- i = rfind (uriref , "#" )
102+ i = uriref . rfind ("#" )
104103 if i >= 0 : return uriref [:i ], uriref [i :]
105104 else : return uriref , ''
106105
@@ -139,16 +138,16 @@ def join(here, there):
139138 u'http://example.org/#Andr\\ xe9'
140139 """
141140
142- assert (find (here , "#" ) < 0 ), "Base may not contain hash: '%s'" % here # caller must splitFrag (why?)
141+ assert (here . find ("#" ) < 0 ), "Base may not contain hash: '%s'" % here # caller must splitFrag (why?)
143142
144- slashl = find (there , '/' )
145- colonl = find (there , ':' )
143+ slashl = there . find ('/' )
144+ colonl = there . find (':' )
146145
147146 # join(base, 'foo:/') -- absolute
148147 if colonl >= 0 and (slashl < 0 or colonl < slashl ):
149148 return there
150149
151- bcolonl = find (here , ':' )
150+ bcolonl = here . find (':' )
152151 assert (bcolonl >= 0 ), "Base uri '%s' is not absolute" % here # else it's not absolute
153152
154153 path , frag = splitFragP (there )
@@ -159,7 +158,7 @@ def join(here, there):
159158 raise ValueError ("Base <%s> has no slash after colon - with relative '%s'." % (here , there ))
160159
161160 if here [bcolonl + 1 :bcolonl + 3 ] == '//' :
162- bpath = find (here , '/' , bcolonl + 3 )
161+ bpath = here . find ('/' , bcolonl + 3 )
163162 else :
164163 bpath = bcolonl + 1
165164
@@ -176,7 +175,7 @@ def join(here, there):
176175 if there [:1 ] == '/' :
177176 return here [:bpath ] + there
178177
179- slashr = rfind (here , '/' )
178+ slashr = here . rfind ('/' )
180179
181180 while 1 :
182181 if path [:2 ] == './' :
@@ -185,7 +184,7 @@ def join(here, there):
185184 path = ''
186185 elif path [:3 ] == '../' or path == '..' :
187186 path = path [3 :]
188- i = rfind (here , '/' , bpath , slashr )
187+ i = here . rfind ('/' , bpath , slashr )
189188 if i >= 0 :
190189 here = here [:i + 1 ]
191190 slashr = i
@@ -261,10 +260,10 @@ def refTo(base, uri):
261260 while i > 0 and uri [i - 1 ] != '/' : i = i - 1 # scan for slash
262261
263262 if i < 3 : return uri # No way.
264- if string .find (base , "//" , i - 2 )> 0 \
265- or string .find (uri , "//" , i - 2 )> 0 : return uri # An unshared "//"
266- if string .find (base , ":" , i )> 0 : return uri # An unshared ":"
267- n = string .count (base , "/" , i )
263+ if base .find ("//" , i - 2 )> 0 \
264+ or uri .find ("//" , i - 2 )> 0 : return uri # An unshared "//"
265+ if base .find (":" , i )> 0 : return uri # An unshared ":"
266+ n = base .count ("/" , i )
268267 if n == 0 and i < len (uri ) and uri [i ] == '#' :
269268 return "./" + uri [i :]
270269 elif n == 0 and i == len (uri ):
@@ -568,10 +567,10 @@ def _do_text(self, node):
568567 Process a text or CDATA node. Render various special characters
569568 as their C14N entity representations.'''
570569 if not _in_subset (self .subset , node ): return
571- s = string . replace ( node .data , "&" , "&" )
572- s = string .replace (s , "<" , "<" )
573- s = string .replace (s , ">" , ">" )
574- s = string .replace (s , "\015 " , "
" )
570+ s = node .data . replace ( "&" , "&" )
571+ s = s .replace ("<" , "<" )
572+ s = s .replace (">" , ">" )
573+ s = s .replace ("\015 " , "
" )
575574 if s : self .write (s )
576575 handlers [Node .TEXT_NODE ] = _do_text
577576 handlers [Node .CDATA_SECTION_NODE ] = _do_text
@@ -622,12 +621,12 @@ def _do_attr(self, n, value):
622621 W (' ' )
623622 W (n )
624623 W ('="' )
625- s = string .replace (value , "&" , "&" )
626- s = string .replace (s , "<" , "<" )
627- s = string .replace (s , '"' , '"' )
628- s = string .replace (s , '\011 ' , '	' )
629- s = string .replace (s , '\012 ' , '
' )
630- s = string .replace (s , '\015 ' , '
' )
624+ s = value .replace (value , "&" , "&" )
625+ s = s .replace ("<" , "<" )
626+ s = s .replace ('"' , '"' )
627+ s = s .replace ('\011 ' , '	' )
628+ s = s .replace ('\012 ' , '
' )
629+ s = s .replace ('\015 ' , '
' )
631630 W (s )
632631 W ('"' )
633632
@@ -1501,7 +1500,7 @@ def uri_ref2(self, str, i, res):
15011500 res .append (self ._variables [symb ])
15021501 else :
15031502 res .append (symb ) # @@@ "#" CONVENTION
1504- if not string .find (ns , "#" ):progress (
1503+ if not ns .find ("#" ):progress (
15051504 "Warning: no # on namespace %s," % ns )
15061505 return j
15071506
@@ -1825,7 +1824,7 @@ def strconst(self, str, i, delim):
18251824 if not ch :
18261825 raise BadSyntax (self ._thisDoc , startline , str , i ,
18271826 "unterminated string literal (2)" )
1828- k = string . find ( 'abfrtvn\\ "' , ch )
1827+ k = 'abfrtvn\\ "' . find ( ch )
18291828 if k >= 0 :
18301829 uch = '\a \b \f \r \t \v \n \\ "' [k ]
18311830 ustr = ustr + uch
@@ -1855,7 +1854,7 @@ def uEscape(self, str, i, startline):
18551854 if ch == "" :
18561855 raise BadSyntax (self ._thisDoc , startline , str , i ,
18571856 "unterminated string literal(3)" )
1858- k = string . find ( "0123456789abcdef" , ch )
1857+ k = "0123456789abcdef" . find ( ch )
18591858 if k < 0 :
18601859 raise BadSyntax (self ._thisDoc , startline , str , i ,
18611860 "bad string literal hex escape" )
@@ -1876,7 +1875,7 @@ def UEscape(self, str, i, startline):
18761875 if ch == "" :
18771876 raise BadSyntax (self ._thisDoc , startline , str , i ,
18781877 "unterminated string literal(3)" )
1879- k = string . find ( "0123456789abcdef" , ch )
1878+ k = "0123456789abcdef" . find ( ch )
18801879 if k < 0 :
18811880 raise BadSyntax (self ._thisDoc , startline , str , i ,
18821881 "bad string literal hex escape" )
@@ -2139,8 +2138,8 @@ def stringToN3(str, singleLine=0, flags=""):
21392138 if (len (str ) > 20 and
21402139 str [- 1 ] <> '"' and
21412140 not singleLine and
2142- (string .find (str , "\n " ) >= 0
2143- or string .find (str , '"' ) >= 0 )):
2141+ (str .find ("\n " ) >= 0
2142+ or str .find ('"' ) >= 0 )):
21442143 delim = '"""'
21452144 forbidden = forbidden1 # (allow tabs too now)
21462145 else :
@@ -2160,7 +2159,7 @@ def stringToN3(str, singleLine=0, flags=""):
21602159 if ch == '"' and delim == '"""' and str [j :j + 3 ] != '"""' : #"
21612160 res = res + ch
21622161 else :
2163- k = string . find ( '\a \b \f \r \t \v \n \\ "' , ch )
2162+ k = '\a \b \f \r \t \v \n \\ "' . find ( ch )
21642163 if k >= 0 : res = res + "\\ " + 'abfrtvn\\ "' [k ]
21652164 else :
21662165 if 'e' in flags :
@@ -2220,16 +2219,16 @@ def hexify(ustr):
22202219
22212220def dummy ():
22222221 res = ""
2223- if len (str ) > 20 and (string .find (str , "\n " ) >= 0
2224- or string .find (str , '"' ) >= 0 ):
2222+ if len (str ) > 20 and (str .find ("\n " ) >= 0
2223+ or str .find ('"' ) >= 0 ):
22252224 delim = '"""'
22262225 forbidden = "\\ \" \a \b \f \r \v " # (allow tabs too now)
22272226 else :
22282227 delim = '"'
22292228 forbidden = "\\ \" \a \b \f \r \v \t \n "
22302229 for i in range (len (str )):
22312230 ch = str [i ]
2232- j = string .find (forbidden , ch )
2231+ j = forbidden .find (ch )
22332232 if ch == '"' and delim == '"""' \
22342233 and i + 1 < len (str ) and str [i + 1 ] != '"' :
22352234 j = - 1 # Single quotes don't need escaping in long format
0 commit comments