mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GwR add startswith, split to PersistentTemporaryFile
This commit is contained in:
parent
197923c54b
commit
e69845eff9
@ -51,6 +51,31 @@ class PersistentTemporaryFile(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
def startswith(self,*args):
|
||||
if len(args):
|
||||
str = args[0]
|
||||
beg = 0
|
||||
end = len(str)
|
||||
else:
|
||||
return False
|
||||
|
||||
if len(args) > 1:
|
||||
begin = args[1]
|
||||
if len(args) > 2:
|
||||
end = args[2]
|
||||
if self._name[beg:end].startswith(str):
|
||||
return True
|
||||
return False
|
||||
|
||||
def split(self,*args):
|
||||
if len(args):
|
||||
sep = args[0]
|
||||
if len(args) > 1:
|
||||
maxsplit = args[1]
|
||||
return self._name.split(sep,maxsplit)
|
||||
else:
|
||||
return self._name.split(sep)
|
||||
|
||||
|
||||
def PersistentTemporaryDirectory(suffix='', prefix='', dir=None):
|
||||
'''
|
||||
|
Loading…
x
Reference in New Issue
Block a user