Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
Marker.opacity | (self) |
Sets the opacity of the bars.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
Sets the opacity of the bars.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above | def opacity(self):
"""
Sets the opacity of the bars.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy... | [
"def",
"opacity",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacity\"",
"]"
] | [
665,
4
] | [
677,
30
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacitysrc | (self) |
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def opacitysrc(self):
"""
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["opacitysrc"] | [
"def",
"opacitysrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacitysrc\"",
"]"
] | [
686,
4
] | [
697,
33
] | python | en | ['en', 'error', 'th'] | False |
Marker.reversescale | (self) |
Reverses the color mapping if true. Has an effect only if in
`marker.color`is set to a numerical array. If true,
`marker.cmin` will correspond to the last color in the array
and `marker.cmax` will correspond to the first color.
The 'reversescale' property must be specified ... |
Reverses the color mapping if true. Has an effect only if in
`marker.color`is set to a numerical array. If true,
`marker.cmin` will correspond to the last color in the array
and `marker.cmax` will correspond to the first color.
The 'reversescale' property must be specified ... | def reversescale(self):
"""
Reverses the color mapping if true. Has an effect only if in
`marker.color`is set to a numerical array. If true,
`marker.cmin` will correspond to the last color in the array
and `marker.cmax` will correspond to the first color.
The 'revers... | [
"def",
"reversescale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"reversescale\"",
"]"
] | [
706,
4
] | [
720,
35
] | python | en | ['en', 'error', 'th'] | False |
Marker.showscale | (self) |
Determines whether or not a colorbar is displayed for this
trace. Has an effect only if in `marker.color`is set to a
numerical array.
The 'showscale' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines whether or not a colorbar is displayed for this
trace. Has an effect only if in `marker.color`is set to a
numerical array.
The 'showscale' property must be specified as a bool
(either True, or False) | def showscale(self):
"""
Determines whether or not a colorbar is displayed for this
trace. Has an effect only if in `marker.color`is set to a
numerical array.
The 'showscale' property must be specified as a bool
(either True, or False)
Returns
------... | [
"def",
"showscale",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"showscale\"",
"]"
] | [
729,
4
] | [
742,
32
] | python | en | ['en', 'error', 'th'] | False |
Marker.__init__ | (
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorbar=None,
colorscale=None,
colorsrc=None,
line=None,
opacity=None,
opacitysrc=None,... |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.barpolar.Marker`
autocolorscale
Determines whether the colorscale is a... |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.barpolar.Marker`
autocolorscale
Determines whether the colorscale is a... | def __init__(
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmid=None,
cmin=None,
color=None,
coloraxis=None,
colorbar=None,
colorscale=None,
colorsrc=None,
line=None,
opacity=None,
opac... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"autocolorscale",
"=",
"None",
",",
"cauto",
"=",
"None",
",",
"cmax",
"=",
"None",
",",
"cmid",
"=",
"None",
",",
"cmin",
"=",
"None",
",",
"color",
"=",
"None",
",",
"coloraxis",
"=",
... | [
839,
4
] | [
1053,
34
] | python | en | ['en', 'error', 'th'] | False |
flush_cache | (**kwargs) |
Flush idmapper cache. When doing so the cache will fire the
at_idmapper_flush hook to allow the object to optionally handle
its own flushing.
Uses a signal so we make sure to catch cascades.
|
Flush idmapper cache. When doing so the cache will fire the
at_idmapper_flush hook to allow the object to optionally handle
its own flushing. | def flush_cache(**kwargs):
"""
Flush idmapper cache. When doing so the cache will fire the
at_idmapper_flush hook to allow the object to optionally handle
its own flushing.
Uses a signal so we make sure to catch cascades.
"""
def class_hierarchy(clslist):
"""Recursively yield a cla... | [
"def",
"flush_cache",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"class_hierarchy",
"(",
"clslist",
")",
":",
"\"\"\"Recursively yield a class hierarchy\"\"\"",
"for",
"cls",
"in",
"clslist",
":",
"subclass_list",
"=",
"cls",
".",
"__subclasses__",
"(",
")",
"if"... | [
450,
0
] | [
472,
23
] | python | en | ['en', 'error', 'th'] | False |
flush_cached_instance | (sender, instance, **kwargs) |
Flush the idmapper cache only for a given instance.
|
Flush the idmapper cache only for a given instance. | def flush_cached_instance(sender, instance, **kwargs):
"""
Flush the idmapper cache only for a given instance.
"""
# XXX: Is this the best way to make sure we can flush?
if not hasattr(instance, 'flush_cached_instance'):
return
sender.flush_cached_instance(instance, force=True) | [
"def",
"flush_cached_instance",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"# XXX: Is this the best way to make sure we can flush?",
"if",
"not",
"hasattr",
"(",
"instance",
",",
"'flush_cached_instance'",
")",
":",
"return",
"sender",
".",
"... | [
479,
0
] | [
487,
54
] | python | en | ['en', 'error', 'th'] | False |
update_cached_instance | (sender, instance, **kwargs) |
Re-cache the given instance in the idmapper cache.
|
Re-cache the given instance in the idmapper cache. | def update_cached_instance(sender, instance, **kwargs):
"""
Re-cache the given instance in the idmapper cache.
"""
if not hasattr(instance, 'cache_instance'):
return
sender.cache_instance(instance) | [
"def",
"update_cached_instance",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"instance",
",",
"'cache_instance'",
")",
":",
"return",
"sender",
".",
"cache_instance",
"(",
"instance",
")"
] | [
493,
0
] | [
500,
35
] | python | en | ['en', 'error', 'th'] | False |
conditional_flush | (max_rmem, force=False) |
Flush the cache if the estimated memory usage exceeds `max_rmem`.
The flusher has a timeout to avoid flushing over and over
in particular situations (this means that for some setups
the memory usage will exceed the requirement and a server with
more memory is probably required for the given game).... |
Flush the cache if the estimated memory usage exceeds `max_rmem`. | def conditional_flush(max_rmem, force=False):
"""
Flush the cache if the estimated memory usage exceeds `max_rmem`.
The flusher has a timeout to avoid flushing over and over
in particular situations (this means that for some setups
the memory usage will exceed the requirement and a server with
... | [
"def",
"conditional_flush",
"(",
"max_rmem",
",",
"force",
"=",
"False",
")",
":",
"global",
"LAST_FLUSH",
"def",
"mem2cachesize",
"(",
"desired_rmem",
")",
":",
"\"\"\"\n Estimate the size of the idmapper cache based on the memory\n desired. This is used to optiona... | [
509,
0
] | [
574,
24
] | python | en | ['en', 'error', 'th'] | False |
cache_size | (mb=True) |
Calculate statistics about the cache.
Note: we cannot get reliable memory statistics from the cache -
whereas we could do `getsizof` each object in cache, the result is
highly imprecise and for a large number of objects the result is
many times larger than the actual memory usage of the entire ser... |
Calculate statistics about the cache. | def cache_size(mb=True):
"""
Calculate statistics about the cache.
Note: we cannot get reliable memory statistics from the cache -
whereas we could do `getsizof` each object in cache, the result is
highly imprecise and for a large number of objects the result is
many times larger than the actua... | [
"def",
"cache_size",
"(",
"mb",
"=",
"True",
")",
":",
"numtotal",
"=",
"[",
"0",
"]",
"# use mutable to keep reference through recursion",
"classdict",
"=",
"{",
"}",
"def",
"get_recurse",
"(",
"submodels",
")",
":",
"for",
"submodel",
"in",
"submodels",
":",... | [
577,
0
] | [
605,
33
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModelBase.__call__ | (cls, *args, **kwargs) |
this method will either create an instance (by calling the default implementation)
or try to retrieve one from the class-wide cache by inferring the pk value from
`args` and `kwargs`. If instance caching is enabled for this class, the cache is
populated whenever possible (ie when it is ... |
this method will either create an instance (by calling the default implementation)
or try to retrieve one from the class-wide cache by inferring the pk value from
`args` and `kwargs`. If instance caching is enabled for this class, the cache is
populated whenever possible (ie when it is ... | def __call__(cls, *args, **kwargs):
"""
this method will either create an instance (by calling the default implementation)
or try to retrieve one from the class-wide cache by inferring the pk value from
`args` and `kwargs`. If instance caching is enabled for this class, the cache is
... | [
"def",
"__call__",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"new_instance",
"(",
")",
":",
"return",
"super",
"(",
"SharedMemoryModelBase",
",",
"cls",
")",
".",
"__call__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
... | [
54,
4
] | [
73,
30
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModelBase._prepare | (cls) |
Prepare the cache, making sure that proxies of the same db base
share the same cache.
|
Prepare the cache, making sure that proxies of the same db base
share the same cache. | def _prepare(cls):
"""
Prepare the cache, making sure that proxies of the same db base
share the same cache.
"""
# the dbmodel is either the proxy base or ourselves
dbmodel = cls._meta.concrete_model if cls._meta.proxy else cls
cls.__dbclass__ = dbmodel
i... | [
"def",
"_prepare",
"(",
"cls",
")",
":",
"# the dbmodel is either the proxy base or ourselves",
"dbmodel",
"=",
"cls",
".",
"_meta",
".",
"concrete_model",
"if",
"cls",
".",
"_meta",
".",
"proxy",
"else",
"cls",
"cls",
".",
"__dbclass__",
"=",
"dbmodel",
"if",
... | [
75,
4
] | [
87,
52
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModelBase.__new__ | (cls, name, bases, attrs) |
Field shortcut creation:
Takes field names `db_*` and creates property wrappers named
without the `db_` prefix. So db_key -> key
This wrapper happens on the class level, so there is no
overhead when creating objects. If a class already has a
wrapper of the given name,... |
Field shortcut creation: | def __new__(cls, name, bases, attrs):
"""
Field shortcut creation:
Takes field names `db_*` and creates property wrappers named
without the `db_` prefix. So db_key -> key
This wrapper happens on the class level, so there is no
overhead when creating objects. If a class... | [
"def",
"__new__",
"(",
"cls",
",",
"name",
",",
"bases",
",",
"attrs",
")",
":",
"attrs",
"[",
"\"typename\"",
"]",
"=",
"cls",
".",
"__name__",
"attrs",
"[",
"\"path\"",
"]",
"=",
"\"%s.%s\"",
"%",
"(",
"attrs",
"[",
"\"__module__\"",
"]",
",",
"nam... | [
89,
4
] | [
205,
81
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel._get_cache_key | (cls, args, kwargs) |
This method is used by the caching subsystem to infer the PK
value from the constructor arguments. It is used to decide if
an instance has to be built or is already in the cache.
|
This method is used by the caching subsystem to infer the PK
value from the constructor arguments. It is used to decide if
an instance has to be built or is already in the cache. | def _get_cache_key(cls, args, kwargs):
"""
This method is used by the caching subsystem to infer the PK
value from the constructor arguments. It is used to decide if
an instance has to be built or is already in the cache.
"""
result = None
# Quick hack for my co... | [
"def",
"_get_cache_key",
"(",
"cls",
",",
"args",
",",
"kwargs",
")",
":",
"result",
"=",
"None",
"# Quick hack for my composites work for now.",
"if",
"hasattr",
"(",
"cls",
".",
"_meta",
",",
"'pks'",
")",
":",
"pk",
"=",
"cls",
".",
"_meta",
".",
"pks",... | [
219,
4
] | [
248,
21
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.get_cached_instance | (cls, id) |
Method to retrieve a cached instance by pk value. Returns None
when not found (which will always be the case when caching is
disabled for this class). Please note that the lookup will be
done even when instance caching is disabled.
|
Method to retrieve a cached instance by pk value. Returns None
when not found (which will always be the case when caching is
disabled for this class). Please note that the lookup will be
done even when instance caching is disabled. | def get_cached_instance(cls, id):
"""
Method to retrieve a cached instance by pk value. Returns None
when not found (which will always be the case when caching is
disabled for this class). Please note that the lookup will be
done even when instance caching is disabled.
"... | [
"def",
"get_cached_instance",
"(",
"cls",
",",
"id",
")",
":",
"return",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
".",
"get",
"(",
"id",
")"
] | [
251,
4
] | [
259,
57
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.cache_instance | (cls, instance, new=False) |
Method to store an instance in the cache.
Args:
instance (Class instance): the instance to cache.
new (bool, optional): this is the first time this instance is
cached (i.e. this is not an update operation like after a
db save).
|
Method to store an instance in the cache. | def cache_instance(cls, instance, new=False):
"""
Method to store an instance in the cache.
Args:
instance (Class instance): the instance to cache.
new (bool, optional): this is the first time this instance is
cached (i.e. this is not an update operation ... | [
"def",
"cache_instance",
"(",
"cls",
",",
"instance",
",",
"new",
"=",
"False",
")",
":",
"pk",
"=",
"instance",
".",
"_get_pk_val",
"(",
")",
"if",
"pk",
"is",
"not",
"None",
":",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
"[",
"pk",
"]",
... | [
262,
4
] | [
283,
24
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.get_all_cached_instances | (cls) |
Return the objects so far cached by idmapper for this class.
|
Return the objects so far cached by idmapper for this class. | def get_all_cached_instances(cls):
"""
Return the objects so far cached by idmapper for this class.
"""
return listvalues(cls.__dbclass__.__instance_cache__) | [
"def",
"get_all_cached_instances",
"(",
"cls",
")",
":",
"return",
"listvalues",
"(",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
")"
] | [
286,
4
] | [
291,
61
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel._flush_cached_by_key | (cls, key, force=True) |
Remove the cached reference.
|
Remove the cached reference. | def _flush_cached_by_key(cls, key, force=True):
"""
Remove the cached reference.
"""
try:
if force or cls.at_idmapper_flush():
del cls.__dbclass__.__instance_cache__[key]
else:
cls._dbclass__.__instance_cache__[key].refresh_from_db... | [
"def",
"_flush_cached_by_key",
"(",
"cls",
",",
"key",
",",
"force",
"=",
"True",
")",
":",
"try",
":",
"if",
"force",
"or",
"cls",
".",
"at_idmapper_flush",
"(",
")",
":",
"del",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
"[",
"key",
"]",
"... | [
294,
4
] | [
306,
16
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.flush_cached_instance | (cls, instance, force=True) |
Method to flush an instance from the cache. The instance will
always be flushed from the cache, since this is most likely
called from delete(), and we want to make sure we don't cache
dead objects.
|
Method to flush an instance from the cache. The instance will
always be flushed from the cache, since this is most likely
called from delete(), and we want to make sure we don't cache
dead objects. | def flush_cached_instance(cls, instance, force=True):
"""
Method to flush an instance from the cache. The instance will
always be flushed from the cache, since this is most likely
called from delete(), and we want to make sure we don't cache
dead objects.
"""
cls... | [
"def",
"flush_cached_instance",
"(",
"cls",
",",
"instance",
",",
"force",
"=",
"True",
")",
":",
"cls",
".",
"_flush_cached_by_key",
"(",
"instance",
".",
"_get_pk_val",
"(",
")",
",",
"force",
"=",
"force",
")"
] | [
309,
4
] | [
317,
69
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.flush_instance_cache | (cls, force=False) |
This will clean safe objects from the cache. Use `force`
keyword to remove all objects, safe or not.
|
This will clean safe objects from the cache. Use `force`
keyword to remove all objects, safe or not. | def flush_instance_cache(cls, force=False):
"""
This will clean safe objects from the cache. Use `force`
keyword to remove all objects, safe or not.
"""
if force:
cls.__dbclass__.__instance_cache__ = {}
else:
cls.__dbclass__.__instance_cache__ = d... | [
"def",
"flush_instance_cache",
"(",
"cls",
",",
"force",
"=",
"False",
")",
":",
"if",
"force",
":",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
"=",
"{",
"}",
"else",
":",
"cls",
".",
"__dbclass__",
".",
"__instance_cache__",
"=",
"dict",
"(",
... | [
321,
4
] | [
331,
85
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.at_idmapper_flush | (self) |
This is called when the idmapper cache is flushed and
allows customized actions when this happens.
Returns:
do_flush (bool): If True, flush this object as normal. If
False, don't flush and expect this object to handle
the flushing on its own.
... |
This is called when the idmapper cache is flushed and
allows customized actions when this happens. | def at_idmapper_flush(self):
"""
This is called when the idmapper cache is flushed and
allows customized actions when this happens.
Returns:
do_flush (bool): If True, flush this object as normal. If
False, don't flush and expect this object to handle
... | [
"def",
"at_idmapper_flush",
"(",
"self",
")",
":",
"return",
"True"
] | [
336,
4
] | [
346,
19
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.flush_from_cache | (self, force=False) |
Flush this instance from the instance cache. Use
`force` to override the result of at_idmapper_flush() for the object.
|
Flush this instance from the instance cache. Use
`force` to override the result of at_idmapper_flush() for the object. | def flush_from_cache(self, force=False):
"""
Flush this instance from the instance cache. Use
`force` to override the result of at_idmapper_flush() for the object.
"""
pk = self._get_pk_val()
if pk:
if force or self.at_idmapper_flush():
self._... | [
"def",
"flush_from_cache",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"pk",
"=",
"self",
".",
"_get_pk_val",
"(",
")",
"if",
"pk",
":",
"if",
"force",
"or",
"self",
".",
"at_idmapper_flush",
"(",
")",
":",
"self",
".",
"__class__",
".",
"__db... | [
348,
4
] | [
357,
75
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.delete | (self, *args, **kwargs) |
Delete the object, clearing cache.
|
Delete the object, clearing cache. | def delete(self, *args, **kwargs):
"""
Delete the object, clearing cache.
"""
self.flush_from_cache()
self._is_deleted = True
super(SharedMemoryModel, self).delete(*args, **kwargs) | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"flush_from_cache",
"(",
")",
"self",
".",
"_is_deleted",
"=",
"True",
"super",
"(",
"SharedMemoryModel",
",",
"self",
")",
".",
"delete",
"(",
"*",
"args... | [
359,
4
] | [
366,
62
] | python | en | ['en', 'error', 'th'] | False |
SharedMemoryModel.save | (self, *args, **kwargs) |
Central database save operation.
Notes:
Arguments as per Django documentation.
Calls `self.at_<fieldname>_postsave(new)`
(this is a wrapper set by oobhandler:
self._oob_at_<fieldname>_postsave())
|
Central database save operation. | def save(self, *args, **kwargs):
"""
Central database save operation.
Notes:
Arguments as per Django documentation.
Calls `self.at_<fieldname>_postsave(new)`
(this is a wrapper set by oobhandler:
self._oob_at_<fieldname>_postsave())
"""
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"_MONITOR_HANDLER",
"if",
"not",
"_MONITOR_HANDLER",
":",
"from",
"evennia",
".",
"scripts",
".",
"monitorhandler",
"import",
"MONITOR_HANDLER",
"as",
"_MONITOR_HANDLER"... | [
368,
4
] | [
428,
12
] | python | en | ['en', 'error', 'th'] | False |
TestPresentationProposal.test_init | (self) | Test initializer. | Test initializer. | def test_init(self):
"""Test initializer."""
presentation_proposal = PresentationProposal(
comment="Hello World", presentation_proposal=PRES_PREVIEW
)
assert presentation_proposal.presentation_proposal == PRES_PREVIEW | [
"def",
"test_init",
"(",
"self",
")",
":",
"presentation_proposal",
"=",
"PresentationProposal",
"(",
"comment",
"=",
"\"Hello World\"",
",",
"presentation_proposal",
"=",
"PRES_PREVIEW",
")",
"assert",
"presentation_proposal",
".",
"presentation_proposal",
"==",
"PRES_... | [
31,
4
] | [
36,
74
] | python | de | ['de', 'pl', 'en'] | False |
TestPresentationProposal.test_deserialize | (self) | Test deserialization. | Test deserialization. | def test_deserialize(self):
"""Test deserialization."""
obj = {
"@type": PRESENTATION_PROPOSAL,
"comment": "Hello World",
"presentation_proposal": PRES_PREVIEW.serialize(),
}
pres_proposal = PresentationProposal.deserialize(obj)
assert type(pr... | [
"def",
"test_deserialize",
"(",
"self",
")",
":",
"obj",
"=",
"{",
"\"@type\"",
":",
"PRESENTATION_PROPOSAL",
",",
"\"comment\"",
":",
"\"Hello World\"",
",",
"\"presentation_proposal\"",
":",
"PRES_PREVIEW",
".",
"serialize",
"(",
")",
",",
"}",
"pres_proposal",
... | [
45,
4
] | [
54,
58
] | python | de | ['ro', 'de', 'en'] | False |
TestPresentationProposal.test_serialize | (self) | Test serialization. | Test serialization. | def test_serialize(self):
"""Test serialization."""
pres_proposal = PresentationProposal(
comment="Hello World", presentation_proposal=PRES_PREVIEW
)
pres_proposal_dict = pres_proposal.serialize()
pres_proposal_dict.pop("@id")
assert pres_proposal_dict == {... | [
"def",
"test_serialize",
"(",
"self",
")",
":",
"pres_proposal",
"=",
"PresentationProposal",
"(",
"comment",
"=",
"\"Hello World\"",
",",
"presentation_proposal",
"=",
"PRES_PREVIEW",
")",
"pres_proposal_dict",
"=",
"pres_proposal",
".",
"serialize",
"(",
")",
"pre... | [
56,
4
] | [
70,
9
] | python | en | ['en', 'fy', 'en'] | False |
TestPresentationProposalSchema.test_make_model | (self) | Test making model. | Test making model. | def test_make_model(self):
"""Test making model."""
data = self.presentation_proposal.serialize()
model_instance = PresentationProposal.deserialize(data)
assert isinstance(model_instance, PresentationProposal) | [
"def",
"test_make_model",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"presentation_proposal",
".",
"serialize",
"(",
")",
"model_instance",
"=",
"PresentationProposal",
".",
"deserialize",
"(",
"data",
")",
"assert",
"isinstance",
"(",
"model_instance",
",... | [
80,
4
] | [
84,
63
] | python | en | ['en', 'no', 'en'] | True |
normalize_reply | (text: str, version=1) |
Standardize the capitalization and punctuation spacing of the input text.
Version 1: Fix sentence start casing, and punctuation.
Version 2: Add trailing period, if missing.
|
Standardize the capitalization and punctuation spacing of the input text. | def normalize_reply(text: str, version=1) -> str:
"""
Standardize the capitalization and punctuation spacing of the input text.
Version 1: Fix sentence start casing, and punctuation.
Version 2: Add trailing period, if missing.
"""
switch_list = [(' .', '.'), (' ,', ','), (' ?', '?'), (' !', '... | [
"def",
"normalize_reply",
"(",
"text",
":",
"str",
",",
"version",
"=",
"1",
")",
"->",
"str",
":",
"switch_list",
"=",
"[",
"(",
"' .'",
",",
"'.'",
")",
",",
"(",
"' ,'",
",",
"','",
")",
",",
"(",
"' ?'",
",",
"'?'",
")",
",",
"(",
"' !'",
... | [
12,
0
] | [
53,
19
] | python | en | ['en', 'error', 'th'] | False |
uppercase | (string: str) |
Make the first character of the string uppercase, if the string is non-empty.
|
Make the first character of the string uppercase, if the string is non-empty.
| def uppercase(string: str) -> str:
"""
Make the first character of the string uppercase, if the string is non-empty.
"""
if len(string) == 0:
return string
else:
return string[0].upper() + string[1:] | [
"def",
"uppercase",
"(",
"string",
":",
"str",
")",
"->",
"str",
":",
"if",
"len",
"(",
"string",
")",
"==",
"0",
":",
"return",
"string",
"else",
":",
"return",
"string",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"string",
"[",
"1",
":",
"]"... | [
56,
0
] | [
63,
45
] | python | en | ['en', 'error', 'th'] | False |
ipynb_vega_init | () | Initialize the IPython notebook display elements
This function borrows heavily from the excellent vincent package:
http://github.com/wrobstory/vincent
| Initialize the IPython notebook display elements | def ipynb_vega_init():
"""Initialize the IPython notebook display elements
This function borrows heavily from the excellent vincent package:
http://github.com/wrobstory/vincent
"""
try:
from IPython.core.display import display, HTML
except ImportError:
print('IPython Notebook co... | [
"def",
"ipynb_vega_init",
"(",
")",
":",
"try",
":",
"from",
"IPython",
".",
"core",
".",
"display",
"import",
"display",
",",
"HTML",
"except",
"ImportError",
":",
"print",
"(",
"'IPython Notebook could not be loaded.'",
")",
"require_js",
"=",
"'''\n if (wind... | [
5,
0
] | [
51,
23
] | python | en | ['en', 'en', 'en'] | True |
Contour.color | (self) |
Sets the color of the contour lines.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%... |
Sets the color of the contour lines.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%... | def color(self):
"""
Sets the color of the contour lines.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva s... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Contour.show | (self) |
Sets whether or not dynamic contours are shown on hover
The 'show' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Sets whether or not dynamic contours are shown on hover
The 'show' property must be specified as a bool
(either True, or False) | def show(self):
"""
Sets whether or not dynamic contours are shown on hover
The 'show' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["show"] | [
"def",
"show",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"show\"",
"]"
] | [
74,
4
] | [
85,
27
] | python | en | ['en', 'error', 'th'] | False |
Contour.width | (self) |
Sets the width of the contour lines.
The 'width' property is a number and may be specified as:
- An int or float in the interval [1, 16]
Returns
-------
int|float
|
Sets the width of the contour lines.
The 'width' property is a number and may be specified as:
- An int or float in the interval [1, 16] | def width(self):
"""
Sets the width of the contour lines.
The 'width' property is a number and may be specified as:
- An int or float in the interval [1, 16]
Returns
-------
int|float
"""
return self["width"] | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
94,
4
] | [
105,
28
] | python | en | ['en', 'error', 'th'] | False |
Contour.__init__ | (self, arg=None, color=None, show=None, width=None, **kwargs) |
Construct a new Contour object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mesh3d.Contour`
color
Sets the color of the contour lines.
sh... |
Construct a new Contour object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mesh3d.Contour`
color
Sets the color of the contour lines.
sh... | def __init__(self, arg=None, color=None, show=None, width=None, **kwargs):
"""
Construct a new Contour object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.mes... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"show",
"=",
"None",
",",
"width",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Contour",
",",
"self",
")",
".",
"__init__",
"(",
"\"contou... | [
124,
4
] | [
193,
34
] | python | en | ['en', 'error', 'th'] | False |
Marker.line | (self) |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.choropleth.marker.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.choropleth.marker.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... | def line(self):
"""
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.choropleth.marker.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported d... | [
"def",
"line",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"line\"",
"]"
] | [
15,
4
] | [
46,
27
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacity | (self) |
Sets the opacity of the locations.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
Sets the opacity of the locations.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above | def opacity(self):
"""
Sets the opacity of the locations.
The 'opacity' property is a number and may be specified as:
- An int or float in the interval [0, 1]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|... | [
"def",
"opacity",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacity\"",
"]"
] | [
55,
4
] | [
67,
30
] | python | en | ['en', 'error', 'th'] | False |
Marker.opacitysrc | (self) |
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def opacitysrc(self):
"""
Sets the source reference on Chart Studio Cloud for opacity .
The 'opacitysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["opacitysrc"] | [
"def",
"opacitysrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"opacitysrc\"",
"]"
] | [
76,
4
] | [
87,
33
] | python | en | ['en', 'error', 'th'] | False |
Marker.__init__ | (self, arg=None, line=None, opacity=None, opacitysrc=None, **kwargs) |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.choropleth.Marker`
line
:class:`plotly.graph_objects.choropleth.marker... |
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.choropleth.Marker`
line
:class:`plotly.graph_objects.choropleth.marker... | def __init__(self, arg=None, line=None, opacity=None, opacitysrc=None, **kwargs):
"""
Construct a new Marker object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_ob... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"line",
"=",
"None",
",",
"opacity",
"=",
"None",
",",
"opacitysrc",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Marker",
",",
"self",
")",
".",
"__init__",
"(",
"\"... | [
108,
4
] | [
179,
34
] | python | en | ['en', 'error', 'th'] | False |
filter_asyncio_call | (record: logging.LogRecord) |
filters the asyncio logger to only log calls that show if something is blocking.
|
filters the asyncio logger to only log calls that show if something is blocking.
| def filter_asyncio_call(record: logging.LogRecord):
"""
filters the asyncio logger to only log calls that show if something is blocking.
"""
if record.for_asyncio_enabled is True:
return 1
return 0 | [
"def",
"filter_asyncio_call",
"(",
"record",
":",
"logging",
".",
"LogRecord",
")",
":",
"if",
"record",
".",
"for_asyncio_enabled",
"is",
"True",
":",
"return",
"1",
"return",
"0"
] | [
51,
0
] | [
58,
12
] | python | en | ['en', 'error', 'th'] | False |
configure_logger | () |
Configures the logger from the base_config.ini file.
When logging to file, the file rotates every new run and also when it reaches a size of 10mb.
Mainly to either log to stdout and a file or only a file and how many files it should keep.
|
Configures the logger from the base_config.ini file.
When logging to file, the file rotates every new run and also when it reaches a size of 10mb.
Mainly to either log to stdout and a file or only a file and how many files it should keep.
| def configure_logger():
"""
Configures the logger from the base_config.ini file.
When logging to file, the file rotates every new run and also when it reaches a size of 10mb.
Mainly to either log to stdout and a file or only a file and how many files it should keep.
"""
# TODO: way to convoluted... | [
"def",
"configure_logger",
"(",
")",
":",
"# TODO: way to convoluted, make it simpler look into better loggign frameworks.",
"def",
"from_config",
"(",
"key",
",",
"attr_name",
")",
":",
"\"\"\"\n Helper func to get values from the config, without having to type the section repete... | [
73,
0
] | [
140,
15
] | python | en | ['en', 'error', 'th'] | False |
cli | () |
dummy function to initiate click group.
|
dummy function to initiate click group.
| def cli():
"""
dummy function to initiate click group.
""" | [
"def",
"cli",
"(",
")",
":"
] | [
156,
0
] | [
159,
7
] | python | en | ['en', 'error', 'th'] | False |
collect_data | () |
dummy function to initiate click group.
|
dummy function to initiate click group.
| def collect_data():
"""
dummy function to initiate click group.
""" | [
"def",
"collect_data",
"(",
")",
":"
] | [
168,
0
] | [
171,
7
] | python | en | ['en', 'error', 'th'] | False |
command_info_run | (output_file, verbose) |
Cli command to start up the bot, collect bot-commands extended info, but not connect to discord.
collected in `/docs/resources/data` as `commands_data.json`
|
Cli command to start up the bot, collect bot-commands extended info, but not connect to discord. | def command_info_run(output_file, verbose):
"""
Cli command to start up the bot, collect bot-commands extended info, but not connect to discord.
collected in `/docs/resources/data` as `commands_data.json`
"""
old_cwd = os.getcwd()
os.chdir(THIS_FILE_DIR)
load_dotenv('token.env')
load_do... | [
"def",
"command_info_run",
"(",
"output_file",
",",
"verbose",
")",
":",
"old_cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"THIS_FILE_DIR",
")",
"load_dotenv",
"(",
"'token.env'",
")",
"load_dotenv",
"(",
"\"nextcloud.env\"",
")",
"os",... | [
177,
0
] | [
195,
70
] | python | en | ['en', 'error', 'th'] | False |
clean_user_data | () |
Cli command to clean the 'APPDATA' folder that was created.
Deletes all files, created by this application in the `APPDATA` folder.
Can be seen as a deinstall command.
Raises:
RuntimeError: if you try to delete the folder while `IS_DEV` is set, it raises andd error so not to delete the dev `... |
Cli command to clean the 'APPDATA' folder that was created. | def clean_user_data():
"""
Cli command to clean the 'APPDATA' folder that was created.
Deletes all files, created by this application in the `APPDATA` folder.
Can be seen as a deinstall command.
Raises:
RuntimeError: if you try to delete the folder while `IS_DEV` is set, it raises andd er... | [
"def",
"clean_user_data",
"(",
")",
":",
"if",
"os",
".",
"environ",
"[",
"'IS_DEV'",
"]",
".",
"casefold",
"(",
")",
"in",
"[",
"'true'",
",",
"'yes'",
",",
"'1'",
"]",
"or",
"APPDATA",
".",
"dev",
"is",
"True",
":",
"raise",
"RuntimeError",
"(",
... | [
199,
0
] | [
212,
36
] | python | en | ['en', 'error', 'th'] | False |
stop | (member_id) |
Not Implemented
|
Not Implemented
| def stop(member_id):
"""
Not Implemented
"""
raise NotImplementedError("not yet found good solution") | [
"def",
"stop",
"(",
"member_id",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"not yet found good solution\"",
")"
] | [
217,
0
] | [
221,
60
] | python | en | ['en', 'error', 'th'] | False |
run | (token, nextcloud_username, nextcloud_password, github_token, battlemetrics_token) |
Standard way to start the bot and connect it to discord.
takes the token as string and the key to decrypt the db also as string.
calls the actual main() function.
Args:
token_file ([str]): discord token
nextcloud_username([str]): username for dev_drive on nextcloud
nexctcloud_p... |
Standard way to start the bot and connect it to discord.
takes the token as string and the key to decrypt the db also as string.
calls the actual main() function. | def run(token, nextcloud_username, nextcloud_password, github_token, battlemetrics_token):
"""
Standard way to start the bot and connect it to discord.
takes the token as string and the key to decrypt the db also as string.
calls the actual main() function.
Args:
token_file ([str]): discord... | [
"def",
"run",
"(",
"token",
",",
"nextcloud_username",
",",
"nextcloud_password",
",",
"github_token",
",",
"battlemetrics_token",
")",
":",
"os",
".",
"environ",
"[",
"'INFO_RUN'",
"]",
"=",
"\"0\"",
"main",
"(",
"token",
"=",
"str",
"(",
"token",
")",
",... | [
242,
0
] | [
254,
172
] | python | en | ['en', 'error', 'th'] | False |
main | (token: str, nextcloud_username: str = None, nextcloud_password: str = None, github_token: str = None, battlemetrics_token: str = None) |
Starts the Antistasi Discord Bot 'AntiPetros'.
Instantiates the bot, loads the extensions and starts the bot with the Token.
This is seperated from the Cli run function so the bot can be started via cli but also from within vscode.
Args:
token_file ([str]): discord token
nextcloud_use... |
Starts the Antistasi Discord Bot 'AntiPetros'. | def main(token: str, nextcloud_username: str = None, nextcloud_password: str = None, github_token: str = None, battlemetrics_token: str = None):
"""
Starts the Antistasi Discord Bot 'AntiPetros'.
Instantiates the bot, loads the extensions and starts the bot with the Token.
This is seperated from the Cl... | [
"def",
"main",
"(",
"token",
":",
"str",
",",
"nextcloud_username",
":",
"str",
"=",
"None",
",",
"nextcloud_password",
":",
"str",
"=",
"None",
",",
"github_token",
":",
"str",
"=",
"None",
",",
"battlemetrics_token",
":",
"str",
"=",
"None",
")",
":",
... | [
257,
0
] | [
301,
63
] | python | en | ['en', 'error', 'th'] | False |
roll_init | (character) |
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does not reference the character and si... |
Rolls a number between 1-1000 to determine initiative. | def roll_init(character):
"""
Rolls a number between 1-1000 to determine initiative.
Args:
character (obj): The character to determine initiative for
Returns:
initiative (int): The character's place in initiative - higher
numbers go first.
Notes:
By default, does n... | [
"def",
"roll_init",
"(",
"character",
")",
":",
"return",
"randint",
"(",
"1",
",",
"1000",
")"
] | [
121,
0
] | [
145,
27
] | python | en | ['en', 'error', 'th'] | False |
get_attack | (attacker, defender, attack_type) |
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of attack ('melee' or 'ranged')
Returns:
attack_value (int): Attack roll value, compared against a defense value
... |
Returns a value for an attack roll. | def get_attack(attacker, defender, attack_type):
"""
Returns a value for an attack roll.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of attack ('melee' or 'ranged')
Returns:
attack_value (int): Att... | [
"def",
"get_attack",
"(",
"attacker",
",",
"defender",
",",
"attack_type",
")",
":",
"# For this example, just return a random integer up to 100.",
"attack_value",
"=",
"randint",
"(",
"1",
",",
"100",
")",
"# Make melee attacks more accurate, ranged attacks less accurate",
"... | [
148,
0
] | [
177,
23
] | python | en | ['en', 'error', 'th'] | False |
get_defense | (attacker, defender, attack_type) |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of attack ('melee' or 'ranged')
Returns:
defense_v... |
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit. | def get_defense(attacker, defender, attack_type):
"""
Returns a value for defense, which an attack roll must equal or exceed in order
for an attack to hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of att... | [
"def",
"get_defense",
"(",
"attacker",
",",
"defender",
",",
"attack_type",
")",
":",
"# For this example, just return 50, for about a 50/50 chance of hit.",
"defense_value",
"=",
"50",
"return",
"defense_value"
] | [
180,
0
] | [
202,
24
] | python | en | ['en', 'error', 'th'] | False |
get_damage | (attacker, defender) |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, which is to be deducted from the defending
... |
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit. | def get_damage(attacker, defender):
"""
Returns a value for damage to be deducted from the defender's HP after abilities
successful hit.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being damaged
Returns:
damage_value (int): Damage value, wh... | [
"def",
"get_damage",
"(",
"attacker",
",",
"defender",
")",
":",
"# For this example, just generate a number between 15 and 25.",
"damage_value",
"=",
"randint",
"(",
"15",
",",
"25",
")",
"return",
"damage_value"
] | [
205,
0
] | [
226,
23
] | python | en | ['en', 'error', 'th'] | False |
apply_damage | (defender, damage) |
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
|
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0. | def apply_damage(defender, damage):
"""
Applies damage to a target, reducing their HP by the damage amount to a
minimum of 0.
Args:
defender (obj): Character taking damage
damage (int): Amount of damage being taken
"""
defender.db.hp -= damage # Reduce defender's HP by the dama... | [
"def",
"apply_damage",
"(",
"defender",
",",
"damage",
")",
":",
"defender",
".",
"db",
".",
"hp",
"-=",
"damage",
"# Reduce defender's HP by the damage dealt.",
"# If this reduces it to 0 or less, set HP to 0.",
"if",
"defender",
".",
"db",
".",
"hp",
"<=",
"0",
":... | [
229,
0
] | [
241,
26
] | python | en | ['en', 'error', 'th'] | False |
at_defeat | (defeated) |
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
into a dying state or some... |
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
into a dying state or some... | def at_defeat(defeated):
"""
Announces the defeat of a fighter in combat.
Args:
defeated (obj): Fighter that's been defeated.
Notes:
All this does is announce a defeat message by default, but if you
want anything else to happen to defeated fighters (like putting them
... | [
"def",
"at_defeat",
"(",
"defeated",
")",
":",
"defeated",
".",
"location",
".",
"msg_contents",
"(",
"\"%s has been defeated!\"",
"%",
"defeated",
")"
] | [
243,
0
] | [
256,
70
] | python | en | ['en', 'error', 'th'] | False |
resolve_attack | (attacker, defender, attack_type, attack_value=None, defense_value=None) |
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of attack (melee or ranged)
Notes:
Even though the attack and defense values are calculated
extremely sim... |
Resolves an attack and outputs the result. | def resolve_attack(attacker, defender, attack_type, attack_value=None, defense_value=None):
"""
Resolves an attack and outputs the result.
Args:
attacker (obj): Character doing the attacking
defender (obj): Character being attacked
attack_type (str): Type of attack (melee or ranged)... | [
"def",
"resolve_attack",
"(",
"attacker",
",",
"defender",
",",
"attack_type",
",",
"attack_value",
"=",
"None",
",",
"defense_value",
"=",
"None",
")",
":",
"# Get an attack roll from the attacker.",
"if",
"not",
"attack_value",
":",
"attack_value",
"=",
"get_attac... | [
258,
0
] | [
288,
31
] | python | en | ['en', 'error', 'th'] | False |
get_range | (obj1, obj2) |
Gets the combat range between two objects.
Args:
obj1 (obj): First object
obj2 (obj): Second object
Returns:
range (int or None): Distance between two objects or None if not applicable
|
Gets the combat range between two objects.
Args:
obj1 (obj): First object
obj2 (obj): Second object
Returns:
range (int or None): Distance between two objects or None if not applicable
| def get_range(obj1, obj2):
"""
Gets the combat range between two objects.
Args:
obj1 (obj): First object
obj2 (obj): Second object
Returns:
range (int or None): Distance between two objects or None if not applicable
"""
# Return None if not applicable.
i... | [
"def",
"get_range",
"(",
"obj1",
",",
"obj2",
")",
":",
"# Return None if not applicable.",
"if",
"not",
"obj1",
".",
"db",
".",
"combat_range",
":",
"return",
"None",
"if",
"not",
"obj2",
".",
"db",
".",
"combat_range",
":",
"return",
"None",
"if",
"obj1"... | [
290,
0
] | [
311,
37
] | python | en | ['en', 'error', 'th'] | False |
distance_inc | (mover, target) |
Function that increases distance in range field between mover and target.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
|
Function that increases distance in range field between mover and target.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
| def distance_inc(mover, target):
"""
Function that increases distance in range field between mover and target.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
"""
mover.db.combat_range[target] += 1
target.db.combat_range[mover] = mover.db.... | [
"def",
"distance_inc",
"(",
"mover",
",",
"target",
")",
":",
"mover",
".",
"db",
".",
"combat_range",
"[",
"target",
"]",
"+=",
"1",
"target",
".",
"db",
".",
"combat_range",
"[",
"mover",
"]",
"=",
"mover",
".",
"db",
".",
"combat_range",
"[",
"tar... | [
313,
0
] | [
326,
41
] | python | en | ['en', 'error', 'th'] | False |
approach | (mover, target) |
Manages a character's whole approach, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved toward
Notes:
The mover will also automatically move toward any objects that are closer to the
targe... |
Manages a character's whole approach, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved toward
Notes:
The mover will also automatically move toward any objects that are closer to the
targe... | def approach(mover, target):
"""
Manages a character's whole approach, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved toward
Notes:
The mover will also automatically move toward any objects ... | [
"def",
"approach",
"(",
"mover",
",",
"target",
")",
":",
"def",
"distance_dec",
"(",
"mover",
",",
"target",
")",
":",
"\"\"\"\n Helper function that decreases distance in range field between mover and target.\n \n Args:\n mover (obj): The object movi... | [
328,
0
] | [
372,
31
] | python | en | ['en', 'error', 'th'] | False |
withdraw | (mover, target) |
Manages a character's whole withdrawal, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
Notes:
The mover will also automatically move away from objects that are close to the target
... |
Manages a character's whole withdrawal, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
Notes:
The mover will also automatically move away from objects that are close to the target
... | def withdraw(mover, target):
"""
Manages a character's whole withdrawal, including changes in ranges to other characters.
Args:
mover (obj): The object moving
target (obj): The object to be moved away from
Notes:
The mover will also automatically move away from obje... | [
"def",
"withdraw",
"(",
"mover",
",",
"target",
")",
":",
"contents",
"=",
"mover",
".",
"location",
".",
"contents",
"for",
"thing",
"in",
"contents",
":",
"if",
"thing",
"!=",
"mover",
"and",
"thing",
"!=",
"target",
":",
"# Move away from each object clos... | [
374,
0
] | [
402,
31
] | python | en | ['en', 'error', 'th'] | False |
combat_cleanup | (character) |
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ends.
|
Cleans up all the temporary combat-related attributes on a character. | def combat_cleanup(character):
"""
Cleans up all the temporary combat-related attributes on a character.
Args:
character (obj): Character to have their combat attributes removed
Notes:
Any attribute whose key begins with 'combat_' is temporary and no
longer needed once a fight ... | [
"def",
"combat_cleanup",
"(",
"character",
")",
":",
"for",
"attr",
"in",
"character",
".",
"attributes",
".",
"all",
"(",
")",
":",
"if",
"attr",
".",
"key",
"[",
":",
"7",
"]",
"==",
"\"combat_\"",
":",
"# If the attribute name starts with 'combat_'...",
"... | [
404,
0
] | [
417,
53
] | python | en | ['en', 'error', 'th'] | False |
is_in_combat | (character) |
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
|
Returns true if the given character is in combat. | def is_in_combat(character):
"""
Returns true if the given character is in combat.
Args:
character (obj): Character to determine if is in combat or not
Returns:
(bool): True if in combat or False if not in combat
"""
return bool(character.db.combat_turnhandler) | [
"def",
"is_in_combat",
"(",
"character",
")",
":",
"return",
"bool",
"(",
"character",
".",
"db",
".",
"combat_turnhandler",
")"
] | [
420,
0
] | [
430,
48
] | python | en | ['en', 'error', 'th'] | False |
is_turn | (character) |
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
|
Returns true if it's currently the given character's turn in combat. | def is_turn(character):
"""
Returns true if it's currently the given character's turn in combat.
Args:
character (obj): Character to determine if it is their turn or not
Returns:
(bool): True if it is their turn or False otherwise
"""
turnhandler = character.db.combat_turnhandl... | [
"def",
"is_turn",
"(",
"character",
")",
":",
"turnhandler",
"=",
"character",
".",
"db",
".",
"combat_turnhandler",
"currentchar",
"=",
"turnhandler",
".",
"db",
".",
"fighters",
"[",
"turnhandler",
".",
"db",
".",
"turn",
"]",
"return",
"bool",
"(",
"cha... | [
433,
0
] | [
445,
41
] | python | en | ['en', 'error', 'th'] | False |
spend_action | (character, actions, action_name=None) |
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
action_name (str or None): If a string is given, sets character'... |
Spends a character's available combat actions and checks for end of turn. | def spend_action(character, actions, action_name=None):
"""
Spends a character's available combat actions and checks for end of turn.
Args:
character (obj): Character spending the action
actions (int) or 'all': Number of actions to spend, or 'all' to spend all actions
Kwargs:
a... | [
"def",
"spend_action",
"(",
"character",
",",
"actions",
",",
"action_name",
"=",
"None",
")",
":",
"if",
"action_name",
":",
"character",
".",
"db",
".",
"combat_lastaction",
"=",
"action_name",
"if",
"actions",
"==",
"'all'",
":",
"# If spending all actions",
... | [
448,
0
] | [
468,
61
] | python | en | ['en', 'error', 'th'] | False |
combat_status_message | (fighter) |
Sends a message to a player with their current HP and
distances to other fighters and objects. Called at turn
start and by the 'status' command.
|
Sends a message to a player with their current HP and
distances to other fighters and objects. Called at turn
start and by the 'status' command.
| def combat_status_message(fighter):
"""
Sends a message to a player with their current HP and
distances to other fighters and objects. Called at turn
start and by the 'status' command.
"""
if not fighter.db.max_hp:
fighter.db.hp = 100
fighter.db.max_hp = 100
status_msg = ("H... | [
"def",
"combat_status_message",
"(",
"fighter",
")",
":",
"if",
"not",
"fighter",
".",
"db",
".",
"max_hp",
":",
"fighter",
".",
"db",
".",
"hp",
"=",
"100",
"fighter",
".",
"db",
".",
"max_hp",
"=",
"100",
"status_msg",
"=",
"(",
"\"HP Remaining: %i / %... | [
470,
0
] | [
506,
27
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.at_script_creation | (self) |
Called once, when the script is created.
|
Called once, when the script is created.
| def at_script_creation(self):
"""
Called once, when the script is created.
"""
self.key = "Combat Turn Handler"
self.interval = 5 # Once every 5 seconds
self.persistent = True
self.db.fighters = []
# Add all fighters in the room with at least 1 HP to the... | [
"def",
"at_script_creation",
"(",
"self",
")",
":",
"self",
".",
"key",
"=",
"\"Combat Turn Handler\"",
"self",
".",
"interval",
"=",
"5",
"# Once every 5 seconds",
"self",
".",
"persistent",
"=",
"True",
"self",
".",
"db",
".",
"fighters",
"=",
"[",
"]",
... | [
527,
4
] | [
565,
36
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.at_stop | (self) |
Called at script termination.
|
Called at script termination.
| def at_stop(self):
"""
Called at script termination.
"""
for thing in self.obj.contents:
combat_cleanup(thing) # Clean up the combat attributes for every object in the room.
self.obj.db.combat_turnhandler = None | [
"def",
"at_stop",
"(",
"self",
")",
":",
"for",
"thing",
"in",
"self",
".",
"obj",
".",
"contents",
":",
"combat_cleanup",
"(",
"thing",
")",
"# Clean up the combat attributes for every object in the room.",
"self",
".",
"obj",
".",
"db",
".",
"combat_turnhandler"... | [
567,
4
] | [
573,
45
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.at_repeat | (self) |
Called once every self.interval seconds.
|
Called once every self.interval seconds.
| def at_repeat(self):
"""
Called once every self.interval seconds.
"""
currentchar = self.db.fighters[self.db.turn] # Note the current character in the turn order.
self.db.timer -= self.interval # Count down the timer.
if self.db.timer <= 0:
# Force current ... | [
"def",
"at_repeat",
"(",
"self",
")",
":",
"currentchar",
"=",
"self",
".",
"db",
".",
"fighters",
"[",
"self",
".",
"db",
".",
"turn",
"]",
"# Note the current character in the turn order.",
"self",
".",
"db",
".",
"timer",
"-=",
"self",
".",
"interval",
... | [
575,
4
] | [
590,
48
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.init_range | (self, to_init) |
Initializes range values for an object at the start of a fight.
Args:
to_init (object): Object to initialize range field for.
|
Initializes range values for an object at the start of a fight.
Args:
to_init (object): Object to initialize range field for.
| def init_range(self, to_init):
"""
Initializes range values for an object at the start of a fight.
Args:
to_init (object): Object to initialize range field for.
"""
rangedict = {}
# Get a list of objects in the room.
objectlist = self.obj.cont... | [
"def",
"init_range",
"(",
"self",
",",
"to_init",
")",
":",
"rangedict",
"=",
"{",
"}",
"# Get a list of objects in the room.",
"objectlist",
"=",
"self",
".",
"obj",
".",
"contents",
"for",
"thing",
"in",
"objectlist",
":",
"# Object always at distance 0 from itsel... | [
592,
4
] | [
613,
43
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.join_rangefield | (self, to_init, anchor_obj=None, add_distance=0) |
Adds a new object to the range field of a fight in progress.
Args:
to_init (object): Object to initialize range field for.
Kwargs:
anchor_obj (object): Object to copy range values from, or None for a random object.
add_distance (int): Distan... |
Adds a new object to the range field of a fight in progress.
Args:
to_init (object): Object to initialize range field for.
Kwargs:
anchor_obj (object): Object to copy range values from, or None for a random object.
add_distance (int): Distan... | def join_rangefield(self, to_init, anchor_obj=None, add_distance=0):
"""
Adds a new object to the range field of a fight in progress.
Args:
to_init (object): Object to initialize range field for.
Kwargs:
anchor_obj (object): Object to copy range ... | [
"def",
"join_rangefield",
"(",
"self",
",",
"to_init",
",",
"anchor_obj",
"=",
"None",
",",
"add_distance",
"=",
"0",
")",
":",
"# Get a list of room's contents without to_init object.",
"contents",
"=",
"self",
".",
"obj",
".",
"contents",
"contents",
".",
"remov... | [
615,
4
] | [
643,
41
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.initialize_for_combat | (self, character) |
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
|
Prepares a character for combat when starting or entering a fight. | def initialize_for_combat(self, character):
"""
Prepares a character for combat when starting or entering a fight.
Args:
character (obj): Character to initialize for combat.
"""
combat_cleanup(character) # Clean up leftover combat attributes beforehand, just in case... | [
"def",
"initialize_for_combat",
"(",
"self",
",",
"character",
")",
":",
"combat_cleanup",
"(",
"character",
")",
"# Clean up leftover combat attributes beforehand, just in case.",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"0",
"# Actions remaining - start of tu... | [
645,
4
] | [
655,
47
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.start_turn | (self, character) |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
In this example, characters are given two actions per turn. This allow... |
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up. | def start_turn(self, character):
"""
Readies a character for the start of their turn by replenishing their
available actions and notifying them that their turn has come up.
Args:
character (obj): Character to be readied.
Notes:
In this example, character... | [
"def",
"start_turn",
"(",
"self",
",",
"character",
")",
":",
"character",
".",
"db",
".",
"combat_actionsleft",
"=",
"ACTIONS_PER_TURN",
"# Replenish actions",
"# Prompt the character for their turn and give some information.",
"character",
".",
"msg",
"(",
"\"|wIt's your ... | [
657,
4
] | [
673,
40
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.next_turn | (self) |
Advances to the next character in the turn order.
|
Advances to the next character in the turn order.
| def next_turn(self):
"""
Advances to the next character in the turn order.
"""
# Check to see if every character disengaged as their last action. If so, end combat.
disengage_check = True
for fighter in self.db.fighters:
if fighter.db.combat_lastaction != "di... | [
"def",
"next_turn",
"(",
"self",
")",
":",
"# Check to see if every character disengaged as their last action. If so, end combat.",
"disengage_check",
"=",
"True",
"for",
"fighter",
"in",
"self",
".",
"db",
".",
"fighters",
":",
"if",
"fighter",
".",
"db",
".",
"comba... | [
675,
4
] | [
712,
32
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.turn_end_check | (self, character) |
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
|
Tests to see if a character's turn is over, and cycles to the next turn if it is. | def turn_end_check(self, character):
"""
Tests to see if a character's turn is over, and cycles to the next turn if it is.
Args:
character (obj): Character to test for end of turn
"""
if not character.db.combat_actionsleft: # Character has no actions remaining
... | [
"def",
"turn_end_check",
"(",
"self",
",",
"character",
")",
":",
"if",
"not",
"character",
".",
"db",
".",
"combat_actionsleft",
":",
"# Character has no actions remaining",
"self",
".",
"next_turn",
"(",
")",
"return"
] | [
714,
4
] | [
723,
18
] | python | en | ['en', 'error', 'th'] | False |
TBRangeTurnHandler.join_fight | (self, character) |
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
|
Adds a new character to a fight already in progress. | def join_fight(self, character):
"""
Adds a new character to a fight already in progress.
Args:
character (obj): Character to be added to the fight.
"""
# Inserts the fighter to the turn order, right behind whoever's turn it currently is.
self.db.fighters.ins... | [
"def",
"join_fight",
"(",
"self",
",",
"character",
")",
":",
"# Inserts the fighter to the turn order, right behind whoever's turn it currently is.",
"self",
".",
"db",
".",
"fighters",
".",
"insert",
"(",
"self",
".",
"db",
".",
"turn",
",",
"character",
")",
"# T... | [
725,
4
] | [
740,
59
] | python | en | ['en', 'error', 'th'] | False |
TBRangeCharacter.at_object_creation | (self) |
Called once, when this object is first created. This is the
normal hook to overload for most object types.
|
Called once, when this object is first created. This is the
normal hook to overload for most object types.
| def at_object_creation(self):
"""
Called once, when this object is first created. This is the
normal hook to overload for most object types.
"""
self.db.max_hp = 100 # Set maximum HP to 100
self.db.hp = self.db.max_hp # Set current HP to maximum
"""
Adds... | [
"def",
"at_object_creation",
"(",
"self",
")",
":",
"self",
".",
"db",
".",
"max_hp",
"=",
"100",
"# Set maximum HP to 100",
"self",
".",
"db",
".",
"hp",
"=",
"self",
".",
"db",
".",
"max_hp",
"# Set current HP to maximum",
"\"\"\"\n Adds attributes for a ... | [
756,
4
] | [
769,
11
] | python | en | ['en', 'error', 'th'] | False |
TBRangeCharacter.at_before_move | (self, destination) |
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this method returns False/None, the move is cancelled
... |
Called just before starting to move this object to
destination. | def at_before_move(self, destination):
"""
Called just before starting to move this object to
destination.
Args:
destination (Object): The object we are moving to
Returns:
shouldmove (bool): If we should move or not.
Notes:
If this m... | [
"def",
"at_before_move",
"(",
"self",
",",
"destination",
")",
":",
"# Keep the character from moving if at 0 HP or in combat.",
"if",
"is_in_combat",
"(",
"self",
")",
":",
"self",
".",
"msg",
"(",
"\"You can't exit a room while in combat!\"",
")",
"return",
"False",
"... | [
771,
4
] | [
794,
19
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_before_drop | (self, dropper) |
Called by the default `drop` command before this object has been
dropped.
Args:
dropper (Object): The object which will drop this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default).
Returns:
... |
Called by the default `drop` command before this object has been
dropped. | def at_before_drop(self, dropper):
"""
Called by the default `drop` command before this object has been
dropped.
Args:
dropper (Object): The object which will drop this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding th... | [
"def",
"at_before_drop",
"(",
"self",
",",
"dropper",
")",
":",
"# Can't drop something if in combat and it's not your turn",
"if",
"is_in_combat",
"(",
"dropper",
")",
"and",
"not",
"is_turn",
"(",
"dropper",
")",
":",
"dropper",
".",
"msg",
"(",
"\"You can only dr... | [
803,
4
] | [
825,
19
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_drop | (self, dropper) |
Called by the default `drop` command when this object has been
dropped.
Args:
dropper (Object): The object which just dropped this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default).
Notes:
... |
Called by the default `drop` command when this object has been
dropped. | def at_drop(self, dropper):
"""
Called by the default `drop` command when this object has been
dropped.
Args:
dropper (Object): The object which just dropped this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call... | [
"def",
"at_drop",
"(",
"self",
",",
"dropper",
")",
":",
"# If dropper is currently in combat",
"if",
"dropper",
".",
"location",
".",
"db",
".",
"combat_turnhandler",
":",
"# Object joins the range field",
"self",
".",
"db",
".",
"combat_range",
"=",
"{",
"}",
... | [
827,
4
] | [
846,
92
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_before_get | (self, getter) |
Called by the default `get` command before this object has been
picked up.
Args:
getter (Object): The object about to get this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default).
Returns:
... |
Called by the default `get` command before this object has been
picked up. | def at_before_get(self, getter):
"""
Called by the default `get` command before this object has been
picked up.
Args:
getter (Object): The object about to get this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the cal... | [
"def",
"at_before_get",
"(",
"self",
",",
"getter",
")",
":",
"# Restrictions for getting in combat",
"if",
"is_in_combat",
"(",
"getter",
")",
":",
"if",
"not",
"is_turn",
"(",
"getter",
")",
":",
"# Not your turn",
"getter",
".",
"msg",
"(",
"\"You can only ge... | [
848,
4
] | [
873,
19
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_get | (self, getter) |
Called by the default `get` command when this object has been
picked up.
Args:
getter (Object): The object getting this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default).
Notes:
... |
Called by the default `get` command when this object has been
picked up. | def at_get(self, getter):
"""
Called by the default `get` command when this object has been
picked up.
Args:
getter (Object): The object getting this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by d... | [
"def",
"at_get",
"(",
"self",
",",
"getter",
")",
":",
"# If gotten, erase range values",
"if",
"self",
".",
"db",
".",
"combat_range",
":",
"del",
"self",
".",
"db",
".",
"combat_range",
"# Remove this object from everyone's range fields",
"for",
"thing",
"in",
"... | [
875,
4
] | [
900,
54
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_before_give | (self, giver, getter) |
Called by the default `give` command before this object has been
given.
Args:
giver (Object): The object about to give this object.
getter (Object): The object about to get this object.
**kwargs (dict): Arbitrary, optional arguments for users
... |
Called by the default `give` command before this object has been
given. | def at_before_give(self, giver, getter):
"""
Called by the default `give` command before this object has been
given.
Args:
giver (Object): The object about to give this object.
getter (Object): The object about to get this object.
**kwargs (dict): Arb... | [
"def",
"at_before_give",
"(",
"self",
",",
"giver",
",",
"getter",
")",
":",
"# Restrictions for giving in combat",
"if",
"is_in_combat",
"(",
"giver",
")",
":",
"if",
"not",
"is_turn",
"(",
"giver",
")",
":",
"# Not your turn",
"giver",
".",
"msg",
"(",
"\"... | [
902,
4
] | [
929,
19
] | python | en | ['en', 'error', 'th'] | False |
TBRangeObject.at_give | (self, giver, getter) |
Called by the default `give` command when this object has been
given.
Args:
giver (Object): The object giving this object.
getter (Object): The object getting this object.
**kwargs (dict): Arbitrary, optional arguments for users
overriding th... |
Called by the default `give` command when this object has been
given. | def at_give(self, giver, getter):
"""
Called by the default `give` command when this object has been
given.
Args:
giver (Object): The object giving this object.
getter (Object): The object getting this object.
**kwargs (dict): Arbitrary, optional argu... | [
"def",
"at_give",
"(",
"self",
",",
"giver",
",",
"getter",
")",
":",
"# Spend an action if in combat",
"if",
"is_in_combat",
"(",
"giver",
")",
":",
"spend_action",
"(",
"giver",
",",
"1",
",",
"action_name",
"=",
"\"give\"",
")"
] | [
931,
4
] | [
949,
54
] | python | en | ['en', 'error', 'th'] | False |
CmdFight.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
here = self.caller.location
fighters = []
if not self.caller.db.hp: # If you don't have any hp
self.caller.msg("You can't start a fight if you've been defeated!")
return
if is_in_c... | [
"def",
"func",
"(",
"self",
")",
":",
"here",
"=",
"self",
".",
"caller",
".",
"location",
"fighters",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"caller",
".",
"db",
".",
"hp",
":",
"# If you don't have any hp",
"self",
".",
"caller",
".",
"msg",
"(",... | [
972,
4
] | [
997,
74
] | python | en | ['en', 'error', 'th'] | False |
CmdAttack.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
"Set the attacker to the caller and the defender to the target."
if not is_in_combat(self.caller): # If not in combat, can't attack.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
... | [
"def",
"func",
"(",
"self",
")",
":",
"\"Set the attacker to the caller and the defender to the target.\"",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't attack.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do... | [
1017,
4
] | [
1053,
58
] | python | en | ['en', 'en', 'en'] | True |
CmdShoot.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
"Set the attacker to the caller and the defender to the target."
if not is_in_combat(self.caller): # If not in combat, can't attack.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
... | [
"def",
"func",
"(",
"self",
")",
":",
"\"Set the attacker to the caller and the defender to the target.\"",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't attack.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do... | [
1072,
4
] | [
1115,
58
] | python | en | ['en', 'en', 'en'] | True |
CmdApproach.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
if not is_in_combat(self.caller): # If not in combat, can't approach.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # If it's not your turn, can't approach.
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't approach.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"n... | [
1131,
4
] | [
1167,
56
] | python | en | ['en', 'en', 'en'] | True |
CmdWithdraw.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
if not is_in_combat(self.caller): # If not in combat, can't withdraw.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # If it's not your turn, can't withdraw.
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If not in combat, can't withdraw.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"n... | [
1182,
4
] | [
1218,
56
] | python | en | ['en', 'en', 'en'] | True |
CmdPass.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # Can only pass a turn in combat.
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # Can only pass if it'... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# Can only pass a turn in combat.",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not... | [
1236,
4
] | [
1249,
60
] | python | en | ['en', 'error', 'th'] | False |
CmdDisengage.func | (self) |
This performs the actual command.
|
This performs the actual command.
| def func(self):
"""
This performs the actual command.
"""
if not is_in_combat(self.caller): # If you're not in combat
self.caller.msg("You can only do that in combat. (see: help fight)")
return
if not is_turn(self.caller): # If it's not your turn
... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"not",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're not in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can only do that in combat. (see: help fight)\"",
")",
"return",
"if",
"not",
"is... | [
1268,
4
] | [
1285,
11
] | python | en | ['en', 'error', 'th'] | False |
CmdRest.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
if is_in_combat(self.caller): # If you're in combat
self.caller.msg("You can't rest while you're in combat.")
return
self.caller.db.hp = self.caller.db.max_hp # Set current HP to maximum
self.caller.location.... | [
"def",
"func",
"(",
"self",
")",
":",
"if",
"is_in_combat",
"(",
"self",
".",
"caller",
")",
":",
"# If you're in combat",
"self",
".",
"caller",
".",
"msg",
"(",
"\"You can't rest while you're in combat.\"",
")",
"return",
"self",
".",
"caller",
".",
"db",
... | [
1302,
4
] | [
1313,
11
] | python | en | ['en', 'en', 'en'] | True |
CmdStatus.func | (self) | This performs the actual command. | This performs the actual command. | def func(self):
"This performs the actual command."
combat_status_message(self.caller) | [
"def",
"func",
"(",
"self",
")",
":",
"combat_status_message",
"(",
"self",
".",
"caller",
")"
] | [
1329,
4
] | [
1331,
42
] | python | en | ['en', 'en', 'en'] | True |
BattleCmdSet.at_cmdset_creation | (self) |
Populates the cmdset
|
Populates the cmdset
| def at_cmdset_creation(self):
"""
Populates the cmdset
"""
self.add(CmdFight())
self.add(CmdAttack())
self.add(CmdShoot())
self.add(CmdRest())
self.add(CmdPass())
self.add(CmdDisengage())
self.add(CmdApproach())
self.add(CmdWithdraw... | [
"def",
"at_cmdset_creation",
"(",
"self",
")",
":",
"self",
".",
"add",
"(",
"CmdFight",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdAttack",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdShoot",
"(",
")",
")",
"self",
".",
"add",
"(",
"CmdRest",
"... | [
1369,
4
] | [
1382,
33
] | python | en | ['en', 'error', 'th'] | False |
sanitize_parley | (parley) |
Separate memories from context, pull out response, split context/memories lists.
|
Separate memories from context, pull out response, split context/memories lists.
| def sanitize_parley(parley):
"""
Separate memories from context, pull out response, split context/memories lists.
"""
if '\n' in parley.context:
snippets = parley.context.split('\n')
text = snippets[-1]
mems = snippets[:-1]
parley.context = text
parley.memories = ... | [
"def",
"sanitize_parley",
"(",
"parley",
")",
":",
"if",
"'\\n'",
"in",
"parley",
".",
"context",
":",
"snippets",
"=",
"parley",
".",
"context",
".",
"split",
"(",
"'\\n'",
")",
"text",
"=",
"snippets",
"[",
"-",
"1",
"]",
"mems",
"=",
"snippets",
"... | [
90,
0
] | [
103,
17
] | python | en | ['en', 'error', 'th'] | False |
add_person_tokens | (responses, first_speaker=None, last_speaker=1) | Converts a list of responses into a single tag-separated string
Args:
responses: list of responses (strings)
first_speaker: either 1 or 2; the owner of the first response
last_speaker: either 1 or 2; the owner of the last response
NOTE: if first_speaker is provided, it overrides ... | Converts a list of responses into a single tag-separated string
Args:
responses: list of responses (strings)
first_speaker: either 1 or 2; the owner of the first response
last_speaker: either 1 or 2; the owner of the last response
NOTE: if first_speaker is provided, it overrides ... | def add_person_tokens(responses, first_speaker=None, last_speaker=1):
"""Converts a list of responses into a single tag-separated string
Args:
responses: list of responses (strings)
first_speaker: either 1 or 2; the owner of the first response
last_speaker: either 1 or 2; the owner of th... | [
"def",
"add_person_tokens",
"(",
"responses",
",",
"first_speaker",
"=",
"None",
",",
"last_speaker",
"=",
"1",
")",
":",
"if",
"first_speaker",
"is",
"None",
":",
"first_speaker",
"=",
"(",
"last_speaker",
"+",
"len",
"(",
"responses",
")",
")",
"%",
"2",... | [
106,
0
] | [
130,
23
] | python | en | ['en', 'en', 'en'] | True |
episode_to_examples | (episode, histsz) |
Converts an episode (list of Parleys) into self-feeding compatible examples.
WARNING: we no longer require a histz when making a self-feeding file. Shortening of
the history is typically done in the teacher file or in interactive mode.
|
Converts an episode (list of Parleys) into self-feeding compatible examples. | def episode_to_examples(episode, histsz):
"""
Converts an episode (list of Parleys) into self-feeding compatible examples.
WARNING: we no longer require a histz when making a self-feeding file. Shortening of
the history is typically done in the teacher file or in interactive mode.
"""
examples ... | [
"def",
"episode_to_examples",
"(",
"episode",
",",
"histsz",
")",
":",
"examples",
"=",
"[",
"]",
"history",
"=",
"[",
"]",
"for",
"parley",
"in",
"episode",
":",
"# Update memories and history",
"# memories.extend(parley.memories)",
"history",
".",
"append",
"(",... | [
160,
0
] | [
197,
19
] | python | en | ['en', 'error', 'th'] | False |
LinearBridge.forward | (self, hidden) |
[2, B, enc_hidden_size // 2]
=> [B, 2, enc_hidden_size // 2] (transpose)
=> [B, enc_hidden_size] (view)
=> [B, dec_hidden_size] (linear)
|
[2, B, enc_hidden_size // 2]
=> [B, 2, enc_hidden_size // 2] (transpose)
=> [B, enc_hidden_size] (view)
=> [B, dec_hidden_size] (linear)
| def forward(self, hidden):
"""
[2, B, enc_hidden_size // 2]
=> [B, 2, enc_hidden_size // 2] (transpose)
=> [B, enc_hidden_size] (view)
=> [B, dec_hidden_size] (linear)
"""
if self.rnn_type == 'GRU':
h = hidden
B = h.siz... | [
"def",
"forward",
"(",
"self",
",",
"hidden",
")",
":",
"if",
"self",
".",
"rnn_type",
"==",
"'GRU'",
":",
"h",
"=",
"hidden",
"B",
"=",
"h",
".",
"size",
"(",
"1",
")",
"h",
"=",
"h",
".",
"transpose",
"(",
"0",
",",
"1",
")",
".",
"contiguo... | [
29,
4
] | [
58,
20
] | python | en | ['en', 'error', 'th'] | False |
run_static_task | (cfg: DictConfig, task_directory: str) |
Run static task, given configuration.
|
Run static task, given configuration.
| def run_static_task(cfg: DictConfig, task_directory: str):
"""
Run static task, given configuration.
"""
db, cfg = load_db_and_process_config(cfg)
print(f'\nHydra config:\n{OmegaConf.to_yaml(cfg)}')
random.seed(42)
soft_block_qual_name = cfg.mephisto.task.get('task_name', 'turn_annotation... | [
"def",
"run_static_task",
"(",
"cfg",
":",
"DictConfig",
",",
"task_directory",
":",
"str",
")",
":",
"db",
",",
"cfg",
"=",
"load_db_and_process_config",
"(",
"cfg",
")",
"print",
"(",
"f'\\nHydra config:\\n{OmegaConf.to_yaml(cfg)}'",
")",
"random",
".",
"seed",
... | [
16,
0
] | [
36,
5
] | python | en | ['en', 'error', 'th'] | False |
get_img_annos | (nuim, img_info, cat2id, out_dir, data_root, seg_root) | Get semantic segmentation map for an image.
Args:
nuim (obj:`NuImages`): NuImages dataset object
img_info (dict): Meta information of img
Returns:
np.ndarray: Semantic segmentation map of the image
| Get semantic segmentation map for an image. | def get_img_annos(nuim, img_info, cat2id, out_dir, data_root, seg_root):
"""Get semantic segmentation map for an image.
Args:
nuim (obj:`NuImages`): NuImages dataset object
img_info (dict): Meta information of img
Returns:
np.ndarray: Semantic segmentation map of the image
"""
... | [
"def",
"get_img_annos",
"(",
"nuim",
",",
"img_info",
",",
"cat2id",
",",
"out_dir",
",",
"data_root",
",",
"seg_root",
")",
":",
"sd_token",
"=",
"img_info",
"[",
"'token'",
"]",
"image_id",
"=",
"img_info",
"[",
"'id'",
"]",
"name_to_index",
"=",
"name_t... | [
61,
0
] | [
145,
43
] | python | en | ['en', 'en', 'en'] | True |
setup_args | () |
Set up args.
|
Set up args.
| def setup_args():
"""
Set up args.
"""
parser = ParlaiParser(False, False)
parser.add_parlai_data_path()
reddit = parser.add_argument_group('Download Reddit Docs')
reddit.add_argument(
'-sy', '--start_year', default=2011, type=int, metavar='N', help='starting year'
)
reddit.a... | [
"def",
"setup_args",
"(",
")",
":",
"parser",
"=",
"ParlaiParser",
"(",
"False",
",",
"False",
")",
"parser",
".",
"add_parlai_data_path",
"(",
")",
"reddit",
"=",
"parser",
".",
"add_argument_group",
"(",
"'Download Reddit Docs'",
")",
"reddit",
".",
"add_arg... | [
274,
0
] | [
315,
30
] | python | en | ['en', 'error', 'th'] | False |
Connection.__call__ | (self, method: str, uri: str, params_prefix: str =None, **params) | response codes:
200 - OK
401 - Unauthorized (Invalid API key or insufficient permissions)
404 - Object not found within your account scope
406 - Requested format is not supported - request JSON or XML only
422 - Validation error(s) for create or update method
500 - Somet... | response codes:
200 - OK
401 - Unauthorized (Invalid API key or insufficient permissions)
404 - Object not found within your account scope
406 - Requested format is not supported - request JSON or XML only
422 - Validation error(s) for create or update method
500 - Somet... | async def __call__(self, method: str, uri: str, params_prefix: str =None, **params):
""" response codes:
200 - OK
401 - Unauthorized (Invalid API key or insufficient permissions)
404 - Object not found within your account scope
406 - Requested format is not supported - request JS... | [
"async",
"def",
"__call__",
"(",
"self",
",",
"method",
":",
"str",
",",
"uri",
":",
"str",
",",
"params_prefix",
":",
"str",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"params",
"=",
"self",
".",
"_prepare_params",
"(",
"params",
",",
"params_p... | [
72,
4
] | [
93,
27
] | python | en | ['en', 'sr', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.