Skip to content

Commit

Permalink
Merge e6f0f0e into 781d30a
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcookie committed Apr 9, 2018
2 parents 781d30a + e6f0f0e commit 740574e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions filer/management/commands/import_files.py
Expand Up @@ -5,7 +5,7 @@
from optparse import make_option

from django.core.files import File as DjangoFile
from django.core.management.base import BaseCommand, NoArgsCommand
from django.core.management.base import BaseCommand

from ...models.filemodels import File
from ...models.foldermodels import Folder
Expand Down Expand Up @@ -81,7 +81,7 @@ def walker(self, path=None, base_folder=None):
This method walk a directory structure and create the
Folders and Files as they appear.
"""
path = path or self.path
path = path or self.path if self.path is not False else ''
base_folder = base_folder or self.base_folder
# prevent trailing slashes and other inconsistencies on path.
path = os.path.normpath(upath(path))
Expand All @@ -108,27 +108,30 @@ def walker(self, path=None, base_folder=None):
print(('folder_created #%s / file_created #%s / ' + 'image_created #%s') % (self.folder_created, self.file_created, self.image_created))


class Command(NoArgsCommand):
class Command(BaseCommand):
"""
Import directory structure into the filer ::
manage.py --path=/tmp/assets/images
manage.py --path=/tmp/assets/news --folder=images
"""

option_list = BaseCommand.option_list + (
make_option('--path',
def add_arguments(self, parser):
parser.add_argument(
'--path',
action='store',
dest='path',
default=False,
help='Import files located in the path into django-filer'),
make_option('--folder',
help='Import files located in the path into django-filer'
)

parser.add_argument(
'--folder',
action='store',
dest='base_folder',
default=False,
help='Specify the destination folder in which the directory structure should be imported'),
)
help='Specify the destination folder in which the directory structure should be imported'
)

def handle_noargs(self, **options):
def handle(self, *args, **options):
file_importer = FileImporter(**options)
file_importer.walker()

0 comments on commit 740574e

Please sign in to comment.