def execute(self, path): """ Convert all .less files in the given path to .css """ # Check and warn if not run("lessc", check_only=True): log.warn("lessc is not installed. Less files were not updated") return # Look for oldest css file assets = Assets(path) updated = False oldest = 0 reason = "" for f in os.listdir(path): f = f.lower() if f[-5:] == ".less": fullpath = join(path, f) output_path = fullpath[:-5] + ".css" if not assets.exists(output_path): updated = True reason = "missing css file" break else: opath = assets.resolve(output_path) utime = os.path.getmtime(opath) if utime > oldest: oldest = utime oldest_name = opath # Look for changes to any less files for root, dirnames, filenames in os.walk(path): for f in filenames: f = f.lower() if f[-5:] == ".less": fullpath = join(root, f) otime = os.path.getmtime(fullpath) if otime > oldest: updated = True reason = "less file updated" break # Found some? Ok, process the target dir if updated: for f in os.listdir(path): f = f.lower() if f[-5:] == ".less": fullpath = join(path, f) output_path = fullpath[:-5] + ".css" run("lessc", fullpath, output_path) log.info("css rebuild: %s" % reason)
def execute(self, path): """ Convert all .less files in the given path to .css """ # Check and warn if not run("lessc", check_only=True): log.warn("lessc is not installed. Less files were not updated") return # Run for f in os.listdir(path): f = f.lower() if f[-5:] == ".less": fullpath = join(path, f) output_path = fullpath[:-5] + ".css" run("lessc", fullpath, output_path)
def watch(self, path): """ Watch the given path as long as the app is running """ # Check and warn if not run("lessc", check_only=True): log.warn("lessc is not installed. Less files were not updated") return l = LessWatcher(path) l.start()