Update utils.search argument strings. Resolves #2106.
This commit is contained in:
parent
0281105b4a
commit
399dc3640d
2 changed files with 49 additions and 21 deletions
|
|
@ -31,7 +31,8 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
|
|
||||||
# Attribute manager methods
|
# Attribute manager methods
|
||||||
def get_attribute(
|
def get_attribute(
|
||||||
self, key=None, category=None, value=None, strvalue=None, obj=None, attrtype=None
|
self, key=None, category=None, value=None, strvalue=None, obj=None, attrtype=None, **kwargs
|
||||||
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Return Attribute objects by key, by category, by value, by
|
Return Attribute objects by key, by category, by value, by
|
||||||
|
|
@ -55,6 +56,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
attrype (str, optional): An attribute-type to search for.
|
attrype (str, optional): An attribute-type to search for.
|
||||||
By default this is either `None` (normal Attributes) or
|
By default this is either `None` (normal Attributes) or
|
||||||
`"nick"`.
|
`"nick"`.
|
||||||
|
kwargs (any): Currently unused. Reserved for future use.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
attributes (list): The matching Attributes.
|
attributes (list): The matching Attributes.
|
||||||
|
|
@ -102,7 +104,8 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
key=key, category=category, value=value, strvalue=strvalue, obj=obj
|
key=key, category=category, value=value, strvalue=strvalue, obj=obj
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_by_attribute(self, key=None, category=None, value=None, strvalue=None, attrtype=None):
|
def get_by_attribute(self, key=None, category=None, value=None,
|
||||||
|
strvalue=None, attrtype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return objects having attributes with the given key, category,
|
Return objects having attributes with the given key, category,
|
||||||
value, strvalue or combination of those criteria.
|
value, strvalue or combination of those criteria.
|
||||||
|
|
@ -122,6 +125,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
attrype (str, optional): An attribute-type to search for.
|
attrype (str, optional): An attribute-type to search for.
|
||||||
By default this is either `None` (normal Attributes) or
|
By default this is either `None` (normal Attributes) or
|
||||||
`"nick"`.
|
`"nick"`.
|
||||||
|
kwargs (any): Currently unused. Reserved for future use.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
obj (list): Objects having the matching Attributes.
|
obj (list): Objects having the matching Attributes.
|
||||||
|
|
@ -488,12 +492,12 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
def get_typeclass_totals(self, *args, **kwargs) -> object:
|
def get_typeclass_totals(self, *args, **kwargs) -> object:
|
||||||
"""
|
"""
|
||||||
Returns a queryset of typeclass composition statistics.
|
Returns a queryset of typeclass composition statistics.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
qs (Queryset): A queryset of dicts containing the typeclass (name),
|
qs (Queryset): A queryset of dicts containing the typeclass (name),
|
||||||
the count of objects with that typeclass and a float representing
|
the count of objects with that typeclass and a float representing
|
||||||
the percentage of objects associated with the typeclass.
|
the percentage of objects associated with the typeclass.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
self.values("db_typeclass_path")
|
self.values("db_typeclass_path")
|
||||||
|
|
|
||||||
|
|
@ -205,27 +205,31 @@ help_entries = search_help
|
||||||
# not the attribute object itself (this is usually what you want)
|
# not the attribute object itself (this is usually what you want)
|
||||||
|
|
||||||
|
|
||||||
def search_object_attribute(key=None, category=None, value=None, strvalue=None):
|
def search_object_attribute(key=None, category=None, value=None,
|
||||||
|
strvalue=None, attrtype=None, **kwargs):
|
||||||
return ObjectDB.objects.get_by_attribute(
|
return ObjectDB.objects.get_by_attribute(
|
||||||
key=key, category=category, value=value, strvalue=strvalue
|
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def search_account_attribute(key=None, category=None, value=None, strvalue=None):
|
def search_account_attribute(key=None, category=None, value=None,
|
||||||
|
strvalue=None, attrtype=None, **kwargs):
|
||||||
return AccountDB.objects.get_by_attribute(
|
return AccountDB.objects.get_by_attribute(
|
||||||
key=key, category=category, value=value, strvalue=strvalue
|
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def search_script_attribute(key=None, category=None, value=None, strvalue=None):
|
def search_script_attribute(key=None, category=None, value=None,
|
||||||
|
strvalue=None, attrtype=None, **kwargs):
|
||||||
return ScriptDB.objects.get_by_attribute(
|
return ScriptDB.objects.get_by_attribute(
|
||||||
key=key, category=category, value=value, strvalue=strvalue
|
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def search_channel_attribute(key=None, category=None, value=None, strvalue=None):
|
def search_channel_attribute(key=None, category=None, value=None,
|
||||||
|
strvalue=None, attrtype=None, **kwargs):
|
||||||
return Channel.objects.get_by_attribute(
|
return Channel.objects.get_by_attribute(
|
||||||
key=key, category=category, value=value, strvalue=strvalue
|
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -243,7 +247,7 @@ search_attribute_object = ObjectDB.objects.get_attribute
|
||||||
# object itself (this is usually what you want)
|
# object itself (this is usually what you want)
|
||||||
|
|
||||||
|
|
||||||
def search_object_by_tag(key=None, category=None):
|
def search_object_by_tag(key=None, category=None, tagtype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Find object based on tag or category.
|
Find object based on tag or category.
|
||||||
|
|
||||||
|
|
@ -252,6 +256,11 @@ def search_object_by_tag(key=None, category=None):
|
||||||
category (str, optional): The category of tag
|
category (str, optional): The category of tag
|
||||||
to search for. If not set, uncategorized
|
to search for. If not set, uncategorized
|
||||||
tags will be searched.
|
tags will be searched.
|
||||||
|
tagtype (str, optional): 'type' of Tag, by default
|
||||||
|
this is either `None` (a normal Tag), `alias` or
|
||||||
|
`permission`. This always apply to all queried tags.
|
||||||
|
kwargs (any): Other optional parameter that may be supported
|
||||||
|
by the manager method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): List of Objects with tags matching
|
matches (list): List of Objects with tags matching
|
||||||
|
|
@ -259,13 +268,13 @@ def search_object_by_tag(key=None, category=None):
|
||||||
matches were found.
|
matches were found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return ObjectDB.objects.get_by_tag(key=key, category=category)
|
return ObjectDB.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
search_tag = search_object_by_tag # this is the most common case
|
search_tag = search_object_by_tag # this is the most common case
|
||||||
|
|
||||||
|
|
||||||
def search_account_tag(key=None, category=None):
|
def search_account_tag(key=None, category=None, tagtype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Find account based on tag or category.
|
Find account based on tag or category.
|
||||||
|
|
||||||
|
|
@ -274,6 +283,11 @@ def search_account_tag(key=None, category=None):
|
||||||
category (str, optional): The category of tag
|
category (str, optional): The category of tag
|
||||||
to search for. If not set, uncategorized
|
to search for. If not set, uncategorized
|
||||||
tags will be searched.
|
tags will be searched.
|
||||||
|
tagtype (str, optional): 'type' of Tag, by default
|
||||||
|
this is either `None` (a normal Tag), `alias` or
|
||||||
|
`permission`. This always apply to all queried tags.
|
||||||
|
kwargs (any): Other optional parameter that may be supported
|
||||||
|
by the manager method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): List of Accounts with tags matching
|
matches (list): List of Accounts with tags matching
|
||||||
|
|
@ -281,10 +295,10 @@ def search_account_tag(key=None, category=None):
|
||||||
matches were found.
|
matches were found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return AccountDB.objects.get_by_tag(key=key, category=category)
|
return AccountDB.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def search_script_tag(key=None, category=None):
|
def search_script_tag(key=None, category=None, tagtype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Find script based on tag or category.
|
Find script based on tag or category.
|
||||||
|
|
||||||
|
|
@ -293,6 +307,11 @@ def search_script_tag(key=None, category=None):
|
||||||
category (str, optional): The category of tag
|
category (str, optional): The category of tag
|
||||||
to search for. If not set, uncategorized
|
to search for. If not set, uncategorized
|
||||||
tags will be searched.
|
tags will be searched.
|
||||||
|
tagtype (str, optional): 'type' of Tag, by default
|
||||||
|
this is either `None` (a normal Tag), `alias` or
|
||||||
|
`permission`. This always apply to all queried tags.
|
||||||
|
kwargs (any): Other optional parameter that may be supported
|
||||||
|
by the manager method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): List of Scripts with tags matching
|
matches (list): List of Scripts with tags matching
|
||||||
|
|
@ -300,10 +319,10 @@ def search_script_tag(key=None, category=None):
|
||||||
matches were found.
|
matches were found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return ScriptDB.objects.get_by_tag(key=key, category=category)
|
return ScriptDB.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def search_channel_tag(key=None, category=None):
|
def search_channel_tag(key=None, category=None, tagtype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Find channel based on tag or category.
|
Find channel based on tag or category.
|
||||||
|
|
||||||
|
|
@ -312,6 +331,11 @@ def search_channel_tag(key=None, category=None):
|
||||||
category (str, optional): The category of tag
|
category (str, optional): The category of tag
|
||||||
to search for. If not set, uncategorized
|
to search for. If not set, uncategorized
|
||||||
tags will be searched.
|
tags will be searched.
|
||||||
|
tagtype (str, optional): 'type' of Tag, by default
|
||||||
|
this is either `None` (a normal Tag), `alias` or
|
||||||
|
`permission`. This always apply to all queried tags.
|
||||||
|
kwargs (any): Other optional parameter that may be supported
|
||||||
|
by the manager method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
matches (list): List of Channels with tags matching
|
matches (list): List of Channels with tags matching
|
||||||
|
|
@ -319,7 +343,7 @@ def search_channel_tag(key=None, category=None):
|
||||||
matches were found.
|
matches were found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return Channel.objects.get_by_tag(key=key, category=category)
|
return Channel.objects.get_by_tag(key=key, category=category, tagtype=tagtype, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# search for tag objects (not the objects they are attached to
|
# search for tag objects (not the objects they are attached to
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue