예제 #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
파일: less.py 프로젝트: kchida/kchida_aws
    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 = {}