Skip to content

Commit a7c7e21

Browse files
committed
Misc import and documentation improvements.
1 parent fc79bbb commit a7c7e21

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

sc2reader/__init__.py

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
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+
"""
221
from __future__ import absolute_import, print_function, unicode_literals, division
322

423
__version__ = "0.6.4"
@@ -13,12 +32,25 @@
1332
# setup the library logging
1433
log_utils.setup()
1534

16-
# For backwards compatibility
35+
# For backwards compatibility, goes away in 0.7
1736
SC2Reader = factories.SC2Factory
1837

1938

2039
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+
"""
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

3769
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+
"""
3876
setFactory(factories.FileCachedSC2Factory(cache_dir, **options))
3977

4078

4179
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+
"""
4286
setFactory(factories.DictCachedSC2Factory(cache_max_size, **options))
4387

4488

4589
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+
"""
4698
setFactory(factories.DoubleCachedSC2Factory(cache_dir, cache_max_size, **options))
4799

48100

sc2reader/events/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, unicode_literals, division
33

4-
import sc2reader.events.base
5-
import sc2reader.events.game
6-
import sc2reader.events.message
4+
# Export all events of all types to the package interface
5+
from sc2reader.events import base, game, message, tracker
76
from sc2reader.events.base import *
87
from sc2reader.events.game import *
98
from sc2reader.events.message import *

sc2reader/factories/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import absolute_import
1+
from __future__ import absolute_import, print_function, unicode_literals, division
22

33
from sc2reader.factories.sc2factory import SC2Factory
44
from sc2reader.factories.sc2factory import FileCachedSC2Factory

0 commit comments

Comments
 (0)