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