automation
This commit is contained in:
parent
fbae5dab90
commit
4e3e97f0d6
@ -1,40 +1,40 @@
|
|||||||
What is the Director’s Cut?
|
[ ] What is the Director’s Cut?
|
||||||
Preface
|
[ ] Preface
|
||||||
Introduction
|
[ ] Introduction
|
||||||
Introduction to Objects
|
[ ] Introduction to Objects
|
||||||
Everything Is an Object
|
[ ] Everything Is an Object
|
||||||
Operators
|
[ ] Operators
|
||||||
Controlling Execution
|
[ ] Controlling Execution
|
||||||
Initialization & Cleanup
|
[ ] Initialization & Cleanup
|
||||||
Access Control
|
[ ] Access Control
|
||||||
Reusing Classes
|
[ ] Reusing Classes
|
||||||
Polymorphism
|
[ ] Polymorphism
|
||||||
Interfaces
|
[ ] Interfaces
|
||||||
Inner Classes
|
[ ] Inner Classes
|
||||||
Holding Your Objects
|
[ ] Holding Your Objects
|
||||||
Error Handling with Exceptions
|
[ ] Error Handling with Exceptions
|
||||||
Strings
|
[ ] Strings
|
||||||
Type Information
|
[ ] Type Information
|
||||||
Generics
|
[ ] Generics
|
||||||
Arrays
|
[ ] Arrays
|
||||||
Containers in Depth
|
[ ] Containers in Depth
|
||||||
I/O
|
[ ] I/O
|
||||||
Enumerated Types
|
[ ] Enumerated Types
|
||||||
Annotations
|
[ ] Annotations
|
||||||
Concurrency
|
[ ] Concurrency
|
||||||
Graphical User Interfaces
|
[ ] Graphical User Interfaces
|
||||||
Design Patterns
|
[ ] Design Patterns
|
||||||
Appendix: Supplements
|
[ ] Appendix: Supplements
|
||||||
Appendix: Resources
|
[ ] Appendix: Resources
|
||||||
Appendix: Java Programming Guidelines
|
[ ] Appendix: Java Programming Guidelines
|
||||||
Appendix: Unit Testing
|
[ ] Appendix: Unit Testing
|
||||||
Appendix: Improving Reliability with Assertions
|
[ ] Appendix: Improving Reliability with Assertions
|
||||||
Appendix: Passing & Returning Objects
|
[ ] Appendix: Passing & Returning Objects
|
||||||
Appendix: Logging
|
[ ] Appendix: Logging
|
||||||
Appendix: Debugging
|
[ ] Appendix: Debugging
|
||||||
Appendix: Network Programming
|
[ ] Appendix: Network Programming
|
||||||
Appendix: Remote Methods
|
[ ] Appendix: Remote Methods
|
||||||
Appendix: Profiling and Optimizing
|
[ ] Appendix: Profiling and Optimizing
|
||||||
Appendix: The Benefits and Costs of Static Type Checking
|
[ ] Appendix: The Benefits and Costs of Static Type Checking
|
||||||
Appendix: The Positive Legacy of C++ and Java
|
[ ] Appendix: The Positive Legacy of C++ and Java
|
||||||
Appendix: On Being a Programmer
|
[ ] Appendix: On Being a Programmer
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
<import file="../Ant-Clean.xml"/>
|
<import file="../Ant-Clean.xml"/>
|
||||||
|
|
||||||
<target name="run" description="Compile and run" depends="build">
|
<target name="run" description="Compile and run" depends="build">
|
||||||
|
<echo message="go"/>
|
||||||
|
<exec executable="cmd" dir=".">
|
||||||
|
<arg line="/c go" />
|
||||||
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
1
remote/go.bat
Normal file
1
remote/go.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
start "ptime.bat" ptime.bat
|
@ -2,3 +2,5 @@ start /min "registry.bat" registry.bat 3
|
|||||||
start /min "server.bat" server.bat 3
|
start /min "server.bat" server.bat 3
|
||||||
timeout /t 1
|
timeout /t 1
|
||||||
java DisplayPerfectTime
|
java DisplayPerfectTime
|
||||||
|
timeout /t 3
|
||||||
|
exit
|
@ -18,6 +18,7 @@ maindef = re.compile("public\s+static\s+void\s+main")
|
|||||||
destination = Path('.') / "ExtractedExamples"
|
destination = Path('.') / "ExtractedExamples"
|
||||||
sourceText = Path('.') / "TIJDirectorsCut.txt"
|
sourceText = Path('.') / "TIJDirectorsCut.txt"
|
||||||
github = Path(r'C:\Users\Bruce\Documents\GitHub\TIJ-Directors-Cut')
|
github = Path(r'C:\Users\Bruce\Documents\GitHub\TIJ-Directors-Cut')
|
||||||
|
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
|
||||||
|
|
||||||
startBuild = """\
|
startBuild = """\
|
||||||
<?xml version="1.0" ?>
|
<?xml version="1.0" ?>
|
||||||
@ -38,6 +39,7 @@ endBuild = """\
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def extractExamples():
|
def extractExamples():
|
||||||
|
print("Extracting examples ...")
|
||||||
if not destination.exists():
|
if not destination.exists():
|
||||||
destination.mkdir()
|
destination.mkdir()
|
||||||
if not sourceText.exists():
|
if not sourceText.exists():
|
||||||
@ -65,7 +67,7 @@ def extractExamples():
|
|||||||
@CmdLine("x")
|
@CmdLine("x")
|
||||||
def clean():
|
def clean():
|
||||||
"Remove ExtractedExamples directory"
|
"Remove ExtractedExamples directory"
|
||||||
print("clean")
|
print("Cleaning ...")
|
||||||
if destination.exists():
|
if destination.exists():
|
||||||
shutil.rmtree(str(destination))
|
shutil.rmtree(str(destination))
|
||||||
|
|
||||||
@ -129,16 +131,29 @@ def destDirs(pattern="**"):
|
|||||||
return {str(file)[leader:] for file in destination.glob(pattern)}
|
return {str(file)[leader:] for file in destination.glob(pattern)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@CmdLine("a")
|
@CmdLine("a")
|
||||||
def copySupplementalFilesFromGithub():
|
def copySupplementalFilesFromGithub():
|
||||||
"Copy ant build files from Github repository to extracted examples"
|
"Copy supplemental files from Github repository to extracted examples"
|
||||||
shutil.copy(str(github / "build.xml"), str(destination))
|
print("Copying supplemental files from Github ...")
|
||||||
shutil.copy(str(github / "Ant-Common.xml"), str(destination))
|
def _copy(dir, name_or_pattern, trace=False):
|
||||||
shutil.copy(str(github / "Ant-Clean.xml"), str(destination))
|
source = (github/dir).glob(name_or_pattern)
|
||||||
for face in (github / "gui").glob("*.gif"):
|
dest_dir = examples/dir
|
||||||
shutil.copy(str(face), str(destination / "gui"))
|
assert dest_dir.is_dir()
|
||||||
# for verifier in ["OutputGenerator.py", "OutputVerifier.py"]:
|
for f in source:
|
||||||
# shutil.copy(str(github/verifier), str(destination))
|
if trace:
|
||||||
|
print("source: {}".format(f))
|
||||||
|
print("dest: {}".format(dest_dir))
|
||||||
|
shutil.copy(str(f), str(dest_dir))
|
||||||
|
|
||||||
|
_copy(".", "build.xml")
|
||||||
|
_copy(".", "Ant-*.xml")
|
||||||
|
_copy("gui", "*.gif")
|
||||||
|
_copy("network", "*.bat")
|
||||||
|
_copy("network", "build.xml")
|
||||||
|
_copy("remote", "*.bat")
|
||||||
|
_copy("remote", "build.xml")
|
||||||
|
|
||||||
patterns = destination / "patterns"
|
patterns = destination / "patterns"
|
||||||
trash = patterns / "recycleap" / "Trash.dat"
|
trash = patterns / "recycleap" / "Trash.dat"
|
||||||
shutil.copy(str(trash), str(patterns / "recycleb"))
|
shutil.copy(str(trash), str(patterns / "recycleb"))
|
||||||
@ -167,7 +182,6 @@ class CodeFileOptions(object):
|
|||||||
self.exclude = self.codeFile.name + ".java"
|
self.exclude = self.codeFile.name + ".java"
|
||||||
if self.codeFile.subdirs:
|
if self.codeFile.subdirs:
|
||||||
self.exclude = '/'.join(self.codeFile.subdirs) + '/' + self.exclude
|
self.exclude = '/'.join(self.codeFile.subdirs) + '/' + self.exclude
|
||||||
print("self.exclude {}".format(self.exclude))
|
|
||||||
|
|
||||||
self.continue_on_error = None
|
self.continue_on_error = None
|
||||||
if "{ThrowsException}" in self.codeFile.code:
|
if "{ThrowsException}" in self.codeFile.code:
|
||||||
@ -311,7 +325,7 @@ class Chapter:
|
|||||||
buildFile = startBuild % (self.dir.name, " ".join(self.excludes))
|
buildFile = startBuild % (self.dir.name, " ".join(self.excludes))
|
||||||
for cf in self.code_files:
|
for cf in self.code_files:
|
||||||
if any([cf.name + ".java" in f for f in self.excludes]) or cf.options.validatebyhand:
|
if any([cf.name + ".java" in f for f in self.excludes]) or cf.options.validatebyhand:
|
||||||
print("Excluding {}".format(cf))
|
# print("Excluding {}".format(cf))
|
||||||
continue
|
continue
|
||||||
buildFile += cf.run_command()
|
buildFile += cf.run_command()
|
||||||
buildFile += endBuild
|
buildFile += endBuild
|
||||||
@ -325,51 +339,30 @@ exec = """\
|
|||||||
</exec>
|
</exec>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def addBatchCommand(target_dir, batch_file_name):
|
# def addBatchCommand(target_dir, batch_file_name):
|
||||||
with (destination/target_dir/"build.xml").open() as build:
|
# with (destination/target_dir/"build.xml").open() as build:
|
||||||
lines = build.readlines()
|
# lines = build.readlines()
|
||||||
for n, line in enumerate(lines):
|
# for n, line in enumerate(lines):
|
||||||
if "</target>" in line:
|
# if "</target>" in line:
|
||||||
lines.insert(n, exec.format(batch_file_name, batch_file_name))
|
# lines.insert(n, exec.format(batch_file_name, batch_file_name))
|
||||||
break
|
# break
|
||||||
with (destination/target_dir/"build.xml").open("w") as build:
|
# with (destination/target_dir/"build.xml").open("w") as build:
|
||||||
build.writelines(lines)
|
# build.writelines(lines)
|
||||||
|
|
||||||
def addBatchFile(target_dir, batch_file_name, batch_file_text):
|
# def addBatchFile(target_dir, batch_file_name, batch_file_text):
|
||||||
with (destination/target_dir/batch_file_name).open('w') as ss:
|
# with (destination/target_dir/batch_file_name).open('w') as ss:
|
||||||
ss.write(batch_file_text)
|
# ss.write(batch_file_text)
|
||||||
addBatchCommand(target_dir, batch_file_name)
|
# addBatchCommand(target_dir, batch_file_name)
|
||||||
|
|
||||||
|
|
||||||
@CmdLine("m")
|
@CmdLine("m")
|
||||||
def createAntFiles():
|
def createAntFiles():
|
||||||
"Make ant files that don't exist"
|
"Make ant files that don't exist"
|
||||||
|
print("Creating Ant Files ...")
|
||||||
chapters = [Chapter(fd) for fd in destination.glob("*") if fd.is_dir() if not (fd / "build.xml").exists()]
|
chapters = [Chapter(fd) for fd in destination.glob("*") if fd.is_dir() if not (fd / "build.xml").exists()]
|
||||||
for chapter in chapters:
|
for chapter in chapters:
|
||||||
chapter.checkPackages()
|
chapter.checkPackages()
|
||||||
chapter.makeBuildFile()
|
chapter.makeBuildFile()
|
||||||
# with (destination/"network"/"SimpleServer.bat").open('w') as ss:
|
|
||||||
# ss.write("start java SimpleServer\n")
|
|
||||||
# ss.write("java SimpleClient\n")
|
|
||||||
# addBatchCommand("network", "SimpleServer.bat")
|
|
||||||
addBatchFile("network", "SimpleServer.bat",
|
|
||||||
"""\
|
|
||||||
start java SimpleServer
|
|
||||||
java SimpleClient
|
|
||||||
""")
|
|
||||||
addBatchFile("network", "ChatterServer.bat",
|
|
||||||
"""\
|
|
||||||
start java ChatterServer
|
|
||||||
timeout /t 1
|
|
||||||
java ChatterClient
|
|
||||||
""")
|
|
||||||
addBatchFile("network", "MultiSimpleServer.bat",
|
|
||||||
"""\
|
|
||||||
start java MultiSimpleServer
|
|
||||||
timeout /t 1
|
|
||||||
java MultiSimpleClient
|
|
||||||
""")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@CmdLine("f")
|
@CmdLine("f")
|
||||||
@ -391,8 +384,8 @@ def extractAndCreateBuildFiles():
|
|||||||
"Clean, then extract examples from TIJDirectorsCut.txt, build ant files"
|
"Clean, then extract examples from TIJDirectorsCut.txt, build ant files"
|
||||||
clean()
|
clean()
|
||||||
extractExamples()
|
extractExamples()
|
||||||
copySupplementalFilesFromGithub()
|
|
||||||
createAntFiles()
|
createAntFiles()
|
||||||
|
copySupplementalFilesFromGithub()
|
||||||
os.chdir("ExtractedExamples")
|
os.chdir("ExtractedExamples")
|
||||||
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")
|
||||||
@ -403,7 +396,6 @@ def extractAndCreateBuildFiles():
|
|||||||
@CmdLine('g')
|
@CmdLine('g')
|
||||||
def generateAntClean():
|
def generateAntClean():
|
||||||
"Generate directives for Ant-Clean.xml"
|
"Generate directives for Ant-Clean.xml"
|
||||||
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
|
|
||||||
others = set([f.name for f in examples.rglob("*") if not f.is_dir()
|
others = set([f.name for f in examples.rglob("*") if not f.is_dir()
|
||||||
if not f.suffix == ".java"
|
if not f.suffix == ".java"
|
||||||
if not f.suffix == ".class"
|
if not f.suffix == ".class"
|
||||||
@ -437,7 +429,6 @@ def findTags(lines):
|
|||||||
def findAllCommentTags():
|
def findAllCommentTags():
|
||||||
"Find all '{}' comment tags in Java files"
|
"Find all '{}' comment tags in Java files"
|
||||||
tagdict = defaultdict(list)
|
tagdict = defaultdict(list)
|
||||||
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
|
|
||||||
for jf in [f for f in examples.rglob("*.java")]:
|
for jf in [f for f in examples.rglob("*.java")]:
|
||||||
with jf.open() as code:
|
with jf.open() as code:
|
||||||
lines = code.readlines()
|
lines = code.readlines()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user