def merge_resources(self, dir_name):
        if not dir_name in self.merged_public:
            public_folder = os.path.join(dir_name, self.public_folder)
            if os.path.exists(public_folder) and os.path.isdir(public_folder):
                util.copytree_exists(public_folder,
                                     self.output)
                self.merged_public.add(dir_name)
        for libs in [self.js_libs, self.dynamic_js_libs,
                     self.static_js_libs, self.early_static_js_libs, self.late_static_js_libs]:
            for lib in libs:
                if not lib in self.merged_public:
                    for path in self.path:
                        if os.path.exists(lib) and os.path.isfile(lib):
                            util.copy_exists(lib, os.path.join(self.output, os.path.basename(lib)))
                            self.merged_public.add(lib)
                            break

        # merge all output/css.d/* files into one output/base.css file
        css_d_path = os.path.join(self.output, 'css.d')
        base_css_path = os.path.join(self.output, 'base.css')

        if os.path.exists(css_d_path):
            hdr = '/* name: %s\n * md5: %s\n */\n'
            with open(base_css_path, 'w') as base_css:
                for root, dirs, files in os.walk(css_d_path):
                    docroot = root.replace(root, '', 1).strip('/')
                    for frag in files:
                        frag_path = os.path.join(root, frag)
                        with open(frag_path) as fd:
                            csstxt = fd.read()
                            base_css.write(hdr % (
                                os.path.relpath(frag_path, self.output),
                                md5(csstxt).hexdigest(),
                                ))
                            base_css.write(csstxt)
Ejemplo n.º 2
0
 def merge_resources(self, dir_name):
     if not dir_name in self.merged_public:
         public_folder = os.path.join(dir_name, self.public_folder)
         if os.path.exists(public_folder) and os.path.isdir(public_folder):
             util.copytree_exists(public_folder,
                                  self.output)
             self.merged_public.add(dir_name)
     for libs in [self.js_libs, self.dynamic_js_libs,
                  self.static_js_libs, self.early_static_js_libs, self.late_static_js_libs]:
         for lib in libs:
             if not lib in self.merged_public:
                 for path in self.path:
                     if os.path.exists(lib) and os.path.isfile(lib):
                         util.copy_exists(lib, os.path.join(self.output, os.path.basename(lib)))
                         self.merged_public.add(lib)
                         break
Ejemplo n.º 3
0
 def merge_resources(self, dir_name):
     if not dir_name in self.merged_public:
         public_folder = os.path.join(dir_name, self.public_folder)
         if os.path.exists(public_folder) and os.path.isdir(public_folder):
             util.copytree_exists(public_folder,
                                  self.output)
             self.merged_public.add(dir_name)
     for libs in [self.js_libs, self.dynamic_js_libs,
                  self.static_js_libs, self.early_static_js_libs, self.late_static_js_libs]:
         for lib in libs:
             if not lib in self.merged_public:
                 for path in self.path:
                     if os.path.exists(lib) and os.path.isfile(lib):
                         util.copy_exists(lib, os.path.join(self.output, os.path.basename(lib)))
                         self.merged_public.add(lib)
                         break
Ejemplo n.º 4
0
    def merge_resources(self, dir_name):
        if not dir_name in self.merged_public:
            public_folder = os.path.join(dir_name, self.public_folder)
            if os.path.exists(public_folder) and os.path.isdir(public_folder):
                util.copytree_exists(public_folder, self.output)
                self.merged_public.add(dir_name)
        for libs in [
                self.js_libs, self.dynamic_js_libs, self.static_js_libs,
                self.early_static_js_libs, self.late_static_js_libs
        ]:
            for lib in libs:
                if not lib in self.merged_public:
                    for path in self.path:
                        if os.path.exists(lib) and os.path.isfile(lib):
                            util.copy_exists(
                                lib,
                                os.path.join(self.output,
                                             os.path.basename(lib)))
                            self.merged_public.add(lib)
                            break

        # merge all output/css.d/* files into one output/base.css file
        css_d_path = os.path.join(self.output, 'css.d')
        base_css_path = os.path.join(self.output, 'base.css')

        if os.path.exists(css_d_path):
            hdr = '/* name: %s\n * md5: %s\n */\n'
            with open(base_css_path, 'w') as base_css:
                for root, dirs, files in os.walk(css_d_path):
                    docroot = root.replace(root, '', 1).strip('/')
                    for frag in files:
                        frag_path = os.path.join(root, frag)
                        with open(frag_path) as fd:
                            csstxt = fd.read()
                            base_css.write(hdr % (
                                os.path.relpath(frag_path, self.output),
                                md5(csstxt).hexdigest(),
                            ))
                            base_css.write(csstxt)