示例#1
0
    def cmd_mkfile(self, *args):
        """Creates new file"""

        if len(args) > 1:
            Tools.mkfile(args[0], args[1])
            return
        Tools.mkfile(args[0])
示例#2
0
    def checkDir(self):
        if Tools.exists(C.DIR / "proweb.json"):
            txt = Tools.readJson(C.DIR / "proweb.json")
            C.P_NAME = f" [Pro-{txt['name']}]"
            C.P_FILE = C.DIR / "proweb.json"
            C.P_PATH = C.DIR

        elif Tools.exists(C.DIR / "lib.json"):
            txt = Tools.read(C.DIR / "lib.json")
            data = json.loads(txt)
            C.P_NAME = f" [Lib-{data['name']}"
            C.P_FILE = C.DIR / "lib.json"
            C.P_PATH = C.DIR

        else:
            C.P_NAME = ""
            C.P_FILE = pathlib.Path()
            C.P_PATH = pathlib.Path()
示例#3
0
def process(DIR, name, arg=[]):
	global HTMLS

	print("pro: " + name);

	HTMLS[name]["text"] = Tools.read(HTMLS[name]["link"]);
	
	processJS(DIR, name, arg);
	processChild(DIR, name);

	HTMLS[name]["process"] = True;
示例#4
0
def processJS(DIR, name, args = []):
	path = "OUT/JS/" + name +".js";
	if Tools.exists(DIR / path):
		snippets = Tools.readJson("proweb.json")["snippets"];
		print("processing: " +name);
		path = "OUT/JS/" + name + ".js"
		text = Tools.read(path);

		for arg in args:
			print("arg:" + arg);
			text = arg + ";" + text;

		for k, v in snippets.items():
			k = "(?<=[\s\.])" + k + "\(";
			text = re.sub(k, v + "(", text);


		path = "EXT/JS/" + name + ".js"
		Tools.write(DIR / path , text);
		addScript("./JS/" + name + ".js");
示例#5
0
    def cmd_init(self, *args):
        if not Tools.exists(C.DIR / "proweb.json"):
            props = {}
            props["name"] = input("Name: ")
            props["elements"] = "./IN/ELEMENTS/"
            snips = input("Snippets [E]mpty [D]efault:")
            if snips == "E":
                props["snippets"] = {}
            elif snips == "D":
                props["snippets"] = {
                    "GET": "document.querySelector",
                    "GETALL": "document.querySelectorAll",
                    "NEW": "document.createElement",
                    "CHILD": "appendChild",
                    "EVENT": "addEventListener"
                }
            else:
                print("No project was created")
                return

            Tools.writeJson(C.DIR / "proweb.json", props)
            Tools.mkdir(C.DIR / "IN")
            Tools.mkdir(C.DIR / "IN" / "CSS")
            Tools.mkdir(C.DIR / "IN" / "JS")
            Tools.mkdir(C.DIR / "IN" / "ELEMENTS")
            Tools.mkfile(C.DIR / "index.html")
        else:
            print("there is another project in this folder")
示例#6
0
 def cmd_read(self, *args):
     """Reads file"""
     print(Tools.read(args[0]))
示例#7
0
 def cmd_mv(self, *args):
     """Moves file/dir"""
     Tools.mv(args[0], args[1])
示例#8
0
 def cmd_cp(self, *args):
     """Copies file/dir"""
     Tools.cp(args[0], args[1])
示例#9
0
 def cmd_rm(self, *args):
     """Removes file/dir"""
     Tools.rm(C.DIR / args[0])
示例#10
0
 def cmd_mkdir(self, *args):
     """Creates new dir"""
     args = C.DIR / args[0]
     Tools.mkdir(args)
示例#11
0
 def cmd_rm(self, DIR, *args):
     json = Tools.readJson("proweb.json")
     json["snippets"].pop(args[0])
     Tools.writeJson("proweb.json", json)
示例#12
0
 def cmd_add(self, DIR, *args):
     json = Tools.readJson("proweb.json")
     json["snippets"][args[0]] = args[1]
     Tools.writeJson("proweb.json", json)
示例#13
0
 def cmd_list(self, DIR, *args):
     snippets = Tools.readJson("proweb.json")["snippets"]
     print("")
     for k, v in snippets.items():
         print(k + "\t\t" + v)
     print("")
示例#14
0
def call(DIR, *args):
	global HTMLS
	IN = DIR / "IN";
	OUT = DIR / "OUT";
	EXT = DIR / "EXT";

	Tools.rm(EXT);
	Tools.mkdir(EXT);
	Tools.mkdir(EXT / "JS");

	Tools.rm(OUT);
	Tools.cp(IN, OUT);

	searchLibs(OUT);
	process(DIR, "index");
	processJS(DIR, "tools");


	Tools.write(EXT / "index.html" , HTMLS["index"]["text"]);

	Tools.cp(OUT / "CSS", EXT / "CSS");

	Tools.rm(OUT)
	print("fin");