Re-use resursion code
This commit is contained in:
@@ -29,15 +29,16 @@ class PutIO(DownloaderBase):
|
|||||||
return super(PutIO, self).__init__()
|
return super(PutIO, self).__init__()
|
||||||
|
|
||||||
# This is a recusive function to check for the folders
|
# This is a recusive function to check for the folders
|
||||||
def recursionFolder(self, client, folder, tfolder):
|
def recursionFolder(self, client, folder = 0, tfolder = ''):
|
||||||
files = client.File.list(folder)
|
files = client.File.list(folder)
|
||||||
for f in files:
|
for f in files:
|
||||||
if f.name == tfolder and f.content_type == "application/x-directory":
|
if f.content_type == 'application/x-directory':
|
||||||
return f.id
|
if f.name == tfolder:
|
||||||
elif f.content_type == "application/x-directory":
|
return f.id
|
||||||
result = self.recursionFolder(client, f.id, tfolder)
|
else:
|
||||||
if result != 0:
|
result = self.recursionFolder(client, f.id, tfolder)
|
||||||
return result
|
if result != 0:
|
||||||
|
return result
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# This will check the root for the folder, and kick of recusively checking sub folder
|
# This will check the root for the folder, and kick of recusively checking sub folder
|
||||||
@@ -45,16 +46,7 @@ class PutIO(DownloaderBase):
|
|||||||
if folder == 0:
|
if folder == 0:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
files = client.File.list()
|
return self.recursionFolder(client, 0, folder)
|
||||||
for f in files:
|
|
||||||
if f.name == folder and f.content_type == "application/x-directory":
|
|
||||||
return f.id
|
|
||||||
elif f.content_type == "application/x-directory":
|
|
||||||
result = self.recursionFolder(client, f.id, folder)
|
|
||||||
if result != 0:
|
|
||||||
return result
|
|
||||||
#If we get through the whole list and don't get a match we will use the root
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def download(self, data = None, media = None, filedata = None):
|
def download(self, data = None, media = None, filedata = None):
|
||||||
if not media: media = {}
|
if not media: media = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user