예제 #1
0
    def init_build(self, asset, builder):
        """
        Called when builder group collect files
        Resolves absolute url if relative passed

        :type asset: static_bundle.builders.Asset
        :type builder: static_bundle.builders.StandardBuilder
        """
        if not self.abs_path:
            rel_path = utils.prepare_path(self.rel_bundle_path)
            self.abs_bundle_path = utils.prepare_path([builder.config.input_dir, rel_path])
            self.abs_path = True
        self.input_dir = builder.config.input_dir
예제 #2
0
    def __init__(self, path, prepare_handlers=None):
        path = utils.prepare_path(path)
        abs_path = os.path.isabs(path)
        self.abs_path = abs_path
        if abs_path:
            self.abs_bundle_path = utils.prepare_path(path)
            self.rel_bundle_path = None
        else:
            self.abs_bundle_path = None
            self.rel_bundle_path = path
        self.files = []

        self.prepare_handlers_chain = prepare_handlers

        self.input_dir = None
예제 #3
0
 def __init__(self, file_path, bundle=None):
     """
     :type file_path: str|unicode
     :type bundle: static_bundle.bundles.AbstractBundle
     """
     self.file_path = prepare_path(file_path)
     self.bundle = bundle
예제 #4
0
 def get_compile_file(self, input_file, bundle):
     file_class = bundle.get_file_cls()
     if self.output_dir:
         out_dir = utils.prepare_path([bundle.abs_bundle_path, self.output_dir])
         if not os.path.exists(out_dir):
             os.makedirs(out_dir)
         rel = input_file.rel_path
         filename = rel.replace(bundle.rel_bundle_path, '').strip(os.sep).replace(os.sep, '.')
         return file_class(
             self.replace_file_name(bundle.rel_bundle_path + '/' + self.output_dir.strip('/') + '/' + filename),
             self.replace_file_name(utils.prepare_path([bundle.abs_bundle_path, self.output_dir, filename]))
         )
     else:
         return file_class(
             self.replace_file_name(input_file.rel_path),
             self.replace_file_name(input_file.abs_path)
         )
예제 #5
0
 def __init__(self, directory_path, bundle=None, exclusions=None):
     self.directory_path = prepare_path(directory_path)
     self.bundle = bundle
     self.exclusions = exclusions
예제 #6
0
 def init_path(cls, path):
     path = prepare_path(path)
     if os.path.isabs(path):
         return path
     return os.path.abspath(os.path.join(os.getcwd(), path))