Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
plugin_path = os.path.dirname(os.path.realpath(__file__))
base_path = plugin_path.split("plugins")[0]
LOGGER.info(f"!!!!!!!!!!!!!!!!base path = {base_path}")
sys.path.insert(0, os.path.join(base_path, "../"))
def gen_tasks(self):
for in_name in get_entries(os.path.join(base_path, "../examples")):
name_image = os.path.basename(in_name)
out_name = "output/gallery/" + name_image
# in_name = "/home/blackbird/Projects_heavy/pycontextfree/examples/paper/paper.png"
# out_name = "output/gallery/paper.png"
# out_name = "gallery/paper.png"
LOGGER.info(f"emiting copyi task {in_name} to {out_name}")
yield utils.apply_filters({
'basename': self.name,
'name': out_name,
'file_dep': [in_name],
'targets': [out_name],
'actions': [(utils.copy_file, [in_name, out_name])],
'clean': True,
}, {})
def read_files(self):
self.rows = []
cnt = 0
for fname in get_entries(os.path.join(base_path, "../examples")):
LOGGER.info("processing " + fname)
try:
# data = load_json(fname)
data = {}
data["path"] = fname
data["path_image"] = fname[:-3] + ".png"
data["name"] = os.path.basename(os.path.dirname(fname))
data["url"] = "https://github.com/undertherain/pycontextfree/blob/master/examples/" + data["name"] + "/" + os.path.basename(fname)
data["id"] = cnt
name_image = os.path.basename(fname)[:-3] + ".png"
data["image"] = "/gallery/" + name_image
cnt += 1
self.rows.append(data)
except Exception as e:
LOGGER.warning("error processing " + fname + str(e))