Skip to content

Commit 4e3e97f

Browse files
author
Bruce Eckel
committed
automation
1 parent fbae5da commit 4e3e97f

5 files changed

Lines changed: 88 additions & 90 deletions

File tree

Checklist.txt

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
What is the Director’s Cut?
2-
Preface
3-
Introduction
4-
Introduction to Objects
5-
Everything Is an Object
6-
Operators
7-
Controlling Execution
8-
Initialization & Cleanup
9-
Access Control
10-
Reusing Classes
11-
Polymorphism
12-
Interfaces
13-
Inner Classes
14-
Holding Your Objects
15-
Error Handling with Exceptions
16-
Strings
17-
Type Information
18-
Generics
19-
Arrays
20-
Containers in Depth
21-
I/O
22-
Enumerated Types
23-
Annotations
24-
Concurrency
25-
Graphical User Interfaces
26-
Design Patterns
27-
Appendix: Supplements
28-
Appendix: Resources
29-
Appendix: Java Programming Guidelines
30-
Appendix: Unit Testing
31-
Appendix: Improving Reliability with Assertions
32-
Appendix: Passing & Returning Objects
33-
Appendix: Logging
34-
Appendix: Debugging
35-
Appendix: Network Programming
36-
Appendix: Remote Methods
37-
Appendix: Profiling and Optimizing
38-
Appendix: The Benefits and Costs of Static Type Checking
39-
Appendix: The Positive Legacy of C++ and Java
40-
Appendix: On Being a Programmer
1+
[ ] What is the Director’s Cut?
2+
[ ] Preface
3+
[ ] Introduction
4+
[ ] Introduction to Objects
5+
[ ] Everything Is an Object
6+
[ ] Operators
7+
[ ] Controlling Execution
8+
[ ] Initialization & Cleanup
9+
[ ] Access Control
10+
[ ] Reusing Classes
11+
[ ] Polymorphism
12+
[ ] Interfaces
13+
[ ] Inner Classes
14+
[ ] Holding Your Objects
15+
[ ] Error Handling with Exceptions
16+
[ ] Strings
17+
[ ] Type Information
18+
[ ] Generics
19+
[ ] Arrays
20+
[ ] Containers in Depth
21+
[ ] I/O
22+
[ ] Enumerated Types
23+
[ ] Annotations
24+
[ ] Concurrency
25+
[ ] Graphical User Interfaces
26+
[ ] Design Patterns
27+
[ ] Appendix: Supplements
28+
[ ] Appendix: Resources
29+
[ ] Appendix: Java Programming Guidelines
30+
[ ] Appendix: Unit Testing
31+
[ ] Appendix: Improving Reliability with Assertions
32+
[ ] Appendix: Passing & Returning Objects
33+
[ ] Appendix: Logging
34+
[ ] Appendix: Debugging
35+
[ ] Appendix: Network Programming
36+
[ ] Appendix: Remote Methods
37+
[ ] Appendix: Profiling and Optimizing
38+
[ ] Appendix: The Benefits and Costs of Static Type Checking
39+
[ ] Appendix: The Positive Legacy of C++ and Java
40+
[ ] Appendix: On Being a Programmer

remote/build.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<import file="../Ant-Clean.xml"/>
88

99
<target name="run" description="Compile and run" depends="build">
10+
<echo message="go"/>
11+
<exec executable="cmd" dir=".">
12+
<arg line="/c go" />
13+
</exec>
1014
</target>
1115

1216
</project>

remote/go.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
start "ptime.bat" ptime.bat

remote/ptime.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
start /min "registry.bat" registry.bat 3
22
start /min "server.bat" server.bat 3
33
timeout /t 1
4-
java DisplayPerfectTime
4+
java DisplayPerfectTime
5+
timeout /t 3
6+
exit

tools/Examples.py

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
destination = Path('.') / "ExtractedExamples"
1919
sourceText = Path('.') / "TIJDirectorsCut.txt"
2020
github = Path(r'C:\Users\Bruce\Documents\GitHub\TIJ-Directors-Cut')
21+
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
2122

2223
startBuild = """\
2324
<?xml version="1.0" ?>
@@ -38,6 +39,7 @@
3839
"""
3940

4041
def extractExamples():
42+
print("Extracting examples ...")
4143
if not destination.exists():
4244
destination.mkdir()
4345
if not sourceText.exists():
@@ -65,7 +67,7 @@ def extractExamples():
6567
@CmdLine("x")
6668
def clean():
6769
"Remove ExtractedExamples directory"
68-
print("clean")
70+
print("Cleaning ...")
6971
if destination.exists():
7072
shutil.rmtree(str(destination))
7173

@@ -129,16 +131,29 @@ def destDirs(pattern="**"):
129131
return {str(file)[leader:] for file in destination.glob(pattern)}
130132

131133

