Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Anderson <tony_anderson@usa.net>2010-01-19 20:12:25 (GMT)
committer Tony Anderson <tony_anderson@usa.net>2010-01-19 20:12:25 (GMT)
commit5ab8386102f3ad6952496d94bd85fdbab5248014 (patch)
treec3499c1f1cc3ba0d67f1e6f84c70a7c92b369c82
parent51db5e18ee26bb608684bfa5a8d2c95e7ca3364b (diff)
create ladder from xml descriptionHEADmaster
-rw-r--r--assets/image/badge.pngbin18607 -> 8187 bytes
-rw-r--r--assets/image/box.pngbin10783 -> 4834 bytes
-rw-r--r--assets/image/bull.pngbin8243 -> 4229 bytes
-rw-r--r--assets/image/camel.pngbin14001 -> 7019 bytes
-rw-r--r--assets/image/card.pngbin19069 -> 8676 bytes
-rw-r--r--assets/image/cat.pngbin5454 -> 2599 bytes
-rw-r--r--assets/image/deer.pngbin9392 -> 4287 bytes
-rw-r--r--assets/image/dog.pngbin5924 -> 2891 bytes
-rw-r--r--assets/image/ear.pngbin11859 -> 5623 bytes
-rw-r--r--assets/image/elephant.pngbin6387 -> 3134 bytes
-rw-r--r--assets/image/girl.pngbin12176 -> 6158 bytes
-rw-r--r--assets/image/goat.pngbin9051 -> 4132 bytes
-rw-r--r--assets/image/horse.pngbin6348 -> 3152 bytes
-rw-r--r--assets/image/jar.pngbin5035 -> 2788 bytes
-rw-r--r--assets/image/joker.pngbin7578 -> 3517 bytes
-rw-r--r--assets/image/lantern.pngbin8354 -> 3805 bytes
-rw-r--r--assets/image/lion.pngbin10014 -> 4507 bytes
-rw-r--r--assets/image/man.pngbin7348 -> 3645 bytes
-rw-r--r--assets/image/mask.pngbin15803 -> 6970 bytes
-rw-r--r--assets/image/monkey.pngbin8287 -> 4074 bytes
-rw-r--r--assets/image/mother.pngbin10095 -> 5417 bytes
-rw-r--r--assets/image/mouth.pngbin8733 -> 4127 bytes
-rw-r--r--assets/image/peacock.pngbin7440 -> 3305 bytes
-rw-r--r--assets/image/pencil.pngbin4675 -> 2261 bytes
-rw-r--r--assets/image/pencil_in_hand.pngbin9735 -> 4413 bytes
-rw-r--r--assets/image/puppet_show.pngbin13812 -> 6364 bytes
-rw-r--r--assets/image/rabbit.pngbin4679 -> 2246 bytes
-rw-r--r--assets/image/ram.pngbin12821 -> 5741 bytes
-rw-r--r--assets/image/rat.pngbin7220 -> 3412 bytes
-rw-r--r--assets/image/reindeer.pngbin7502 -> 3697 bytes
-rw-r--r--assets/image/rubber_letter.pngbin7924 -> 3781 bytes
-rw-r--r--assets/image/squirrel.pngbin15250 -> 6691 bytes
-rw-r--r--assets/image/swing.pngbin0 -> 4555 bytes
-rw-r--r--assets/image/teddy.pngbin14600 -> 6861 bytes
-rw-r--r--assets/image/tortoise.pngbin9949 -> 4457 bytes
-rw-r--r--assets/image/train.pngbin9505 -> 4123 bytes
-rw-r--r--assets/image/tree.pngbin11641 -> 6022 bytes
-rw-r--r--assets/image/triangle.pngbin923 -> 984 bytes
-rw-r--r--assets/image/village.pngbin10716 -> 4678 bytes
-rwxr-xr-xindex.html4
-rw-r--r--js/activities.js1
-rw-r--r--js/assets.js88
-rwxr-xr-xjs/lesson.js364
-rw-r--r--makeladder.py113
-rwxr-xr-xpath.py971
-rw-r--r--test_ladder.xml92
46 files changed, 1306 insertions, 327 deletions
diff --git a/assets/image/badge.png b/assets/image/badge.png
index 430ba8a..39596a6 100644
--- a/assets/image/badge.png
+++ b/assets/image/badge.png
Binary files differ
diff --git a/assets/image/box.png b/assets/image/box.png
index d087fb9..61db6a6 100644
--- a/assets/image/box.png
+++ b/assets/image/box.png
Binary files differ
diff --git a/assets/image/bull.png b/assets/image/bull.png
index b3e4489..c7f30e3 100644
--- a/assets/image/bull.png
+++ b/assets/image/bull.png
Binary files differ
diff --git a/assets/image/camel.png b/assets/image/camel.png
index d30191d..3f6d4b8 100644
--- a/assets/image/camel.png
+++ b/assets/image/camel.png
Binary files differ
diff --git a/assets/image/card.png b/assets/image/card.png
index b7c5e93..a75fb12 100644
--- a/assets/image/card.png
+++ b/assets/image/card.png
Binary files differ
diff --git a/assets/image/cat.png b/assets/image/cat.png
index 8bafdd2..b03d339 100644
--- a/assets/image/cat.png
+++ b/assets/image/cat.png
Binary files differ
diff --git a/assets/image/deer.png b/assets/image/deer.png
index 2e70ce2..8aea0f5 100644
--- a/assets/image/deer.png
+++ b/assets/image/deer.png
Binary files differ
diff --git a/assets/image/dog.png b/assets/image/dog.png
index 7f266a3..58b0f08 100644
--- a/assets/image/dog.png
+++ b/assets/image/dog.png
Binary files differ
diff --git a/assets/image/ear.png b/assets/image/ear.png
index 50139ab..bfee466 100644
--- a/assets/image/ear.png
+++ b/assets/image/ear.png
Binary files differ
diff --git a/assets/image/elephant.png b/assets/image/elephant.png
index 2783dd5..13eda50 100644
--- a/assets/image/elephant.png
+++ b/assets/image/elephant.png
Binary files differ
diff --git a/assets/image/girl.png b/assets/image/girl.png
index 7cc062c..ca2ff79 100644
--- a/assets/image/girl.png
+++ b/assets/image/girl.png
Binary files differ
diff --git a/assets/image/goat.png b/assets/image/goat.png
index bc6927f..30116d2 100644
--- a/assets/image/goat.png
+++ b/assets/image/goat.png
Binary files differ
diff --git a/assets/image/horse.png b/assets/image/horse.png
index b685a11..9660d36 100644
--- a/assets/image/horse.png
+++ b/assets/image/horse.png
Binary files differ
diff --git a/assets/image/jar.png b/assets/image/jar.png
index 8b98246..2f3dd62 100644
--- a/assets/image/jar.png
+++ b/assets/image/jar.png
Binary files differ
diff --git a/assets/image/joker.png b/assets/image/joker.png
index fa78ec5..d9b577b 100644
--- a/assets/image/joker.png
+++ b/assets/image/joker.png
Binary files differ
diff --git a/assets/image/lantern.png b/assets/image/lantern.png
index 7675ca2..49ee451 100644
--- a/assets/image/lantern.png
+++ b/assets/image/lantern.png
Binary files differ
diff --git a/assets/image/lion.png b/assets/image/lion.png
index d8b5b6a..0f210d1 100644
--- a/assets/image/lion.png
+++ b/assets/image/lion.png
Binary files differ
diff --git a/assets/image/man.png b/assets/image/man.png
index f466914..63feab3 100644
--- a/assets/image/man.png
+++ b/assets/image/man.png
Binary files differ
diff --git a/assets/image/mask.png b/assets/image/mask.png
index e09a7d1..fe1c5b6 100644
--- a/assets/image/mask.png
+++ b/assets/image/mask.png
Binary files differ
diff --git a/assets/image/monkey.png b/assets/image/monkey.png
index a4eb43f..ed06e2d 100644
--- a/assets/image/monkey.png
+++ b/assets/image/monkey.png
Binary files differ
diff --git a/assets/image/mother.png b/assets/image/mother.png
index fc29fcb..fd4f75d 100644
--- a/assets/image/mother.png
+++ b/assets/image/mother.png
Binary files differ
diff --git a/assets/image/mouth.png b/assets/image/mouth.png
index af08d24..24f4f38 100644
--- a/assets/image/mouth.png
+++ b/assets/image/mouth.png
Binary files differ
diff --git a/assets/image/peacock.png b/assets/image/peacock.png
index ed16801..5a5dc89 100644
--- a/assets/image/peacock.png
+++ b/assets/image/peacock.png
Binary files differ
diff --git a/assets/image/pencil.png b/assets/image/pencil.png
index 1879ece..260bfcd 100644
--- a/assets/image/pencil.png
+++ b/assets/image/pencil.png
Binary files differ
diff --git a/assets/image/pencil_in_hand.png b/assets/image/pencil_in_hand.png
index c531919..8410a2a 100644
--- a/assets/image/pencil_in_hand.png
+++ b/assets/image/pencil_in_hand.png
Binary files differ
diff --git a/assets/image/puppet_show.png b/assets/image/puppet_show.png
index 698bd16..42579e2 100644
--- a/assets/image/puppet_show.png
+++ b/assets/image/puppet_show.png
Binary files differ
diff --git a/assets/image/rabbit.png b/assets/image/rabbit.png
index 3fc75f2..d753f14 100644
--- a/assets/image/rabbit.png
+++ b/assets/image/rabbit.png
Binary files differ
diff --git a/assets/image/ram.png b/assets/image/ram.png
index 592fcc3..1b9a169 100644
--- a/assets/image/ram.png
+++ b/assets/image/ram.png
Binary files differ
diff --git a/assets/image/rat.png b/assets/image/rat.png
index 6ed8b11..437aaa2 100644
--- a/assets/image/rat.png
+++ b/assets/image/rat.png
Binary files differ
diff --git a/assets/image/reindeer.png b/assets/image/reindeer.png
index 81df5a6..4dd5f44 100644
--- a/assets/image/reindeer.png
+++ b/assets/image/reindeer.png
Binary files differ
diff --git a/assets/image/rubber_letter.png b/assets/image/rubber_letter.png
index edc4a6a..7602276 100644
--- a/assets/image/rubber_letter.png
+++ b/assets/image/rubber_letter.png
Binary files differ
diff --git a/assets/image/squirrel.png b/assets/image/squirrel.png
index 86b6f06..e3a44ba 100644
--- a/assets/image/squirrel.png
+++ b/assets/image/squirrel.png
Binary files differ
diff --git a/assets/image/swing.png b/assets/image/swing.png
new file mode 100644
index 0000000..06bfde4
--- /dev/null
+++ b/assets/image/swing.png
Binary files differ
diff --git a/assets/image/teddy.png b/assets/image/teddy.png
index 2c49839..46e1b02 100644
--- a/assets/image/teddy.png
+++ b/assets/image/teddy.png
Binary files differ
diff --git a/assets/image/tortoise.png b/assets/image/tortoise.png
index e2c4a8e..9ec2a9a 100644
--- a/assets/image/tortoise.png
+++ b/assets/image/tortoise.png
Binary files differ
diff --git a/assets/image/train.png b/assets/image/train.png
index 1ce398b..bde8759 100644
--- a/assets/image/train.png
+++ b/assets/image/train.png
Binary files differ
diff --git a/assets/image/tree.png b/assets/image/tree.png
index efceb5a..3f8e1c8 100644
--- a/assets/image/tree.png
+++ b/assets/image/tree.png
Binary files differ
diff --git a/assets/image/triangle.png b/assets/image/triangle.png
index 406f27c..3d278bc 100644
--- a/assets/image/triangle.png
+++ b/assets/image/triangle.png
Binary files differ
diff --git a/assets/image/village.png b/assets/image/village.png
index 2c34e2a..d5033b6 100644
--- a/assets/image/village.png
+++ b/assets/image/village.png
Binary files differ
diff --git a/index.html b/index.html
index e0bb43c..341287e 100755
--- a/index.html
+++ b/index.html
@@ -10,8 +10,10 @@
<script type="text/javascript" src="js/karma.js"></script>
<script type="text/javascript" src="js/jquery.svg.js"></script>
<script type="text/javascript" src="js/lesson.js"></script>
+ <script type="text/javascript" src="js/assets.js"></script>
+ <script type="text/javascript" src="js/activities.js"></script>
</head>
<body>
- <canvas id="ladder" width= 1200 + 'px' height= 16000 + 'px'></canvas>
+ <canvas id="ladder"/>
</body>
</html>
diff --git a/js/activities.js b/js/activities.js
new file mode 100644
index 0000000..5624a46
--- /dev/null
+++ b/js/activities.js
@@ -0,0 +1 @@
+activities = [[37,1],[11,1],[22,1],[37,1],[37,1],[11,1],[37,1],[22,1],[0,1],[37,2],[11,2],[22,2],[37,2],[37,2],[11,2],[22,2],[37,2],[0,2],[37,3],[11,3],[37,3],[11,3],[37,3],[22,3],[22,3],[37,3],[0,3],[37,4],[11,4],[22,4],[37,4],[37,4],[11,4],[37,4],[22,4],[0,4],[37,5],[11,5],[37,5],[11,5],[22,5],[37,5],[37,5],[22,5],[0,5],[37,6],[11,6],[22,6],[37,6],[37,6],[11,6],[37,6],[22,6],[0,6],[37,7],[11,7],[37,7],[11,7],[37,7],[22,7],[37,7],[22,7],[0,7],[37,8],[11,8],[22,8],[37,8],[37,8],[11,8],[37,8],[22,8],[0,8],[37,9],[37,9],[37,9],[11,9],[22,9],[11,9],[37,9],[22,9],[0,9],];
diff --git a/js/assets.js b/js/assets.js
new file mode 100644
index 0000000..f0e9b16
--- /dev/null
+++ b/js/assets.js
@@ -0,0 +1,88 @@
+var assetList = {image: [
+{name:"horse", file:"horse.png"},
+{name:"mouth", file:"mouth.png"},
+{name:"ram", file:"ram.png"},
+{name:"teddy", file:"teddy.png"},
+{name:"lantern", file:"lantern.png"},
+{name:"jar", file:"jar.png"},
+{name:"village", file:"village.png"},
+{name:"man", file:"man.png"},
+{name:"elephant", file:"elephant.png"},
+{name:"mask", file:"mask.png"},
+{name:"swing", file:"swing.png"},
+{name:"card", file:"card.png"},
+{name:"pencil_in_hand", file:"pencil_in_hand.png"},
+{name:"triangle", file:"triangle.png"},
+{name:"lion", file:"lion.png"},
+{name:"rubber_letter", file:"rubber_letter.png"},
+{name:"girl", file:"girl.png"},
+{name:"badge", file:"badge.png"},
+{name:"box", file:"box.png"},
+{name:"cat", file:"cat.png"},
+{name:"rat", file:"rat.png"},
+{name:"camel", file:"camel.png"},
+{name:"train", file:"train.png"},
+{name:"bull", file:"bull.png"},
+{name:"ear", file:"ear.png"},
+{name:"deer", file:"deer.png"},
+{name:"dog", file:"dog.png"},
+{name:"tortoise", file:"tortoise.png"},
+{name:"reindeer", file:"reindeer.png"},
+{name:"monkey", file:"monkey.png"},
+{name:"puppet_show", file:"puppet_show.png"},
+{name:"peacock", file:"peacock.png"},
+{name:"mother", file:"mother.png"},
+{name:"squirrel", file:"squirrel.png"},
+{name:"pencil", file:"pencil.png"},
+{name:"goat", file:"goat.png"},
+{name:"rabbit", file:"rabbit.png"},
+{name:"tree", file:"tree.png"},
+{name:"joker", file:"joker.png"},
+],
+
+ canvas: [
+ {name:"ladder", domId:"ladder"}
+ ]
+ };
+
+var logos =[
+"horse",
+"mouth",
+"ram",
+"teddy",
+"lantern",
+"jar",
+"village",
+"man",
+"elephant",
+"mask",
+"swing",
+"card",
+"pencil_in_hand",
+"triangle",
+"lion",
+"rubber_letter",
+"girl",
+"badge",
+"box",
+"cat",
+"rat",
+"camel",
+"train",
+"bull",
+"ear",
+"deer",
+"dog",
+"tortoise",
+"reindeer",
+"monkey",
+"puppet_show",
+"peacock",
+"mother",
+"squirrel",
+"pencil",
+"goat",
+"rabbit",
+"tree",
+"joker",
+];
diff --git a/js/lesson.js b/js/lesson.js
index c0b01a6..e986897 100755
--- a/js/lesson.js
+++ b/js/lesson.js
@@ -1,329 +1,35 @@
$(document).ready(
function(){
- var k = Karma({
- image: [
- {name:"camel" , file:"camel.png"},
- {name:"jar" , file:"jar.png"},
- {name:"cat" , file:"cat.png"},
- {name:"teddy" , file:"teddy.png"},
- {name:"squirrel" , file:"squirrel.png"},
- {name:"box" , file:"box.png"},
- {name:"deer" , file:"deer.png"},
- {name:"elephant" , file:"elephant.png"},
- {name:"lantern" , file:"lantern.png"},
- {name:"triangle" , file:"triangle.png"},
- {name:"man" , file:"man.png"},
- {name:"monkey" , file:"monkey.png"},
- {name:"reindeer" , file:"reindeer.png"},
- {name:"horse" , file:"horse.png"},
- {name:"mouth" , file:"mouth.png"},
- {name:"mother" , file:"mother.png"},
- {name:"rabbit" , file:"rabbit.png"},
- {name:"badge" , file:"badge.png"},
- {name:"pencil" , file:"pencil.png"},
- {name:"pencil_in_hand" , file:"pencil_in_hand.png"},
- {name:"tortoise" , file:"tortoise.png"},
- {name:"lion" , file:"lion.png"},
- {name:"joker" , file:"joker.png"},
- {name:"train" , file:"train.png"},
- {name:"ear" , file:"ear.png"},
- {name:"dog" , file:"dog.png"},
- {name:"rubber_letter" , file:"rubber_letter.png"},
- {name:"ram" , file:"ram.png"},
- {name:"puppet_show" , file:"puppet_show.png"},
- {name:"bull" , file:"bull.png"},
- {name:"card" , file:"card.png"},
- {name:"rat" , file:"rat.png"},
- {name:"goat" , file:"goat.png"},
- {name:"peacock" , file:"peacock.png"},
- {name:"girl" , file:"girl.png"},
- {name:"mask" , file:"mask.png"},
- {name:"tree" , file:"tree.png"},
- {name:"village" , file:"village.png"}
- ],
-
- canvas: [
- {name:"ladder", domId:"ladder"}
- ]
- });
-
-
+ var k = Karma(assetList);
+
k.ready(function() {
- var logos =["camel", "jar","cat","teddy","squirrel","box","deer","elephant","lantern","triangle","man","monkey",
- "reindeer","horse",
- "mouth","mother","rabbit","badge","pencil","pencil_in_hand","tortoise","lion","joker",
- "train","ear","dog","rubber_letter","ram","puppet_show",
- "bull","card","rat","goat","peacock","girl","mask","tree","village","village"];
-
- var activities = new Array();
- activities[0] = new Array(23,0);
- activities[1] = new Array(4,0);
- activities[2] = new Array(32,0);
- activities[3] = new Array(18,0);
- activities[4] = new Array(30,0);
- activities[5] = new Array(38,0);
- activities[6] = new Array(25,0);
- activities[7] = new Array(2,0);
- activities[8] = new Array(9,0);
- activities[9] = new Array(34,0);
- activities[10] = new Array(35,0);
- activities[11] = new Array(11,0);
- activities[12] = new Array(28,0);
- activities[13] = new Array(22,0);
- activities[14] = new Array(24,0);
- activities[15] = new Array(5,0);
- activities[16] = new Array(32,0);
- activities[17] = new Array(36,0);
- activities[18] = new Array(6,0);
- activities[19] = new Array(31,0);
- activities[20] = new Array(19,0);
- activities[21] = new Array(37,0);
- activities[22] = new Array(24,0);
- activities[23] = new Array(16,0);
- activities[24] = new Array(32,0);
- activities[25] = new Array(17,0);
- activities[26] = new Array(39,0);
- activities[27] = new Array(10,0);
- activities[28] = new Array(15,0);
- activities[29] = new Array(0,1);
- activities[30] = new Array(17,1);
- activities[31] = new Array(30,1);
- activities[32] = new Array(31,1);
- activities[33] = new Array(7,1);
- activities[34] = new Array(8,1);
- activities[35] = new Array(38,1);
- activities[36] = new Array(0,2);
- activities[37] = new Array(17,2);
- activities[38] = new Array(30,2);
- activities[39] = new Array(31,2);
- activities[40] = new Array(7,2);
- activities[41] = new Array(8,2);
- activities[42] = new Array(12,1);
- activities[43] = new Array(20,0);
- activities[44] = new Array(38,18);
- activities[45] = new Array(0,3);
- activities[46] = new Array(17,3);
- activities[47] = new Array(30,2);
- activities[48] = new Array(31,3);
- activities[49] = new Array(13,1);
- activities[50] = new Array(8,3);
- activities[51] = new Array(38,17);
- activities[52] = new Array(0,4);
- activities[53] = new Array(17,4);
- activities[54] = new Array(30,3);
- activities[55] = new Array(31,4);
- activities[56] = new Array(13,0);
- activities[57] = new Array(8,4);
- activities[58] = new Array(29,1);
- activities[59] = new Array(21,2);
- activities[60] = new Array(36,0);
- activities[61] = new Array(38,19);
- activities[62] = new Array(0,5);
- activities[63] = new Array(17,5);
- activities[64] = new Array(30,4);
- activities[65] = new Array(31,5);
- activities[66] = new Array(7,0);
- activities[67] = new Array(8,5);
- activities[68] = new Array(5,1);
- activities[69] = new Array(21,3);
- activities[70] = new Array(1,1);
- activities[71] = new Array(3,1);
- activities[72] = new Array(38,20);
- activities[73] = new Array(0,6);
- activities[74] = new Array(17,6);
- activities[75] = new Array(30,5);
- activities[76] = new Array(31,6);
- activities[77] = new Array(7,2);
- activities[78] = new Array(8,6);
- activities[79] = new Array(29,2);
- activities[80] = new Array(21,4);
- activities[81] = new Array(12,2);
- activities[82] = new Array(33,1);
- activities[83] = new Array(38,21);
- activities[84] = new Array(0,7);
- activities[85] = new Array(17,7);
- activities[86] = new Array(30,5);
- activities[87] = new Array(31,7);
- activities[88] = new Array(7,0);
- activities[89] = new Array(8,7);
- activities[90] = new Array(21,5);
- activities[91] = new Array(12,3);
- activities[92] = new Array(1,2);
- activities[93] = new Array(38,22);
- activities[94] = new Array(0,8);
- activities[95] = new Array(17,8);
- activities[96] = new Array(30,6);
- activities[97] = new Array(31,8);
- activities[98] = new Array(7,0);
- activities[99] = new Array(8,8);
- activities[100] = new Array(21,6);
- activities[101] = new Array(5,2);
- activities[102] = new Array(33,2);
- activities[103] = new Array(36,0);
- activities[104] = new Array(38,19);
- activities[105] = new Array(0,9);
- activities[106] = new Array(17,9);
- activities[107] = new Array(30,7);
- activities[108] = new Array(31,9);
- activities[109] = new Array(7,3);
- activities[110] = new Array(8,9);
- activities[111] = new Array(21,7);
- activities[112] = new Array(12,4);
- activities[113] = new Array(33,3);
- activities[114] = new Array(38,23);
- activities[115] = new Array(0,10);
- activities[116] = new Array(17,10);
- activities[117] = new Array(31,10);
- activities[118] = new Array(7,0);
- activities[119] = new Array(8,10);
- activities[120] = new Array(21,8);
- activities[121] = new Array(1,3);
- activities[122] = new Array(26,2);
- activities[123] = new Array(38,24);
- activities[124] = new Array(0,11);
- activities[125] = new Array(17,11);
- activities[126] = new Array(30,7);
- activities[127] = new Array(31,11);
- activities[128] = new Array(7,0);
- activities[129] = new Array(8,11);
- activities[130] = new Array(29,3);
- activities[131] = new Array(21,9);
- activities[132] = new Array(5,3);
- activities[133] = new Array(12,5);
- activities[134] = new Array(38,25);
- activities[135] = new Array(0,12);
- activities[136] = new Array(17,12);
- activities[137] = new Array(30,8);
- activities[138] = new Array(31,12);
- activities[139] = new Array(7,0);
- activities[140] = new Array(8,12);
- activities[141] = new Array(21,10);
- activities[142] = new Array(1,4);
- activities[143] = new Array(33,4);
- activities[144] = new Array(36,0);
- activities[145] = new Array(38,19);
- activities[146] = new Array(0,13);
- activities[147] = new Array(17,13);
- activities[148] = new Array(31,13);
- activities[149] = new Array(7,4);
- activities[150] = new Array(8,13);
- activities[151] = new Array(21,11);
- activities[152] = new Array(12,6);
- activities[153] = new Array(1,5);
- activities[154] = new Array(38,26);
- activities[155] = new Array(0,14);
- activities[156] = new Array(17,14);
- activities[157] = new Array(30,9);
- activities[158] = new Array(31,14);
- activities[159] = new Array(7,10);
- activities[160] = new Array(8,14);
- activities[161] = new Array(21,12);
- activities[162] = new Array(29,4);
- activities[163] = new Array(33,5);
- activities[164] = new Array(20,0);
- activities[165] = new Array(38,27);
- activities[166] = new Array(0,15);
- activities[167] = new Array(17,15);
- activities[168] = new Array(30,10);
- activities[169] = new Array(31,15);
- activities[170] = new Array(7,5);
- activities[171] = new Array(8,15);
- activities[172] = new Array(29,5);
- activities[173] = new Array(21,13);
- activities[174] = new Array(1,6);
- activities[175] = new Array(33,6);
- activities[176] = new Array(3,3);
- activities[177] = new Array(38,20);
- activities[178] = new Array(0,16);
- activities[179] = new Array(17,16);
- activities[180] = new Array(31,16);
- activities[181] = new Array(7,0);
- activities[182] = new Array(8,16);
- activities[183] = new Array(29,6);
- activities[184] = new Array(21,14);
- activities[185] = new Array(5,5);
- activities[186] = new Array(12,7);
- activities[187] = new Array(36,0);
- activities[188] = new Array(38,19);
- activities[189] = new Array(0,17);
- activities[190] = new Array(17,17);
- activities[191] = new Array(31,17);
- activities[192] = new Array(7,0);
- activities[193] = new Array(8,17);
- activities[194] = new Array(29,7);
- activities[195] = new Array(21,15);
- activities[196] = new Array(12,8);
- activities[197] = new Array(1,7);
- activities[198] = new Array(38,28);
- activities[199] = new Array(0,18);
- activities[200] = new Array(17,18);
- activities[201] = new Array(31,18);
- activities[202] = new Array(7,6);
- activities[203] = new Array(8,18);
- activities[204] = new Array(29,8);
- activities[205] = new Array(21,16);
- activities[206] = new Array(5,6);
- activities[207] = new Array(33,7);
- activities[208] = new Array(20,0);
- activities[209] = new Array(38,29);
- activities[210] = new Array(0,19);
- activities[211] = new Array(17,19);
- activities[212] = new Array(31,19);
- activities[213] = new Array(7,0);
- activities[214] = new Array(8,19);
- activities[215] = new Array(29,9);
- activities[216] = new Array(21,17);
- activities[217] = new Array(12,9);
- activities[218] = new Array(33,8);
- activities[219] = new Array(38,30);
- activities[220] = new Array(0,20);
- activities[221] = new Array(17,20);
- activities[222] = new Array(31,20);
- activities[223] = new Array(7,0);
- activities[224] = new Array(8,20);
- activities[225] = new Array(29,10);
- activities[226] = new Array(21,18);
- activities[227] = new Array(5,7);
- activities[228] = new Array(1,8);
- activities[229] = new Array(36,0);
- activities[230] = new Array(38,19);
- activities[231] = new Array(0,21);
- activities[232] = new Array(17,21);
- activities[233] = new Array(31,21);
- activities[234] = new Array(7,7);
- activities[235] = new Array(8,21);
- activities[236] = new Array(21,19);
- activities[237] = new Array(33,9);
- activities[238] = new Array(14,1);
- activities[239] = new Array(3,4);
- activities[240] = new Array(20,0);
- activities[241] = new Array(38,30);
- activities[242] = new Array(0,22);
- activities[243] = new Array(20,0);
- activities[244] = new Array(36,0);
- activities[245] = new Array(8,22);
- activities[246] = new Array(21,20);
- activities[247] = new Array(0,23);
-
- k.ready(function(){
+
+ logos;
+
+ activities;
+
+ k.ready(function(){
+
//game logic
function draw(){
var canvas = document.getElementById('ladder');
- if (canvas.getContext){
+ if (canvas.getContext){
var ctx = canvas.getContext('2d');
+ var rows = 1 + (activities.length / 7);
var maxx = 1200;
- var maxy = 16000;
+ var cellsize = 64;
+ var maxy = rows * 2.5 * cellsize;
+ canvas.setAttribute('width', maxx);
+ canvas.setAttribute('height', maxy);
var x = 0;
var y = 0;
var odd = 1;
- var cellsize = 100;
- var xstart = 16 + 2 * cellsize;
- var ystart = maxy - cellsize * 0.5;
- var rows = 1 + activities.length / 3;
+ var xstart = 1.7 * cellsize;
+ var ystart = maxy - cellsize;
var row = 0;
- var cells = 8;
+ var cells = 15;
var cell = 0;
var id = -1;
var ix = 0;
@@ -343,24 +49,30 @@ $(document).ready(
ctx.moveTo(x-cellsize*0.5,y+0.5*cellsize);
ctx.lineTo(x-cellsize*0.2,y+0.25*cellsize);
for(row=0;row<rows;row++){
+ if (activity == activities.length) {
+ break;
+ };
if (row % 2 == 0) {
x = xstart;
} else {
x = xstart + (cells - 1)*cellsize;
- }
+ };
for(cell=0;cell<cells;cell++){
- ctx.strokeRect(x,y,cellsize, cellsize / 2);
- if (cell % 2 == 1) {
- drawlogo(x,y,activity);
- activity = activity + 1;
- }
- if (row % 2 == 0){
- x = x + cellsize;
- } else {
- x = x - cellsize;
+ if (activity < activities.length){
+ ctx.strokeRect(x,y,cellsize, cellsize / 2);
+ if (cell % 2 == 1) {
+ drawlogo(x,y,activity);
+ activity = activity + 1;
+ }
+ if (row % 2 == 0){
+ x = x + cellsize;
+ } else {
+ x = x - cellsize;
+ }
}
}
- if (row + 1 < rows) {
+ if ((row + 1 < rows) &&
+ (activity < activities.length)) {
if (odd == 1) {
ctx.moveTo(x,y);
ctx.arc(x, y-cellsize, cellsize, Math.PI/2, 0, 1);
@@ -381,14 +93,14 @@ $(document).ready(
}
}
y = y - 2.5 * cellsize;
- x = xstart;
+ x = xstart;
}
}
function drawlogo(x, y, activity) {
- id = activities[activity][0]
- ix = activities[activity][1]
+ id = activities[activity][0];
+ ix = activities[activity][1];
if (id == 0){
// draw milestone
ctx.moveTo(x,y);
diff --git a/makeladder.py b/makeladder.py
new file mode 100644
index 0000000..cbed010
--- /dev/null
+++ b/makeladder.py
@@ -0,0 +1,113 @@
+#!/usr/bin/python
+
+#usage: python makeladder.py file.xml
+#assumptions:
+ #cwd contains makeladder.py + path.py
+ #cwd contains folder images which contains the icons (currently .png)
+ #cwd contains file.xml which defines ladder
+ #cwd contains folder js with lesson.js
+ #cwd contains copy of index.html
+ #output is assets.js and activities.js
+from xml.dom.minidom import parse
+from path import path
+import sys
+import logging
+
+logo_prefix = '<html>\n<head>\n<title>Language_1</title>\n'
+logo_prefix = logo_prefix + '<style type="text/css">\n.hiddenPic {display:none;}\n</style>\n'
+logo_prefix = logo_prefix + '<SCRIPT LANGUAGE="JavaScript"><!--\n'
+logo_prefix = logo_prefix + 'function redirect () { window.location.href = "file:///home/tony/Desktop/tony-river/ladder/language_1_ladder.html"; }\n'
+logo_prefix = logo_prefix + '//--></SCRIPT>\n</head>\n\n<body onload="redirect()">\n'
+logo_prefix = logo_prefix + '<h1>English_1</h1>\n<br/>\n<h3>Loading logos</h3>\n'
+
+logo_template = '<img src="images/xxxxx" alt="yyyyy" height="64" width="64" class="hiddenPic">'
+logo_suffix = "</body>\n</html>"
+
+if '__main__' == __name__:
+ # Late import, in case this project becomes a library, never to be run as main again.
+ import optparse
+
+ # Populate our options, -h/--help is already there for you.
+ optp = optparse.OptionParser()
+ optp.add_option('-v', '--verbose', dest='verbose', action='count',
+ help="Increase verbosity (specify multiple times for more)")
+ # Parse the arguments (defaults to parsing sys.argv).
+ opts, args = optp.parse_args()
+
+ # Here would be a good place to check what came in on the command line and
+ # call optp.error("Useful message") to exit if all it not well.
+
+ log_level = logging.WARNING # default
+ if opts.verbose == 1:
+ log_level = logging.INFO
+ elif opts.verbose >= 2:
+ log_level = logging.DEBUG
+
+ # Set up basic configuration, out to stderr with a reasonable default format.
+ logging.basicConfig(level=log_level)
+
+ if len(args) < 1:
+ print 'usage: makeladder file.xml'
+
+ dom = parse(args[0])
+ ladder = dom.getElementsByTagName('ladder')
+ title = str(ladder[0].attributes["id"].value) + '_' + str(ladder[0].attributes["ix"].value)
+ print 'title', title
+ logos = []
+ activities = []
+ ids = {}
+
+ imgs = path('assets/image').files()
+ for img in imgs:
+ logos.append(path(img).name)
+ ids[img.namebase] = len(logos)
+ milestones = dom.getElementsByTagName('milestone')
+ for milestone in milestones:
+ activity_list = milestone.getElementsByTagName('activity')
+ for activity in activity_list:
+ temp = activity.attributes["id"].value
+ id = ids[temp]
+ ix = activity.attributes["ix"].value
+ activities.append((id,ix))
+ activities.append((0,milestone.attributes["ix"].value))
+
+ #new version
+ #create activities.js and assets.js
+ #use standard index.html and lesson.js
+
+ #now create js file for assets
+
+ assets = "var assetList = {image: [\n"
+ for idx in range(len(logos)):
+ pos = logos[idx].find('.')
+ name = logos[idx][:pos]
+ assets = assets + '{name:"' + name + '", file:"' + logos[idx] + '"},\n'
+ assets = assets[:-1]
+ assets = assets + ' \n],\n\n canvas: [\n {name:"ladder", domId:"ladder"}\n ]\n };\n\n'
+
+ assets = assets + 'var logos =[\n'
+ for idx in range(len(logos)):
+ pos1 = logos[idx].find('.')
+ name = logos[idx][:pos1]
+ assets = assets + '"' + name + '",\n'
+ assets = assets + '];\n'
+
+ #now create js file for activities
+
+ activityList = "activities = ["
+ for idx in range(len(activities)):
+ activityList = activityList + '[' + str(activities[idx][0]) + ',' + str(activities[idx][1]) + '],'
+ activityList = activityList + '];\n'
+
+ pth = 'js/activities.js'
+ fout = open(pth, 'w')
+ fout.write(activityList)
+ fout.close()
+
+ #now create js file for assets
+ pth = 'js/assets.js'
+ fout = open(pth, 'w')
+ fout.write(assets)
+ fout.close()
+
+ sys.exit()
diff --git a/path.py b/path.py
new file mode 100755
index 0000000..01c2c04
--- /dev/null
+++ b/path.py
@@ -0,0 +1,971 @@
+""" path.py - An object representing a path to a file or directory.
+
+Example:
+
+from path import path
+d = path('/home/guido/bin')
+for f in d.files('*.py'):
+ f.chmod(0755)
+
+This module requires Python 2.2 or later.
+
+
+URL: http://www.jorendorff.com/articles/python/path
+Author: Jason Orendorff <jason.orendorff\x40gmail\x2ecom> (and others - see the url!)
+Date: 9 Mar 2007
+"""
+
+
+# TODO
+# - Tree-walking functions don't avoid symlink loops. Matt Harrison
+# sent me a patch for this.
+# - Bug in write_text(). It doesn't support Universal newline mode.
+# - Better error message in listdir() when self isn't a
+# directory. (On Windows, the error message really sucks.)
+# - Make sure everything has a good docstring.
+# - Add methods for regex find and replace.
+# - guess_content_type() method?
+# - Perhaps support arguments to touch().
+
+from __future__ import generators
+
+import sys, warnings, os, fnmatch, glob, shutil, codecs, md5
+
+__version__ = '2.2'
+__all__ = ['path']
+
+# Platform-specific support for path.owner
+if os.name == 'nt':
+ try:
+ import win32security
+ except ImportError:
+ win32security = None
+else:
+ try:
+ import pwd
+ except ImportError:
+ pwd = None
+
+# Pre-2.3 support. Are unicode filenames supported?
+_base = str
+_getcwd = os.getcwd
+try:
+ if os.path.supports_unicode_filenames:
+ _base = unicode
+ _getcwd = os.getcwdu
+except AttributeError:
+ pass
+
+# Pre-2.3 workaround for booleans
+try:
+ True, False
+except NameError:
+ True, False = 1, 0
+
+# Pre-2.3 workaround for basestring.
+try:
+ basestring
+except NameError:
+ basestring = (str, unicode)
+
+# Universal newline support
+_textmode = 'r'
+if hasattr(file, 'newlines'):
+ _textmode = 'U'
+
+
+class TreeWalkWarning(Warning):
+ pass
+
+class path(_base):
+ """ Represents a filesystem path.
+
+ For documentation on individual methods, consult their
+ counterparts in os.path.
+ """
+
+ # --- Special Python methods.
+
+ def __repr__(self):
+ return 'path(%s)' % _base.__repr__(self)
+
+ # Adding a path and a string yields a path.
+ def __add__(self, more):
+ try:
+ resultStr = _base.__add__(self, more)
+ except TypeError: #Python bug
+ resultStr = NotImplemented
+ if resultStr is NotImplemented:
+ return resultStr
+ return self.__class__(resultStr)
+
+ def __radd__(self, other):
+ if isinstance(other, basestring):
+ return self.__class__(other.__add__(self))
+ else:
+ return NotImplemented
+
+ # The / operator joins paths.
+ def __div__(self, rel):
+ """ fp.__div__(rel) == fp / rel == fp.joinpath(rel)
+
+ Join two path components, adding a separator character if
+ needed.
+ """
+ return self.__class__(os.path.join(self, rel))
+
+ # Make the / operator work even when true division is enabled.
+ __truediv__ = __div__
+
+ def getcwd(cls):
+ """ Return the current working directory as a path object. """
+ return cls(_getcwd())
+ getcwd = classmethod(getcwd)
+
+
+ # --- Operations on path strings.
+
+ isabs = os.path.isabs
+ def abspath(self): return self.__class__(os.path.abspath(self))
+ def normcase(self): return self.__class__(os.path.normcase(self))
+ def normpath(self): return self.__class__(os.path.normpath(self))
+ def realpath(self): return self.__class__(os.path.realpath(self))
+ def expanduser(self): return self.__class__(os.path.expanduser(self))
+ def expandvars(self): return self.__class__(os.path.expandvars(self))
+ def dirname(self): return self.__class__(os.path.dirname(self))
+ basename = os.path.basename
+
+ def expand(self):
+ """ Clean up a filename by calling expandvars(),
+ expanduser(), and normpath() on it.
+
+ This is commonly everything needed to clean up a filename
+ read from a configuration file, for example.
+ """
+ return self.expandvars().expanduser().normpath()
+
+ def _get_namebase(self):
+ base, ext = os.path.splitext(self.name)
+ return base
+
+ def _get_ext(self):
+ f, ext = os.path.splitext(_base(self))
+ return ext
+
+ def _get_drive(self):
+ drive, r = os.path.splitdrive(self)
+ return self.__class__(drive)
+
+ parent = property(
+ dirname, None, None,
+ """ This path's parent directory, as a new path object.
+
+ For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')
+ """)
+
+ name = property(
+ basename, None, None,
+ """ The name of this file or directory without the full path.
+
+ For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'
+ """)
+
+ namebase = property(
+ _get_namebase, None, None,
+ """ The same as path.name, but with one file extension stripped off.
+
+ For example, path('/home/guido/python.tar.gz').name == 'python.tar.gz',
+ but path('/home/guido/python.tar.gz').namebase == 'python.tar'
+ """)
+
+ ext = property(
+ _get_ext, None, None,
+ """ The file extension, for example '.py'. """)
+
+ drive = property(
+ _get_drive, None, None,
+ """ The drive specifier, for example 'C:'.
+ This is always empty on systems that don't use drive specifiers.
+ """)
+
+ def splitpath(self):
+ """ p.splitpath() -> Return (p.parent, p.name). """
+ parent, child = os.path.split(self)
+ return self.__class__(parent), child
+
+ def splitdrive(self):
+ """ p.splitdrive() -> Return (p.drive, <the rest of p>).
+
+ Split the drive specifier from this path. If there is
+ no drive specifier, p.drive is empty, so the return value
+ is simply (path(''), p). This is always the case on Unix.
+ """
+ drive, rel = os.path.splitdrive(self)
+ return self.__class__(drive), rel
+
+ def splitext(self):
+ """ p.splitext() -> Return (p.stripext(), p.ext).
+
+ Split the filename extension from this path and return
+ the two parts. Either part may be empty.
+
+ The extension is everything from '.' to the end of the
+ last path segment. This has the property that if
+ (a, b) == p.splitext(), then a + b == p.
+ """
+ filename, ext = os.path.splitext(self)
+ return self.__class__(filename), ext
+
+ def stripext(self):
+ """ p.stripext() -> Remove one file extension from the path.
+
+ For example, path('/home/guido/python.tar.gz').stripext()
+ returns path('/home/guido/python.tar').
+ """
+ return self.splitext()[0]
+
+ if hasattr(os.path, 'splitunc'):
+ def splitunc(self):
+ unc, rest = os.path.splitunc(self)
+ return self.__class__(unc), rest
+
+ def _get_uncshare(self):
+ unc, r = os.path.splitunc(self)
+ return self.__class__(unc)
+
+ uncshare = property(
+ _get_uncshare, None, None,
+ """ The UNC mount point for this path.
+ This is empty for paths on local drives. """)
+
+ def joinpath(self, *args):
+ """ Join two or more path components, adding a separator
+ character (os.sep) if needed. Returns a new path
+ object.
+ """
+ return self.__class__(os.path.join(self, *args))
+
+ def splitall(self):
+ r""" Return a list of the path components in this path.
+
+ The first item in the list will be a path. Its value will be
+ either os.curdir, os.pardir, empty, or the root directory of
+ this path (for example, '/' or 'C:\\'). The other items in
+ the list will be strings.
+
+ path.path.joinpath(*result) will yield the original path.
+ """
+ parts = []
+ loc = self
+ while loc != os.curdir and loc != os.pardir:
+ prev = loc
+ loc, child = prev.splitpath()
+ if loc == prev:
+ break
+ parts.append(child)
+ parts.append(loc)
+ parts.reverse()
+ return parts
+
+ def relpath(self):
+ """ Return this path as a relative path,
+ based from the current working directory.
+ """
+ cwd = self.__class__(os.getcwd())
+ return cwd.relpathto(self)
+
+ def relpathto(self, dest):
+ """ Return a relative path from self to dest.
+
+ If there is no relative path from self to dest, for example if
+ they reside on different drives in Windows, then this returns
+ dest.abspath().
+ """
+ origin = self.abspath()
+ dest = self.__class__(dest).abspath()
+
+ orig_list = origin.normcase().splitall()
+ # Don't normcase dest! We want to preserve the case.
+ dest_list = dest.splitall()
+
+ if orig_list[0] != os.path.normcase(dest_list[0]):
+ # Can't get here from there.
+ return dest
+
+ # Find the location where the two paths start to differ.
+ i = 0
+ for start_seg, dest_seg in zip(orig_list, dest_list):
+ if start_seg != os.path.normcase(dest_seg):
+ break
+ i += 1
+
+ # Now i is the point where the two paths diverge.
+ # Need a certain number of "os.pardir"s to work up
+ # from the origin to the point of divergence.
+ segments = [os.pardir] * (len(orig_list) - i)
+ # Need to add the diverging part of dest_list.
+ segments += dest_list[i:]
+ if len(segments) == 0:
+ # If they happen to be identical, use os.curdir.
+ relpath = os.curdir
+ else:
+ relpath = os.path.join(*segments)
+ return self.__class__(relpath)
+
+ # --- Listing, searching, walking, and matching
+
+ def listdir(self, pattern=None):
+ """ D.listdir() -> List of items in this directory.
+
+ Use D.files() or D.dirs() instead if you want a listing
+ of just files or just subdirectories.
+
+ The elements of the list are path objects.
+
+ With the optional 'pattern' argument, this only lists
+ items whose names match the given pattern.
+ """
+ names = os.listdir(self)
+ if pattern is not None:
+ names = fnmatch.filter(names, pattern)
+ return [self / child for child in names]
+
+ def dirs(self, pattern=None):
+ """ D.dirs() -> List of this directory's subdirectories.
+
+ The elements of the list are path objects.
+ This does not walk recursively into subdirectories
+ (but see path.walkdirs).
+
+ With the optional 'pattern' argument, this only lists
+ directories whose names match the given pattern. For
+ example, d.dirs('build-*').
+ """
+ return [p for p in self.listdir(pattern) if p.isdir()]
+
+ def files(self, pattern=None):
+ """ D.files() -> List of the files in this directory.
+
+ The elements of the list are path objects.
+ This does not walk into subdirectories (see path.walkfiles).
+
+ With the optional 'pattern' argument, this only lists files
+ whose names match the given pattern. For example,
+ d.files('*.pyc').
+ """
+
+ return [p for p in self.listdir(pattern) if p.isfile()]
+
+ def walk(self, pattern=None, errors='strict'):
+ """ D.walk() -> iterator over files and subdirs, recursively.
+
+ The iterator yields path objects naming each child item of
+ this directory and its descendants. This requires that
+ D.isdir().
+
+ This performs a depth-first traversal of the directory tree.
+ Each directory is returned just before all its children.
+
+ The errors= keyword argument controls behavior when an
+ error occurs. The default is 'strict', which causes an
+ exception. The other allowed values are 'warn', which
+ reports the error via warnings.warn(), and 'ignore'.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ childList = self.listdir()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in childList:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ try:
+ isdir = child.isdir()
+ except Exception:
+ if errors == 'ignore':
+ isdir = False
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to access '%s': %s"
+ % (child, sys.exc_info()[1]),
+ TreeWalkWarning)
+ isdir = False
+ else:
+ raise
+
+ if isdir:
+ for item in child.walk(pattern, errors):
+ yield item
+
+ def walkdirs(self, pattern=None, errors='strict'):
+ """ D.walkdirs() -> iterator over subdirs, recursively.
+
+ With the optional 'pattern' argument, this yields only
+ directories whose names match the given pattern. For
+ example, mydir.walkdirs('*test') yields only directories
+ with names ending in 'test'.
+
+ The errors= keyword argument controls behavior when an
+ error occurs. The default is 'strict', which causes an
+ exception. The other allowed values are 'warn', which
+ reports the error via warnings.warn(), and 'ignore'.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ dirs = self.dirs()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in dirs:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ for subsubdir in child.walkdirs(pattern, errors):
+ yield subsubdir
+
+ def walkfiles(self, pattern=None, errors='strict'):
+ """ D.walkfiles() -> iterator over files in D, recursively.
+
+ The optional argument, pattern, limits the results to files
+ with names that match the pattern. For example,
+ mydir.walkfiles('*.tmp') yields only files with the .tmp
+ extension.
+ """
+ if errors not in ('strict', 'warn', 'ignore'):
+ raise ValueError("invalid errors parameter")
+
+ try:
+ childList = self.listdir()
+ except Exception:
+ if errors == 'ignore':
+ return
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to list directory '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ return
+ else:
+ raise
+
+ for child in childList:
+ try:
+ isfile = child.isfile()
+ isdir = not isfile and child.isdir()
+ except:
+ if errors == 'ignore':
+ continue
+ elif errors == 'warn':
+ warnings.warn(
+ "Unable to access '%s': %s"
+ % (self, sys.exc_info()[1]),
+ TreeWalkWarning)
+ continue
+ else:
+ raise
+
+ if isfile:
+ if pattern is None or child.fnmatch(pattern):
+ yield child
+ elif isdir:
+ for f in child.walkfiles(pattern, errors):
+ yield f
+
+ def fnmatch(self, pattern):
+ """ Return True if self.name matches the given pattern.
+
+ pattern - A filename pattern with wildcards,
+ for example '*.py'.
+ """
+ return fnmatch.fnmatch(self.name, pattern)
+
+ def glob(self, pattern):
+ """ Return a list of path objects that match the pattern.
+
+ pattern - a path relative to this directory, with wildcards.
+
+ For example, path('/users').glob('*/bin/*') returns a list
+ of all the files users have in their bin directories.
+ """
+ cls = self.__class__
+ return [cls(s) for s in glob.glob(_base(self / pattern))]
+
+
+ # --- Reading or writing an entire file at once.
+
+ def open(self, mode='r'):
+ """ Open this file. Return a file object. """
+ return file(self, mode)
+
+ def bytes(self):
+ """ Open this file, read all bytes, return them as a string. """
+ f = self.open('rb')
+ try:
+ return f.read()
+ finally:
+ f.close()
+
+ def write_bytes(self, bytes, append=False):
+ """ Open this file and write the given bytes to it.
+
+ Default behavior is to overwrite any existing file.
+ Call p.write_bytes(bytes, append=True) to append instead.
+ """
+ if append:
+ mode = 'ab'
+ else:
+ mode = 'wb'
+ f = self.open(mode)
+ try:
+ f.write(bytes)
+ finally:
+ f.close()
+
+ def text(self, encoding=None, errors='strict'):
+ r""" Open this file, read it in, return the content as a string.
+
+ This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r'
+ are automatically translated to '\n'.
+
+ Optional arguments:
+
+ encoding - The Unicode encoding (or character set) of
+ the file. If present, the content of the file is
+ decoded and returned as a unicode object; otherwise
+ it is returned as an 8-bit str.
+ errors - How to handle Unicode errors; see help(str.decode)
+ for the options. Default is 'strict'.
+ """
+ if encoding is None:
+ # 8-bit
+ f = self.open(_textmode)
+ try:
+ return f.read()
+ finally:
+ f.close()
+ else:
+ # Unicode
+ f = codecs.open(self, 'r', encoding, errors)
+ # (Note - Can't use 'U' mode here, since codecs.open
+ # doesn't support 'U' mode, even in Python 2.3.)
+ try:
+ t = f.read()
+ finally:
+ f.close()
+ return (t.replace(u'\r\n', u'\n')
+ .replace(u'\r\x85', u'\n')
+ .replace(u'\r', u'\n')
+ .replace(u'\x85', u'\n')
+ .replace(u'\u2028', u'\n'))
+
+ def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False):
+ r""" Write the given text to this file.
+
+ The default behavior is to overwrite any existing file;
+ to append instead, use the 'append=True' keyword argument.
+
+ There are two differences between path.write_text() and
+ path.write_bytes(): newline handling and Unicode handling.
+ See below.
+
+ Parameters:
+
+ - text - str/unicode - The text to be written.
+
+ - encoding - str - The Unicode encoding that will be used.
+ This is ignored if 'text' isn't a Unicode string.
+
+ - errors - str - How to handle Unicode encoding errors.
+ Default is 'strict'. See help(unicode.encode) for the
+ options. This is ignored if 'text' isn't a Unicode
+ string.
+
+ - linesep - keyword argument - str/unicode - The sequence of
+ characters to be used to mark end-of-line. The default is
+ os.linesep. You can also specify None; this means to
+ leave all newlines as they are in 'text'.
+
+ - append - keyword argument - bool - Specifies what to do if
+ the file already exists (True: append to the end of it;
+ False: overwrite it.) The default is False.
+
+
+ --- Newline handling.
+
+ write_text() converts all standard end-of-line sequences
+ ('\n', '\r', and '\r\n') to your platform's default end-of-line
+ sequence (see os.linesep; on Windows, for example, the
+ end-of-line marker is '\r\n').
+
+ If you don't like your platform's default, you can override it
+ using the 'linesep=' keyword argument. If you specifically want
+ write_text() to preserve the newlines as-is, use 'linesep=None'.
+
+ This applies to Unicode text the same as to 8-bit text, except
+ there are three additional standard Unicode end-of-line sequences:
+ u'\x85', u'\r\x85', and u'\u2028'.
+
+ (This is slightly different from when you open a file for
+ writing with fopen(filename, "w") in C or file(filename, 'w')
+ in Python.)
+
+
+ --- Unicode
+
+ If 'text' isn't Unicode, then apart from newline handling, the
+ bytes are written verbatim to the file. The 'encoding' and
+ 'errors' arguments are not used and must be omitted.
+
+ If 'text' is Unicode, it is first converted to bytes using the
+ specified 'encoding' (or the default encoding if 'encoding'
+ isn't specified). The 'errors' argument applies only to this
+ conversion.
+
+ """
+ if isinstance(text, unicode):
+ if linesep is not None:
+ # Convert all standard end-of-line sequences to
+ # ordinary newline characters.
+ text = (text.replace(u'\r\n', u'\n')
+ .replace(u'\r\x85', u'\n')
+ .replace(u'\r', u'\n')
+ .replace(u'\x85', u'\n')
+ .replace(u'\u2028', u'\n'))
+ text = text.replace(u'\n', linesep)
+ if encoding is None:
+ encoding = sys.getdefaultencoding()
+ bytes = text.encode(encoding, errors)
+ else:
+ # It is an error to specify an encoding if 'text' is
+ # an 8-bit string.
+ assert encoding is None
+
+ if linesep is not None:
+ text = (text.replace('\r\n', '\n')
+ .replace('\r', '\n'))
+ bytes = text.replace('\n', linesep)
+
+ self.write_bytes(bytes, append)
+
+ def lines(self, encoding=None, errors='strict', retain=True):
+ r""" Open this file, read all lines, return them in a list.
+
+ Optional arguments:
+ encoding - The Unicode encoding (or character set) of
+ the file. The default is None, meaning the content
+ of the file is read as 8-bit characters and returned
+ as a list of (non-Unicode) str objects.
+ errors - How to handle Unicode errors; see help(str.decode)
+ for the options. Default is 'strict'
+ retain - If true, retain newline characters; but all newline
+ character combinations ('\r', '\n', '\r\n') are
+ translated to '\n'. If false, newline characters are
+ stripped off. Default is True.
+
+ This uses 'U' mode in Python 2.3 and later.
+ """
+ if encoding is None and retain:
+ f = self.open(_textmode)
+ try:
+ return f.readlines()
+ finally:
+ f.close()
+ else:
+ return self.text(encoding, errors).splitlines(retain)
+
+ def write_lines(self, lines, encoding=None, errors='strict',
+ linesep=os.linesep, append=False):
+ r""" Write the given lines of text to this file.
+
+ By default this overwrites any existing file at this path.
+
+ This puts a platform-specific newline sequence on every line.
+ See 'linesep' below.
+
+ lines - A list of strings.
+
+ encoding - A Unicode encoding to use. This applies only if
+ 'lines' contains any Unicode strings.
+
+ errors - How to handle errors in Unicode encoding. This
+ also applies only to Unicode strings.
+
+ linesep - The desired line-ending. This line-ending is
+ applied to every line. If a line already has any
+ standard line ending ('\r', '\n', '\r\n', u'\x85',
+ u'\r\x85', u'\u2028'), that will be stripped off and
+ this will be used instead. The default is os.linesep,
+ which is platform-dependent ('\r\n' on Windows, '\n' on
+ Unix, etc.) Specify None to write the lines as-is,
+ like file.writelines().
+
+ Use the keyword argument append=True to append lines to the
+ file. The default is to overwrite the file. Warning:
+ When you use this with Unicode data, if the encoding of the
+ existing data in the file is different from the encoding
+ you specify with the encoding= parameter, the result is
+ mixed-encoding data, which can really confuse someone trying
+ to read the file later.
+ """
+ if append:
+ mode = 'ab'
+ else:
+ mode = 'wb'
+ f = self.open(mode)
+ try:
+ for line in lines:
+ isUnicode = isinstance(line, unicode)
+ if linesep is not None:
+ # Strip off any existing line-end and add the
+ # specified linesep string.
+ if isUnicode:
+ if line[-2:] in (u'\r\n', u'\x0d\x85'):
+ line = line[:-2]
+ elif line[-1:] in (u'\r', u'\n',
+ u'\x85', u'\u2028'):
+ line = line[:-1]
+ else:
+ if line[-2:] == '\r\n':
+ line = line[:-2]
+ elif line[-1:] in ('\r', '\n'):
+ line = line[:-1]
+ line += linesep
+ if isUnicode:
+ if encoding is None:
+ encoding = sys.getdefaultencoding()
+ line = line.encode(encoding, errors)
+ f.write(line)
+ finally:
+ f.close()
+
+ def read_md5(self):
+ """ Calculate the md5 hash for this file.
+
+ This reads through the entire file.
+ """
+ f = self.open('rb')
+ try:
+ m = md5.new()
+ while True:
+ d = f.read(8192)
+ if not d:
+ break
+ m.update(d)
+ finally:
+ f.close()
+ return m.digest()
+
+ # --- Methods for querying the filesystem.
+
+ exists = os.path.exists
+ isdir = os.path.isdir
+ isfile = os.path.isfile
+ islink = os.path.islink
+ ismount = os.path.ismount
+
+ if hasattr(os.path, 'samefile'):
+ samefile = os.path.samefile
+
+ getatime = os.path.getatime
+ atime = property(
+ getatime, None, None,
+ """ Last access time of the file. """)
+
+ getmtime = os.path.getmtime
+ mtime = property(
+ getmtime, None, None,
+ """ Last-modified time of the file. """)
+
+ if hasattr(os.path, 'getctime'):
+ getctime = os.path.getctime
+ ctime = property(
+ getctime, None, None,
+ """ Creation time of the file. """)
+
+ getsize = os.path.getsize
+ size = property(
+ getsize, None, None,
+ """ Size of the file, in bytes. """)
+
+ if hasattr(os, 'access'):
+ def access(self, mode):
+ """ Return true if current user has access to this path.
+
+ mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK
+ """
+ return os.access(self, mode)
+
+ def stat(self):
+ """ Perform a stat() system call on this path. """
+ return os.stat(self)
+
+ def lstat(self):
+ """ Like path.stat(), but do not follow symbolic links. """
+ return os.lstat(self)
+
+ def get_owner(self):
+ r""" Return the name of the owner of this file or directory.
+
+ This follows symbolic links.
+
+ On Windows, this returns a name of the form ur'DOMAIN\User Name'.
+ On Windows, a group can own a file or directory.
+ """
+ if os.name == 'nt':
+ if win32security is None:
+ raise Exception("path.owner requires win32all to be installed")
+ desc = win32security.GetFileSecurity(
+ self, win32security.OWNER_SECURITY_INFORMATION)
+ sid = desc.GetSecurityDescriptorOwner()
+ account, domain, typecode = win32security.LookupAccountSid(None, sid)
+ return domain + u'\\' + account
+ else:
+ if pwd is None:
+ raise NotImplementedError("path.owner is not implemented on this platform.")
+ st = self.stat()
+ return pwd.getpwuid(st.st_uid).pw_name
+
+ owner = property(
+ get_owner, None, None,
+ """ Name of the owner of this file or directory. """)
+
+ if hasattr(os, 'statvfs'):
+ def statvfs(self):
+ """ Perform a statvfs() system call on this path. """
+ return os.statvfs(self)
+
+ if hasattr(os, 'pathconf'):
+ def pathconf(self, name):
+ return os.pathconf(self, name)
+
+
+ # --- Modifying operations on files and directories
+
+ def utime(self, times):
+ """ Set the access and modified times of this file. """
+ os.utime(self, times)
+
+ def chmod(self, mode):
+ os.chmod(self, mode)
+
+ if hasattr(os, 'chown'):
+ def chown(self, uid, gid):
+ os.chown(self, uid, gid)
+
+ def rename(self, new):
+ os.rename(self, new)
+
+ def renames(self, new):
+ os.renames(self, new)
+
+
+ # --- Create/delete operations on directories
+
+ def mkdir(self, mode=0777):
+ os.mkdir(self, mode)
+
+ def makedirs(self, mode=0777):
+ os.makedirs(self, mode)
+
+ def rmdir(self):
+ os.rmdir(self)
+
+ def removedirs(self):
+ os.removedirs(self)
+
+
+ # --- Modifying operations on files
+
+ def touch(self):
+ """ Set the access/modified times of this file to the current time.
+ Create the file if it does not exist.
+ """
+ fd = os.open(self, os.O_WRONLY | os.O_CREAT, 0666)
+ os.close(fd)
+ os.utime(self, None)
+
+ def remove(self):
+ os.remove(self)
+
+ def unlink(self):
+ os.unlink(self)
+
+
+ # --- Links
+
+ if hasattr(os, 'link'):
+ def link(self, newpath):
+ """ Create a hard link at 'newpath', pointing to this file. """
+ os.link(self, newpath)
+
+ if hasattr(os, 'symlink'):
+ def symlink(self, newlink):
+ """ Create a symbolic link at 'newlink', pointing here. """
+ os.symlink(self, newlink)
+
+ if hasattr(os, 'readlink'):
+ def readlink(self):
+ """ Return the path to which this symbolic link points.
+
+ The result may be an absolute or a relative path.
+ """
+ return self.__class__(os.readlink(self))
+
+ def readlinkabs(self):
+ """ Return the path to which this symbolic link points.
+
+ The result is always an absolute path.
+ """
+ p = self.readlink()
+ if p.isabs():
+ return p
+ else:
+ return (self.parent / p).abspath()
+
+
+ # --- High-level functions from shutil
+
+ copyfile = shutil.copyfile
+ copymode = shutil.copymode
+ copystat = shutil.copystat
+ copy = shutil.copy
+ copy2 = shutil.copy2
+ copytree = shutil.copytree
+ if hasattr(shutil, 'move'):
+ move = shutil.move
+ rmtree = shutil.rmtree
+
+
+ # --- Special stuff from os
+
+ if hasattr(os, 'chroot'):
+ def chroot(self):
+ os.chroot(self)
+
+ if hasattr(os, 'startfile'):
+ def startfile(self):
+ os.startfile(self)
+
+
diff --git a/test_ladder.xml b/test_ladder.xml
new file mode 100644
index 0000000..50aefab
--- /dev/null
+++ b/test_ladder.xml
@@ -0,0 +1,92 @@
+<ladder id = "language" ix = "1">
+<milestone ix='1'>
+<activity id='rabbit' ix='1'/>
+<activity id='swing' ix='1'/>
+<activity id='camel' ix='1'/>
+<activity id='rabbit' ix='1'/>
+<activity id='rabbit' ix='1'/>
+<activity id='swing' ix='1'/>
+<activity id='rabbit' ix='1'/>
+<activity id='camel' ix='1'/>
+</milestone>
+<milestone ix='2'>
+<activity id='rabbit' ix='2'/>
+<activity id='swing' ix='2'/>
+<activity id='camel' ix='2'/>
+<activity id='rabbit' ix='2'/>
+<activity id='rabbit' ix='2'/>
+<activity id='swing' ix='2'/>
+<activity id='camel' ix='2'/>
+<activity id='rabbit' ix='2'/>
+</milestone>
+<milestone ix='3'>
+<activity id='rabbit' ix='3'/>
+<activity id='swing' ix='3'/>
+<activity id='rabbit' ix='3'/>
+<activity id='swing' ix='3'/>
+<activity id='rabbit' ix='3'/>
+<activity id='camel' ix='3'/>
+<activity id='camel' ix='3'/>
+<activity id='rabbit' ix='3'/>
+</milestone>
+<milestone ix='4'>
+<activity id='rabbit' ix='4'/>
+<activity id='swing' ix='4'/>
+<activity id='camel' ix='4'/>
+<activity id='rabbit' ix='4'/>
+<activity id='rabbit' ix='4'/>
+<activity id='swing' ix='4'/>
+<activity id='rabbit' ix='4'/>
+<activity id='camel' ix='4'/>
+</milestone>
+<milestone ix='5'>
+<activity id='rabbit' ix='5'/>
+<activity id='swing' ix='5'/>
+<activity id='rabbit' ix='5'/>
+<activity id='swing' ix='5'/>
+<activity id='camel' ix='5'/>
+<activity id='rabbit' ix='5'/>
+<activity id='rabbit' ix='5'/>
+<activity id='camel' ix='5'/>
+</milestone>
+<milestone ix='6'>
+<activity id='rabbit' ix='6'/>
+<activity id='swing' ix='6'/>
+<activity id='camel' ix='6'/>
+<activity id='rabbit' ix='6'/>
+<activity id='rabbit' ix='6'/>
+<activity id='swing' ix='6'/>
+<activity id='rabbit' ix='6'/>
+<activity id='camel' ix='6'/>
+</milestone>
+<milestone ix='7'>
+<activity id='rabbit' ix='7'/>
+<activity id='swing' ix='7'/>
+<activity id='rabbit' ix='7'/>
+<activity id='swing' ix='7'/>
+<activity id='rabbit' ix='7'/>
+<activity id='camel' ix='7'/>
+<activity id='rabbit' ix='7'/>
+<activity id='camel' ix='7'/>
+</milestone>
+<milestone ix='8'>
+<activity id='rabbit' ix='8'/>
+<activity id='swing' ix='8'/>
+<activity id='camel' ix='8'/>
+<activity id='rabbit' ix='8'/>
+<activity id='rabbit' ix='8'/>
+<activity id='swing' ix='8'/>
+<activity id='rabbit' ix='8'/>
+<activity id='camel' ix='8'/>
+</milestone>
+<milestone ix='9'>
+<activity id='rabbit' ix='9'/>
+<activity id='rabbit' ix='9'/>
+<activity id='rabbit' ix='9'/>
+<activity id='swing' ix='9'/>
+<activity id='camel' ix='9'/>
+<activity id='swing' ix='9'/>
+<activity id='rabbit' ix='9'/>
+<activity id='camel' ix='9'/>
+</milestone>
+</ladder>