-
-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Framework for multi-search. #3493
base: main
Are you sure you want to change the base?
Conversation
There's also a series of linter formatting. I can undo that if desired. |
@@ -530,13 +539,17 @@ def handle_search_results(self, searchdata, results, **kwargs): | |||
|
|||
nofound_string = kwargs.get("nofound_string") | |||
multimatch_string = kwargs.get("multimatch_string") | |||
return_quantity = kwargs.get("return_quantity") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point of interest.
@@ -2354,48 +2413,65 @@ def display_len(target): | |||
# Replace this hook function by changing settings.SEARCH_AT_RESULT. | |||
|
|||
|
|||
class SearchReturnType(Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point of interest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to look into this a bit more, have a few questions so far. This also doesn't actually exemplifies how this would be used which could be the next step.
Also, please use the correct line width in your IDE (Evennia uses 100 character line width) to make your PR diff smaller (and you won't have to specify your 'points of interests'). As it is I'll have to reformat your code after merging.
if any( | ||
sessid | ||
for sessid in self._sessid_cache | ||
if sessid not in evennia.SESSION_HANDLER | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please set up your IDE to follow Evennia line width standard (100 characters). That makes the PR smaller (easier to review) and clearer since you only see the important changes.
matches = None | ||
elif len(matches) > 1: | ||
return_quantity = kwargs.get("return_quantity", 1) | ||
return_type = kwargs.get("return_type", SearchReturnType.DEFAULT) | ||
if return_type == SearchReturnType.ONE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a match ... case
structure.
return_quantity = kwargs.get("return_quantity", 1) | ||
return_type = kwargs.get("return_type", SearchReturnType.DEFAULT) | ||
if return_type == SearchReturnType.ONE: | ||
return matches[return_quantity - 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this not traceback if matches
and return_quantity
are out of sync?
elif return_type == SearchReturnType.MULTIPLE: | ||
matches = matches[:return_quantity] | ||
return matches | ||
elif return_type == SearchReturnType.ALL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not the default?
Brief overview of PR changes/additions
This PR isn't intended to go live yet (although it won't break anything). This is my proposal on how we rebuild the search function in order to handle queries such as:
get sword
,get 2 swords
, andget all
as discussed in #3468.With this framework, I use regular expression patterns within
parse
for functionsget
,drop
,give
, andput
which would also need to be implemented, but I think this gives an idea for a direction to go. If desired, I can attachCmdGet
andCmdDrop
.