recursive functions for directories
This commit is contained in:
parent
1f7e442d04
commit
34115a3a7d
@ -15,9 +15,8 @@ class WPimport:
|
||||
|
||||
def fromDirectory(self, directory):
|
||||
directory = "{0}/archives".format(directory)
|
||||
for item in os.listdir(directory):
|
||||
subdirectory = self._checkDirectory(item)
|
||||
print(subdirectory)
|
||||
subdirectory = self._checkDirectory([], "{0}".format(directory))
|
||||
print(subdirectory)
|
||||
|
||||
|
||||
def fromFile(self, files):
|
||||
@ -34,10 +33,13 @@ class WPimport:
|
||||
|
||||
# Private method
|
||||
|
||||
def _checkDirectory(self, item):
|
||||
if os.path.isdir(item):
|
||||
self._checkDirectory(item)
|
||||
return item
|
||||
def _checkDirectory(self, subdirectory, item):
|
||||
sub = subdirectory
|
||||
for i in os.listdir(item):
|
||||
if os.path.isdir("{0}/{1}".format(item, i)):
|
||||
sub.append("{0}/{1}".format(item, i))
|
||||
subdirectory = self._checkDirectory(sub, "{0}/{1}".format(item, i))
|
||||
return subdirectory
|
||||
|
||||
## Add or update featured media
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user