Пример #1
0
def _find_root(name):
    for root in get_media_dirs():
        sprite_root = os.path.join(root, re.sub(".sprite$", "", name))
        if os.path.isdir(sprite_root):
            return sprite_root

    raise Exception("No sprite dirrectory found %s" % name)
Пример #2
0
    def __init__(self, **kwargs):
        self.config(kwargs,
                    exclude_main_libs=False,
                    main_module=None,
                    debug=None,
                    path=(),
                    only_dependencies=None)
        if isinstance(self.path, basestring):
            self.path = (self.path, )
        self.path += tuple(get_media_dirs())
        if self.only_dependencies is None:
            self.only_dependencies = bool(self.main_module)
        if self.only_dependencies:
            self.path += (STDLIB_PATH, BUILTIN_PATH, EXTRA_LIBS_PATH)
        super(Pyjs, self).__init__(**kwargs)
        assert self.filetype == 'js', ('Pyjs only supports compilation to js. '
                                       'The parent filter expects "%s".' %
                                       self.filetype)

        if self.only_dependencies:
            assert self.main_module, \
                'You must provide a main module in only_dependencies mode'

        self._compiled = {}
        self._collected = {}
Пример #3
0
    def __init__(self, **kwargs):
        self.config(kwargs, path=(), main_module=None)
        if isinstance(self.path, str):
            self.path = (self.path, )

        # we need to be able to mutate self.path
        self.path = [*self.path]

        # super(Less, self).__init__(**kwargs)
        super().__init__(**kwargs)

        assert self.filetype == 'css', (
            'Less only supports compilation to CSS. '
            'The parent filter expects "{}".'.format(self.filetype))
        assert self.main_module, 'You must provide a main module'

        # lessc can't cope with nonexistent directories, so filter them
        media_dirs = [
            directory for directory in get_media_dirs()
            if os.path.exists(directory)
        ]
        self.path += tuple(media_dirs)

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}
Пример #4
0
def _find_root(name):
    for root in get_media_dirs():
        sprite_root = os.path.join(root, re.sub(".sprite$", "", name))
        if os.path.isdir(sprite_root):
            return sprite_root
    
    raise Exception("No sprite dirrectory found %s" % name)
Пример #5
0
    def get_dev_output_names(self):
        media_files = {}
        for root in get_media_dirs():
            self.collect_copyable_files(media_files, root)

        for name, source in media_files.items():
            hash = str(os.path.getmtime(source))
            yield name, name, hash
Пример #6
0
    def get_dev_output_names(self):
        media_files = {}
        for root in get_media_dirs():
            self.collect_copyable_files(media_files, root)

        for name, source in media_files.items():
            fp = open(source, 'rb')
            hash = sha1(fp.read()).hexdigest()
            fp.close()
            yield name, name, hash
Пример #7
0
    def get_dev_output_names(self):
        media_files = {}
        for root in get_media_dirs():
            self.collect_copyable_files(media_files, root)

        for name, source in media_files.items():
            fp = open(source, 'rb')
            hash = sha1(fp.read()).hexdigest()
            fp.close()
            yield name, name, hash
Пример #8
0
    def __init__(self, **kwargs):
        self.config(kwargs, path=(), main_module=None)
        if isinstance(self.path, basestring):
            self.path = (self.path,)
        super(Sass, self).__init__(**kwargs)
        assert self.filetype == "css", (
            "Sass only supports compilation to css. " 'The parent filter expects "%s".' % self.filetype
        )
        assert self.main_module, "You must provide a main module"

        self.path += tuple(get_media_dirs())
        self.path_args = []
        for path in self.path:
            self.path_args.extend(("-I", path))

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}
Пример #9
0
def _find_files(path_from, pattern):

    path_root = os.path.abspath(".")

    if pattern.startswith("."):
        search_prefix = path_from.replace(path_root, "").strip("/")
        pattern = search_prefix + "/" + pattern

    found = []
    for cdir in get_media_dirs():
        if not os.path.isdir(cdir):
            continue

        os.chdir(cdir)
        found = glob2.glob(pattern)
        if found:
            break

    return [os.path.normpath(f) for f in found]
