11# -*- 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+ """
221from __future__ import absolute_import , print_function , unicode_literals , division
322
423__version__ = "0.6.4"
1332# setup the library logging
1433log_utils .setup ()
1534
16- # For backwards compatibility
35+ # For backwards compatibility, goes away in 0.7
1736SC2Reader = factories .SC2Factory
1837
1938
2039def 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+ """
2254 module = sys .modules [__name__ ]
2355 module .load_replays = factory .load_replays
2456 module .load_replay = factory .load_replay
@@ -35,14 +67,34 @@ def setFactory(factory):
3567
3668
3769def 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+ """
3876 setFactory (factories .FileCachedSC2Factory (cache_dir , ** options ))
3977
4078
4179def 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+ """
4286 setFactory (factories .DictCachedSC2Factory (cache_max_size , ** options ))
4387
4488
4589def 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+ """
4698 setFactory (factories .DoubleCachedSC2Factory (cache_dir , cache_max_size , ** options ))
4799
48100
0 commit comments