1
1
# -*- coding: utf-8 -*-
2
+ """
3
+ sc2reader
4
+ ~~~~~~~~~~~
5
+
6
+ A library for loading data from Starcraft II game resources.
7
+
8
+ SC2Factory methods called on the package will be delegated to the default
9
+ SC2Factory. To default to a cached factory set one or more of the following
10
+ variables in your environment:
11
+
12
+ SC2READER_CACHE_DIR = '/absolute/path/to/existing/cache/directory/'
13
+ SC2READER_CACHE_MAX_SIZE = MAXIMUM_CACHE_ENTRIES_TO_HOLD_IN_MEMORY
14
+
15
+ You can also set the default factory via setFactory, useFileCache, useDictCache,
16
+ or useDoubleCache functions.
17
+
18
+ :copyright: (c) 2011 by Graylin Kim.
19
+ :license: MIT, see LICENSE for more details.
20
+ """
2
21
from __future__ import absolute_import , print_function , unicode_literals , division
3
22
4
23
__version__ = "0.6.4"
13
32
# setup the library logging
14
33
log_utils .setup ()
15
34
16
- # For backwards compatibility
35
+ # For backwards compatibility, goes away in 0.7
17
36
SC2Reader = factories .SC2Factory
18
37
19
38
20
39
def setFactory (factory ):
21
- # Expose a nice module level interface
40
+ """
41
+ :param factory: The new default factory for the package.
42
+
43
+ Links the following sc2reader global methods to the specified factory::
44
+
45
+ * sc2reader.load_replay(s)
46
+ * sc2reader.load_map(s)
47
+ * sc2reader.load_game_summar(y|ies)
48
+ * sc2reader.configure
49
+ * sc2reader.reset
50
+ * sc2reader.register_plugin
51
+
52
+ These methods when called will delegate to the factory for execution.
53
+ """
22
54
module = sys .modules [__name__ ]
23
55
module .load_replays = factory .load_replays
24
56
module .load_replay = factory .load_replay
@@ -35,14 +67,34 @@ def setFactory(factory):
35
67
36
68
37
69
def useFileCache (cache_dir , ** options ):
70
+ """
71
+ :param cache_dir: Absolute path to the existing cache directory
72
+
73
+ Set the default factory to a new FileCachedSC2Factory with the given cache_dir.
74
+ All remote resources are saved to the file system for faster access times.
75
+ """
38
76
setFactory (factories .FileCachedSC2Factory (cache_dir , ** options ))
39
77
40
78
41
79
def useDictCache (cache_max_size = 0 , ** options ):
80
+ """
81
+ :param cache_max_size: The maximum number of cache entries to hold in memory
82
+
83
+ Set the default factory to a new DictCachedSC2Factory with the given cache_dir.
84
+ A limited number of remote resources are cached in memory for faster access times.
85
+ """
42
86
setFactory (factories .DictCachedSC2Factory (cache_max_size , ** options ))
43
87
44
88
45
89
def useDoubleCache (cache_dir , cache_max_size = 0 , ** options ):
90
+ """
91
+ :param cache_dir: Absolute path to the existing cache directory
92
+ :param cache_max_size: The maximum number of cache entries to hold in memory
93
+
94
+ Set the default factory to a new DoubleCachedSC2Factory with the given cache_dir.
95
+ A limited number of remote resources are cached in memory for faster access times.
96
+ All remote resources are saved to the file system for faster access times.
97
+ """
46
98
setFactory (factories .DoubleCachedSC2Factory (cache_dir , cache_max_size , ** options ))
47
99
48
100
0 commit comments