def list(self, ignore_patterns): """ List all files in all locations. """ for prefix, root in self.locations: storage = self.storages[root] for path in utils.get_files(storage, ignore_patterns): yield path, storage
def list(self, ignore_patterns): """ List all files in all app storages. """ for storage in self.storages.itervalues(): if storage.exists(''): # check if storage location exists for path in utils.get_files(storage, ignore_patterns): yield path, storage
def list(self, ignore_patterns): """ List all files in all app storages. """ for storage in self.storages.values(): if storage.exists(''): # check if storage location exists for path in utils.get_files(storage, ignore_patterns): yield path, storage
def handle_app(self, app, **options): """ Copy all static media files from an application. """ ignore_patterns = options['ignore_patterns'] prefix = utils.get_app_prefix(app) for storage in utils.app_static_storages(app): for path in utils.get_files(storage, ignore_patterns): self.copy_file(path, prefix, storage, **options)
def pre_handle_apps(self, **options): """ Copy all files from a directory. """ if not options.get('exclude_dirs', False): ignore_patterns = options['ignore_patterns'] for root in DIRS: if isinstance(root, (list, tuple)): prefix, root = root else: prefix = '' source_storage = FileSystemStorage(location=root) for source in utils.get_files(source_storage, ignore_patterns): self.copy_file(source, prefix, source_storage, **options)
def handle(self, *app_labels, **options): ignore_patterns = options['ignore_patterns'] if options['use_default_ignore_patterns']: ignore_patterns += ['CVS', '.*', '*~'] options['ignore_patterns'] = ignore_patterns options['skipped_files'] = [] options['copied_files'] = [] options['symlinked_files'] = [] storage = get_storage_class(STORAGE)() options['destination_storage'] = storage try: destination_paths = utils.get_files(storage, ignore_patterns) except OSError: # The destination storage location may not exist yet. It'll get # created when the first file is copied. destination_paths = [] options['destination_paths'] = destination_paths try: storage.path('') destination_local = True except NotImplementedError: destination_local = False options['destination_local'] = destination_local if options.get('link', False): if sys.platform == 'win32': message = "Symlinking is not supported by this platform (%s)." raise CommandError(message % sys.platform) if not destination_local: raise CommandError("Can't symlink to a remote destination.") # Warn before doing anything more. if options.get('interactive'): confirm = raw_input(""" You have requested to collate static media files and copy them to the destination location as specified in your settings file. This will overwrite existing files. Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: """) if confirm != 'yes': raise CommandError("Static files build cancelled.") return super(Command, self).handle(*app_labels, **options)
def handle(self, *app_labels, **options): ignore_patterns = options['ignore_patterns'] if options['use_default_ignore_patterns']: ignore_patterns += ['CVS', '.*', '*~'] options['ignore_patterns'] = ignore_patterns options['skipped_files'] = [] options['copied_files'] = [] options['symlinked_files'] = [] storage = utils.dynamic_import(STORAGE)() options['destination_storage'] = storage try: destination_paths = utils.get_files(storage, ignore_patterns) except OSError: # The destination storage location may not exist yet. It'll get # created when the first file is copied. destination_paths = [] options['destination_paths'] = destination_paths try: storage.path('') destination_local = True except NotImplementedError: destination_local = False options['destination_local'] = destination_local if options.get('link', False): if sys.platform == 'win32': message = "Symlinking is not supported by this platform (%s)." raise CommandError(message % sys.platform) if not destination_local: raise CommandError("Can't symlink to a remote destination.") # Warn before doing anything more. if options.get('interactive'): confirm = raw_input(""" You have requested to collate static media files and copy them to the destination location as specified in your settings file. This will overwrite existing files. Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: """) if confirm != 'yes': raise CommandError("Static files build cancelled.") return super(Command, self).handle(*app_labels, **options)
def list(self, ignore_patterns): """ List all files of the storage. """ for path in utils.get_files(self.storage, ignore_patterns): yield path, self.storage