134+
132135
@CmdLine("a")
133136
def copySupplementalFilesFromGithub():
134-
"Copy ant build files from Github repository to extracted examples"
135-
shutil.copy(str(github / "build.xml"), str(destination))
136-
shutil.copy(str(github / "Ant-Common.xml"), str(destination))
137-
shutil.copy(str(github / "Ant-Clean.xml"), str(destination))
138-
for face in (github / "gui").glob("*.gif"):
139-
shutil.copy(str(face), str(destination / "gui"))
140-
# for verifier in ["OutputGenerator.py", "OutputVerifier.py"]:
141-
# shutil.copy(str(github/verifier), str(destination))
137+
"Copy supplemental files from Github repository to extracted examples"
138+
print("Copying supplemental files from Github ...")
139+
def _copy(dir, name_or_pattern, trace=False):
140+
source = (github/dir).glob(name_or_pattern)
141+
dest_dir = examples/dir
142+
assert dest_dir.is_dir()
143+
for f in source:
144+
if trace:
145+
print("source: {}".format(f))
146+
print("dest: {}".format(dest_dir))
147+
shutil.copy(str(f), str(dest_dir))
148+
149+
_copy(".", "build.xml")
150+
_copy(".", "Ant-*.xml")
151+
_copy("gui", "*.gif")
152+
_copy("network", "*.bat")
153+
_copy("network", "build.xml")
154+
_copy("remote", "*.bat")
155+
_copy("remote", "build.xml")
156+
142157
patterns = destination / "patterns"
143158
trash = patterns / "recycleap" / "Trash.dat"
144159
shutil.copy(str(trash), str(patterns / "recycleb"))
@@ -167,7 +182,6 @@ def __init__(self, codeFile):
167182
self.exclude = self.codeFile.name + ".java"
168183
if self.codeFile.subdirs:
169184
self.exclude = '/'.join(self.codeFile.subdirs) + '/' + self.exclude
170-
print("self.exclude {}".format(self.exclude))
171185

172186
self.continue_on_error = None
173187
if "{ThrowsException}" in self.codeFile.code:
@@ -311,7 +325,7 @@ def makeBuildFile(self):
311325
buildFile = startBuild % (self.dir.name, " ".join(self.excludes))
312326
for cf in self.code_files:
313327
if any([cf.name + ".java" in f for f in self.excludes]) or cf.options.validatebyhand:
314-
print("Excluding {}".format(cf))
328+
# print("Excluding {}".format(cf))
315329
continue
316330
buildFile += cf.run_command()
317331
buildFile += endBuild
@@ -325,51 +339,30 @@ def makeBuildFile(self):
325339
</exec>
326340
"""
327341

328-
def addBatchCommand(target_dir, batch_file_name):
329-
with (destination/target_dir/"build.xml").open() as build:
330-
lines = build.readlines()
331-
for n, line in enumerate(lines):
332-
if "</target>" in line:
333-
lines.insert(n, exec.format(batch_file_name, batch_file_name))
334-
break
335-
with (destination/target_dir/"build.xml").open("w") as build:
336-
build.writelines(lines)
342+
# def addBatchCommand(target_dir, batch_file_name):
343+
# with (destination/target_dir/"build.xml").open() as build:
344+
# lines = build.readlines()
345+
# for n, line in enumerate(lines):
346+
# if "</target>" in line:
347+
# lines.insert(n, exec.format(batch_file_name, batch_file_name))
348+
# break
349+
# with (destination/target_dir/"build.xml").open("w") as build:
350+
# build.writelines(lines)
337351

338-
def addBatchFile(target_dir, batch_file_name, batch_file_text):
339-
with (destination/target_dir/batch_file_name).open('w') as ss:
340-
ss.write(batch_file_text)
341-
addBatchCommand(target_dir, batch_file_name)
352+
# def addBatchFile(target_dir, batch_file_name, batch_file_text):
353+
# with (destination/target_dir/batch_file_name).open('w') as ss:
354+
# ss.write(batch_file_text)
355+
# addBatchCommand(target_dir, batch_file_name)
342356

343357

344358
@CmdLine("m")
345359
def createAntFiles():
346360
"Make ant files that don't exist"
361+
print("Creating Ant Files ...")
347362
chapters = [Chapter(fd) for fd in destination.glob("*") if fd.is_dir() if not (fd / "build.xml").exists()]
348363
for chapter in chapters:
349364
chapter.checkPackages()
350365
chapter.makeBuildFile()
351-
# with (destination/"network"/"SimpleServer.bat").open('w') as ss:
352-
# ss.write("start java SimpleServer\n")
353-
# ss.write("java SimpleClient\n")
354-
# addBatchCommand("network", "SimpleServer.bat")
355-
addBatchFile("network", "SimpleServer.bat",
356-
"""\
357-
start java SimpleServer
358-
java SimpleClient
359-
""")
360-
addBatchFile("network", "ChatterServer.bat",
361-
"""\
362-
start java ChatterServer
363-
timeout /t 1
364-
java ChatterClient
365-
""")
366-
addBatchFile("network", "MultiSimpleServer.bat",
367-
"""\
368-
start java MultiSimpleServer
369-
timeout /t 1
370-
java MultiSimpleClient
371-
""")
372-
373366

374367

375368
@CmdLine("f")
@@ -391,8 +384,8 @@ def extractAndCreateBuildFiles():
391384
"Clean, then extract examples from TIJDirectorsCut.txt, build ant files"
392385
clean()
393386
extractExamples()
394-
copySupplementalFilesFromGithub()
395387
createAntFiles()
388+
copySupplementalFilesFromGithub()
396389
os.chdir("ExtractedExamples")
397390
with open("run.bat", 'w') as run:
398391
run.write(r"python ..\Validate.py -p" + "\n")
@@ -403,7 +396,6 @@ def extractAndCreateBuildFiles():
403396
@CmdLine('g')
404397
def generateAntClean():
405398
"Generate directives for Ant-Clean.xml"
406-
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
407399
others = set([f.name for f in examples.rglob("*") if not f.is_dir()
408400
if not f.suffix == ".java"
409401
if not f.suffix == ".class"
@@ -437,7 +429,6 @@ def findTags(lines):
437429
def findAllCommentTags():
438430
"Find all '{}' comment tags in Java files"
439431
tagdict = defaultdict(list)
440-
examples = Path(r"C:\Users\Bruce\Dropbox\__TIJ4-ebook\ExtractedExamples")
441432
for jf in [f for f in examples.rglob("*.java")]:
442433
with jf.open() as code:
443434
lines = code.readlines()

0 commit comments

Comments
 (0)