Reshuffling the Evennia package into the new template paradigm.
This commit is contained in:
parent
2846e64833
commit
2b3a32e447
371 changed files with 17250 additions and 304 deletions
41
lib/utils/idmapper/__init__.py
Executable file
41
lib/utils/idmapper/__init__.py
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
import os.path
|
||||
import warnings
|
||||
|
||||
__version__ = (0, 2)
|
||||
|
||||
def _get_git_revision(path):
|
||||
revision_file = os.path.join(path, 'refs', 'heads', 'master')
|
||||
if not os.path.exists(revision_file):
|
||||
return None
|
||||
fh = open(revision_file, 'r')
|
||||
try:
|
||||
return fh.read()
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
def get_revision():
|
||||
"""
|
||||
:returns: Revision number of this branch/checkout, if available. None if
|
||||
no revision number can be determined.
|
||||
"""
|
||||
package_dir = os.path.dirname(__file__)
|
||||
checkout_dir = os.path.normpath(os.path.join(package_dir, '..'))
|
||||
path = os.path.join(checkout_dir, '.git')
|
||||
if os.path.exists(path):
|
||||
return _get_git_revision(path)
|
||||
return None
|
||||
|
||||
__build__ = get_revision()
|
||||
|
||||
def lazy_object(location):
|
||||
def inner(*args, **kwargs):
|
||||
parts = location.rsplit('.', 1)
|
||||
warnings.warn('`idmapper.%s` is deprecated. Please use `%s` instead.' % (parts[1], location), DeprecationWarning)
|
||||
imp = __import__(parts[0], globals(), locals(), [parts[1]], -1)
|
||||
func = getattr(imp, parts[1])
|
||||
if callable(func):
|
||||
return func(*args, **kwargs)
|
||||
return func
|
||||
return inner
|
||||
|
||||
SharedMemoryModel = lazy_object('idmapper.models.SharedMemoryModel')
|
||||
Loading…
Add table
Add a link
Reference in a new issue