mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix AttributeHandler.get with no Attributes. Also make return_list=True return [] rather than [None]. Resolves #1866
This commit is contained in:
parent
ea07a81696
commit
bb5324ba52
3 changed files with 21 additions and 28 deletions
20
CHANGELOG.md
20
CHANGELOG.md
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
## Evennia 1.0 (2019-) (WIP)
|
||||
|
||||
### Already in master
|
||||
### Already in master
|
||||
|
||||
- `py` command now reroutes stdout to output results in-game client. `py`
|
||||
without arguments starts a full interactive Python console.
|
||||
without arguments starts a full interactive Python console.
|
||||
- Webclient default to a single input pane instead of two. Now defaults to no help-popup.
|
||||
- Webclient fix of prompt display
|
||||
- Webclient multimedia support for relaying images, video and sounds via
|
||||
`.msg(image=URL)`, `.msg(video=URL)`
|
||||
`.msg(image=URL)`, `.msg(video=URL)`
|
||||
and `.msg(audio=URL)`
|
||||
- Add Spanish translation (fermuch)
|
||||
- Expand `GLOBAL_SCRIPTS` container to always start scripts and to include all
|
||||
|
|
@ -19,6 +19,10 @@ without arguments starts a full interactive Python console.
|
|||
- Make new `CHANNEL_MUDINFO` setting for specifying the mudinfo channel
|
||||
- Make `CHANNEL_CONNECTINFO` take full channel definition
|
||||
- Make `DEFAULT_CHANNELS` list auto-create channels missing at reload
|
||||
- Webclient `ANSI->HTML` parser updated. Webclient line width changed from 1.6em to 1.1em
|
||||
to better make ANSI graphics look the same as for third-party clients
|
||||
- `AttributeHandler.get(return_list=True)` will return `[]` if there are no
|
||||
Attributes instead of `[None]`.
|
||||
|
||||
|
||||
## Evennia 0.9 (2018-2019)
|
||||
|
|
@ -57,12 +61,12 @@ without arguments starts a full interactive Python console.
|
|||
|
||||
- Change webclient from old txws version to use more supported/feature-rich Autobahn websocket library
|
||||
|
||||
#### Evennia game index
|
||||
#### Evennia game index
|
||||
|
||||
- Made Evennia game index client a part of core - now configured from settings file (old configs
|
||||
need to be moved)
|
||||
- The `evennia connections` command starts a wizard that helps you connect your game to the game index.
|
||||
- The game index now accepts games with no public telnet/webclient info (for early prototypes).
|
||||
- The game index now accepts games with no public telnet/webclient info (for early prototypes).
|
||||
|
||||
#### New golden-layout based Webclient UI (@friarzen)
|
||||
- Features
|
||||
|
|
@ -197,9 +201,9 @@ without arguments starts a full interactive Python console.
|
|||
|
||||
### Contribs
|
||||
|
||||
- Evscaperoom - a full puzzle engine for making multiplayer escape rooms in Evennia. Used to make
|
||||
the entry for the MUD-Coder's Guild's 2019 Game Jam with the theme "One Room", where it ranked #1.
|
||||
- Evennia game-index client no longer a contrib - moved into server core and configured with new
|
||||
- Evscaperoom - a full puzzle engine for making multiplayer escape rooms in Evennia. Used to make
|
||||
the entry for the MUD-Coder's Guild's 2019 Game Jam with the theme "One Room", where it ranked #1.
|
||||
- Evennia game-index client no longer a contrib - moved into server core and configured with new
|
||||
setting `GAME_INDEX_ENABLED`.
|
||||
- The `extended_room` contrib saw some backwards-incompatible refactoring:
|
||||
+ All commands now begin with `CmdExtendedRoom`. So before it was `CmdExtendedLook`, now
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ def _run_code_snippet(caller, pycode, mode="eval", measure_time=False,
|
|||
sys.stdout = old_stdout
|
||||
sys.stderr = old_stderr
|
||||
|
||||
if not ret:
|
||||
if ret is None:
|
||||
return
|
||||
|
||||
for session in sessions:
|
||||
|
|
|
|||
|
|
@ -420,10 +420,11 @@ class AttributeHandler(object):
|
|||
return_list (bool, optional):
|
||||
|
||||
Returns:
|
||||
result (any or list): One or more matches for keys and/or categories. Each match will be
|
||||
the value of the found Attribute(s) unless `return_obj` is True, at which point it
|
||||
will be the attribute object itself or None. If `return_list` is True, this will
|
||||
always be a list, regardless of the number of elements.
|
||||
result (any or list): One or more matches for keys and/or
|
||||
categories. Each match will be the value of the found Attribute(s)
|
||||
unless `return_obj` is True, at which point it will be the
|
||||
attribute object itself or None. If `return_list` is True, this
|
||||
will always be a list, regardless of the number of elements.
|
||||
|
||||
Raises:
|
||||
AttributeError: If `raise_exception` is set and no matching Attribute
|
||||
|
|
@ -431,15 +432,6 @@ class AttributeHandler(object):
|
|||
|
||||
"""
|
||||
|
||||
class RetDefault(object):
|
||||
"""Holds default values"""
|
||||
|
||||
def __init__(self):
|
||||
self.key = None
|
||||
self.value = default
|
||||
self.category = None
|
||||
self.strvalue = str(default) if default is not None else None
|
||||
|
||||
ret = []
|
||||
for keystr in make_iter(key):
|
||||
# it's okay to send a None key
|
||||
|
|
@ -450,13 +442,12 @@ class AttributeHandler(object):
|
|||
raise AttributeError
|
||||
elif return_obj:
|
||||
ret.append(None)
|
||||
else:
|
||||
ret.append(RetDefault())
|
||||
|
||||
if accessing_obj:
|
||||
# check 'attrread' locks
|
||||
ret = [attr for attr in ret if attr.access(accessing_obj,
|
||||
self._attrread, default=default_access)]
|
||||
self._attrread,
|
||||
default=default_access)]
|
||||
if strattr:
|
||||
ret = ret if return_obj else [attr.strvalue for attr in ret if attr]
|
||||
else:
|
||||
|
|
@ -464,9 +455,7 @@ class AttributeHandler(object):
|
|||
|
||||
if return_list:
|
||||
return ret if ret else [default] if default is not None else []
|
||||
elif not ret:
|
||||
return ret if len(key) > 1 else default
|
||||
return ret[0] if len(ret) == 1 else ret
|
||||
return ret[0] if ret and len(ret) == 1 else ret or default
|
||||
|
||||
def add(self, key, value, category=None, lockstring="",
|
||||
strattr=False, accessing_obj=None, default_access=True):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue