organization
This commit is contained in:
parent
6d5be38ccb
commit
22a862f420
@ -345,7 +345,5 @@ def extractAndCreateBuildFiles():
|
|||||||
with open("run.bat", 'w') as run:
|
with open("run.bat", 'w') as run:
|
||||||
run.write(r"python ..\Validate.py -p" + "\n")
|
run.write(r"python ..\Validate.py -p" + "\n")
|
||||||
run.write(r"powershell .\runall.ps1" + "\n")
|
run.write(r"powershell .\runall.ps1" + "\n")
|
||||||
# with open("v.bat", 'w') as run:
|
|
||||||
# run.write(r"python ..\Validate.py %*" + "\n")
|
|
||||||
|
|
||||||
if __name__ == '__main__': CmdLine.run()
|
if __name__ == '__main__': CmdLine.run()
|
||||||
|
8
tools/StripLastBlankLine.py
Normal file
8
tools/StripLastBlankLine.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
for j in Path("ExtractedExamples").glob("**/*.java"):
|
||||||
|
print(str(j))
|
||||||
|
with j.open() as f:
|
||||||
|
code = f.read().strip()
|
||||||
|
with j.open('w') as w:
|
||||||
|
w.write(code)
|
@ -3,6 +3,8 @@
|
|||||||
Run all (possible) java files and capture output and errors
|
Run all (possible) java files and capture output and errors
|
||||||
|
|
||||||
TODO: 1st and last 10 lines, with ... in between? {FirstAndLast: 10 Lines}
|
TODO: 1st and last 10 lines, with ... in between? {FirstAndLast: 10 Lines}
|
||||||
|
|
||||||
|
TODO: format __newOutput() for line width using textwrap
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pprint
|
import pprint
|
||||||
@ -278,6 +280,25 @@ class Result:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def appendOutputFiles(self):
|
||||||
|
if not self.output_tags.has_output: # no /* Output: at all
|
||||||
|
with self.javaFilePath.open() as jf:
|
||||||
|
code = jf.read()
|
||||||
|
lines = code.splitlines()
|
||||||
|
while lines[-1].strip() is "":
|
||||||
|
lines.pop()
|
||||||
|
assert lines[-1].rstrip() == "} ///:~"
|
||||||
|
lines[-1] = "} /* Output:"
|
||||||
|
lines.append(self.new_output)
|
||||||
|
lines.append("*///:~")
|
||||||
|
result = "\n".join(lines) + "\n"
|
||||||
|
with self.javaFilePath.open("w") as jf:
|
||||||
|
jf.write(result)
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
print("{} already has Output: tags:".format(self.javaFilePath))
|
||||||
|
print(self.output_tags)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
@CmdLine("d", "discover")
|
@CmdLine("d", "discover")
|
||||||
@ -328,6 +349,7 @@ def findExceptionsFromRun():
|
|||||||
print(errfile.read())
|
print(errfile.read())
|
||||||
head()
|
head()
|
||||||
|
|
||||||
|
|
||||||
@CmdLine("a", "editall")
|
@CmdLine("a", "editall")
|
||||||
def editAllJavaFiles():
|
def editAllJavaFiles():
|
||||||
"""
|
"""
|
||||||
@ -338,12 +360,14 @@ def editAllJavaFiles():
|
|||||||
for java in Path(".").rglob("*.java"):
|
for java in Path(".").rglob("*.java"):
|
||||||
cmdfile.write("{} ".format(java))
|
cmdfile.write("{} ".format(java))
|
||||||
|
|
||||||
@CmdLine("s", "single", 1)
|
|
||||||
|
@CmdLine("s", "single", "+")
|
||||||
def attachToSingleFile():
|
def attachToSingleFile():
|
||||||
"""
|
"""
|
||||||
Attach output to single file.
|
Attach output to selected file(s).
|
||||||
"""
|
"""
|
||||||
javafilepath = Path(sys.argv[2])
|
for jfp in sys.argv[2:]:
|
||||||
|
javafilepath = Path(jfp)
|
||||||
if not javafilepath.exists():
|
if not javafilepath.exists():
|
||||||
print("Error: cannot find {}".format(javafilepath))
|
print("Error: cannot find {}".format(javafilepath))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -351,7 +375,7 @@ def attachToSingleFile():
|
|||||||
if not result:
|
if not result:
|
||||||
print("Error: no output or error files for {}".format(javafilepath))
|
print("Error: no output or error files for {}".format(javafilepath))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print(result)
|
print(result.appendOutputFiles())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
40
tools/backup.bat
Normal file
40
tools/backup.bat
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
@setlocal enabledelayedexpansion && py -3 -x "%~f0" %* & exit /b !ERRORLEVEL!
|
||||||
|
#start python code here
|
||||||
|
import zipfile
|
||||||
|
import datetime
|
||||||
|
import os, sys, shutil
|
||||||
|
from glob import glob
|
||||||
|
#import platform
|
||||||
|
#print(platform.python_version())
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
destdirs = [ # Different paths for different machines:
|
||||||
|
r'''C:\Users\Bruce Eckel\Box Sync\TIJ4-ebook-Backups''',
|
||||||
|
r'''C:\Users\Bruce\Box Sync\TIJ4-ebook-Backups''',
|
||||||
|
]
|
||||||
|
|
||||||
|
for destdir in destdirs:
|
||||||
|
if os.path.exists(destdir):
|
||||||
|
break
|
||||||
|
assert(os.path.exists(destdir))
|
||||||
|
|
||||||
|
now = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
|
||||||
|
zip_file_name = 'TIJDirectorsCut-' + now + '.zip'
|
||||||
|
dest = os.path.join(destdir, zip_file_name)
|
||||||
|
|
||||||
|
with zipfile.ZipFile(dest, 'w') as myzip:
|
||||||
|
# for f in glob("*.odt") + glob("*.docx") + glob("*.doc") + glob("*.txt") + glob("*.bat") + glob("*.py"):
|
||||||
|
for f in ["Examples.py", "Validate.py", "Notes.txt", "backup.bat", "backupall.bat"] + glob("*.docx"):
|
||||||
|
myzip.write(f)
|
||||||
|
# myzip.write("TIJDirectorsCut.docx")
|
||||||
|
|
||||||
|
# copy dest to:
|
||||||
|
# double_back = os.path.join(r'C:\Users\Bruce\IDrive-Sync\TIJ4-ebook-Backups', zip_file_name)
|
||||||
|
shutil.copy(dest, r'C:\Users\Bruce\Google Drive\TIJ4RefreshedBackups')
|
||||||
|
shutil.copy(dest, r'C:\Users\Bruce\IDrive-Sync\TIJ4-ebook-Backups')
|
||||||
|
|
||||||
|
shutil.copy("Examples.py", r'C:\Users\Bruce\Documents\GitHub\TIJ-Directors-Cut\tools')
|
||||||
|
shutil.copy("Validate.py", r'C:\Users\Bruce\Documents\GitHub\TIJ-Directors-Cut\tools')
|
||||||
|
|
||||||
|
# Touch this file to indicate most recent update time:
|
||||||
|
os.utime("backup.bat", None)
|
Loading…
x
Reference in New Issue
Block a user