22 sphinx-quickstart on Sun May 01 12:39:48 2011.
33
44
5- sc2reader Official Documentation
5+ sc2reader Documentation
66=====================================
77
8- Stuff in here...
8+ sc2reader is a library for extracting game information from Starcraft II
9+ replay files into a structured replay object. sc2reader aims to give anyone
10+ and everyone the power to construct their own tools and hack on their own
11+ Starcraft II projects under the open MIT license.
12+
13+ This document is a work in progress and an attempt to document the use and
14+ configuration of sc2reader as well as the data that it makes available. I'll
15+ try to keep it up to date and fill out some of the missing sections as time
16+ goes on. While this document will hopefully give you an idea how sc2reader works
17+ there is no substitute for reading the source code. If you plan on seriously
18+ using the library please feel welcome to ask questions in #sc2reader on FreeNode
19+ (IRC) or on the `mailing list `_. I'd be happy to help you out.
20+
21+ .. _mailing list : http://groups.google.com/group/sc2reader
922
1023Use and Configuration
1124=======================
@@ -70,7 +83,7 @@ replay parser and processor. This can be used to effect scanning of the file
7083tree, the output and logging destination, and the fullness of the parsing. In
7184the example above, we have restricted the file set to a partial parse and
7285excluded the replay.game.events file from the parsing process. While sc2reader
73- doesn't support custom games, by restricting the fileset it can successfully
86+ doesn't support custom games, by restricting the file set it can successfully
7487read custom games to get non-event related information including summary game
7588information as well as a general profile of the players.
7689
@@ -125,54 +138,76 @@ Options
125138
126139 Its primary purpose is to allow developers to push post processing back
127140 into the sc2reader module. It can also be used as a final gateway for
128- transforming the replay datastructure into something more useful for your
141+ transforming the replay data structure into something more useful for your
129142 purposes. Eventually sc2reader will come with a small contrib module with
130143 useful post-processing tasks out of the box.
131144
132145.. attribute :: debug
133146
134- pass
147+ *Default: False *
148+
149+ When enabled this will make more information available for debugging. Right
150+ now all this does is tack a ``bytes `` attribute onto all the parsed events
151+ so that their byte code can be inspected post replay parsing.
135152
136153.. attribute :: verbose
137154
138155 *Default: False *
139156
140- The verbose option can be used to get a detailed readout of the replay
141- parsing progress. **Experimental option **
142-
143- .. attribute :: parse_events
157+ The verbose option can be used to get a more detailed readout of the replay
158+ parsing progress. Currently this will only print the file name being parsed
159+ during read _ calls and not much else.
144160
145- pass
161+ .. attribute :: recursive
146162
147- .. attribute :: include_regex
163+ * Default: True *
148164
149- pass
165+ When scanning for files, do so recursively.
150166
151- .. attribute :: exclude_dirs
167+ .. attribute :: depth
152168
153- pass
169+ * Default: -1 *
154170
155- .. attribute :: recursive
171+ When scanning for files recursively, limit the depth of recursion. The default,
172+ -1, puts no limit on the recursion.
156173
157- pass
174+ .. attribute :: exclude_dirs
158175
159- .. attribute :: depth
176+ * Default: [] *
160177
161- pass
178+ A list of directory names to exclude if they are encountered during a
179+ recursive scan.
162180
163181.. attribute :: follow_symlinks
164182
165- pass
183+ *Default: True *
184+
185+ When scanning for files with the read _ function this flag instructs sc2reader
186+ to follow symlinks.
166187
167188.. attribute :: parse
168189
169190 *Default: sc2reader.config.files.all *
170191
171- TODO: Fill this in
192+ Indicates which files should be parsed out of the replay (all replays are
193+ actually archives; like a zip file). While by default we parse all parsable
194+ files you might have need to parse only a subset of them because you either
195+ have a need for speed (the replay.game.events file takes a long time) or
196+ because you are dealing with custom maps where the replay.game.events file
197+ cannot be parsed.
198+
199+ The most common alternate value to use is ``sc2reader.config.files.partial ``
200+ which excludes the replay.game.events file from the processing. Other built
201+ in options are available and, if you wish, you can supply your own list.
172202
173203.. attribute :: apply
174204
175- pass
205+ *Default: False *
206+
207+ A flag for whether or not sc2reader should attempt to step through the game
208+ events and reconstruct the game frame by frame. Applying the events is a
209+ work in progress and is slow so the functionality is turned off for now. You
210+ can turn it on with this flag if you are interested.
176211
177212
178213Structures
@@ -188,6 +223,13 @@ replay. Depending on the level of parsing performed, different attributes
188223here will have values. They will always be set.
189224
190225
226+ .. attribute :: raw
227+
228+ An AttributeDict mapping replay file name to a fairly raw form that has
229+ been extracted. If you want to do your own processing or want to inspect
230+ how and/or what sc2reader was able to parse out of those files this is
231+ where you should look. Not particularly useful unless you think there is
232+ a problem with the file parsing.
191233
192234.. attribute :: release_str
193235
@@ -299,7 +341,7 @@ here will have values. They will always be set.
299341.. attribute :: recorder
300342
301343 A Person _ object representing the person that recorded the game. Packets
302- are currently used to determine the recording player (who won't recieve
344+ are currently used to determine the recording player (who won't receive
303345 packets from themselves).
304346
305347.. attribute :: events
@@ -387,7 +429,7 @@ Player
387429
388430.. attribute :: avg_apm
389431
390- The average of all the avlues in the APM dict up until the point that
432+ The average of all the values in the APM dict up until the point that
391433 the player has died.
392434
393435.. attribute :: result
@@ -405,7 +447,7 @@ Player
405447
406448.. attribute :: pick_race
407449
408- The race choosen at the beginning of the game. This includes Random.
450+ The race chosen at the beginning of the game. This includes Random.
409451
410452.. attribute :: play_race
411453
@@ -497,6 +539,110 @@ Packets are not yet documented
497539
498540
499541
542+ Processors
543+ =================
544+
545+ jsonEncode
546+ ---------------
547+
548+ The jsonEncode processor can be used to return a encoded json string instead
549+ of a replay object. This shortcut processor might be useful for web apps or
550+ interprocess communication perhaps.
551+
552+ ::
553+
554+ >>> import sc2reader;
555+ >>> from sc2reader.processors import jsonEncode
556+ >>> print sc2reader.read_file('test_replays/1.4.0.19679/36663.SC2Replay', processors=[jsonEncode])
557+
558+ The processor also comes in a slightly different class based flavor which
559+ allows you to configure the encoding process by basically piping your options
560+ through to python's ``json.dumps `` standard library function.
561+
562+ ::
563+
564+ >>> import sc2reader;
565+ >>> from sc2reader.processors import jsonEncoder
566+ >>> print sc2reader.read_file(
567+ ... 'test_replays/1.4.0.19679/36663.SC2Replay',
568+ ... processors=[jsonEncoder(indent=4)]
569+ ... )
570+ {
571+ "category": "Ladder",
572+ "map": "Xel'Naga Caverns",
573+ "players": [
574+ {
575+ "uid": 934659,
576+ "play_race": "Terran",
577+ "color": {
578+ "a": 255,
579+ "r": 180,
580+ "b": 30,
581+ "g": 20
582+ },
583+ "pick_race": "Terran",
584+ "pid": 1,
585+ "result": "Win",
586+ "name": "MaNNErCHOMP",
587+ "url": "http://us.battle.net/sc2/en/profile/934659/1/MaNNErCHOMP/",
588+ "messages": [
589+ {
590+ "text": "lol",
591+ "is_public": true,
592+ "time": 9
593+ },
594+ {
595+ "text": "sup bra",
596+ "is_public": true,
597+ "time": 23
598+ },
599+ {
600+ "text": ":(",
601+ "is_public": true,
602+ "time": 48
603+ }
604+ ],
605+ "type": "Human",
606+ "avg_apm": 148.13353566009107
607+ },
608+ {
609+ {
610+ "uid": 493391,
611+ "play_race": "Protoss",
612+ "color": {
613+ "a": 255,
614+ "r": 0,
615+ "b": 255,
616+ "g": 66
617+ },
618+ "pick_race": "Protoss",
619+ "pid": 2,
620+ "result": "Loss",
621+ "name": "vVvHasuu",
622+ "url": "http://us.battle.net/sc2/en/profile/493391/1/vVvHasuu/",
623+ "messages": [],
624+ "type": "Human",
625+ "avg_apm": 143.52583586626139
626+ }
627+ ],
628+ "type": "1v1",
629+ "is_ladder": true,
630+ "utc_date": "2011-09-21 06:49:47",
631+ "file_time": 129610613871027307,
632+ "observers": [],
633+ "frames": 10552,
634+ "build": 19679,
635+ "date": "2011-09-21 02:49:47",
636+ "unix_timestamp": 1316587787,
637+ "filename": "test_replays/1.4.0.19679/36663.SC2Replay",
638+ "speed": "Faster",
639+ "gateway": "us",
640+ "is_private": false,
641+ "release": "1.4.0.19679"
642+ }
643+
644+
645+
500646Indices and tables
501647==================
502648
0 commit comments