VIStk 0.3.6__py3-none-any.whl → 0.3.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of VIStk might be problematic. Click here for more details.

VIS/Form.zip CHANGED
Binary file
VIS/Templates/screen.txt CHANGED
@@ -6,8 +6,6 @@ import sys
6
6
  #File Specific Imports
7
7
 
8
8
  #Configure Screen
9
- print(cfp)
10
-
11
9
  w = 1080
12
10
  h = 720
13
11
  ws = root.winfo_screenwidth()
VIS/Templates/spec.txt CHANGED
@@ -29,5 +29,5 @@ $name$_exe = EXE(
29
29
  target_arch=None,
30
30
  codesign_identity=None,
31
31
  entitlements_file=None,
32
- icon=['../Icons/$icon$.ico'],)
33
-
32
+ icon=['../Icons/$icon$.ico'],
33
+ version='$meta$')
@@ -0,0 +1,30 @@
1
+ # UTF-8
2
+
3
+ VSVersionInfo(
4
+ ffi=FixedFileInfo(
5
+ filevers=($sM$,$sm$,$sp$,0),
6
+ prodvers=($M$,$m$,$p$,0),
7
+ mask=0x3f,
8
+ flags=0x0,
9
+ OS=0x40004,
10
+ fileType=0x1,
11
+ subtype=0x0,
12
+ date=(0, 0)
13
+ ),
14
+ kids=[
15
+ StringFileInfo(
16
+ [
17
+ StringTable(
18
+ u'040904B0',
19
+ [StringStruct(u'CompanyName', u'$company$'),
20
+ StringStruct(u'FileDescription', u'$desc$'),
21
+ StringStruct(u'FileVersion', u'$sM$.$sm$.$sp$'),
22
+ StringStruct(u'InternalName', u'$title$-$name$'),
23
+ StringStruct(u'LegalCopyright', u'Copyright © $year$ $company$'),
24
+ StringStruct(u'OriginalFilename', u'$name$.exe'),
25
+ StringStruct(u'ProductName', u'$name$'),
26
+ StringStruct(u'ProductVersion', u'$M$.$m$.$p$')])
27
+ ]),
28
+ VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
29
+ ]
30
+ )
VIS/VIS.py CHANGED
@@ -1,26 +1,15 @@
1
1
  import sys
2
2
  import os
3
3
  import zipfile
4
- import subprocess
5
- import shutil
6
- import project as vp
4
+ from VIS.project import *
7
5
  from importlib import metadata
8
- import json
9
-
10
- #Need to get current python location where VIS is installed
11
- vl = subprocess.check_output('python -c "import os, sys; print(os.path.dirname(sys.executable))"').decode().strip("\r\n")+"\\Lib\\site-packages\\VIS\\"
12
- #print(vl)
6
+ from VIS.release import newRelease
13
7
 
14
8
  inp = sys.argv
15
- #print("entered ",inp[1]," as ",inp)
16
- try:
17
- (wd := os.getcwd()) if inp[1] in ["new","New","N","n"] else (wd := vp.getPath())
18
- except:
19
- print(f"VIS Version {metadata.version("VIS")}")
20
- sys.exit()
9
+ print(f"VIS Version {metadata.version("VIStk")}")
10
+
21
11
 
22
- #Copied from source
23
- #https://stackoverflow.com/a/75246706
12
+ #Copied from source https://stackoverflow.com/a/75246706
24
13
  def unzip_without_overwrite(src_path, dst_dir):
25
14
  with zipfile.ZipFile(src_path, "r") as zf:
26
15
  for member in zf.infolist():
@@ -30,67 +19,35 @@ def unzip_without_overwrite(src_path, dst_dir):
30
19
  def __main__():
31
20
  match inp[1]:
32
21
  case "new"|"New"|"N"|"n":#Create a new VIS project
33
- if vp.getPath() == None:
34
- os.mkdir(wd+"\\.VIS")
35
- open(wd+"/.VIS/path.cfg","w").write(wd) if os.path.exists(wd+"/.VIS/path.cfg") else open(wd+"/.VIS/path.cfg", 'a').write(wd)
36
- print(f"Created path.cfg as {vp.getPath()}")
37
- unzip_without_overwrite(vl.replace("\\","/")+"Form.zip",wd)#Unzip project template to project
38
- shutil.copytree(vl+"Templates",wd+".VIS/Templates",dirs_exist_ok=True)#copy templates to project
39
- #DO NOT MESS WITH THE TEMPLATE HEADERS
40
- title = input("Enter a name for the VIS project:")
41
- info = {}
42
- info[title] = {}
43
- info[title]["Screens"]={}
44
- info[title]["defaults"]={}
45
- info[title]["defaults"]["icon"]="VIS"#default icon
46
- os.mkdir(wd+"\\.VIS\\project.json")
47
- with open(wd+"/.VIS/project.json","w") as f:
48
- json.dump(info,f,indent=4)
49
- else:
50
- print(f"VIS project already initialized with path {vp.getPath()}")
22
+ project = VINFO()
51
23
 
52
24
  case "add" | "Add" | "a" | "A":
25
+ project = Project()
53
26
  match inp[2]:
54
27
  case "screen" | "Screen" | "s" | "S":
