Beispiel #1
0
    def test_expand_file_names(self):
        current_dir = os.path.dirname(__file__)
        files_in_dir = os.listdir(current_dir)
        python_files_in_dir = [fn for fn in files_in_dir if fn[-3:] == '.py']

        expanded_file_list = expand_file_names("*.py", current_dir)

        self.assertEqual(expanded_file_list, python_files_in_dir)
Beispiel #2
0
    def test_expand_file_names(self):
        current_dir = os.path.dirname(__file__)
        files_in_dir = os.listdir(current_dir)
        python_files_in_dir = [fn for fn in files_in_dir if fn[-3:] == '.py']

        expanded_file_list = expand_file_names("*.py", current_dir)

        self.assertEqual(expanded_file_list, python_files_in_dir)
Beispiel #3
0
    def __init__(self, conf):
        """
        Initialize a bundle and it's BundleFiles based on a conf dict
        """
        self.name = conf[0]

        conf_dict = conf[1]

        # Basic settings and defaults
        self.bundle_type = conf_dict['type']
        self.files_url_root = conf_dict.get('files_url_root', settings.MEDIA_URL)
        self.files_root = conf_dict.get('files_root', settings.MEDIA_ROOT)
        self.uglify_command = conf_dict.get('uglify_command')
        self.source_map_file_root = conf_dict.get('source_map_file_root')
        self.source_map_url_root = conf_dict.get('source_map_url_root')
        self.source_map_files_url_root = conf_dict.get('source_map_files_url_root') or self.files_url_root
        self.media = conf_dict.get('media')
        self.bundle_url_root = conf_dict.get('bundle_url_root') or self.files_url_root
        self.bundle_file_root = conf_dict.get('bundle_file_root') or self.files_root
        self.bundle_filename = conf_dict.get('bundle_filename') or self.name
        self.precompile_in_debug = False if bundles_settings.GLOBAL_PRECOMPILE_DISABLE else conf_dict.get('precompile_in_debug', False)
        self.fixed_bundle_url = conf_dict.get('bundle_url')
        self.fixed_bundle_file_path = conf_dict.get('bundle_file_path')

        # Build the list of BundleFiles
        self.files = []
        self._bundle_files = {}

        for fileconf in list(conf_dict['files']):
            path, extra = fileconf, None
            # Each file definition can be a string or tuple containing the path and the conf dict
            if isinstance(fileconf, (tuple, list)):
                path = fileconf[0]
                extra = fileconf[1]

            # Expand *s in filenames
            try:
                for filename in expand_file_names(path, self.files_root):
                    bundle_file = BundleFile(filename, self.files_root, self.files_url_root, self.media, self.bundle_type, self.precompile_in_debug, extra=extra)
                    self.files.append(bundle_file)
                    self._bundle_files[bundle_file.file_path] = bundle_file
            except OSError:
                raise ImproperlyConfigured("Bundle %s - could not find file(s): %s" % (self.name, path))

        # Get the processors or use the default list
        if 'processors' in conf_dict:
            self.processors = processor_library.get_processors(conf_dict['processors'])
        else:
            self.processors = processor_library.get_default_postprocessors_for(self.bundle_type)
Beispiel #4
0
    def __init__(self, conf):
        """
        Initialize a bundle and it's BundleFiles based on a conf dict
        """
        self.name = conf[0]

        conf_dict = conf[1]

        # Basic settings and defaults
        self.bundle_type = conf_dict['type']
        self.files_url_root = conf_dict.get('files_url_root', settings.MEDIA_URL)
        self.files_root = conf_dict.get('files_root', settings.MEDIA_ROOT)
        self.uglify_command = conf_dict.get('uglify_command')
        self.source_map_file_root = conf_dict.get('source_map_file_root')
        self.source_map_url_root = conf_dict.get('source_map_url_root')
        self.source_map_files_url_root = conf_dict.get('source_map_files_url_root') or self.files_url_root
        self.media = conf_dict.get('media')
        self.bundle_url_root = conf_dict.get('bundle_url_root') or self.files_url_root
        self.bundle_file_root = conf_dict.get('bundle_file_root') or self.files_root
        self.bundle_filename = conf_dict.get('bundle_filename') or self.name
        self.create_debug = conf_dict.get('debug', False)

        # Build the list of BundleFiles
        self.files = []
        self._bundle_files = {}

        for fileconf in list(conf_dict['files']):
            path, extra = fileconf, None
            # Each file definition can be a string or tuple containing the path and the conf dict
            if isinstance(fileconf, (tuple, list)):
                path = fileconf[0]
                extra = fileconf[1]

            # Expand *s in filenames
            try:
                for filename in expand_file_names(path, self.files_root):
                    bundle_file = BundleFile(filename, self.files_root, self.files_url_root, self.media, self.bundle_type, extra=extra)
                    self.files.append(bundle_file)
                    self._bundle_files[bundle_file.file_path] = bundle_file
            except OSError:
                raise ImproperlyConfigured("Bundle %s - could not find file(s): %s" % (self.name, path))

        # Get the processors or use the default list
        if 'processors' in conf_dict:
            self.processors = processor_library.get_processors(conf_dict['processors'])
        else:
            self.processors = processor_library.get_default_postprocessors_for(self.bundle_type)