diff --git a/evennia/__init__.py b/evennia/__init__.py index 51b4ef5245..53e6a8b30c 100644 --- a/evennia/__init__.py +++ b/evennia/__init__.py @@ -69,28 +69,34 @@ OOB_HANDLER = None CHANNEL_HANDLER = None -import os -from subprocess import check_output, CalledProcessError, STDOUT - -__version__ = "Unknown" - -root = os.path.dirname(os.path.abspath(__file__)) -try: - with open(os.path.join(root, "VERSION.txt"), 'r') as f: - __version__ = f.read().strip() -except IOError as err: - print err -try: - __version__ = "%s" % (check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip()) -except (IOError, CalledProcessError): - pass - - -def init(): +def _create_version(): """ - This is called by the launcher only after Evennia has fully - initialized all its models. It sets up the API in a safe - environment where all models are available already. + Helper function for building the version string + """ + import os + from subprocess import check_output, CalledProcessError, STDOUT + + version = "Unknown" + root = os.path.dirname(os.path.abspath(__file__)) + try: + with open(os.path.join(root, "VERSION.txt"), 'r') as f: + version = f.read().strip() + except IOError as err: + print err + try: + version = "%s (rev %s)" % (version, check_output("git rev-parse --short HEAD", shell=True, cwd=root, stderr=STDOUT).strip()) + except (IOError, CalledProcessError): + pass + return version + +__version__ = _create_version() +del _create_version + +def _init(): + """ + This function is called automatically by the launcher only after + Evennia has fully initialized all its models. It sets up the API + in a safe environment where all models are available already. """ def imp(path, variable=True): "Helper function" diff --git a/evennia/commands/__init__.py b/evennia/commands/__init__.py index 40a96afc6f..5f77fa3a30 100644 --- a/evennia/commands/__init__.py +++ b/evennia/commands/__init__.py @@ -1 +1,10 @@ # -*- coding: utf-8 -*- +""" +This sub-package contains Evennia's command system. It handles +everything related to parsing input from the player, building cmdsets +and executing the code associated with a found command class. + +commands.default contains all the default "mux-like" commands of +Evennia. + +""" diff --git a/evennia/comms/__init__.py b/evennia/comms/__init__.py index f069f5cebe..e8f2bc8449 100644 --- a/evennia/comms/__init__.py +++ b/evennia/comms/__init__.py @@ -1,5 +1,6 @@ """ -Makes it easier to import by grouping all relevant things already at this -level. +This sub-package contains Evennia's comms-system, a set of models and +handlers for in-game communication via channels and messages as well +as code related to external communication like IRC or RSS. """ diff --git a/evennia/comms/channelhandler.py b/evennia/comms/channelhandler.py index ad2a026dca..97cf80ef04 100644 --- a/evennia/comms/channelhandler.py +++ b/evennia/comms/channelhandler.py @@ -82,13 +82,25 @@ class ChannelCommand(command.Command): class ChannelHandler(object): """ - Handles the set of commands related to channels. + The ChannelHandler manages all active in-game channels and + dynamically creates channel commands for users so that they can + just give the channek's key or alias to write to it. Whenever a + new channel is created in the database, the update() method on + this handler must be called to sync it with the database (this is + done automatically if creating the channel with + evennia.create_channel()) + """ def __init__(self): + """ + Initializes the channel handler's internal state. + + """ self.cached_channel_cmds = [] self.cached_cmdsets = {} def __str__(self): + "Returns the string representation of the handler" return ", ".join(str(cmd) for cmd in self.cached_channel_cmds) def clear(self): @@ -133,7 +145,9 @@ class ChannelHandler(object): self.cached_cmdsets = {} def update(self): - "Updates the handler completely." + """ + Updates the handler completely. + """ self.cached_channel_cmds = [] self.cached_cmdsets = {} for channel in ChannelDB.objects.get_all_channels(): diff --git a/evennia/contrib/__init__.py b/evennia/contrib/__init__.py index 40a96afc6f..3a4073ffe2 100644 --- a/evennia/contrib/__init__.py +++ b/evennia/contrib/__init__.py @@ -1 +1,7 @@ # -*- coding: utf-8 -*- +""" +This sub-package holds Evennia's contributions - code that may be +useful but are deemed too game-specific to go into the core library. + +See README.md for more info. +""" diff --git a/evennia/game_template/__init__.py b/evennia/game_template/__init__.py index e69de29bb2..6e3dbee766 100644 --- a/evennia/game_template/__init__.py +++ b/evennia/game_template/__init__.py @@ -0,0 +1,6 @@ +""" +This sub-package holds the template for creating a new game folder. +The new game folder (when running evennia --init) is a copy of this +folder. + +""" diff --git a/evennia/help/__init__.py b/evennia/help/__init__.py index 8b13789179..0aa1b685f0 100644 --- a/evennia/help/__init__.py +++ b/evennia/help/__init__.py @@ -1 +1,7 @@ +""" +This sub-package defines the help system of Evennia. It is pretty +simple, mainly consisting of a database model to hold help entries. +The auto-cmd-help is rather handled by the default 'help' command +itself. +""" diff --git a/evennia/locks/__init__.py b/evennia/locks/__init__.py index 40a96afc6f..3b5361021e 100644 --- a/evennia/locks/__init__.py +++ b/evennia/locks/__init__.py @@ -1 +1,7 @@ # -*- coding: utf-8 -*- +""" +This sub-package defines the lock (access) mechanism of Evennia. All +lock strings are processed through the lockhandler in this package. It +also contains the default lock functions used in lock definitions. + +""" diff --git a/evennia/objects/__init__.py b/evennia/objects/__init__.py index 48d48ecabe..28056809a8 100644 --- a/evennia/objects/__init__.py +++ b/evennia/objects/__init__.py @@ -1 +1,6 @@ +""" +This sub-package defines the basic in-game "Object". All in-game +objects inherit from classes in this package. + +""" from objects import DefaultObject, DefaultRoom, DefaultExit, DefaultCharacter diff --git a/evennia/players/__init__.py b/evennia/players/__init__.py index 10650a54a5..321d69a8e7 100644 --- a/evennia/players/__init__.py +++ b/evennia/players/__init__.py @@ -1 +1,7 @@ +""" +This sub-package defines the out-of-character entities known as +Players. These are equivalent to 'accounts' and can puppet one or +more Objects depending on settings. A Player has no in-game existence. + +""" from players import DefaultGuest, DefaultPlayer diff --git a/evennia/scripts/__init__.py b/evennia/scripts/__init__.py index 1dfe7ab584..46f4e0c3b7 100644 --- a/evennia/scripts/__init__.py +++ b/evennia/scripts/__init__.py @@ -1 +1,8 @@ +""" +This sub-package holds the Scripts system. Scripts are database +entities that can store data both in connection to Objects and Players +or globally. They may also have a timer-component to execute various +timed effects. + +""" from scripts import DefaultScript diff --git a/evennia/server/__init__.py b/evennia/server/__init__.py index e69de29bb2..5e96b10992 100644 --- a/evennia/server/__init__.py +++ b/evennia/server/__init__.py @@ -0,0 +1,7 @@ +""" +This sub-package holds the Server and Portal programs - the "core" of +Evennia. It also contains the SessionHandler that manages all +connected users as well as defines all the connection protocols used +to connect to the game. + +""" diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index 685eb12f04..dbd1f25bca 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -458,7 +458,7 @@ def check_database(): if tables and u'players_playerdb' in tables: # database exists and seems set up. Initialize evennia. import evennia - evennia.init() + evennia._init() # Try to get Player#1 from evennia.players.models import PlayerDB try: diff --git a/evennia/server/portal/portal.py b/evennia/server/portal/portal.py index f36300b94f..1c1c522de2 100644 --- a/evennia/server/portal/portal.py +++ b/evennia/server/portal/portal.py @@ -19,7 +19,7 @@ django.setup() from django.conf import settings import evennia -evennia.init() +evennia._init() from evennia.utils.utils import get_evennia_version, mod_import, make_iter from evennia.server.portal.portalsessionhandler import PORTAL_SESSIONS diff --git a/evennia/server/server.py b/evennia/server/server.py index d5efc52b7c..1a0ec9c658 100644 --- a/evennia/server/server.py +++ b/evennia/server/server.py @@ -18,7 +18,7 @@ import django django.setup() import evennia -evennia.init() +evennia._init() from django.db import connection from django.conf import settings diff --git a/evennia/server/tests.py b/evennia/server/tests.py index 0d2ecb7eda..59bd8b8eb2 100644 --- a/evennia/server/tests.py +++ b/evennia/server/tests.py @@ -43,5 +43,5 @@ class EvenniaTestSuiteRunner(DiscoverRunner): If not given, a subset of settings.INSTALLED_APPS will be used. """ import evennia - evennia.init() + evennia._init() return super(EvenniaTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs) diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 04642a218a..f94722decc 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -4,13 +4,13 @@ Master configuration file for Evennia. NOTE: NO MODIFICATIONS SHOULD BE MADE TO THIS FILE! All settings changes should be done by copy-pasting the variable and -its value to game/settings.py. An empty game/settings.py can be -auto-generated by running game/manage.py without any arguments. +its value to /conf/settings.py. Hint: Don't copy&paste over more from this file than you actually want to change. Anything you don't copy&paste will thus retain its default value - which may change as Evennia is developed. This way you can always be sure of what you have changed and what is default behaviour. + """ import os diff --git a/evennia/typeclasses/__init__.py b/evennia/typeclasses/__init__.py index 40a96afc6f..b72aa9ba39 100644 --- a/evennia/typeclasses/__init__.py +++ b/evennia/typeclasses/__init__.py @@ -1 +1,10 @@ # -*- coding: utf-8 -*- +""" +This sub-package defines the typeclass-system, a way to wrap database +access into almost-normal Python classes. Using typeclasses one can +work in normal Python while having the luxury of persistent data +storage at every turn. ObjectDB, ChannelDB, PlayerDB and ScriptDB all +inherit from the models in this package. Here is also were the +Attribute and Tag models are defined along with their handlers. + +""" diff --git a/evennia/utils/__init__.py b/evennia/utils/__init__.py index e9aa243a1a..25eb6c1abf 100644 --- a/evennia/utils/__init__.py +++ b/evennia/utils/__init__.py @@ -1,3 +1,9 @@ +""" +This sub-package holds the miscelaneous utilities used by other +modules in Evennia. It also holds the idmapper in-memory caching +functionality. + +""" # simple check to determine if we are currently running under pypy. try: import __pypy__ as is_pypy diff --git a/evennia/web/__init__.py b/evennia/web/__init__.py index e69de29bb2..03578813e4 100644 --- a/evennia/web/__init__.py +++ b/evennia/web/__init__.py @@ -0,0 +1,7 @@ +""" +This sub-package holds the web presence of Evennia, using normal +Django to relate the database contents to web pages. Also the basic +webclient and the website are defined in here (the webserver itself is +found under the `server` package). +""" +