def compile_css(item): path_src = find_static_path(item) path_dst = os.path.join(settings.ROOT, 'static', '%s.css' % item) updated_src = os.path.getmtime(find_static_path(item)) updated_dst = 0 # If the file doesn't exist, force a refresh. if os.path.exists(path_dst): updated_dst = os.path.getmtime(path_dst) # Is the uncompiled version newer? Then recompile! if not updated_dst or updated_src > updated_dst: ensure_path_exists(os.path.dirname(path_dst)) if item.endswith('.less'): with open(path_dst, 'w') as output: subprocess.Popen([settings.LESS_BIN, path_src], stdout=output)
def _get_mtime(item): """Get a last-changed timestamp for development.""" if not item.startswith(('//', 'http://', 'https://')): filename = find_static_path(item) if filename: return int(os.path.getmtime(filename)) return int(time.time())
def get_static_path(name): """Returns the full static path of the given name.""" if settings.DEBUG: path = find_static_path(name) if path is None: path = staticfiles_storage.path(name) else: path = staticfiles_storage.path(name) return os.path.abspath(path)
def _preprocess_file(self, filename): """Preprocess files and return new filenames.""" css_bin = filename.endswith('.less') and settings.LESS_BIN source = find_static_path(filename) target = source if css_bin: target = '%s.css' % source run_command('{lessc} {source} {target}'.format(lessc=css_bin, source=str(source), target=str(target))) return target
def _preprocess_file(self, filename): """Preprocess files and return new filenames.""" css_bin = filename.endswith('.less') and settings.LESS_BIN source = find_static_path(filename) target = source if css_bin: target = '%s.css' % source run_command('{lessc} {source} {target}'.format( lessc=css_bin, source=str(source), target=str(target))) return target
def get_static_path(name): """Returns the full static path of the given name.""" path = find_static_path(name) if path is None: path = staticfiles_storage.path(name) return os.path.abspath(path)