55
- screen = inp[3] #File & directory creation for VIS structure
56
- print("Screens/"+screen+"\t exists") if os.path.exists(wd+"/Screens/"+screen) else os.mkdir(wd+"/Screens/"+screen)
57
- print("modules/"+screen+"\t exists") if os.path.exists(wd+"/modules/"+screen) else os.mkdir(wd+"/modules/"+screen)
58
- print(screen+".py\t\t exists") if os.path.exists(wd+screen+".py") else shutil.copyfile(wd+"/.VIS/Templates/screen.txt",wd+"/"+screen+".py")
59
-
60
- with open(wd+"/.VIS/project.json","r") as f:
61
- info = json.load(f)
62
- name = list(info.keys())[0]
63
- if info[name]["Screens"].get(screen) == None:
64
- sc_name = input("What is the name of this screen?: ")
65
- info[name]["Screens"][sc_name] ={}
66
- info[name]["Screens"][sc_name]["script"] = screen+".py"
67
- match input("Should this screen have its own .exe?: "):
68
- case "Yes" | "yes" | "Y" | "y":
69
- info[name]["Screens"][sc_name]["release"] = "TRUE"
70
- case _:
71
- info[name]["Screens"][sc_name]["release"] = "FALSE"
72
- ictf =input("What is the icon for this screen (or none)?: ")
73
- if ".ICO" in ictf.upper():
74
- info[name]["Screens"][sc_name]["icon"] = ictf.strip(".ico")
75
- with open(wd+"/.VIS/project.json","w") as f:
76
- json.dump(info,f,indent=4)
77
- #somewhere in this process we can attempt to replace "Placeholder Title" and the root.iconbitmap
78
-
79
-
80
- if len(inp) >= 5:
81
- match inp[4]:
82
- case "menu" | "Menu" | "m" | "M":
83
- print("Add screen menu")
84
- case "elements" | "Elements" | "e" | "E":
85
- subprocess.call("python " + vl.replace("\\","/")+"/elements.py "+ screen + " " + inp[5])
86
- else:
87
- print("Add Screen")
88
-
89
- case "patch" | "Patch" | "p" | "P":
90
- subprocess.call("python " + vl.replace("\\","/")+"/patch.py " + inp[2])
28
+ if not inp[3] == None:
29
+ screen = project.verScreen(inp[3])
30
+ if len(inp) >= 5:
31
+ match inp[4]:
32
+ case "menu" | "Menu" | "m" | "M":
33
+ screen.addMenu(inp[5])
34
+ case "elements" | "Elements" | "e" | "E":
35
+ for i in inp[5].split("-"):
36
+ screen.addElement(i)
37
+ screen.stitch()
38
+ else:
39
+ project.newScreen(inp[3])
91
40
 
92
41
  case "stitch" | "Stitch" | "s" | "S":
93
- subprocess.call("python " + vl.replace("\\","/")+"/stitch.py "+ inp[2])
42
+ project = Project()
43
+ screen = project.getScreen(inp[2])
44
+ if not screen == None:
45
+ screen.stitch()
46
+ else:
47
+ print("Screen does not exist")
94
48
 
95
49
  case "release" | "Release" | "r" | "R":
96
- subprocess.call("python " + vl.replace("\\","/")+"/release.py " + inp[2])
50
+ if len(inp) == 4:
51
+ newRelease(inp[2],inp[3])
52
+ else:
53
+ newRelease(inp[2])
VIS/project.py CHANGED
@@ -1,4 +1,20 @@
1
1
  import os
2
+ import json
3
+ import zipfile
4
+ import shutil
5
+ import re
6
+ import glob
7
+ import subprocess
8
+
9
+ #Copied from source
10
+ #https://stackoverflow.com/a/75246706
11
+ def unzip_without_overwrite(src_path, dst_dir):
12
+ with zipfile.ZipFile(src_path, "r") as zf:
13
+ for member in zf.infolist():
14
+ file_path = os.path.join(dst_dir, member.filename)
15
+ if not os.path.exists(file_path):
16
+ zf.extract(member, dst_dir)
17
+
2
18
  def getPath():
3
19
  """Searches for .VIS folder and returns from path.cfg
4
20
  """
@@ -11,6 +27,336 @@ def getPath():
11
27
  if os.path.exists(step+".VIS/"):
12
28
  return open(step+".VIS/path.cfg","r").read().replace("\\","/") #return stored path
13
29
  else:
14
- sto += 1
30
+ if os.path.exists(step):
31
+ sto += 1
32
+ else:
33
+ return None #return none if cant escape more
15
34
  except:
