Permalink
Browse files

Added a script to sort xml event files

Also sorted the sample event file
  • Loading branch information...
1 parent cf62666 commit d0406add8afe1029d822da34b6151d2506e51828 @rictic committed Aug 27, 2008
Showing with 34 additions and 5 deletions.
  1. +6 −0 convert_logs/config.template
  2. +25 −0 convert_logs/sort_code_swarm_input.py
  3. +2 −4 data/sample-repevents.xml
  4. +1 −1 data/sample.config
@@ -83,5 +83,11 @@ PersonLife=255
# Force calculation algorithms (PhysicsEngineLegacy, PhysicsEngineSimple...) :
PhysicsEngineSelection=PhysicsEngineChaotic
+#Is the input xml sorted by date? It's faster and uses much less memory if it is
+IsInputSorted=true
+# - All of the given scripts for producing repository xml files produce sorted data
+# - Please file a bug if one doesn't
+
+
# OpenGL is experimental. Use at your own risk.
UseOpenGL=true
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+
+#sorts a code_swarm xml file
+#assumes: one <event> element per line
+# the string "<event" is in each <event> line and only in <event> lines
+# the xml isn't pathological
+
+import sys, re
+
+try:
+ xml_lines = open(sys.argv[1])
+except Exception, e:
+ xml_lines = sys.stdin
+
+xml_lines = filter(lambda line: "<event" in line, xml_lines)
+
+date_extractor = re.compile(r".*date\s*=\s*(\'|\")(\d+)(\'|\").*")
+def get_date_value(line):
+ return int(date_extractor.search(line).group(2))
+xml_lines.sort(key=get_date_value)
+
+print """<?xml version="1.0"?>
+<file_events>
+%s
+</file_events> """ % "".join(xml_lines)
@@ -1,6 +1,4 @@
<?xml version="1.0"?>
-<!-- One commit per day for one month by a documenter and programmer. -->
-
<file_events>
<event filename="/src/hello1.c" date="0" author="programmer" />
<event filename="/docs/COPYING" date="0" author="documenter" />
@@ -132,9 +130,9 @@
<event filename="/src1/hello9.c" date="5325000000" author="programmer" />
<event filename="/src1/hello10.c" date="5345000000" author="helper" />
<event filename="/src1/hello12.c" date="5345000000" author="helper" />
- <event filename="/src1/hello1.c" date="5416000000" author="helper" />
<event filename="/docs/README" date="5395000000" author="documenter" />
<event filename="/src2/hello13.c" date="5398000000" author="helper" />
+ <event filename="/src1/hello1.c" date="5416000000" author="helper" />
<event filename="/src2/hello2.c" date="5416000000" author="programmer" />
<event filename="/src2/hello3.c" date="5416000000" author="programmer" />
<event filename="/src2/hello4.c" date="5416000000" author="programmer" />
@@ -173,5 +171,5 @@
<event filename="/src/hello5.c" date="6130000000" author="helper" />
<event filename="/src/hello10.c" date="6130000000" author="helper" />
<event filename="/src/hello12.c" date="6195000000" author="helper" />
-</file_events>
+</file_events>
View
@@ -119,7 +119,7 @@ PhysicsEngineConfigDir=physics_engine
PhysicsEngineSelection=PhysicsEngineLegacy
#Is the input xml sorted by date? It's faster and uses much less memory if it is
-IsInputSorted=false
+IsInputSorted=true
# OpenGL is experimental. Use at your own risk.
UseOpenGL=false

0 comments on commit d0406ad

Please sign in to comment.