def build_css_js(root_path, source_files, target_file, compress=True):
    target_file = os.path.join(root_path, target_file)
    file_type = 'js' if target_file.endswith('.js') else 'css'
    all_source = ''
    for source in source_files:
        all_source = '%s "%s"' % (all_source, os.path.join(root_path, source))
    if compress:
        subprocess.call('cat %s > %s.tmp' % (all_source, target_file), shell=True)
        cmd = '%s %s.tmp -o %s --type %s --charset utf-8' % (css_js_compressor(), target_file, target_file, file_type)
        subprocess.call(cmd, shell=True)
        subprocess.call('rm %s.tmp' % target_file, shell=True)
    else:
        subprocess.call('cat %s > %s' % (all_source, target_file), shell=True)
    log.info('build %s', target_file)
Merge/compress css js file
dataset/ETHPy150Open remyzane/flask-http-api/http_api/assist/coding.py/build_css_js