def map_file(self, fname, mapper=None): """Convenience function to map the sprites of a given CSS file.""" from spritecss.css import CSSParser from spritecss.finder import find_sprite_refs with open(fname, "rb") as fp: parser = CSSParser.read_file(fp) evs = list(parser.iter_events()) conf = CSSConfig(evs, base=self.conf, fname=fname) srefs = find_sprite_refs(evs, source=fname, conf=conf) if mapper is None: mapper = SpriteDirsMapper.from_conf(conf) return self.map_sprite_refs(srefs, mapper=mapper)
def open_parser(self): yield CSSParser.read_file(self.data)
def open_parser(self): with open(self.fname, "rb") as fp: yield CSSParser.read_file(fp)