Пример #10
0
    def __init__(self, **kwargs):
        self.config(kwargs, path=(), main_module=None)
        if isinstance(self.path, basestring):
            self.path = (self.path,)
        super(Sass, self).__init__(**kwargs)
        assert self.filetype == 'css', (
            'Sass only supports compilation to css. '
            'The parent filter expects "%s".' % self.filetype)
        assert self.main_module, \
            'You must provide a main module'

        self.path += tuple(get_media_dirs())
        self.path_args = []
        for path in self.path:
            self.path_args.extend(('-I', path.replace('\\', '/')))

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}
Пример #11
0
def _find_files(path_from, pattern):
    
    path_root = os.path.abspath(".")

    if pattern.startswith("."):
        search_prefix = path_from.replace(path_root, "").strip("/")
        pattern = search_prefix + "/" + pattern
    
    found = []
    for cdir in get_media_dirs():
        if not os.path.isdir(cdir):
            continue

        os.chdir(cdir)
        found = glob2.glob(pattern)
        if found:
            break

    return [os.path.normpath(f) for f in found]
Пример #12
0
    def __init__(self, **kwargs):
        self.config(kwargs, exclude_main_libs=False, main_module=None,
                    debug=None, path=(), only_dependencies=None)
        if isinstance(self.path, basestring):
            self.path = (self.path,)
        self.path += tuple(get_media_dirs())
        if self.only_dependencies is None:
            self.only_dependencies = bool(self.main_module)
        if self.only_dependencies:
            self.path += (STDLIB_PATH, BUILTIN_PATH, EXTRA_LIBS_PATH)
        super(Pyjs, self).__init__(**kwargs)
        assert self.filetype == 'js', (
            'Pyjs only supports compilation to js. '
            'The parent filter expects "%s".' % self.filetype)

        if self.only_dependencies:
            assert self.main_module, \
                'You must provide a main module in only_dependencies mode'

        self._compiled = {}
        self._collected = {}
Пример #13
0
    def __init__(self, **kwargs):
        self.config(kwargs, name=kwargs["name"], path=(), template_name=kwargs.get("template_name"))
        if isinstance(self.path, basestring):
            self.path = (self.path,)

        # we need to be able to mutate self.path
        self.path = list(self.path)

        super(HandlebarsFilter, self).__init__(**kwargs)

        media_dirs = [directory for directory in get_media_dirs()
                      if os.path.exists(directory)]
        self.path += tuple(media_dirs)

        # search from template directories first
        from django.template.loaders.app_directories import app_template_dirs
        self.path = list(app_template_dirs) + self.path

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}
Пример #14
0
    def __init__(self, **kwargs):
        self.config(kwargs, name=kwargs["name"], path=(), template_name=kwargs.get("template_name"))
        if isinstance(self.path, basestring):
            self.path = (self.path,)

        # we need to be able to mutate self.path
        self.path = list(self.path)

        super(DustFilter, self).__init__(**kwargs)

        # dustc can't cope with nonexistent directories, so filter them
        media_dirs = [directory for directory in get_media_dirs()
                      if os.path.exists(directory)]
        self.path += tuple(media_dirs)

        # search from template directories first
        from django.template.loaders.app_directories import app_template_dirs
        self.path = list(app_template_dirs) + self.path

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}
Пример #15
0
    def __init__(self, **kwargs):
        self.config(kwargs, path=(), main_module=None)
        if isinstance(self.path, basestring):
            self.path = (self.path,)

        # we need to be able to mutate self.path,
        self.path = list(self.path)

        super(Less, self).__init__(**kwargs)

        assert self.filetype == 'css', (
            'Less only supports compilation to CSS. '
            'The parent filter expects "%s".' % self.filetype)
        assert self.main_module, \
            'You must provide a main module'

        # lessc can't cope with nonexistent directories, so filter them
        media_dirs = [directory for directory in get_media_dirs()
                      if os.path.exists(directory)]
        self.path += tuple(media_dirs)

        self._compiled = None
        self._compiled_hash = None
        self._dependencies = {}