16
- return None #if failed return none
35
+ return None #if failed return none
36
+
37
+ def validName(name:str):
38
+ """Checks if provided path is a valid filename
39
+ """
40
+ if " " in name:
41
+ print("Cannot have spaces in file name.")
42
+ return False
43
+ if "/" in name or "\\" in name:
44
+ print("Cannot have filepath deliminator in file name.")
45
+ return False
46
+ if "<" in name or ">" in name or ":" in name or '"' in name or "|" in name or "?" in name or "*" in name:
47
+ print('Invlaid ASCII characters for windows file creation, please remove all <>:"|?* from file name.')
48
+ return False
49
+ if name.split(".")[0] in ["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]:
50
+ print(f"Filename {name} reserved by OS.")
51
+ return False
52
+ if "" == name:
53
+ print("Must provide a name for file.")
54
+ return False
55
+ else:
56
+ return True
57
+
58
+
59
+ class VINFO():
60
+ """Overarching control structure within the /.VIS/ folder
61
+ """
62
+ def __init__(self):
63
+ if getPath() == None:
64
+ wd = os.getcwd()
65
+ os.mkdir(wd+"\\.VIS")
66
+ open(wd+"/.VIS/path.cfg","w").write(wd) if os.path.exists(wd+"/.VIS/path.cfg") else open(wd+"/.VIS/path.cfg", 'a').write(wd)
67
+ print(f"Stored project path in path.cfg as {wd} in {wd}/.VIS/path.cfg")
68
+
69
+ unzip_without_overwrite("./Form.zip",wd)
70
+ print(f"Copied structure to {wd}")
71
+
72
+ shutil.copytree("./Templates",wd+"/.VIS/Templates",dirs_exist_ok=True)
73
+ print(f"Loaded default templates into {wd}/.VIS/Templates/")
74
+
75
+
76
+ #DO NOT MESS WITH THE TEMPLATE HEADERS
77
+
78
+ title = input("Enter a name for the VIS project: ")
79
+ self.title = title
80
+ info = {}
81
+ info[self.title] = {}
82
+ info[self.title]["Screens"]={}
83
+ info[self.title]["defaults"]={}
84
+ info[self.title]["defaults"]["icon"]="VIS"#default icon
85
+ self.d_icon = "VIS"
86
+ self[self.title]["metadata"]={}
87
+ comp = input("What company is this for(or none)? ")
88
+ if not comp in ["none","None"]:
89
+ info[self.title]["metadata"]["company"] = comp
90
+ self.company = comp
91
+ else:
92
+ info[self.title]["metadata"]["company"] = None
93
+ self.company = None
94
+
95
+ version = input("What is the initial version for the project (0.0.1 default): ")
96
+ vers = version.split(".")
97
+ if len(vers)==3:
98
+ if vers[0].isnumeric() and vers[1].isnumeric() and vers[2].isnumeric():
99
+ self.version = version
100
+ else:
101
+ self.version = "0.0.1"
102
+ else:
103
+ self.version = "0.0.1"
104
+ info[self.title]["metadata"]["version"] = self.version
105
+
106
+ with open(wd+"/.VIS/project.json","w") as f:
107
+ f.write("{}")
108
+ json.dump(info,f,indent=4)
109
+ print(f"Setup project.json for project {self.title} in {wd}/.VIS/")
110
+
111
+
112
+ #Need to get current python location where VIS is installed
113
+ self.p_vis = subprocess.check_output('python -c "import os, sys; print(os.path.dirname(sys.executable))"').decode().strip("\r\n")+"\\Lib\\site-packages\\VIS\\"
114
+
115
+
116
+ self.p_project = getPath()
117
+ self.p_vinfo = self.p_project + "/.VIS"
118
+ self.p_sinfo = self.p_vinfo + "/project.json"
119
+ with open(self.p_sinfo,"r") as f:
120
+ info = json.load(f)
121
+ self.title = list(info.keys())[0]
122
+ self.version = info[self.title]["metadata"]["version"]
123
+ self.company = info[self.title]["metadata"]["company"]
124
+
125
+ self.screenlist = []
126
+ self.p_screens = self.p_project +"/Screens"
127
+ self.p_modules = self.p_project +"/modules"
128
+ self.p_templates = self.p_vinfo + "/Templates"
129
+ self.p_icons = self.p_project + "/Icons"
130
+ self.p_images = self.p_project + "/Images"
131
+
132
+ def setVersion(self,version:str):
133
+ """Sets a new project version
134
+ """
135
+ with open(self.p_sinfo,"r") as f:
136
+ info = json.load(f)
137
+
138
+ info[self.title]["metadata"]["version"] = version
139
+
140
+ with open(self.p_sinfo,"w") as f:
141
+ json.dump(info,f,indent=4)
142
+
143
+
144
+ class Screen(VINFO):
145
+ """A VIS screen object
146
+ """
147
+ def __init__(self,name:str,script:str,release:bool=False,icon:str=None,exists:bool=True,desc:str=None):
148
+ super().__init__()
149
+ self.name=name
150
+ self.script=script
151
+ self.release=release
152
+ self.icon=icon
153
+ self.path = self.p_screens+"/"+self.name
154
+ self.m_path = self.p_modules+"/"+self.name
155
+
156
+ if not exists:
157
+ with open(self.p_sinfo,"r") as f:
158
+ info = json.load(f)
159
+
160
+ info[self.title]["Screens"][self.name] = {"script":script,"release":release}
161
+ if not icon == None:
162
+ info[self.title]["Screens"][self.name]["icon"] = icon
163
+
164
+ if not desc == None:
165
+ info[self.title]["Screens"][self.name]["desc"] = desc
166
+ else:
167
+ info[self.title]["Screens"][self.name]["desc"] = "A VIS Created Executable"
168
+
169
+ info[self.title]["Screens"][self.name]["version"] = "1.0.0"#always making first major version of screen
170
+
171
+ info[self.title]["Screens"][self.name]["current"] = None#always making first major version of screen
172
+
173
+ with open(self.p_sinfo,"w") as f:
174
+ json.dump(info,f,indent=4)
175
+
176
+ shutil.copyfile(self.p_templates+"/screen.txt",self.p_project+"/"+script)
177
+ os.mkdir(self.p_screens+"/"+self.name)
178
+ os.mkdir(self.p_modules+"/"+self.name)
179
+
180
+ with open(self.p_sinfo,"r") as f:
181
+ info = json.load(f)
182
+ self.desc = info[self.title]["Screens"][self.name]["desc"]
183
+ self.s_version = info[self.title]["Screens"][self.name]["version"]
184
+ self.current = info[self.title]["Screens"][self.name]["current"]
185
+
186
+
187
+ def addElement(self,element:str) -> int:
188
+ if validName(element):
189
+ if not os.path.exists(self.path+"/f_"+element+".py"):
190
+ shutil.copyfile(self.p_templates+"/f_element.txt",self.path+"/f_"+element+".py")
191
+ print(f"Created element f_{element}.py in {self.path}")
192
+ self.patch(element)
193
+ if not os.path.exists(self.m_path+"/m_"+element+".py"):
194
+ with open(self.m_path+"/m_"+element+".py", "w"): pass
195
+ print(f"Created module m_{element}.py in {self.m_path}")
196
+ return 1
197
+ else:
198
+ return 0
199
+
200
+ def addMenu(self,menu:str) -> int:
201
+ pass #will be command line menu creation tool
202
+
203
+ def patch(self,element:str) -> int:
204
+ """Patches up the template after its copied
205
+ """
206
+ if os.path.exists(self.path+"/f_"+element+".py"):
207
+ with open(self.path+"/f_"+element+".py","r") as f:
208
+ text = f.read()
209
+ text = text.replace("<frame>","f_"+element)
210
+ with open(self.path+"/f_"+element+".py","w") as f:
211
+ f.write(text)
212
+ print(f"patched f_{element}.py")
213
+ return 1
214
+ else:
215
+ print(f"Could not patch, element does not exist.")
216
+ return 0
217
+
218
+ def stitch(self) -> int:
219
+ """Connects screen elements to a screen
220
+ """
221
+ with open(self.p_project+"/"+self.script,"r") as f: text = f.read()
222
+ stitched = []
223
+ #Elements
224
+ pattern = r"#Screen Elements.*#Screen Grid"
225
+
226
+ elements = glob.glob(self.path+'/f_*')#get all elements
227
+ for i in range(0,len(elements),1):#iterate into module format
228
+ elements[i] = elements[i].replace("\\","/")
229
+ elements[i] = elements[i].replace(self.path+"/","Screens."+self.name+".")[:-3]
230
+ stitched.append(elements[i])
231
+ #combine and change text
232
+ elements = "from " + " import *\nfrom ".join(elements) + " import *\n"
233
+ text = re.sub(pattern, "#Screen Elements\n" + elements + "\n#Screen Grid", text, flags=re.DOTALL)
234
+
235
+ #Modules
236
+ pattern = r"#Screen Modules.*#Handle Arguments"
237
+
238
+ modules = glob.glob(self.m_path+'/m_*')#get all modules
239
+ for i in range(0,len(modules),1):#iterate into module format
240
+ modules[i] = modules[i].replace("\\","/")
241
+ modules[i] = modules[i].replace(self.m_path+"/","modules."+self.name+".")[:-3]
242
+ stitched.append(modules[i])
243
+ #combine and change text
244
+ modules = "from " + " import *\nfrom ".join(modules) + " import *\n"
245
+ text = re.sub(pattern, "#Screen Modules\n" + modules + "\n#Handle Arguments", text, flags=re.DOTALL)
246
+
247
+ #write out
248
+ with open(self.p_project+"/"+self.script,"w") as f:
249
+ f.write(text)
250
+ print("Stitched: ")
251
+ for i in stitched:
252
+ print(f"\t{i} to {self.name}")
253
+
254
+ def syncVersion(self) -> int:
255
+ """Syncs the version stored in sinfo with the version in memory
256
+ """
257
+ with open(self.p_sinfo,"r") as f:
258
+ info = json.load(f)
259
+ info[self.title]["Screens"][self.name]["current"] = self.current
260
+ with open(self.p_sinfo,"w") as f:
261
+ json.dump(info,f)
262
+ return 1
263
+
264
+ def crntVersion(self) -> int:
265
+ """Checks if the version needs to be synced and returns 1 if its synced
266
+ """
267
+ if not self.s_version == self.current:
268
+ self.current = self.version
269
+ self.syncVersion()
270
+ return 1
271
+ else:
272
+ return 0
273
+
274
+
275
+ class Project(VINFO):
276
+ """VIS Project Object
277
+ """
278
+ def __init__(self):
279
+ """Initializes or load a VIS project
280
+ """
281
+ super().__init__()
282
+ with open(self.p_sinfo,"r") as f:
283
+ info = json.load(f)
284
+ self.name = list(info.keys())[0]
285
+
286
+ for screen in list(info[self.name]["Screens"].keys()):
287
+ scr = Screen(screen,
288
+ info[self.name]["Screens"][screen]["script"],
289
+ info[self.name]["Screens"][screen]["release"],
290
+ info[self.name]["Screens"][screen].get("icon"),
291
+ exists=True)
292
+ self.screenlist.append(scr)
293
+ self.d_icon = info[self.name]["defaults"]["icon"]
294
+
295
+ def newScreen(self,screen:str) -> int:
296
+ """Creates a new screen with some prompting
297
+
298
+ Returns:
299
+ 0 Failed
300
+ 1 Success
301
+ """
302
+ #Check for valid filename
303
+ if not validName(screen):
304
+ return 0
305
+
306
+ with open(self.p_sinfo,"r") as f:
307
+ info = json.load(f) #Load info
308
+
309
+ name = self.title
310
+ if info[name]["Screens"].get(screen) == None: #If Screen does not exist in VINFO
311
+ while True: #ensures a valid name is used for script
312
+ match input(f"Should python script use name {screen}.py? "):
313
+ case "Yes" | "yes" | "Y" | "y":
314
+ script = screen + ".py"
315
+ break
316
+ case _:
317
+ script = input("Enter the name for the script file: ").strip(".py")+".py"
318
+ if validName(script):
319
+ break
320
+
321
+ match input("Should this screen have its own .exe?: "):
322
+ case "Yes" | "yes" | "Y" | "y":
323
+ release = True
324
+ case _:
325
+ release = False
326
+ ictf =input("What is the icon for this screen (or none)?: ")
327
+ icon = ictf.strip(".ico") if ".ICO" in ictf.upper() else None
328
+ desc = input("Write a description for this screen: ")
329
+ self.screenlist.append(Screen(screen,script,release,icon,False,desc))
330
+
331
+ return 1
332
+ else:
333
+ print(f"Information for {screen} already in project.")
334
+ return 1
335
+
336
+ def hasScreen(self,screen:str) -> bool:
337
+ """Checks if the project has the correct screen
338
+ """
339
+ for i in self.screenlist:
340
+ if i.name == screen:
341
+ return True
342
+ return False
343
+
344
+ def getScreen(self,screen:str) -> Screen:
345
+ """Returns a screen object by its name
346
+ """
347
+ for i in self.screenlist:
348
+ if i.name == screen:
349
+ return i
350
+ return None
351
+
352
+ def verScreen(self,screen:str) -> Screen:
353
+ """Verifies a screen exists and returns it
354
+
355
+ Returns:
356
+ screen (Screen): Verified screen
357
+ """
358
+ if not self.hasScreen(screen):
359
+ self.newScreen(screen)
360
+ scr = self.getScreen(screen)
361
+ return scr
362
+
VIS/release.py CHANGED
@@ -1,107 +1,158 @@
1
- import sys
2
- from project import *
1
+ from VIS.project import *
3
2
  import subprocess
4
- import json
5
3
  import shutil
6
4
  from os.path import exists
5
+ import time
6
+ import datetime
7
7
 
8
- root = getPath()
9
8
  info = {}
10
- with open(root+"/.VIS/project.json","r") as f:
11
- info = json.load(f)
12
- name = list(info.keys())[0]
9
+ project = Project()
10
+
13
11
 
14
12
  def build(version:str=""):
15
13
  """Build project spec file with specific version
16
14
  """
17
15
 
18
- print(f"Creating project.spec for {name}")
16
+ print(f"Creating project.spec for {project.name}")
19
17
 
20
- with open(root+"/.VIS/Templates/spec.txt","r") as f:
18
+ with open(project.p_vinfo+"/Templates/spec.txt","r") as f:
21
19
  spec = f.read()
22
- with open(root+"/.VIS/Templates/collect.txt","r") as f:
20
+ with open(project.p_vinfo+"/Templates/collect.txt","r") as f:
23
21
  collect = f.read()
24
22
 
25
23
  spec_list = []
26
24
  name_list = []
27
-
28
- for i in info[name]["Screens"].keys():
29
- if info[name]["Screens"][i]["release"] == "TRUE":
30
- name_list.append(i)
31
- file = info[name]["Screens"][i]["script"]
32
- #icon = "du"
33
- if not info[name]["Screens"][i].get("icon") == None:
34
- icon = info[name]["Screens"][i]["icon"]
25
+ os.mkdir(project.p_vinfo+"/Build")
26
+ for i in project.screenlist:
27
+ if i.release:
28
+ name_list.append(i.name)
29
+ if not i.icon == None:
30
+ icon = i.icon
35
31
  else:
36
- icon = info[name]["defaults"]["icon"]
37
- spec_list.append(spec.replace("$name$",i))
32
+ icon = project.d_icon
33
+ spec_list.append(spec.replace("$name$",i.name))
38
34
  spec_list[len(spec_list)-1] = spec_list[len(spec_list)-1].replace("$icon$",icon)
39
- spec_list[len(spec_list)-1] = spec_list[len(spec_list)-1].replace("$file$",file)
35
+ spec_list[len(spec_list)-1] = spec_list[len(spec_list)-1].replace("$file$",i.script)
36
+
37
+ #build metadata
38
+ with open(project.p_templates+"/version.txt","r") as f:
39
+ meta = f.read()
40
+
41
+ #Update Overall Project Version
42
+ vers = project.version.split(".")
43
+ major = vers[0]
44
+ minor = vers[1]
45
+ patch = vers[2]
46
+ meta = meta.replace("$M$",major)
47
+ meta = meta.replace("$m$",minor)
48
+ meta = meta.replace("$p$",patch)
49
+
50
+ #Update Screen Version
51
+ vers = i.s_version.split(".")
52
+ major = vers[0]
53
+ minor = vers[1]
54
+ patch = vers[2]
55
+ meta = meta.replace("$sM$",major)
56
+ meta = meta.replace("$sm$",minor)
57
+ meta = meta.replace("$sp$",patch)
58
+
59
+ if project.company != None:
60
+ meta = meta.replace("$company$",project.company)
61
+ meta = meta.replace("$year$",str(datetime.datetime.now().year))
62
+ else:
63
+ meta = meta.replace(" VALUE \"CompanyName\", VER_COMPANYNAME_STR\n","")
64
+ meta = meta.replace(" VALUE \"LegalCopyright\", VER_LEGALCOPYRIGHT_STR\n","")
65
+ meta = meta.replace("#define VER_LEGAL_COPYRIGHT_STR \"Copyright © $year$ $company$\\0\"\n\n","")
66
+ meta = meta.replace("$name$",i.name)
67
+ meta = meta.replace("$desc$",i.desc)
68
+
69
+ with open(project.p_vinfo+f"/Build/{i.name}.txt","w") as f:
70
+ f.write(meta)
71
+ spec_list[len(spec_list)-1] = spec_list[len(spec_list)-1].replace("$meta$",project.p_vinfo+f"/Build/{i.name}.txt")
40
72
  spec_list.append("\n\n")
41
73
 
42
74
  insert = ""
43
75
  for i in name_list:
44
76
  insert=insert+"\n\t"+i+"_exe,\n\t"+i+"_a.binaries,\n\t"+i+"_a.zipfiles,\n\t"+i+"_a.datas,"
45
77
  collect = collect.replace("$insert$",insert)
46
- collect = collect.replace("$version$",name+"-"+version) if not version == "" else collect.replace("$version$",name)
78
+ collect = collect.replace("$version$",project.name+"-"+version) if not version == "" else collect.replace("$version$",project.name)
47
79
 
48
80
  header = "# -*- mode: python ; coding: utf-8 -*-\n\n\n"
49
81
 
50
- with open(root+"/.VIS/project.spec","w") as f:
82
+ with open(project.p_vinfo+"/project.spec","w") as f:
51
83
  f.write(header)
52
- with open(root+"/.VIS/project.spec","a") as f:
84
+ with open(project.p_vinfo+"/project.spec","a") as f:
53
85
  f.writelines(spec_list)
54
86
  f.write(collect)
55
87
 
56
- print(f"Setup project.spec for {name} {version if not version =="" else "current"}")#advanced version will improve this
88
+ print(f"Finished creating project.spec for {project.title} {version if not version =="" else "current"}")#advanced version will improve this
57
89
 
58
90
  def clean(version:str=" "):
59
91
  """Cleans up build environment to save space
60
92
  """
61
93
  print("Cleaning up build environment")
62
- if version == "":
63
- if exists(f"{root}/dist/{name}/Icons/"): shutil.rmtree(f"{root}/dist/{name}/Icons/")
64
- if exists(f"{root}/dist/{name}/Images/"): shutil.rmtree(f"{root}/dist/{name}/Images/")
65
- shutil.copytree(root+"/Icons/",f"{root}/dist/{name}/Icons/",dirs_exist_ok=True)
66
- shutil.copytree(root+"/Images/",f"{root}/dist/{name}/Images/",dirs_exist_ok=True)
94
+ project=Project()
95
+ shutil.rmtree(project.p_vinfo+"/Build")
96
+ print("Appending Screen Data To Environment")
97
+ if version == " ":
98
+ if exists(f"{project.p_project}/dist/{project.title}/Icons/"): shutil.rmtree(f"{project.p_project}/dist/{project.title}/Icons/")
99
+ if exists(f"{project.p_project}/dist/{project.title}/Images/"): shutil.rmtree(f"{project.p_project}/dist/{project.title}/Images/")
100
+ shutil.copytree(project.p_project+"/Icons/",f"{project.p_project}/dist/{project.title}/Icons/",dirs_exist_ok=True)
101
+ shutil.copytree(project.p_project+"/Images/",f"{project.p_project}/dist/{project.title}/Images/",dirs_exist_ok=True)
67
102
  else:
68
- if exists(f"{root}/dist/{name}/Icons/"): shutil.rmtree(f"{root}/dist/{name}/Icons/")
69
- if exists(f"{root}/dist/{name}/Images/"): shutil.rmtree(f"{root}/dist/{name}/Images/")
70
- shutil.copytree(root+"/Icons/",f"{root}/dist/{name}-{version.strip(" ")}/Icons/",dirs_exist_ok=True)
71
- shutil.copytree(root+"/Images/",f"{root}/dist/{name}-{version.strip(" ")}/Images/",dirs_exist_ok=True)
72
- print(f"\n\nReleased new{version}build of {name}!")
103
+ if exists(f"{project.p_project}/dist/{project.title}/Icons/"): shutil.rmtree(f"{project.p_project}/dist/{project.name}/Icons/")
104
+ if exists(f"{project.p_project}/dist/{project.title}/Images/"): shutil.rmtree(f"{project.p_project}/dist/{project.name}/Images/")
105
+ shutil.copytree(project.p_project+"/Icons/",f"{project.p_project}/dist/{project.title}-{version.strip(" ")}/Icons/",dirs_exist_ok=True)
106
+ shutil.copytree(project.p_project+"/Images/",f"{project.p_project}/dist/{project.title}-{version.strip(" ")}/Images/",dirs_exist_ok=True)
107
+ print(f"\n\nReleased new{version}build of {project.title}!")
108
+
109
+ def newVersion(version:str):
110
+ """Updates the project version, permanent, cannot be undone
111
+ """
112
+ project = VINFO()
113
+ old = str(project.version)
114
+ vers = project.version.split(".")
115
+ if version == "Major":
116
+ vers[0] = str(int(vers[0])+1)
117
+ vers[1] = str(0)
118
+ vers[2] = str(0)
119
+ if version == "Minor":
120
+ vers[1] = str(int(vers[1])+1)
121
+ vers[2] = str(0)
122
+ if version == "Patch":
123
+ vers[2] = str(int(vers[2])+1)
73
124
 
74
- version = sys.argv[1]
75
- match version:
76
- case "a":
77
- build("alpha")
78
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
79
- clean(" alpha ")
80
- case "b":
81
- build("beta")
82
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
83
- clean(" beta ")
84
- case "c":
85
- build()
86
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
87
- clean()
88
- case "sync":
89
- build("alpha")
90
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
91
- clean(" alpha ")
92
- build("beta")
93
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
94
- clean(" beta ")
95
- build()
96
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
97
- clean()
98
- print("\t- alpha\n\t- beta\n\t- current")
99
- case _:
100
- inp = input(f"Release Project Version {version}?")
101
- match inp:
102
- case "y" | "Y" | "yes" | "Yes":
103
- build(version)
104
- subprocess.call(f"pyinstaller {root}/.VIS/project.spec --noconfirm --distpath {root}/dist/ --log-level FATAL")
105
- clean(f" {version} ")
106
- case _:
107
- print(f"Could not release Project Version {version}")
125
+ project.setVersion(f"{vers[0]}.{vers[1]}.{vers[2]}")
126
+ project = VINFO()
127
+ print(f"Updated Version {old}=>{project.version}")
128
+
129
+ def newRelease(version,type:str="Patch"):
130
+ """Releases a version of your project
131
+ """
132
+ match version:
133
+ case "a":
134
+ build("alpha")
135
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
136
+ clean(" alpha ")
137
+ case "b":
138
+ build("beta")
139
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
140
+ clean(" beta ")
141
+ case "c":
142
+ newVersion(type)
143
+ build()
144
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
145
+ clean()
146
+ case "sync":
147
+ build("alpha")
148
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
149
+ clean(" alpha ")
150
+ build("beta")
151
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
152
+ clean(" beta ")
153
+ build()
154
+ subprocess.call(f"pyinstaller {project.p_vinfo}/project.spec --noconfirm --distpath {project.p_project}/dist/ --log-level FATAL")
155
+ clean()
156
+ print("\t- alpha\n\t- beta\n\t- current")
157
+ case _:
158
+ print(f"Could not release Project Version {version}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: VIStk
3
- Version: 0.3.6
3
+ Version: 0.3.8
4
4
  Summary: Visual Interfacing Structure for python using tkinter
5
5
  Author-email: Elijah Love <elijah2005l@gmail.com>
6
6
  Maintainer-email: Elijah Love <elijah2005l@gmail.com>
@@ -0,0 +1,18 @@
1
+ VIS/Form.zip,sha256=qyNG6hPgFcMkkilC1D3KnIC2BStmFJabyGXQmxqvQzg,24596
2
+ VIS/VIS.py,sha256=Wu-RoboUtWyqeUydhYxkov6kXvA-tgbnujUrgZxWQYg,1892
3
+ VIS/__init__.py,sha256=gO-ri9N9K-CQ3wJi-CX12MYhbrdqz2fvhJU-ZGf5BjI,69
4
+ VIS/menu.py,sha256=PqPYzsFfGpVeej85v59wbeWeSy24I-m0bFUAxtRBiSQ,1815
5
+ VIS/project.py,sha256=aSG0xJKqhp3s_fMwO14fAcY5llC4PKSfLTDJrULs8VE,13804
6
+ VIS/release.py,sha256=HltNabVQdMzRP7-WCgAqieu0N5nJuL963jSYvNKMkzw,6934
7
+ VIS/Templates/collect.txt,sha256=ZU5m4g2VBOWNWAGMUjZoi2UIc2uWmlV-L7_IXc3lBVU,96
8
+ VIS/Templates/f_element.txt,sha256=MVovajsLC2O5t_ZSOb9NppGqzziGqISWSaEJ7kbrl7U,485
9
+ VIS/Templates/screen.txt,sha256=qjEB8x_krQ1UGcVjbIxuVgasxcpJwIMh2UKbdeeE0KI,791
10
+ VIS/Templates/spec.txt,sha256=3PReA_cz0TqQ3l_eo7C_aVGZNneWOPT5KoK-lOom4RI,709
11
+ VIS/Templates/version.txt,sha256=O3e6gO4MkPps1plgkpsIfMxutxqVbT8sVDf91-LUmvc,826
12
+ VIS/__pycache__/__init__.cpython-313.pyc,sha256=G_EdBuWyhjGJ4zI9Sc81loMtV0ANdEzC6JmUwcnaomI,218
13
+ vistk-0.3.8.dist-info/licenses/LICENSE,sha256=FxXH04vmzWaQWNEoGwgDcLEG8Li5qf36NNz3UyrBMvQ,1300
14
+ vistk-0.3.8.dist-info/METADATA,sha256=B-O45Y0rQ8X18nv-YK6NqGjtJuu7XwF_OZXiS_rTvr0,2493
15
+ vistk-0.3.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ vistk-0.3.8.dist-info/entry_points.txt,sha256=Fq_VLNEc6Rk4-S8ICPkPjNozFeDeeeFAF5lvK7hQu7o,41
17
+ vistk-0.3.8.dist-info/top_level.txt,sha256=iFRNav6cokh9J-6nat5rgNWLdQm371xQ3OPb9w7i5mI,4
18
+ vistk-0.3.8.dist-info/RECORD,,
VIS/elements.py DELETED
@@ -1,27 +0,0 @@
1
- import sys
2
- import shutil
3
- import os
4
- import subprocess
5
- import project as vp
6
-
7
- screen = sys.argv[1]
8
- elements = sys.argv[2]
9
- elements = elements.split('-')
10
-
11
- project = vp.getPath()
12
-
13
- for e in elements:
14
- if not os.path.exists(project+"/Screens/"+screen+"/f_"+e+".py"):
15
- shutil.copyfile(project+"/.VIS/Templates/f_element.txt",project+"/Screens/"+screen+"/f_"+e+".py")
16
- print("element\tf_"+e+".py\tcreated in\tScreens/"+screen+"/")
17
- subprocess.call("VIS patch "+project+"/Screens/"+screen+"/"+e+".py")
18
-
19
- if not os.path.exists(project+"/modules/"+screen+"/m_"+e+".py"):
20
- with open(project+"/modules/"+screen+"/m_"+e+".py", "w"): pass
21
- print("module\tm_"+e+".py\tcreated in\tScreens/"+screen+"/")
22
-
23
- if not os.path.exists(project+"/"+screen+".py"):#cannot create elements without screen so will create screen if it doesnt exist
24
- shutil.copyfile(project+"/.VIS/Templates/screen.txt"+project+"/"+screen+".py")
25
- print("screen\t"+e+".py \tcreated in\troot")
26
-
27
- subprocess.call("VIS stitch "+screen)
VIS/patch.py DELETED
@@ -1,11 +0,0 @@
1
- import sys
2
-
3
- file = sys.argv[1]
4
- frame = file.split('/')[-1][:-3]
5
- file=file.replace(frame,"f_"+frame)
6
- with open(file,"r") as f:
7
- text = f.read()
8
- text = text.replace("<frame>","f_"+frame)
9
- with open(file,"w") as f:
10
- f.write(text)
11
- print("patched\tf_"+frame+".py")
VIS/screen.py DELETED
@@ -1,15 +0,0 @@
1
- import sys
2
- file = sys.argv[1]
3
- frame = file.split('\\')[-1][:-3]
4
- dump_screens = False
5
- dump_modules = False
6
- with open(file,"r") as f:
7
- text= f.readlines()
8
- for line in text:
9
- if "screen elements" in line.lower():
10
- dump_screens=True
11
- elif "screen elements" in line.lower():
12
- dump_modules=True
13
-
14
- with open(file,"w") as f:
15
- f.write(text)
VIS/stitch.py DELETED
@@ -1,37 +0,0 @@
1
- import sys
2
- import re
3
- import glob
4
- import project as vp
5
-
6
- project = vp.getPath()
7
- screen = sys.argv[1]
8
- with open(project+"/"+screen+".py","r") as f:
9
- text = f.read()
10
-
11
- #Elements
12
- pattern = r"#Screen Elements.*#Screen Grid"
13
- replacement = glob.glob(project+"/Screens/"+screen+'/f_*')
14
- for i in range(0,len(replacement),1):
15
- replacement[i] = replacement[i].replace("\\","/")
16
- replacement[i] = replacement[i].replace(project+"/Screens/"+screen+"/","Screens."+screen+".")[:-3]
17
- #print(replacement)
18
- replacement = "from " + " import *\nfrom ".join(replacement) + " import *\n"
19
- #print(replacement)
20
- text = re.sub(pattern, "#Screen Elements\n" + replacement + "\n#Screen Grid", text, flags=re.DOTALL)
21
-
22
- #Modules
23
- pattern = r"#Screen Modules.*#Handle Arguments"
24
- replacement = glob.glob(project+"/modules/"+screen+'/m_*')
25
- for i in range(0,len(replacement),1):
26
- replacement[i] = replacement[i].replace("\\","/")
27
- print("stitching\t"+replacement[i].strip(project)+"\tto\t"+screen+".py")
28
- replacement[i] = replacement[i].replace(project+"/modules/"+screen+"/","modules."+screen+".")[:-3]
29
- #print(replacement)
30
- replacement = "from " + " import *\nfrom ".join(replacement) + " import *\n"
31
- #print(replacement)
32
- text = re.sub(pattern, "#Screen Modules\n" + replacement + "\n#Handle Arguments", text, flags=re.DOTALL)
33
- #print(text)
34
-
35
- with open(project+"/"+screen+".py","w") as f:
36
- f.write(text)
37
- print("stitched\t"+screen+".py\twith\tall")
@@ -1,21 +0,0 @@
1
- VIS/Form.zip,sha256=Uu6GK-n26kOSxSzL7HWHcqZf6p3bCn7tHCZ2F1YWnxk,25866
2
- VIS/VIS.py,sha256=4ZpMLbYSlvHpiQvWptY-pb4kH3tflbNfu4wumbJXQWM,4885
3
- VIS/__init__.py,sha256=gO-ri9N9K-CQ3wJi-CX12MYhbrdqz2fvhJU-ZGf5BjI,69
4
- VIS/elements.py,sha256=cq5__ICkdiKVF981o5AbetbmD3lB3HgMp0nsfZ6vKIo,1041
5
- VIS/menu.py,sha256=PqPYzsFfGpVeej85v59wbeWeSy24I-m0bFUAxtRBiSQ,1815
6
- VIS/patch.py,sha256=xvXXSF1cWH1aQhYauHkHulAyoj-RB85pJgSaPvGkglM,268
7
- VIS/project.py,sha256=kWkNzCSIdc6Ij0vnGVGugSjbWs0EFCkPmDtCF8w5850,536
8
- VIS/release.py,sha256=grA6M5hVbZDdJyi3bUXcwYzcye21yiNThThsjRgzTuY,4478
9
- VIS/screen.py,sha256=am3pRnfXoC2G1TSVA_FyAuOKQ_PuVCKQMQCwkwSWe_s,377
10
- VIS/stitch.py,sha256=AT9y9bDAJp-wmfUCWeUCp3mn_b8u9yEL5DE5XOn32Sc,1428
11
- VIS/Templates/collect.txt,sha256=ZU5m4g2VBOWNWAGMUjZoi2UIc2uWmlV-L7_IXc3lBVU,96
12
- VIS/Templates/f_element.txt,sha256=MVovajsLC2O5t_ZSOb9NppGqzziGqISWSaEJ7kbrl7U,485
13
- VIS/Templates/screen.txt,sha256=4k732aBbT_tf3fwcsM1RLB8UPFNA03EWBRo1aw0jw8U,803
14
- VIS/Templates/spec.txt,sha256=_IlwxuNxmtFOriZ6JWgtPANLkA8GFzOm80lE9PhqKfs,690
15
- VIS/__pycache__/__init__.cpython-313.pyc,sha256=G_EdBuWyhjGJ4zI9Sc81loMtV0ANdEzC6JmUwcnaomI,218
16
- vistk-0.3.6.dist-info/licenses/LICENSE,sha256=FxXH04vmzWaQWNEoGwgDcLEG8Li5qf36NNz3UyrBMvQ,1300
17
- vistk-0.3.6.dist-info/METADATA,sha256=dUjKSYpAIYq7nrYOFYdsZ8SNNJMtXkRqrTRREg9SLoc,2493
18
- vistk-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- vistk-0.3.6.dist-info/entry_points.txt,sha256=Fq_VLNEc6Rk4-S8ICPkPjNozFeDeeeFAF5lvK7hQu7o,41
20
- vistk-0.3.6.dist-info/top_level.txt,sha256=iFRNav6cokh9J-6nat5rgNWLdQm371xQ3OPb9w7i5mI,4
21
- vistk-0.3.6.dist-info/RECORD,,
File without changes