repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
libtcod/python-tcod
tcod/libtcodpy.py
map_set_properties
def map_set_properties( m: tcod.map.Map, x: int, y: int, isTrans: bool, isWalk: bool ) -> None: """Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these p...
python
def map_set_properties( m: tcod.map.Map, x: int, y: int, isTrans: bool, isWalk: bool ) -> None: """Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these p...
[ "def", "map_set_properties", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ",", "isTrans", ":", "bool", ",", "isWalk", ":", "bool", ")", "->", "None", ":", "lib", ".", "TCOD_map_set_properties", "(", "m"...
Set the properties of a single cell. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties.
[ "Set", "the", "properties", "of", "a", "single", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3187-L3198
train
libtcod/python-tcod
tcod/libtcodpy.py
map_clear
def map_clear( m: tcod.map.Map, transparent: bool = False, walkable: bool = False ) -> None: """Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ m.transparent[:] = t...
python
def map_clear( m: tcod.map.Map, transparent: bool = False, walkable: bool = False ) -> None: """Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties. """ m.transparent[:] = t...
[ "def", "map_clear", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "transparent", ":", "bool", "=", "False", ",", "walkable", ":", "bool", "=", "False", ")", "->", "None", ":", "m", ".", "transparent", "[", ":", "]", "=", "transparent", "m", ...
Change all map cells to a specific value. .. deprecated:: 4.5 Use :any:`tcod.map.Map.transparent` and :any:`tcod.map.Map.walkable` arrays to set these properties.
[ "Change", "all", "map", "cells", "to", "a", "specific", "value", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3202-L3212
train
libtcod/python-tcod
tcod/libtcodpy.py
map_compute_fov
def map_compute_fov( m: tcod.map.Map, x: int, y: int, radius: int = 0, light_walls: bool = True, algo: int = FOV_RESTRICTIVE, ) -> None: """Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead. """ m.compute_fov(x,...
python
def map_compute_fov( m: tcod.map.Map, x: int, y: int, radius: int = 0, light_walls: bool = True, algo: int = FOV_RESTRICTIVE, ) -> None: """Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead. """ m.compute_fov(x,...
[ "def", "map_compute_fov", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ",", "radius", ":", "int", "=", "0", ",", "light_walls", ":", "bool", "=", "True", ",", "algo", ":", "int", "=", "FOV_RESTRICTIVE...
Compute the field-of-view for a map instance. .. deprecated:: 4.5 Use :any:`tcod.map.Map.compute_fov` instead.
[ "Compute", "the", "field", "-", "of", "-", "view", "for", "a", "map", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3216-L3229
train
libtcod/python-tcod
tcod/libtcodpy.py
map_is_in_fov
def map_is_in_fov(m: tcod.map.Map, x: int, y: int) -> bool: """Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property. """ return bool(lib.TCOD_map_is_in_f...
python
def map_is_in_fov(m: tcod.map.Map, x: int, y: int) -> bool: """Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property. """ return bool(lib.TCOD_map_is_in_f...
[ "def", "map_is_in_fov", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "bool", ":", "return", "bool", "(", "lib", ".", "TCOD_map_is_in_fov", "(", "m", ".", "map_c", ",", "x", ",", "y", ")",...
Return True if the cell at x,y is lit by the last field-of-view algorithm. .. note:: This function is slow. .. deprecated:: 4.5 Use :any:`tcod.map.Map.fov` to check this property.
[ "Return", "True", "if", "the", "cell", "at", "x", "y", "is", "lit", "by", "the", "last", "field", "-", "of", "-", "view", "algorithm", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3233-L3242
train
libtcod/python-tcod
tcod/libtcodpy.py
noise_new
def noise_new( dim: int, h: float = NOISE_DEFAULT_HURST, l: float = NOISE_DEFAULT_LACUNARITY, # noqa: E741 random: Optional[tcod.random.Random] = None, ) -> tcod.noise.Noise: """Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hur...
python
def noise_new( dim: int, h: float = NOISE_DEFAULT_HURST, l: float = NOISE_DEFAULT_LACUNARITY, # noqa: E741 random: Optional[tcod.random.Random] = None, ) -> tcod.noise.Noise: """Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hur...
[ "def", "noise_new", "(", "dim", ":", "int", ",", "h", ":", "float", "=", "NOISE_DEFAULT_HURST", ",", "l", ":", "float", "=", "NOISE_DEFAULT_LACUNARITY", ",", "# noqa: E741", "random", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", "=", ...
Return a new Noise instance. Args: dim (int): Number of dimensions. From 1 to 4. h (float): The hurst exponent. Should be in the 0.0-1.0 range. l (float): The noise lacunarity. random (Optional[Random]): A Random instance, or None. Returns: Noise: The new Noise instan...
[ "Return", "a", "new", "Noise", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3356-L3373
train
libtcod/python-tcod
tcod/libtcodpy.py
noise_set_type
def noise_set_type(n: tcod.noise.Noise, typ: int) -> None: """Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant. """ n.algorithm = typ
python
def noise_set_type(n: tcod.noise.Noise, typ: int) -> None: """Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant. """ n.algorithm = typ
[ "def", "noise_set_type", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "typ", ":", "int", ")", "->", "None", ":", "n", ".", "algorithm", "=", "typ" ]
Set a Noise objects default noise algorithm. Args: typ (int): Any NOISE_* constant.
[ "Set", "a", "Noise", "objects", "default", "noise", "algorithm", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3377-L3383
train
libtcod/python-tcod
tcod/libtcodpy.py
noise_get
def noise_get( n: tcod.noise.Noise, f: Sequence[float], typ: int = NOISE_DEFAULT ) -> float: """Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coo...
python
def noise_get( n: tcod.noise.Noise, f: Sequence[float], typ: int = NOISE_DEFAULT ) -> float: """Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coo...
[ "def", "noise_get", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ")", "->", "float", ":", "return", "float", "(", "lib", ".", "TCOD_noise_get_ex", "(", ...
Return the noise value sampled from the ``f`` coordinate. ``f`` should be a tuple or list with a length matching :any:`Noise.dimensions`. If ``f`` is shoerter than :any:`Noise.dimensions` the missing coordinates will be filled with zeros. Args: n (Noise): A Noise instance. f (Seque...
[ "Return", "the", "noise", "value", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3387-L3405
train
libtcod/python-tcod
tcod/libtcodpy.py
noise_get_fbm
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
python
def noise_get_fbm( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
[ "def", "noise_get_fbm", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "oc", ":", "float", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ",", ")", "->", "float", ":", "return", "float", "(", ...
Return the fractal Brownian motion sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: ...
[ "Return", "the", "fractal", "Brownian", "motion", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3409-L3428
train
libtcod/python-tcod
tcod/libtcodpy.py
noise_get_turbulence
def noise_get_turbulence( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
python
def noise_get_turbulence( n: tcod.noise.Noise, f: Sequence[float], oc: float, typ: int = NOISE_DEFAULT, ) -> float: """Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. ...
[ "def", "noise_get_turbulence", "(", "n", ":", "tcod", ".", "noise", ".", "Noise", ",", "f", ":", "Sequence", "[", "float", "]", ",", "oc", ":", "float", ",", "typ", ":", "int", "=", "NOISE_DEFAULT", ",", ")", "->", "float", ":", "return", "float", ...
Return the turbulence noise sampled from the ``f`` coordinate. Args: n (Noise): A Noise instance. f (Sequence[float]): The point to sample the noise from. typ (int): The noise algorithm to use. octaves (float): The level of level. Should be more than 1. Returns: float:...
[ "Return", "the", "turbulence", "noise", "sampled", "from", "the", "f", "coordinate", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3432-L3453
train
libtcod/python-tcod
tcod/libtcodpy.py
random_get_instance
def random_get_instance() -> tcod.random.Random: """Return the default Random instance. Returns: Random: A Random instance using the default random number generator. """ return tcod.random.Random._new_from_cdata( ffi.cast("mersenne_data_t*", lib.TCOD_random_get_instance()) )
python
def random_get_instance() -> tcod.random.Random: """Return the default Random instance. Returns: Random: A Random instance using the default random number generator. """ return tcod.random.Random._new_from_cdata( ffi.cast("mersenne_data_t*", lib.TCOD_random_get_instance()) )
[ "def", "random_get_instance", "(", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", ".", "_new_from_cdata", "(", "ffi", ".", "cast", "(", "\"mersenne_data_t*\"", ",", "lib", ".", "TCOD_random_get_instance", ...
Return the default Random instance. Returns: Random: A Random instance using the default random number generator.
[ "Return", "the", "default", "Random", "instance", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3635-L3643
train
libtcod/python-tcod
tcod/libtcodpy.py
random_new
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random: """Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo)
python
def random_new(algo: int = RNG_CMWC) -> tcod.random.Random: """Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm. """ return tcod.random.Random(algo)
[ "def", "random_new", "(", "algo", ":", "int", "=", "RNG_CMWC", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", "(", "algo", ")" ]
Return a new Random instance. Using ``algo``. Args: algo (int): The random number algorithm to use. Returns: Random: A new Random instance using the given algorithm.
[ "Return", "a", "new", "Random", "instance", ".", "Using", "algo", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3647-L3656
train
libtcod/python-tcod
tcod/libtcodpy.py
random_new_from_seed
def random_new_from_seed( seed: Hashable, algo: int = RNG_CMWC ) -> tcod.random.Random: """Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. al...
python
def random_new_from_seed( seed: Hashable, algo: int = RNG_CMWC ) -> tcod.random.Random: """Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. al...
[ "def", "random_new_from_seed", "(", "seed", ":", "Hashable", ",", "algo", ":", "int", "=", "RNG_CMWC", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", "(", "algo", ",", "seed", ")" ]
Return a new Random instance. Using the given ``seed`` and ``algo``. Args: seed (Hashable): The RNG seed. Should be a 32-bit integer, but any hashable object is accepted. algo (int): The random number algorithm to use. Returns: Random: A new Random instance u...
[ "Return", "a", "new", "Random", "instance", ".", "Using", "the", "given", "seed", "and", "algo", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3660-L3673
train
libtcod/python-tcod
tcod/libtcodpy.py
random_set_distribution
def random_set_distribution( rnd: Optional[tcod.random.Random], dist: int ) -> None: """Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*...
python
def random_set_distribution( rnd: Optional[tcod.random.Random], dist: int ) -> None: """Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*...
[ "def", "random_set_distribution", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ",", "dist", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_random_set_distribution", "(", "rnd", ".", "random_c", "if", "rnd", "else", ...
Change the distribution mode of a random number generator. Args: rnd (Optional[Random]): A Random instance, or None to use the default. dist (int): The distribution mode to use. Should be DISTRIBUTION_*.
[ "Change", "the", "distribution", "mode", "of", "a", "random", "number", "generator", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3677-L3686
train
libtcod/python-tcod
tcod/libtcodpy.py
random_save
def random_save(rnd: Optional[tcod.random.Random]) -> tcod.random.Random: """Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ return tcod.random.Random._new_from_cdata( ffi.gc( ...
python
def random_save(rnd: Optional[tcod.random.Random]) -> tcod.random.Random: """Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state. """ return tcod.random.Random._new_from_cdata( ffi.gc( ...
[ "def", "random_save", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ")", "->", "tcod", ".", "random", ".", "Random", ":", "return", "tcod", ".", "random", ".", "Random", ".", "_new_from_cdata", "(", "ffi", ".", "gc", "(...
Return a copy of a random number generator. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a random state.
[ "Return", "a", "copy", "of", "a", "random", "number", "generator", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3812-L3827
train
libtcod/python-tcod
tcod/libtcodpy.py
random_restore
def random_restore( rnd: Optional[tcod.random.Random], backup: tcod.random.Random ) -> None: """Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a back...
python
def random_restore( rnd: Optional[tcod.random.Random], backup: tcod.random.Random ) -> None: """Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a back...
[ "def", "random_restore", "(", "rnd", ":", "Optional", "[", "tcod", ".", "random", ".", "Random", "]", ",", "backup", ":", "tcod", ".", "random", ".", "Random", ")", "->", "None", ":", "lib", ".", "TCOD_random_restore", "(", "rnd", ".", "random_c", "if"...
Restore a random number generator from a backed up copy. Args: rnd (Optional[Random]): A Random instance, or None to use the default. backup (Random): The Random instance which was used as a backup. .. deprecated:: 8.4 You can use the standard library copy and pickle modules to save a ...
[ "Restore", "a", "random", "number", "generator", "from", "a", "backed", "up", "copy", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3831-L3844
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_set_renderer
def sys_set_renderer(renderer: int) -> None: """Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available. """ lib.TCOD_sys_set_renderer(renderer) if tcod.console._root_console is not None: tcod.console.Console._g...
python
def sys_set_renderer(renderer: int) -> None: """Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available. """ lib.TCOD_sys_set_renderer(renderer) if tcod.console._root_console is not None: tcod.console.Console._g...
[ "def", "sys_set_renderer", "(", "renderer", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_sys_set_renderer", "(", "renderer", ")", "if", "tcod", ".", "console", ".", "_root_console", "is", "not", "None", ":", "tcod", ".", "console", ".", "Console",...
Change the current rendering mode to renderer. .. deprecated:: 2.0 RENDERER_GLSL and RENDERER_OPENGL are not currently available.
[ "Change", "the", "current", "rendering", "mode", "to", "renderer", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3973-L3981
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_save_screenshot
def sys_save_screenshot(name: Optional[str] = None) -> None: """Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is ...
python
def sys_save_screenshot(name: Optional[str] = None) -> None: """Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is ...
[ "def", "sys_save_screenshot", "(", "name", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "lib", ".", "TCOD_sys_save_screenshot", "(", "_bytes", "(", "name", ")", "if", "name", "is", "not", "None", "else", "ffi", ".", "NULL", ")...
Save a screenshot to a file. By default this will automatically save screenshots in the working directory. The automatic names are formatted as screenshotNNN.png. For example: screenshot000.png, screenshot001.png, etc. Whichever is available first. Args: file Optional[AnyStr]: File path...
[ "Save", "a", "screenshot", "to", "a", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L3992-L4006
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_update_char
def sys_update_char( asciiCode: int, fontx: int, fonty: int, img: tcod.image.Image, x: int, y: int, ) -> None: """Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode ...
python
def sys_update_char( asciiCode: int, fontx: int, fonty: int, img: tcod.image.Image, x: int, y: int, ) -> None: """Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode ...
[ "def", "sys_update_char", "(", "asciiCode", ":", "int", ",", "fontx", ":", "int", ",", "fonty", ":", "int", ",", "img", ":", "tcod", ".", "image", ".", "Image", ",", "x", ":", "int", ",", "y", ":", "int", ",", ")", "->", "None", ":", "lib", "."...
Dynamically update the current font with img. All cells using this asciiCode will be updated at the next call to :any:`tcod.console_flush`. Args: asciiCode (int): Ascii code corresponding to the character to update. fontx (int): Left coordinate of the character in the ...
[ "Dynamically", "update", "the", "current", "font", "with", "img", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4054-L4077
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_register_SDL_renderer
def sys_register_SDL_renderer(callback: Callable[[Any], None]) -> None: """Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is c...
python
def sys_register_SDL_renderer(callback: Callable[[Any], None]) -> None: """Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is c...
[ "def", "sys_register_SDL_renderer", "(", "callback", ":", "Callable", "[", "[", "Any", "]", ",", "None", "]", ")", "->", "None", ":", "with", "_PropagateException", "(", ")", "as", "propagate", ":", "@", "ffi", ".", "def_extern", "(", "onerror", "=", "pr...
Register a custom randering function with libtcod. Note: This callback will only be called by the SDL renderer. The callack will receive a :any:`CData <ffi-cdata>` void* to an SDL_Surface* struct. The callback is called on every call to :any:`tcod.console_flush`. Args: callback C...
[ "Register", "a", "custom", "randering", "function", "with", "libtcod", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4081-L4102
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_check_for_event
def sys_check_for_event( mask: int, k: Optional[Key], m: Optional[Mouse] ) -> int: """Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. ...
python
def sys_check_for_event( mask: int, k: Optional[Key], m: Optional[Mouse] ) -> int: """Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. ...
[ "def", "sys_check_for_event", "(", "mask", ":", "int", ",", "k", ":", "Optional", "[", "Key", "]", ",", "m", ":", "Optional", "[", "Mouse", "]", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_sys_check_for_event", "(", "mask", ",", "k...
Check for and return an event. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated with an event. Can be None. m (Optional[Mouse]): A tcod.Mouse instance which might be updated ...
[ "Check", "for", "and", "return", "an", "event", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4106-L4125
train
libtcod/python-tcod
tcod/libtcodpy.py
sys_wait_for_event
def sys_wait_for_event( mask: int, k: Optional[Key], m: Optional[Mouse], flush: bool ) -> int: """Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int):...
python
def sys_wait_for_event( mask: int, k: Optional[Key], m: Optional[Mouse], flush: bool ) -> int: """Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int):...
[ "def", "sys_wait_for_event", "(", "mask", ":", "int", ",", "k", ":", "Optional", "[", "Key", "]", ",", "m", ":", "Optional", "[", "Mouse", "]", ",", "flush", ":", "bool", ")", "->", "int", ":", "return", "int", "(", "lib", ".", "TCOD_sys_wait_for_eve...
Wait for an event then return. If flush is True then the buffer will be cleared before waiting. Otherwise each available event will be returned in the order they're recieved. Args: mask (int): :any:`Event types` to wait for. k (Optional[Key]): A tcod.Key instance which might be updated wit...
[ "Wait", "for", "an", "event", "then", "return", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4129-L4155
train
libtcod/python-tcod
tcod/libtcodpy.py
_atexit_verify
def _atexit_verify() -> None: """Warns if the libtcod root console is implicitly deleted.""" if lib.TCOD_ctx.root: warnings.warn( "The libtcod root console was implicitly deleted.\n" "Make sure the 'with' statement is used with the root console to" " ensure that it cl...
python
def _atexit_verify() -> None: """Warns if the libtcod root console is implicitly deleted.""" if lib.TCOD_ctx.root: warnings.warn( "The libtcod root console was implicitly deleted.\n" "Make sure the 'with' statement is used with the root console to" " ensure that it cl...
[ "def", "_atexit_verify", "(", ")", "->", "None", ":", "if", "lib", ".", "TCOD_ctx", ".", "root", ":", "warnings", ".", "warn", "(", "\"The libtcod root console was implicitly deleted.\\n\"", "\"Make sure the 'with' statement is used with the root console to\"", "\" ensure tha...
Warns if the libtcod root console is implicitly deleted.
[ "Warns", "if", "the", "libtcod", "root", "console", "is", "implicitly", "deleted", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L4179-L4189
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.clear
def clear( self, back_r: int = 0, back_g: int = 0, back_b: int = 0, fore_r: int = 0, fore_g: int = 0, fore_b: int = 0, char: str = " ", ) -> None: """Clears the console. Values to fill it with are optional, defaults to black with no ch...
python
def clear( self, back_r: int = 0, back_g: int = 0, back_b: int = 0, fore_r: int = 0, fore_g: int = 0, fore_b: int = 0, char: str = " ", ) -> None: """Clears the console. Values to fill it with are optional, defaults to black with no ch...
[ "def", "clear", "(", "self", ",", "back_r", ":", "int", "=", "0", ",", "back_g", ":", "int", "=", "0", ",", "back_b", ":", "int", "=", "0", ",", "fore_r", ":", "int", "=", "0", ",", "fore_g", ":", "int", "=", "0", ",", "fore_b", ":", "int", ...
Clears the console. Values to fill it with are optional, defaults to black with no characters. Args: back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (int): Blue background color, from 0 to 255. ...
[ "Clears", "the", "console", ".", "Values", "to", "fill", "it", "with", "are", "optional", "defaults", "to", "black", "with", "no", "characters", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L120-L149
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.copy
def copy(self) -> "ConsoleBuffer": """Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy. """ other = ConsoleBuffer(0, 0) # type: "ConsoleBuffer" other.width = self.width other.height = self.height other.back_r = l...
python
def copy(self) -> "ConsoleBuffer": """Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy. """ other = ConsoleBuffer(0, 0) # type: "ConsoleBuffer" other.width = self.width other.height = self.height other.back_r = l...
[ "def", "copy", "(", "self", ")", "->", "\"ConsoleBuffer\"", ":", "other", "=", "ConsoleBuffer", "(", "0", ",", "0", ")", "# type: \"ConsoleBuffer\"", "other", ".", "width", "=", "self", ".", "width", "other", ".", "height", "=", "self", ".", "height", "o...
Returns a copy of this ConsoleBuffer. Returns: ConsoleBuffer: A new ConsoleBuffer copy.
[ "Returns", "a", "copy", "of", "this", "ConsoleBuffer", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L151-L167
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set_fore
def set_fore( self, x: int, y: int, r: int, g: int, b: int, char: str ) -> None: """Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. ...
python
def set_fore( self, x: int, y: int, r: int, g: int, b: int, char: str ) -> None: """Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. ...
[ "def", "set_fore", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ",", "char", ":", "str", ")", "->", "None", ":", "i", "=", "self", ".", "width", "*", "y", "+", ...
Set the character and foreground color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red foreground color, from 0 to 255. g (int): Green foreground color, from 0 to 255. b (int): Blue foreground color, from ...
[ "Set", "the", "character", "and", "foreground", "color", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L169-L186
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set_back
def set_back(self, x: int, y: int, r: int, g: int, b: int) -> None: """Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color,...
python
def set_back(self, x: int, y: int, r: int, g: int, b: int) -> None: """Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color,...
[ "def", "set_back", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "None", ":", "i", "=", "self", ".", "width", "*", "y", "+", "x", "self", ".", "back_r...
Set the background color of one cell. Args: x (int): X position to change. y (int): Y position to change. r (int): Red background color, from 0 to 255. g (int): Green background color, from 0 to 255. b (int): Blue background color, from 0 to 255.
[ "Set", "the", "background", "color", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L188-L201
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.set
def set( self, x: int, y: int, back_r: int, back_g: int, back_b: int, fore_r: int, fore_g: int, fore_b: int, char: str, ) -> None: """Set the background color, foreground color and character of one cell. Args: ...
python
def set( self, x: int, y: int, back_r: int, back_g: int, back_b: int, fore_r: int, fore_g: int, fore_b: int, char: str, ) -> None: """Set the background color, foreground color and character of one cell. Args: ...
[ "def", "set", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "back_r", ":", "int", ",", "back_g", ":", "int", ",", "back_b", ":", "int", ",", "fore_r", ":", "int", ",", "fore_g", ":", "int", ",", "fore_b", ":", "int", ",", "cha...
Set the background color, foreground color and character of one cell. Args: x (int): X position to change. y (int): Y position to change. back_r (int): Red background color, from 0 to 255. back_g (int): Green background color, from 0 to 255. back_b (i...
[ "Set", "the", "background", "color", "foreground", "color", "and", "character", "of", "one", "cell", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L203-L235
train
libtcod/python-tcod
tcod/libtcodpy.py
ConsoleBuffer.blit
def blit( self, dest: tcod.console.Console, fill_fore: bool = True, fill_back: bool = True, ) -> None: """Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): ...
python
def blit( self, dest: tcod.console.Console, fill_fore: bool = True, fill_back: bool = True, ) -> None: """Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): ...
[ "def", "blit", "(", "self", ",", "dest", ":", "tcod", ".", "console", ".", "Console", ",", "fill_fore", ":", "bool", "=", "True", ",", "fill_back", ":", "bool", "=", "True", ",", ")", "->", "None", ":", "if", "not", "dest", ":", "dest", "=", "tco...
Use libtcod's "fill" functions to write the buffer to a console. Args: dest (Console): Console object to modify. fill_fore (bool): If True, fill the foreground color and characters. fill_back (bool): If True, fill the background color.
[ "Use", "libtcod", "s", "fill", "functions", "to", "write", "the", "buffer", "to", "a", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L237-L271
train
libtcod/python-tcod
tcod/image.py
Image.clear
def clear(self, color: Tuple[int, int, int]) -> None: """Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_clear(self.image_c, color)
python
def clear(self, color: Tuple[int, int, int]) -> None: """Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_clear(self.image_c, color)
[ "def", "clear", "(", "self", ",", "color", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_image_clear", "(", "self", ".", "image_c", ",", "color", ")" ]
Fill this entire Image with color. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance.
[ "Fill", "this", "entire", "Image", "with", "color", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L59-L66
train
libtcod/python-tcod
tcod/image.py
Image.scale
def scale(self, width: int, height: int) -> None: """Scale this Image to the new width and height. Args: width (int): The new width of the Image after scaling. height (int): The new height of the Image after scaling. """ lib.TCOD_image_scale(self.image_c, width, ...
python
def scale(self, width: int, height: int) -> None: """Scale this Image to the new width and height. Args: width (int): The new width of the Image after scaling. height (int): The new height of the Image after scaling. """ lib.TCOD_image_scale(self.image_c, width, ...
[ "def", "scale", "(", "self", ",", "width", ":", "int", ",", "height", ":", "int", ")", "->", "None", ":", "lib", ".", "TCOD_image_scale", "(", "self", ".", "image_c", ",", "width", ",", "height", ")", "self", ".", "width", ",", "self", ".", "height...
Scale this Image to the new width and height. Args: width (int): The new width of the Image after scaling. height (int): The new height of the Image after scaling.
[ "Scale", "this", "Image", "to", "the", "new", "width", "and", "height", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L88-L96
train
libtcod/python-tcod
tcod/image.py
Image.set_key_color
def set_key_color(self, color: Tuple[int, int, int]) -> None: """Set a color to be transparent during blitting functions. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_set_key_color(self....
python
def set_key_color(self, color: Tuple[int, int, int]) -> None: """Set a color to be transparent during blitting functions. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance. """ lib.TCOD_image_set_key_color(self....
[ "def", "set_key_color", "(", "self", ",", "color", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_image_set_key_color", "(", "self", ".", "image_c", ",", "color", ")" ]
Set a color to be transparent during blitting functions. Args: color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance.
[ "Set", "a", "color", "to", "be", "transparent", "during", "blitting", "functions", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L98-L105
train
libtcod/python-tcod
tcod/image.py
Image.get_alpha
def get_alpha(self, x: int, y: int) -> int: """Get the Image alpha of the pixel at x, y. Args: x (int): X pixel of the image. Starting from the left at 0. y (int): Y pixel of the image. Starting from the top at 0. Returns: int: The alpha value of the pixel...
python
def get_alpha(self, x: int, y: int) -> int: """Get the Image alpha of the pixel at x, y. Args: x (int): X pixel of the image. Starting from the left at 0. y (int): Y pixel of the image. Starting from the top at 0. Returns: int: The alpha value of the pixel...
[ "def", "get_alpha", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "int", ":", "return", "lib", ".", "TCOD_image_get_alpha", "(", "self", ".", "image_c", ",", "x", ",", "y", ")" ]
Get the Image alpha of the pixel at x, y. Args: x (int): X pixel of the image. Starting from the left at 0. y (int): Y pixel of the image. Starting from the top at 0. Returns: int: The alpha value of the pixel. With 0 being fully transparent and 255 be...
[ "Get", "the", "Image", "alpha", "of", "the", "pixel", "at", "x", "y", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L107-L118
train
libtcod/python-tcod
tcod/image.py
Image.get_pixel
def get_pixel(self, x: int, y: int) -> Tuple[int, int, int]: """Get the color of a pixel in this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. Returns: Tuple[int, int, in...
python
def get_pixel(self, x: int, y: int) -> Tuple[int, int, int]: """Get the color of a pixel in this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. Returns: Tuple[int, int, in...
[ "def", "get_pixel", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Tuple", "[", "int", ",", "int", ",", "int", "]", ":", "color", "=", "lib", ".", "TCOD_image_get_pixel", "(", "self", ".", "image_c", ",", "x", ",", "y", ")...
Get the color of a pixel in this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. Returns: Tuple[int, int, int]: An (r, g, b) tuple containing the pixels color value...
[ "Get", "the", "color", "of", "a", "pixel", "in", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L145-L158
train
libtcod/python-tcod
tcod/image.py
Image.get_mipmap_pixel
def get_mipmap_pixel( self, left: float, top: float, right: float, bottom: float ) -> Tuple[int, int, int]: """Get the average color of a rectangle in this Image. Parameters should stay within the following limits: * 0 <= left < right < Image.width * 0 <= top < bottom < Imag...
python
def get_mipmap_pixel( self, left: float, top: float, right: float, bottom: float ) -> Tuple[int, int, int]: """Get the average color of a rectangle in this Image. Parameters should stay within the following limits: * 0 <= left < right < Image.width * 0 <= top < bottom < Imag...
[ "def", "get_mipmap_pixel", "(", "self", ",", "left", ":", "float", ",", "top", ":", "float", ",", "right", ":", "float", ",", "bottom", ":", "float", ")", "->", "Tuple", "[", "int", ",", "int", ",", "int", "]", ":", "color", "=", "lib", ".", "TCO...
Get the average color of a rectangle in this Image. Parameters should stay within the following limits: * 0 <= left < right < Image.width * 0 <= top < bottom < Image.height Args: left (float): Left corner of the region. top (float): Top corner of the region. ...
[ "Get", "the", "average", "color", "of", "a", "rectangle", "in", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L160-L183
train
libtcod/python-tcod
tcod/image.py
Image.put_pixel
def put_pixel(self, x: int, y: int, color: Tuple[int, int, int]) -> None: """Change a pixel on this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. color (Union[Tuple[int, int, int]...
python
def put_pixel(self, x: int, y: int, color: Tuple[int, int, int]) -> None: """Change a pixel on this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. color (Union[Tuple[int, int, int]...
[ "def", "put_pixel", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "color", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "lib", ".", "TCOD_image_put_pixel", "(", "self", ".", "image_c", ",", "x", ...
Change a pixel on this Image. Args: x (int): X pixel of the Image. Starting from the left at 0. y (int): Y pixel of the Image. Starting from the top at 0. color (Union[Tuple[int, int, int], Sequence[int]]): An (r, g, b) sequence or Color instance.
[ "Change", "a", "pixel", "on", "this", "Image", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L185-L194
train
libtcod/python-tcod
tcod/image.py
Image.blit
def blit( self, console: tcod.console.Console, x: float, y: float, bg_blend: int, scale_x: float, scale_y: float, angle: float, ) -> None: """Blit onto a Console using scaling and rotation. Args: console (Console): Blit des...
python
def blit( self, console: tcod.console.Console, x: float, y: float, bg_blend: int, scale_x: float, scale_y: float, angle: float, ) -> None: """Blit onto a Console using scaling and rotation. Args: console (Console): Blit des...
[ "def", "blit", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "float", ",", "y", ":", "float", ",", "bg_blend", ":", "int", ",", "scale_x", ":", "float", ",", "scale_y", ":", "float", ",", "angle", ":", "...
Blit onto a Console using scaling and rotation. Args: console (Console): Blit destination Console. x (float): Console X position for the center of the Image blit. y (float): Console Y position for the center of the Image blit. The Image blit is centered ...
[ "Blit", "onto", "a", "Console", "using", "scaling", "and", "rotation", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L196-L229
train
libtcod/python-tcod
tcod/image.py
Image.blit_rect
def blit_rect( self, console: tcod.console.Console, x: int, y: int, width: int, height: int, bg_blend: int, ) -> None: """Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. ...
python
def blit_rect( self, console: tcod.console.Console, x: int, y: int, width: int, height: int, bg_blend: int, ) -> None: """Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. ...
[ "def", "blit_rect", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "bg_blend", ":", "int", ",", ")", "->", "None", ...
Blit onto a Console without scaling or rotation. Args: console (Console): Blit destination Console. x (int): Console tile X position starting from the left at 0. y (int): Console tile Y position starting from the top at 0. width (int): Use -1 for Image width. ...
[ "Blit", "onto", "a", "Console", "without", "scaling", "or", "rotation", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L231-L252
train
libtcod/python-tcod
tcod/image.py
Image.blit_2x
def blit_2x( self, console: tcod.console.Console, dest_x: int, dest_y: int, img_x: int = 0, img_y: int = 0, img_width: int = -1, img_height: int = -1, ) -> None: """Blit onto a Console with double resolution. Args: console ...
python
def blit_2x( self, console: tcod.console.Console, dest_x: int, dest_y: int, img_x: int = 0, img_y: int = 0, img_width: int = -1, img_height: int = -1, ) -> None: """Blit onto a Console with double resolution. Args: console ...
[ "def", "blit_2x", "(", "self", ",", "console", ":", "tcod", ".", "console", ".", "Console", ",", "dest_x", ":", "int", ",", "dest_y", ":", "int", ",", "img_x", ":", "int", "=", "0", ",", "img_y", ":", "int", "=", "0", ",", "img_width", ":", "int"...
Blit onto a Console with double resolution. Args: console (Console): Blit destination Console. dest_x (int): Console tile X position starting from the left at 0. dest_y (int): Console tile Y position starting from the top at 0. img_x (int): Left corner pixel of t...
[ "Blit", "onto", "a", "Console", "with", "double", "resolution", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L254-L286
train
libtcod/python-tcod
tcod/image.py
Image.save_as
def save_as(self, filename: str) -> None: """Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image. """ lib.TCOD_image_save(self.image_c, filename.encode("utf-8"))
python
def save_as(self, filename: str) -> None: """Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image. """ lib.TCOD_image_save(self.image_c, filename.encode("utf-8"))
[ "def", "save_as", "(", "self", ",", "filename", ":", "str", ")", "->", "None", ":", "lib", ".", "TCOD_image_save", "(", "self", ".", "image_c", ",", "filename", ".", "encode", "(", "\"utf-8\"", ")", ")" ]
Save the Image to a 32-bit .bmp or .png file. Args: filename (Text): File path to same this Image.
[ "Save", "the", "Image", "to", "a", "32", "-", "bit", ".", "bmp", "or", ".", "png", "file", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/image.py#L288-L294
train
libtcod/python-tcod
examples/sdlevent.py
main
def main(): """Example program for tcod.event""" WIDTH, HEIGHT = 120, 60 TITLE = None with tcod.console_init_root(WIDTH, HEIGHT, TITLE, order="F", renderer=tcod.RENDERER_SDL) as console: tcod.sys_set_fps(24) while True: tcod.console_flush() ...
python
def main(): """Example program for tcod.event""" WIDTH, HEIGHT = 120, 60 TITLE = None with tcod.console_init_root(WIDTH, HEIGHT, TITLE, order="F", renderer=tcod.RENDERER_SDL) as console: tcod.sys_set_fps(24) while True: tcod.console_flush() ...
[ "def", "main", "(", ")", ":", "WIDTH", ",", "HEIGHT", "=", "120", ",", "60", "TITLE", "=", "None", "with", "tcod", ".", "console_init_root", "(", "WIDTH", ",", "HEIGHT", ",", "TITLE", ",", "order", "=", "\"F\"", ",", "renderer", "=", "tcod", ".", "...
Example program for tcod.event
[ "Example", "program", "for", "tcod", ".", "event" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/examples/sdlevent.py#L7-L27
train
libtcod/python-tcod
scripts/tag_release.py
parse_changelog
def parse_changelog(args: Any) -> Tuple[str, str]: """Return an updated changelog and and the list of changes.""" with open("CHANGELOG.rst", "r") as file: match = re.match( pattern=r"(.*?Unreleased\n---+\n)(.+?)(\n*[^\n]+\n---+\n.*)", string=file.read(), flags=re.DOTA...
python
def parse_changelog(args: Any) -> Tuple[str, str]: """Return an updated changelog and and the list of changes.""" with open("CHANGELOG.rst", "r") as file: match = re.match( pattern=r"(.*?Unreleased\n---+\n)(.+?)(\n*[^\n]+\n---+\n.*)", string=file.read(), flags=re.DOTA...
[ "def", "parse_changelog", "(", "args", ":", "Any", ")", "->", "Tuple", "[", "str", ",", "str", "]", ":", "with", "open", "(", "\"CHANGELOG.rst\"", ",", "\"r\"", ")", "as", "file", ":", "match", "=", "re", ".", "match", "(", "pattern", "=", "r\"(.*?Un...
Return an updated changelog and and the list of changes.
[ "Return", "an", "updated", "changelog", "and", "and", "the", "list", "of", "changes", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/scripts/tag_release.py#L29-L45
train
libtcod/python-tcod
tcod/bsp.py
BSP.split_once
def split_once(self, horizontal: bool, position: int) -> None: """Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int): """ cdata = self._as_cdata() lib.TCOD_bsp_split_once(cdata, horizontal, position) self._unpack_b...
python
def split_once(self, horizontal: bool, position: int) -> None: """Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int): """ cdata = self._as_cdata() lib.TCOD_bsp_split_once(cdata, horizontal, position) self._unpack_b...
[ "def", "split_once", "(", "self", ",", "horizontal", ":", "bool", ",", "position", ":", "int", ")", "->", "None", ":", "cdata", "=", "self", ".", "_as_cdata", "(", ")", "lib", ".", "TCOD_bsp_split_once", "(", "cdata", ",", "horizontal", ",", "position", ...
Split this partition into 2 sub-partitions. Args: horizontal (bool): position (int):
[ "Split", "this", "partition", "into", "2", "sub", "-", "partitions", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L131-L140
train
libtcod/python-tcod
tcod/bsp.py
BSP.split_recursive
def split_recursive( self, depth: int, min_width: int, min_height: int, max_horizontal_ratio: float, max_vertical_ratio: float, seed: Optional[tcod.random.Random] = None, ) -> None: """Divide this partition recursively. Args: depth...
python
def split_recursive( self, depth: int, min_width: int, min_height: int, max_horizontal_ratio: float, max_vertical_ratio: float, seed: Optional[tcod.random.Random] = None, ) -> None: """Divide this partition recursively. Args: depth...
[ "def", "split_recursive", "(", "self", ",", "depth", ":", "int", ",", "min_width", ":", "int", ",", "min_height", ":", "int", ",", "max_horizontal_ratio", ":", "float", ",", "max_vertical_ratio", ":", "float", ",", "seed", ":", "Optional", "[", "tcod", "."...
Divide this partition recursively. Args: depth (int): The maximum depth to divide this object recursively. min_width (int): The minimum width of any individual partition. min_height (int): The minimum height of any individual partition. max_horizontal_ratio (floa...
[ "Divide", "this", "partition", "recursively", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L142-L174
train
libtcod/python-tcod
tcod/bsp.py
BSP.in_order
def in_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3 """ if self.children: yield from self.children[0].in_order() yield self yield from self.children[1].in_order() else: yield ...
python
def in_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3 """ if self.children: yield from self.children[0].in_order() yield self yield from self.children[1].in_order() else: yield ...
[ "def", "in_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "if", "self", ".", "children", ":", "yield", "from", "self", ".", "children", "[", "0", "]", ".", "in_order", "(", ")", "yield", "self", "yield", "from", "self", ".", ...
Iterate over this BSP's hierarchy in order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L194-L204
train
libtcod/python-tcod
tcod/bsp.py
BSP.level_order
def level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3 """ next = [self] # type: List['BSP'] while next: level = next # type: List['BSP'] next = [] yield from level fo...
python
def level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3 """ next = [self] # type: List['BSP'] while next: level = next # type: List['BSP'] next = [] yield from level fo...
[ "def", "level_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "next", "=", "[", "self", "]", "# type: List['BSP']", "while", "next", ":", "level", "=", "next", "# type: List['BSP']", "next", "=", "[", "]", "yield", "from", "level", ...
Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "level", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L215-L226
train
libtcod/python-tcod
tcod/bsp.py
BSP.inverted_level_order
def inverted_level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3 """ levels = [] # type: List[List['BSP']] next = [self] # type: List['BSP'] while next: levels.append(next) lev...
python
def inverted_level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3 """ levels = [] # type: List[List['BSP']] next = [self] # type: List['BSP'] while next: levels.append(next) lev...
[ "def", "inverted_level_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "levels", "=", "[", "]", "# type: List[List['BSP']]", "next", "=", "[", "self", "]", "# type: List['BSP']", "while", "next", ":", "levels", ".", "append", "(", "next...
Iterate over this BSP's hierarchy in inverse level order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "inverse", "level", "order", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L228-L242
train
libtcod/python-tcod
tcod/bsp.py
BSP.contains
def contains(self, x: int, y: int) -> bool: """Returns True if this node contains these coordinates. Args: x (int): X position to check. y (int): Y position to check. Returns: bool: True if this node contains these coordinates. Otherwise Fa...
python
def contains(self, x: int, y: int) -> bool: """Returns True if this node contains these coordinates. Args: x (int): X position to check. y (int): Y position to check. Returns: bool: True if this node contains these coordinates. Otherwise Fa...
[ "def", "contains", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "bool", ":", "return", "(", "self", ".", "x", "<=", "x", "<", "self", ".", "x", "+", "self", ".", "width", "and", "self", ".", "y", "<=", "y", "<", "self...
Returns True if this node contains these coordinates. Args: x (int): X position to check. y (int): Y position to check. Returns: bool: True if this node contains these coordinates. Otherwise False.
[ "Returns", "True", "if", "this", "node", "contains", "these", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L244-L258
train
libtcod/python-tcod
tcod/bsp.py
BSP.find_node
def find_node(self, x: int, y: int) -> Optional["BSP"]: """Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None. """ if not self.contains(x, y): return None for child in self.children: found = ch...
python
def find_node(self, x: int, y: int) -> Optional["BSP"]: """Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None. """ if not self.contains(x, y): return None for child in self.children: found = ch...
[ "def", "find_node", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "Optional", "[", "\"BSP\"", "]", ":", "if", "not", "self", ".", "contains", "(", "x", ",", "y", ")", ":", "return", "None", "for", "child", "in", "self", "....
Return the deepest node which contains these coordinates. Returns: Optional[BSP]: BSP object or None.
[ "Return", "the", "deepest", "node", "which", "contains", "these", "coordinates", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L260-L272
train
libtcod/python-tcod
tdl/style.py
backport
def backport(func): """ Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If t...
python
def backport(func): """ Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If t...
[ "def", "backport", "(", "func", ")", ":", "if", "not", "__debug__", ":", "return", "func", "@", "_functools", ".", "wraps", "(", "func", ")", "def", "deprecated_function", "(", "*", "args", ",", "*", "*", "kargs", ")", ":", "_warnings", ".", "warn", ...
Backport a function name into an old style for compatibility. The docstring is updated to reflect that the new function returned is deprecated and that the other function is preferred. A DeprecationWarning is also raised for using this function. If the script is run with an optimizatio...
[ "Backport", "a", "function", "name", "into", "an", "old", "style", "for", "compatibility", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/style.py#L9-L29
train
libtcod/python-tcod
tdl/map.py
_get_fov_type
def _get_fov_type(fov): "Return a FOV from a string" oldFOV = fov fov = str(fov).upper() if fov in _FOVTYPES: return _FOVTYPES[fov] if fov[:10] == 'PERMISSIVE' and fov[10].isdigit() and fov[10] != '9': return 4 + int(fov[10]) raise _tdl.TDLError('No such fov option as %s' % oldFO...
python
def _get_fov_type(fov): "Return a FOV from a string" oldFOV = fov fov = str(fov).upper() if fov in _FOVTYPES: return _FOVTYPES[fov] if fov[:10] == 'PERMISSIVE' and fov[10].isdigit() and fov[10] != '9': return 4 + int(fov[10]) raise _tdl.TDLError('No such fov option as %s' % oldFO...
[ "def", "_get_fov_type", "(", "fov", ")", ":", "oldFOV", "=", "fov", "fov", "=", "str", "(", "fov", ")", ".", "upper", "(", ")", "if", "fov", "in", "_FOVTYPES", ":", "return", "_FOVTYPES", "[", "fov", "]", "if", "fov", "[", ":", "10", "]", "==", ...
Return a FOV from a string
[ "Return", "a", "FOV", "from", "a", "string" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L29-L37
train
libtcod/python-tcod
tdl/map.py
quick_fov
def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True): """All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the til...
python
def quick_fov(x, y, callback, fov='PERMISSIVE', radius=7.5, lightWalls=True, sphere=True): """All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the til...
[ "def", "quick_fov", "(", "x", ",", "y", ",", "callback", ",", "fov", "=", "'PERMISSIVE'", ",", "radius", "=", "7.5", ",", "lightWalls", "=", "True", ",", "sphere", "=", "True", ")", ":", "trueRadius", "=", "radius", "radius", "=", "int", "(", "_math"...
All field-of-view functionality in one call. Before using this call be sure to make a function, lambda, or method that takes 2 positional parameters and returns True if light can pass through the tile or False for light-blocking tiles and for indexes that are out of bounds of the dungeon. This fun...
[ "All", "field", "-", "of", "-", "view", "functionality", "in", "one", "call", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L235-L306
train
libtcod/python-tcod
tdl/map.py
bresenham
def bresenham(x1, y1, x2, y2): """ Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points. """ points = [] issteep = abs(y2-y1) > abs(x2...
python
def bresenham(x1, y1, x2, y2): """ Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points. """ points = [] issteep = abs(y2-y1) > abs(x2...
[ "def", "bresenham", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "points", "=", "[", "]", "issteep", "=", "abs", "(", "y2", "-", "y1", ")", ">", "abs", "(", "x2", "-", "x1", ")", "if", "issteep", ":", "x1", ",", "y1", "=", "y1", ...
Return a list of points in a bresenham line. Implementation hastily copied from RogueBasin. Returns: List[Tuple[int, int]]: A list of (x, y) points, including both the start and end-points.
[ "Return", "a", "list", "of", "points", "in", "a", "bresenham", "line", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L308-L349
train
libtcod/python-tcod
tdl/map.py
Map.compute_fov
def compute_fov(self, x, y, fov='PERMISSIVE', radius=None, light_walls=True, sphere=True, cumulative=False): """Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Po...
python
def compute_fov(self, x, y, fov='PERMISSIVE', radius=None, light_walls=True, sphere=True, cumulative=False): """Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Po...
[ "def", "compute_fov", "(", "self", ",", "x", ",", "y", ",", "fov", "=", "'PERMISSIVE'", ",", "radius", "=", "None", ",", "light_walls", "=", "True", ",", "sphere", "=", "True", ",", "cumulative", "=", "False", ")", ":", "# refresh cdata", "if", "radius...
Compute the field-of-view of this Map and return an iterator of the points touched. Args: x (int): Point of view, x-coordinate. y (int): Point of view, y-coordinate. fov (Text): The type of field-of-view to be used. Available types are: ...
[ "Compute", "the", "field", "-", "of", "-", "view", "of", "this", "Map", "and", "return", "an", "iterator", "of", "the", "points", "touched", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L94-L130
train
libtcod/python-tcod
tdl/map.py
Map.compute_path
def compute_path(self, start_x, start_y, dest_x, dest_y, diagonal_cost=_math.sqrt(2)): """Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position...
python
def compute_path(self, start_x, start_y, dest_x, dest_y, diagonal_cost=_math.sqrt(2)): """Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position...
[ "def", "compute_path", "(", "self", ",", "start_x", ",", "start_y", ",", "dest_x", ",", "dest_y", ",", "diagonal_cost", "=", "_math", ".", "sqrt", "(", "2", ")", ")", ":", "return", "tcod", ".", "path", ".", "AStar", "(", "self", ",", "diagonal_cost", ...
Get the shortest path between two points. Args: start_x (int): Starting x-position. start_y (int): Starting y-position. dest_x (int): Destination x-position. dest_y (int): Destination y-position. diagonal_cost (float): Multiplier for diagonal movement...
[ "Get", "the", "shortest", "path", "between", "two", "points", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L133-L153
train
libtcod/python-tcod
tdl/map.py
AStar.get_path
def get_path(self, origX, origY, destX, destY): """ Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. ...
python
def get_path(self, origX, origY, destX, destY): """ Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. ...
[ "def", "get_path", "(", "self", ",", "origX", ",", "origY", ",", "destX", ",", "destY", ")", ":", "return", "super", "(", "AStar", ",", "self", ")", ".", "get_path", "(", "origX", ",", "origY", ",", "destX", ",", "destY", ")" ]
Get the shortest path from origXY to destXY. Returns: List[Tuple[int, int]]: Returns a list walking the path from orig to dest. This excludes the starting point and includes the destination. If no path is found then an empty list is returned.
[ "Get", "the", "shortest", "path", "from", "origXY", "to", "destXY", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tdl/map.py#L220-L232
train
libtcod/python-tcod
setup.py
get_long_description
def get_long_description(): """Return this projects description.""" with open("README.rst", "r") as f: readme = f.read() with open("CHANGELOG.rst", "r") as f: changelog = f.read() changelog = changelog.replace("\nUnreleased\n------------------", "") return "\n".join([readme, chan...
python
def get_long_description(): """Return this projects description.""" with open("README.rst", "r") as f: readme = f.read() with open("CHANGELOG.rst", "r") as f: changelog = f.read() changelog = changelog.replace("\nUnreleased\n------------------", "") return "\n".join([readme, chan...
[ "def", "get_long_description", "(", ")", ":", "with", "open", "(", "\"README.rst\"", ",", "\"r\"", ")", "as", "f", ":", "readme", "=", "f", ".", "read", "(", ")", "with", "open", "(", "\"CHANGELOG.rst\"", ",", "\"r\"", ")", "as", "f", ":", "changelog",...
Return this projects description.
[ "Return", "this", "projects", "description", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/setup.py#L78-L85
train
libtcod/python-tcod
tcod/console.py
get_height_rect
def get_height_rect(width: int, string: str) -> int: """Return the number of lines which would be printed from these parameters. `width` is the width of the print boundary. `string` is a Unicode string which may include color control characters. .. versionadded:: 9.2 """ string_ = string.enco...
python
def get_height_rect(width: int, string: str) -> int: """Return the number of lines which would be printed from these parameters. `width` is the width of the print boundary. `string` is a Unicode string which may include color control characters. .. versionadded:: 9.2 """ string_ = string.enco...
[ "def", "get_height_rect", "(", "width", ":", "int", ",", "string", ":", "str", ")", "->", "int", ":", "string_", "=", "string", ".", "encode", "(", "\"utf-8\"", ")", "# type: bytes", "return", "int", "(", "lib", ".", "get_height_rect2", "(", "width", ","...
Return the number of lines which would be printed from these parameters. `width` is the width of the print boundary. `string` is a Unicode string which may include color control characters. .. versionadded:: 9.2
[ "Return", "the", "number", "of", "lines", "which", "would", "be", "printed", "from", "these", "parameters", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L1084-L1094
train
libtcod/python-tcod
tcod/console.py
Console._get_root
def _get_root(cls, order: Optional[str] = None) -> "Console": """Return a root console singleton with valid buffers. This function will also update an already active root console. """ global _root_console if _root_console is None: _root_console = object.__new__(cls) ...
python
def _get_root(cls, order: Optional[str] = None) -> "Console": """Return a root console singleton with valid buffers. This function will also update an already active root console. """ global _root_console if _root_console is None: _root_console = object.__new__(cls) ...
[ "def", "_get_root", "(", "cls", ",", "order", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "\"Console\"", ":", "global", "_root_console", "if", "_root_console", "is", "None", ":", "_root_console", "=", "object", ".", "__new__", "(", "cls", "...
Return a root console singleton with valid buffers. This function will also update an already active root console.
[ "Return", "a", "root", "console", "singleton", "with", "valid", "buffers", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L164-L177
train
libtcod/python-tcod
tcod/console.py
Console._init_setup_console_data
def _init_setup_console_data(self, order: str = "C") -> None: """Setup numpy arrays over libtcod data buffers.""" global _root_console self._key_color = None if self.console_c == ffi.NULL: _root_console = self self._console_data = lib.TCOD_ctx.root else: ...
python
def _init_setup_console_data(self, order: str = "C") -> None: """Setup numpy arrays over libtcod data buffers.""" global _root_console self._key_color = None if self.console_c == ffi.NULL: _root_console = self self._console_data = lib.TCOD_ctx.root else: ...
[ "def", "_init_setup_console_data", "(", "self", ",", "order", ":", "str", "=", "\"C\"", ")", "->", "None", ":", "global", "_root_console", "self", ".", "_key_color", "=", "None", "if", "self", ".", "console_c", "==", "ffi", ".", "NULL", ":", "_root_console...
Setup numpy arrays over libtcod data buffers.
[ "Setup", "numpy", "arrays", "over", "libtcod", "data", "buffers", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L179-L196
train
libtcod/python-tcod
tcod/console.py
Console.tiles
def tiles(self) -> np.array: """An array of this consoles tile data. This acts as a combination of the `ch`, `fg`, and `bg` attributes. Colors include an alpha channel but how alpha works is currently undefined. Example:: >>> con = tcod.console.Console(10, 2, order=...
python
def tiles(self) -> np.array: """An array of this consoles tile data. This acts as a combination of the `ch`, `fg`, and `bg` attributes. Colors include an alpha channel but how alpha works is currently undefined. Example:: >>> con = tcod.console.Console(10, 2, order=...
[ "def", "tiles", "(", "self", ")", "->", "np", ".", "array", ":", "return", "self", ".", "_tiles", ".", "T", "if", "self", ".", "_order", "==", "\"F\"", "else", "self", ".", "_tiles" ]
An array of this consoles tile data. This acts as a combination of the `ch`, `fg`, and `bg` attributes. Colors include an alpha channel but how alpha works is currently undefined. Example:: >>> con = tcod.console.Console(10, 2, order="F") >>> con.tiles[0, 0] = (...
[ "An", "array", "of", "this", "consoles", "tile", "data", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L249-L268
train
libtcod/python-tcod
tcod/console.py
Console.__clear_warning
def __clear_warning(self, name: str, value: Tuple[int, int, int]) -> None: """Raise a warning for bad default values during calls to clear.""" warnings.warn( "Clearing with the console default values is deprecated.\n" "Add %s=%r to this call." % (name, value), Depreca...
python
def __clear_warning(self, name: str, value: Tuple[int, int, int]) -> None: """Raise a warning for bad default values during calls to clear.""" warnings.warn( "Clearing with the console default values is deprecated.\n" "Add %s=%r to this call." % (name, value), Depreca...
[ "def", "__clear_warning", "(", "self", ",", "name", ":", "str", ",", "value", ":", "Tuple", "[", "int", ",", "int", ",", "int", "]", ")", "->", "None", ":", "warnings", ".", "warn", "(", "\"Clearing with the console default values is deprecated.\\n\"", "\"Add ...
Raise a warning for bad default values during calls to clear.
[ "Raise", "a", "warning", "for", "bad", "default", "values", "during", "calls", "to", "clear", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L312-L319
train
libtcod/python-tcod
tcod/console.py
Console.__deprecate_defaults
def __deprecate_defaults( self, new_func: str, bg_blend: Any, alignment: Any = ..., clear: Any = ..., ) -> None: """Return the parameters needed to recreate the current default state. """ if not __debug__: return fg = self.default_...
python
def __deprecate_defaults( self, new_func: str, bg_blend: Any, alignment: Any = ..., clear: Any = ..., ) -> None: """Return the parameters needed to recreate the current default state. """ if not __debug__: return fg = self.default_...
[ "def", "__deprecate_defaults", "(", "self", ",", "new_func", ":", "str", ",", "bg_blend", ":", "Any", ",", "alignment", ":", "Any", "=", "...", ",", "clear", ":", "Any", "=", "...", ",", ")", "->", "None", ":", "if", "not", "__debug__", ":", "return"...
Return the parameters needed to recreate the current default state.
[ "Return", "the", "parameters", "needed", "to", "recreate", "the", "current", "default", "state", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L390-L448
train
libtcod/python-tcod
tcod/console.py
Console.get_height_rect
def get_height_rect( self, x: int, y: int, width: int, height: int, string: str ) -> int: """Return the height of this text word-wrapped into this rectangle. Args: x (int): The x coordinate from the left. y (int): The y coordinate from the top. width (int...
python
def get_height_rect( self, x: int, y: int, width: int, height: int, string: str ) -> int: """Return the height of this text word-wrapped into this rectangle. Args: x (int): The x coordinate from the left. y (int): The y coordinate from the top. width (int...
[ "def", "get_height_rect", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "string", ":", "str", ")", "->", "int", ":", "string_", "=", "string", ".", "encode", "(", "\"utf-8\"", "...
Return the height of this text word-wrapped into this rectangle. Args: x (int): The x coordinate from the left. y (int): The y coordinate from the top. width (int): Maximum width to render the text. height (int): Maximum lines to render the text. stri...
[ "Return", "the", "height", "of", "this", "text", "word", "-", "wrapped", "into", "this", "rectangle", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L529-L549
train
libtcod/python-tcod
tcod/console.py
Console.print_frame
def print_frame( self, x: int, y: int, width: int, height: int, string: str = "", clear: bool = True, bg_blend: int = tcod.constants.BKGND_DEFAULT, ) -> None: """Draw a framed rectangle with optional text. This uses the default backgro...
python
def print_frame( self, x: int, y: int, width: int, height: int, string: str = "", clear: bool = True, bg_blend: int = tcod.constants.BKGND_DEFAULT, ) -> None: """Draw a framed rectangle with optional text. This uses the default backgro...
[ "def", "print_frame", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "string", ":", "str", "=", "\"\"", ",", "clear", ":", "bool", "=", "True", ",", "bg_blend", ":", "int", "="...
Draw a framed rectangle with optional text. This uses the default background color and blend mode to fill the rectangle and the default foreground to draw the outline. `string` will be printed on the inside of the rectangle, word-wrapped. If `string` is empty then no title will be draw...
[ "Draw", "a", "framed", "rectangle", "with", "optional", "text", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L639-L681
train
libtcod/python-tcod
tcod/console.py
Console.blit
def blit( self, dest: "Console", dest_x: int = 0, dest_y: int = 0, src_x: int = 0, src_y: int = 0, width: int = 0, height: int = 0, fg_alpha: float = 1.0, bg_alpha: float = 1.0, key_color: Optional[Tuple[int, int, int]] = None, ...
python
def blit( self, dest: "Console", dest_x: int = 0, dest_y: int = 0, src_x: int = 0, src_y: int = 0, width: int = 0, height: int = 0, fg_alpha: float = 1.0, bg_alpha: float = 1.0, key_color: Optional[Tuple[int, int, int]] = None, ...
[ "def", "blit", "(", "self", ",", "dest", ":", "\"Console\"", ",", "dest_x", ":", "int", "=", "0", ",", "dest_y", ":", "int", "=", "0", ",", "src_x", ":", "int", "=", "0", ",", "src_y", ":", "int", "=", "0", ",", "width", ":", "int", "=", "0",...
Blit from this console onto the ``dest`` console. Args: dest (Console): The destintaion console to blit onto. dest_x (int): Leftmost coordinate of the destintaion console. dest_y (int): Topmost coordinate of the destintaion console. src_x (int): X coordinate from...
[ "Blit", "from", "this", "console", "onto", "the", "dest", "console", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L683-L766
train
libtcod/python-tcod
tcod/console.py
Console.print
def print( self, x: int, y: int, string: str, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, alignment: int = tcod.constants.LEFT, ) -> None: """Print a string on ...
python
def print( self, x: int, y: int, string: str, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, alignment: int = tcod.constants.LEFT, ) -> None: """Print a string on ...
[ "def", "print", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "string", ":", "str", ",", "fg", ":", "Optional", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", "=", "None", ",", "bg", ":", "Optional", "[", "Tuple",...
Print a string on a console with manual line breaks. `x` and `y` are the starting tile, with ``0,0`` as the upper-left corner of the console. You can use negative numbers if you want to start printing relative to the bottom-right corner, but this behavior may change in future versions....
[ "Print", "a", "string", "on", "a", "console", "with", "manual", "line", "breaks", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L874-L921
train
libtcod/python-tcod
tcod/console.py
Console.draw_frame
def draw_frame( self, x: int, y: int, width: int, height: int, title: str = "", clear: bool = True, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, ) -> Non...
python
def draw_frame( self, x: int, y: int, width: int, height: int, title: str = "", clear: bool = True, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, ) -> Non...
[ "def", "draw_frame", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "title", ":", "str", "=", "\"\"", ",", "clear", ":", "bool", "=", "True", ",", "fg", ":", "Optional", "[", ...
Draw a framed rectangle with an optional title. `x` and `y` are the starting tile, with ``0,0`` as the upper-left corner of the console. You can use negative numbers if you want to start printing relative to the bottom-right corner, but this behavior may change in future versions. ...
[ "Draw", "a", "framed", "rectangle", "with", "an", "optional", "title", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L982-L1033
train
libtcod/python-tcod
tcod/console.py
Console.draw_rect
def draw_rect( self, x: int, y: int, width: int, height: int, ch: int, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, ) -> None: """Draw characters and col...
python
def draw_rect( self, x: int, y: int, width: int, height: int, ch: int, fg: Optional[Tuple[int, int, int]] = None, bg: Optional[Tuple[int, int, int]] = None, bg_blend: int = tcod.constants.BKGND_SET, ) -> None: """Draw characters and col...
[ "def", "draw_rect", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "width", ":", "int", ",", "height", ":", "int", ",", "ch", ":", "int", ",", "fg", ":", "Optional", "[", "Tuple", "[", "int", ",", "int", ",", "int", "]", "]", ...
Draw characters and colors over a rectangular region. `x` and `y` are the starting tile, with ``0,0`` as the upper-left corner of the console. You can use negative numbers if you want to start printing relative to the bottom-right corner, but this behavior may change in future versions...
[ "Draw", "characters", "and", "colors", "over", "a", "rectangular", "region", "." ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/console.py#L1035-L1081
train
libtcod/python-tcod
fonts/X11/bdf/bdf2png.py
Glyph.blit
def blit(self, image, x, y): """blit to the image array""" # adjust the position with the local bbox x += self.font_bbox[2] - self.bbox[2] y += self.font_bbox[3] - self.bbox[3] x += self.font_bbox[0] - self.bbox[0] y += self.font_bbox[1] - self.bbox[1] image[y:y+s...
python
def blit(self, image, x, y): """blit to the image array""" # adjust the position with the local bbox x += self.font_bbox[2] - self.bbox[2] y += self.font_bbox[3] - self.bbox[3] x += self.font_bbox[0] - self.bbox[0] y += self.font_bbox[1] - self.bbox[1] image[y:y+s...
[ "def", "blit", "(", "self", ",", "image", ",", "x", ",", "y", ")", ":", "# adjust the position with the local bbox", "x", "+=", "self", ".", "font_bbox", "[", "2", "]", "-", "self", ".", "bbox", "[", "2", "]", "y", "+=", "self", ".", "font_bbox", "["...
blit to the image array
[ "blit", "to", "the", "image", "array" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/fonts/X11/bdf/bdf2png.py#L80-L87
train
libtcod/python-tcod
fonts/X11/bdf/bdf2png.py
Glyph.parseBits
def parseBits(self, hexcode, width): """enumerate over bits in a line of data""" bitarray = [] for byte in hexcode[::-1]: bits = int(byte, 16) for x in range(4): bitarray.append(bool((2 ** x) & bits)) bitarray = bitarray[::-1] return enumer...
python
def parseBits(self, hexcode, width): """enumerate over bits in a line of data""" bitarray = [] for byte in hexcode[::-1]: bits = int(byte, 16) for x in range(4): bitarray.append(bool((2 ** x) & bits)) bitarray = bitarray[::-1] return enumer...
[ "def", "parseBits", "(", "self", ",", "hexcode", ",", "width", ")", ":", "bitarray", "=", "[", "]", "for", "byte", "in", "hexcode", "[", ":", ":", "-", "1", "]", ":", "bits", "=", "int", "(", "byte", ",", "16", ")", "for", "x", "in", "range", ...
enumerate over bits in a line of data
[ "enumerate", "over", "bits", "in", "a", "line", "of", "data" ]
8ba10c5cfb813eaf3e834de971ba2d6acb7838e4
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/fonts/X11/bdf/bdf2png.py#L89-L97
train
Netflix-Skunkworks/raven-python-lambda
raven_python_lambda/__init__.py
memory_warning
def memory_warning(config, context): """Determines when memory usage is nearing it's max.""" used = psutil.Process(os.getpid()).memory_info().rss / 1048576 limit = float(context.memory_limit_in_mb) p = used / limit memory_threshold = config.get('memory_warning_threshold') if p >= memory_thresh...
python
def memory_warning(config, context): """Determines when memory usage is nearing it's max.""" used = psutil.Process(os.getpid()).memory_info().rss / 1048576 limit = float(context.memory_limit_in_mb) p = used / limit memory_threshold = config.get('memory_warning_threshold') if p >= memory_thresh...
[ "def", "memory_warning", "(", "config", ",", "context", ")", ":", "used", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")", ")", ".", "memory_info", "(", ")", ".", "rss", "/", "1048576", "limit", "=", "float", "(", "context", ".", ...
Determines when memory usage is nearing it's max.
[ "Determines", "when", "memory", "usage", "is", "nearing", "it", "s", "max", "." ]
640d5cfcef6e69ea685ca13469cfca71adf0e78c
https://github.com/Netflix-Skunkworks/raven-python-lambda/blob/640d5cfcef6e69ea685ca13469cfca71adf0e78c/raven_python_lambda/__init__.py#L233-L252
train
Netflix-Skunkworks/raven-python-lambda
raven_python_lambda/__init__.py
install_timers
def install_timers(config, context): """Create the timers as specified by the plugin configuration.""" timers = [] if config.get('capture_timeout_warnings'): timeout_threshold = config.get('timeout_warning_threshold') # Schedule the warning at the user specified threshold given in percent. ...
python
def install_timers(config, context): """Create the timers as specified by the plugin configuration.""" timers = [] if config.get('capture_timeout_warnings'): timeout_threshold = config.get('timeout_warning_threshold') # Schedule the warning at the user specified threshold given in percent. ...
[ "def", "install_timers", "(", "config", ",", "context", ")", ":", "timers", "=", "[", "]", "if", "config", ".", "get", "(", "'capture_timeout_warnings'", ")", ":", "timeout_threshold", "=", "config", ".", "get", "(", "'timeout_warning_threshold'", ")", "# Sche...
Create the timers as specified by the plugin configuration.
[ "Create", "the", "timers", "as", "specified", "by", "the", "plugin", "configuration", "." ]
640d5cfcef6e69ea685ca13469cfca71adf0e78c
https://github.com/Netflix-Skunkworks/raven-python-lambda/blob/640d5cfcef6e69ea685ca13469cfca71adf0e78c/raven_python_lambda/__init__.py#L255-L274
train
ellmetha/django-machina
machina/templatetags/forum_tags.py
recurseforumcontents
def recurseforumcontents(parser, token): """ Iterates over the content nodes and renders the contained forum block for each node. """ bits = token.contents.split() forums_contents_var = template.Variable(bits[1]) template_nodes = parser.parse(('endrecurseforumcontents',)) parser.delete_first_token(...
python
def recurseforumcontents(parser, token): """ Iterates over the content nodes and renders the contained forum block for each node. """ bits = token.contents.split() forums_contents_var = template.Variable(bits[1]) template_nodes = parser.parse(('endrecurseforumcontents',)) parser.delete_first_token(...
[ "def", "recurseforumcontents", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "forums_contents_var", "=", "template", ".", "Variable", "(", "bits", "[", "1", "]", ")", "template_nodes", "=", "parser", ...
Iterates over the content nodes and renders the contained forum block for each node.
[ "Iterates", "over", "the", "content", "nodes", "and", "renders", "the", "contained", "forum", "block", "for", "each", "node", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/templatetags/forum_tags.py#L40-L48
train
ellmetha/django-machina
machina/templatetags/forum_tags.py
forum_list
def forum_list(context, forum_visibility_contents): """ Renders the considered forum list. This will render the given list of forums by respecting the order and the depth of each forum in the forums tree. Usage:: {% forum_list my_forums %} """ request = context.get('request') tra...
python
def forum_list(context, forum_visibility_contents): """ Renders the considered forum list. This will render the given list of forums by respecting the order and the depth of each forum in the forums tree. Usage:: {% forum_list my_forums %} """ request = context.get('request') tra...
[ "def", "forum_list", "(", "context", ",", "forum_visibility_contents", ")", ":", "request", "=", "context", ".", "get", "(", "'request'", ")", "tracking_handler", "=", "TrackingHandler", "(", "request", "=", "request", ")", "data_dict", "=", "{", "'forum_content...
Renders the considered forum list. This will render the given list of forums by respecting the order and the depth of each forum in the forums tree. Usage:: {% forum_list my_forums %}
[ "Renders", "the", "considered", "forum", "list", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/templatetags/forum_tags.py#L52-L80
train
ellmetha/django-machina
machina/apps/forum_feeds/feeds.py
LastTopicsFeed.get_object
def get_object(self, request, *args, **kwargs): """ Handles the considered object. """ forum_pk = kwargs.get('forum_pk', None) descendants = kwargs.get('descendants', None) self.user = request.user if forum_pk: forum = get_object_or_404(Forum, pk=forum_pk) ...
python
def get_object(self, request, *args, **kwargs): """ Handles the considered object. """ forum_pk = kwargs.get('forum_pk', None) descendants = kwargs.get('descendants', None) self.user = request.user if forum_pk: forum = get_object_or_404(Forum, pk=forum_pk) ...
[ "def", "get_object", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "forum_pk", "=", "kwargs", ".", "get", "(", "'forum_pk'", ",", "None", ")", "descendants", "=", "kwargs", ".", "get", "(", "'descendants'", ",", "N...
Handles the considered object.
[ "Handles", "the", "considered", "object", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_feeds/feeds.py#L34-L52
train
ellmetha/django-machina
machina/apps/forum_feeds/feeds.py
LastTopicsFeed.items
def items(self): """ Returns the items to include into the feed. """ return Topic.objects.filter(forum__in=self.forums, approved=True).order_by('-last_post_on')
python
def items(self): """ Returns the items to include into the feed. """ return Topic.objects.filter(forum__in=self.forums, approved=True).order_by('-last_post_on')
[ "def", "items", "(", "self", ")", ":", "return", "Topic", ".", "objects", ".", "filter", "(", "forum__in", "=", "self", ".", "forums", ",", "approved", "=", "True", ")", ".", "order_by", "(", "'-last_post_on'", ")" ]
Returns the items to include into the feed.
[ "Returns", "the", "items", "to", "include", "into", "the", "feed", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_feeds/feeds.py#L54-L56
train
ellmetha/django-machina
machina/apps/forum_feeds/feeds.py
LastTopicsFeed.item_link
def item_link(self, item): """ Generates a link for a specific item of the feed. """ return reverse_lazy( 'forum_conversation:topic', kwargs={ 'forum_slug': item.forum.slug, 'forum_pk': item.forum.pk, 'slug': item.slug, ...
python
def item_link(self, item): """ Generates a link for a specific item of the feed. """ return reverse_lazy( 'forum_conversation:topic', kwargs={ 'forum_slug': item.forum.slug, 'forum_pk': item.forum.pk, 'slug': item.slug, ...
[ "def", "item_link", "(", "self", ",", "item", ")", ":", "return", "reverse_lazy", "(", "'forum_conversation:topic'", ",", "kwargs", "=", "{", "'forum_slug'", ":", "item", ".", "forum", ".", "slug", ",", "'forum_pk'", ":", "item", ".", "forum", ".", "pk", ...
Generates a link for a specific item of the feed.
[ "Generates", "a", "link", "for", "a", "specific", "item", "of", "the", "feed", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_feeds/feeds.py#L58-L68
train
ellmetha/django-machina
machina/templatetags/forum_conversation_tags.py
topic_pages_inline_list
def topic_pages_inline_list(topic): """ This will render an inline pagination for the posts related to the given topic. Usage:: {% topic_pages_inline_list my_topic %} """ data_dict = { 'topic': topic, } pages_number = ((topic.posts_count - 1) // machina_settings.TOPIC_POSTS_N...
python
def topic_pages_inline_list(topic): """ This will render an inline pagination for the posts related to the given topic. Usage:: {% topic_pages_inline_list my_topic %} """ data_dict = { 'topic': topic, } pages_number = ((topic.posts_count - 1) // machina_settings.TOPIC_POSTS_N...
[ "def", "topic_pages_inline_list", "(", "topic", ")", ":", "data_dict", "=", "{", "'topic'", ":", "topic", ",", "}", "pages_number", "=", "(", "(", "topic", ".", "posts_count", "-", "1", ")", "//", "machina_settings", ".", "TOPIC_POSTS_NUMBER_PER_PAGE", ")", ...
This will render an inline pagination for the posts related to the given topic. Usage:: {% topic_pages_inline_list my_topic %}
[ "This", "will", "render", "an", "inline", "pagination", "for", "the", "posts", "related", "to", "the", "given", "topic", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/templatetags/forum_conversation_tags.py#L22-L41
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.get_urls
def get_urls(self): """ Returns the URLs associated with the admin abstraction. """ urls = super().get_urls() forum_admin_urls = [ url( r'^(?P<forum_id>[0-9]+)/move-forum/(?P<direction>up|down)/$', self.admin_site.admin_view(self.moveforum_view), ...
python
def get_urls(self): """ Returns the URLs associated with the admin abstraction. """ urls = super().get_urls() forum_admin_urls = [ url( r'^(?P<forum_id>[0-9]+)/move-forum/(?P<direction>up|down)/$', self.admin_site.admin_view(self.moveforum_view), ...
[ "def", "get_urls", "(", "self", ")", ":", "urls", "=", "super", "(", ")", ".", "get_urls", "(", ")", "forum_admin_urls", "=", "[", "url", "(", "r'^(?P<forum_id>[0-9]+)/move-forum/(?P<direction>up|down)/$'", ",", "self", ".", "admin_site", ".", "admin_view", "(",...
Returns the URLs associated with the admin abstraction.
[ "Returns", "the", "URLs", "associated", "with", "the", "admin", "abstraction", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L66-L116
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.get_forum_perms_base_context
def get_forum_perms_base_context(self, request, obj=None): """ Returns the context to provide to the template for permissions contents. """ context = { 'adminform': {'model_admin': self}, 'media': self.media, 'object': obj, 'app_label': self.model._meta.ap...
python
def get_forum_perms_base_context(self, request, obj=None): """ Returns the context to provide to the template for permissions contents. """ context = { 'adminform': {'model_admin': self}, 'media': self.media, 'object': obj, 'app_label': self.model._meta.ap...
[ "def", "get_forum_perms_base_context", "(", "self", ",", "request", ",", "obj", "=", "None", ")", ":", "context", "=", "{", "'adminform'", ":", "{", "'model_admin'", ":", "self", "}", ",", "'media'", ":", "self", ".", "media", ",", "'object'", ":", "obj"...
Returns the context to provide to the template for permissions contents.
[ "Returns", "the", "context", "to", "provide", "to", "the", "template", "for", "permissions", "contents", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L118-L135
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.moveforum_view
def moveforum_view(self, request, forum_id, direction): """ Moves the given forum toward the requested direction. """ forum = get_object_or_404(Forum, pk=forum_id) # Fetch the target target, position = None, None if direction == 'up': target, position = forum.get_pre...
python
def moveforum_view(self, request, forum_id, direction): """ Moves the given forum toward the requested direction. """ forum = get_object_or_404(Forum, pk=forum_id) # Fetch the target target, position = None, None if direction == 'up': target, position = forum.get_pre...
[ "def", "moveforum_view", "(", "self", ",", "request", ",", "forum_id", ",", "direction", ")", ":", "forum", "=", "get_object_or_404", "(", "Forum", ",", "pk", "=", "forum_id", ")", "# Fetch the target", "target", ",", "position", "=", "None", ",", "None", ...
Moves the given forum toward the requested direction.
[ "Moves", "the", "given", "forum", "toward", "the", "requested", "direction", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L137-L155
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.editpermissions_index_view
def editpermissions_index_view(self, request, forum_id=None): """ Allows to select how to edit forum permissions. The view displays a form to select a user or a group in order to edit its permissions for the considered forum. """ forum = get_object_or_404(Forum, pk=forum_id) if...
python
def editpermissions_index_view(self, request, forum_id=None): """ Allows to select how to edit forum permissions. The view displays a form to select a user or a group in order to edit its permissions for the considered forum. """ forum = get_object_or_404(Forum, pk=forum_id) if...
[ "def", "editpermissions_index_view", "(", "self", ",", "request", ",", "forum_id", "=", "None", ")", ":", "forum", "=", "get_object_or_404", "(", "Forum", ",", "pk", "=", "forum_id", ")", "if", "forum_id", "else", "None", "# Set up the context", "context", "="...
Allows to select how to edit forum permissions. The view displays a form to select a user or a group in order to edit its permissions for the considered forum.
[ "Allows", "to", "select", "how", "to", "edit", "forum", "permissions", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L157-L240
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.editpermissions_user_view
def editpermissions_user_view(self, request, user_id, forum_id=None): """ Allows to edit user permissions for the considered forum. The view displays a form to define which permissions are granted for the given user for the considered forum. """ user_model = get_user_model() ...
python
def editpermissions_user_view(self, request, user_id, forum_id=None): """ Allows to edit user permissions for the considered forum. The view displays a form to define which permissions are granted for the given user for the considered forum. """ user_model = get_user_model() ...
[ "def", "editpermissions_user_view", "(", "self", ",", "request", ",", "user_id", ",", "forum_id", "=", "None", ")", ":", "user_model", "=", "get_user_model", "(", ")", "user", "=", "get_object_or_404", "(", "user_model", ",", "pk", "=", "user_id", ")", "foru...
Allows to edit user permissions for the considered forum. The view displays a form to define which permissions are granted for the given user for the considered forum.
[ "Allows", "to", "edit", "user", "permissions", "for", "the", "considered", "forum", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L242-L261
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.editpermissions_anonymous_user_view
def editpermissions_anonymous_user_view(self, request, forum_id=None): """ Allows to edit anonymous user permissions for the considered forum. The view displays a form to define which permissions are granted for the anonymous user for the considered forum. """ forum = get_objec...
python
def editpermissions_anonymous_user_view(self, request, forum_id=None): """ Allows to edit anonymous user permissions for the considered forum. The view displays a form to define which permissions are granted for the anonymous user for the considered forum. """ forum = get_objec...
[ "def", "editpermissions_anonymous_user_view", "(", "self", ",", "request", ",", "forum_id", "=", "None", ")", ":", "forum", "=", "get_object_or_404", "(", "Forum", ",", "pk", "=", "forum_id", ")", "if", "forum_id", "else", "None", "# Set up the context", "contex...
Allows to edit anonymous user permissions for the considered forum. The view displays a form to define which permissions are granted for the anonymous user for the considered forum.
[ "Allows", "to", "edit", "anonymous", "user", "permissions", "for", "the", "considered", "forum", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L263-L280
train
ellmetha/django-machina
machina/apps/forum/admin.py
ForumAdmin.editpermissions_group_view
def editpermissions_group_view(self, request, group_id, forum_id=None): """ Allows to edit group permissions for the considered forum. The view displays a form to define which permissions are granted for the given group for the considered forum. """ group = get_object_or_404(Gr...
python
def editpermissions_group_view(self, request, group_id, forum_id=None): """ Allows to edit group permissions for the considered forum. The view displays a form to define which permissions are granted for the given group for the considered forum. """ group = get_object_or_404(Gr...
[ "def", "editpermissions_group_view", "(", "self", ",", "request", ",", "group_id", ",", "forum_id", "=", "None", ")", ":", "group", "=", "get_object_or_404", "(", "Group", ",", "pk", "=", "group_id", ")", "forum", "=", "get_object_or_404", "(", "Forum", ",",...
Allows to edit group permissions for the considered forum. The view displays a form to define which permissions are granted for the given group for the considered forum.
[ "Allows", "to", "edit", "group", "permissions", "for", "the", "considered", "forum", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/admin.py#L282-L300
train
ellmetha/django-machina
machina/templatetags/forum_permission_tags.py
get_permission
def get_permission(context, method, *args, **kwargs): """ This will return a boolean indicating if the considered permission is granted for the passed user. Usage:: {% get_permission 'can_access_moderation_panel' request.user as var %} """ request = context.get('request', None) pe...
python
def get_permission(context, method, *args, **kwargs): """ This will return a boolean indicating if the considered permission is granted for the passed user. Usage:: {% get_permission 'can_access_moderation_panel' request.user as var %} """ request = context.get('request', None) pe...
[ "def", "get_permission", "(", "context", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", "=", "context", ".", "get", "(", "'request'", ",", "None", ")", "perm_handler", "=", "request", ".", "forum_permission_handler", "if", ...
This will return a boolean indicating if the considered permission is granted for the passed user. Usage:: {% get_permission 'can_access_moderation_panel' request.user as var %}
[ "This", "will", "return", "a", "boolean", "indicating", "if", "the", "considered", "permission", "is", "granted", "for", "the", "passed", "user", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/templatetags/forum_permission_tags.py#L14-L35
train
ellmetha/django-machina
machina/apps/forum_conversation/forum_polls/forms.py
BaseTopicPollOptionFormset.total_form_count
def total_form_count(self): """ This rewrite of total_form_count allows to add an empty form to the formset only when no initial data is provided. """ total_forms = super().total_form_count() if not self.data and not self.files and self.initial_form_count() > 0: ...
python
def total_form_count(self): """ This rewrite of total_form_count allows to add an empty form to the formset only when no initial data is provided. """ total_forms = super().total_form_count() if not self.data and not self.files and self.initial_form_count() > 0: ...
[ "def", "total_form_count", "(", "self", ")", ":", "total_forms", "=", "super", "(", ")", ".", "total_form_count", "(", ")", "if", "not", "self", ".", "data", "and", "not", "self", ".", "files", "and", "self", ".", "initial_form_count", "(", ")", ">", "...
This rewrite of total_form_count allows to add an empty form to the formset only when no initial data is provided.
[ "This", "rewrite", "of", "total_form_count", "allows", "to", "add", "an", "empty", "form", "to", "the", "formset", "only", "when", "no", "initial", "data", "is", "provided", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/forum_polls/forms.py#L52-L60
train
ellmetha/django-machina
machina/core/loading.py
get_classes
def get_classes(module_label, classnames): """ Imports a set of classes from a given module. Usage:: get_classes('forum.models', ['Forum', 'ForumReadTrack', ]) """ app_label = module_label.split('.')[0] app_module_path = _get_app_module_path(module_label) if not app_module_path: ...
python
def get_classes(module_label, classnames): """ Imports a set of classes from a given module. Usage:: get_classes('forum.models', ['Forum', 'ForumReadTrack', ]) """ app_label = module_label.split('.')[0] app_module_path = _get_app_module_path(module_label) if not app_module_path: ...
[ "def", "get_classes", "(", "module_label", ",", "classnames", ")", ":", "app_label", "=", "module_label", ".", "split", "(", "'.'", ")", "[", "0", "]", "app_module_path", "=", "_get_app_module_path", "(", "module_label", ")", "if", "not", "app_module_path", ":...
Imports a set of classes from a given module. Usage:: get_classes('forum.models', ['Forum', 'ForumReadTrack', ])
[ "Imports", "a", "set", "of", "classes", "from", "a", "given", "module", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/core/loading.py#L19-L59
train
ellmetha/django-machina
machina/core/loading.py
_import_module
def _import_module(module_path, classnames): """ Tries to import the given Python module path. """ try: imported_module = __import__(module_path, fromlist=classnames) return imported_module except ImportError: # In case of an ImportError, the module being loaded generally does not ex...
python
def _import_module(module_path, classnames): """ Tries to import the given Python module path. """ try: imported_module = __import__(module_path, fromlist=classnames) return imported_module except ImportError: # In case of an ImportError, the module being loaded generally does not ex...
[ "def", "_import_module", "(", "module_path", ",", "classnames", ")", ":", "try", ":", "imported_module", "=", "__import__", "(", "module_path", ",", "fromlist", "=", "classnames", ")", "return", "imported_module", "except", "ImportError", ":", "# In case of an Impor...
Tries to import the given Python module path.
[ "Tries", "to", "import", "the", "given", "Python", "module", "path", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/core/loading.py#L62-L79
train
ellmetha/django-machina
machina/core/loading.py
_pick_up_classes
def _pick_up_classes(modules, classnames): """ Given a list of class names to retrieve, try to fetch them from the specified list of modules and returns the list of the fetched classes. """ klasses = [] for classname in classnames: klass = None for module in modules: ...
python
def _pick_up_classes(modules, classnames): """ Given a list of class names to retrieve, try to fetch them from the specified list of modules and returns the list of the fetched classes. """ klasses = [] for classname in classnames: klass = None for module in modules: ...
[ "def", "_pick_up_classes", "(", "modules", ",", "classnames", ")", ":", "klasses", "=", "[", "]", "for", "classname", "in", "classnames", ":", "klass", "=", "None", "for", "module", "in", "modules", ":", "if", "hasattr", "(", "module", ",", "classname", ...
Given a list of class names to retrieve, try to fetch them from the specified list of modules and returns the list of the fetched classes.
[ "Given", "a", "list", "of", "class", "names", "to", "retrieve", "try", "to", "fetch", "them", "from", "the", "specified", "list", "of", "modules", "and", "returns", "the", "list", "of", "the", "fetched", "classes", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/core/loading.py#L82-L98
train
ellmetha/django-machina
machina/core/loading.py
_get_app_module_path
def _get_app_module_path(module_label): """ Given a module label, loop over the apps specified in the INSTALLED_APPS to find the corresponding application module path. """ app_name = module_label.rsplit('.', 1)[0] for app in settings.INSTALLED_APPS: if app.endswith('.' + app_name) or app...
python
def _get_app_module_path(module_label): """ Given a module label, loop over the apps specified in the INSTALLED_APPS to find the corresponding application module path. """ app_name = module_label.rsplit('.', 1)[0] for app in settings.INSTALLED_APPS: if app.endswith('.' + app_name) or app...
[ "def", "_get_app_module_path", "(", "module_label", ")", ":", "app_name", "=", "module_label", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", "for", "app", "in", "settings", ".", "INSTALLED_APPS", ":", "if", "app", ".", "endswith", "(", "'.'", ...
Given a module label, loop over the apps specified in the INSTALLED_APPS to find the corresponding application module path.
[ "Given", "a", "module", "label", "loop", "over", "the", "apps", "specified", "in", "the", "INSTALLED_APPS", "to", "find", "the", "corresponding", "application", "module", "path", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/core/loading.py#L101-L109
train
ellmetha/django-machina
machina/apps/forum_tracking/handler.py
TrackingHandler.get_unread_forums
def get_unread_forums(self, user): """ Returns the list of unread forums for the given user. """ return self.get_unread_forums_from_list( user, self.perm_handler.get_readable_forums(Forum.objects.all(), user))
python
def get_unread_forums(self, user): """ Returns the list of unread forums for the given user. """ return self.get_unread_forums_from_list( user, self.perm_handler.get_readable_forums(Forum.objects.all(), user))
[ "def", "get_unread_forums", "(", "self", ",", "user", ")", ":", "return", "self", ".", "get_unread_forums_from_list", "(", "user", ",", "self", ".", "perm_handler", ".", "get_readable_forums", "(", "Forum", ".", "objects", ".", "all", "(", ")", ",", "user", ...
Returns the list of unread forums for the given user.
[ "Returns", "the", "list", "of", "unread", "forums", "for", "the", "given", "user", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/handler.py#L36-L39
train
ellmetha/django-machina
machina/apps/forum_tracking/handler.py
TrackingHandler.get_unread_forums_from_list
def get_unread_forums_from_list(self, user, forums): """ Returns the list of unread forums for the given user from a given list of forums. """ unread_forums = [] # A user which is not authenticated will never see a forum as unread if not user.is_authenticated: return unread_...
python
def get_unread_forums_from_list(self, user, forums): """ Returns the list of unread forums for the given user from a given list of forums. """ unread_forums = [] # A user which is not authenticated will never see a forum as unread if not user.is_authenticated: return unread_...
[ "def", "get_unread_forums_from_list", "(", "self", ",", "user", ",", "forums", ")", ":", "unread_forums", "=", "[", "]", "# A user which is not authenticated will never see a forum as unread", "if", "not", "user", ".", "is_authenticated", ":", "return", "unread_forums", ...
Returns the list of unread forums for the given user from a given list of forums.
[ "Returns", "the", "list", "of", "unread", "forums", "for", "the", "given", "user", "from", "a", "given", "list", "of", "forums", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/handler.py#L41-L52
train
ellmetha/django-machina
machina/apps/forum_tracking/handler.py
TrackingHandler.get_unread_topics
def get_unread_topics(self, topics, user): """ Returns a list of unread topics for the given user from a given set of topics. """ unread_topics = [] # A user which is not authenticated will never see a topic as unread. # If there are no topics to consider, we stop here. if not u...
python
def get_unread_topics(self, topics, user): """ Returns a list of unread topics for the given user from a given set of topics. """ unread_topics = [] # A user which is not authenticated will never see a topic as unread. # If there are no topics to consider, we stop here. if not u...
[ "def", "get_unread_topics", "(", "self", ",", "topics", ",", "user", ")", ":", "unread_topics", "=", "[", "]", "# A user which is not authenticated will never see a topic as unread.", "# If there are no topics to consider, we stop here.", "if", "not", "user", ".", "is_authent...
Returns a list of unread topics for the given user from a given set of topics.
[ "Returns", "a", "list", "of", "unread", "topics", "for", "the", "given", "user", "from", "a", "given", "set", "of", "topics", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/handler.py#L54-L98
train
ellmetha/django-machina
machina/apps/forum_tracking/handler.py
TrackingHandler.mark_forums_read
def mark_forums_read(self, forums, user): """ Marks a list of forums as read. """ if not forums or not user.is_authenticated: return forums = sorted(forums, key=lambda f: f.level) # Update all forum tracks to the current date for the considered forums for forum in f...
python
def mark_forums_read(self, forums, user): """ Marks a list of forums as read. """ if not forums or not user.is_authenticated: return forums = sorted(forums, key=lambda f: f.level) # Update all forum tracks to the current date for the considered forums for forum in f...
[ "def", "mark_forums_read", "(", "self", ",", "forums", ",", "user", ")", ":", "if", "not", "forums", "or", "not", "user", ".", "is_authenticated", ":", "return", "forums", "=", "sorted", "(", "forums", ",", "key", "=", "lambda", "f", ":", "f", ".", "...
Marks a list of forums as read.
[ "Marks", "a", "list", "of", "forums", "as", "read", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/handler.py#L100-L114
train
ellmetha/django-machina
machina/apps/forum_tracking/handler.py
TrackingHandler.mark_topic_read
def mark_topic_read(self, topic, user): """ Marks a topic as read. """ if not user.is_authenticated: return forum = topic.forum try: forum_track = ForumReadTrack.objects.get(forum=forum, user=user) except ForumReadTrack.DoesNotExist: forum_tra...
python
def mark_topic_read(self, topic, user): """ Marks a topic as read. """ if not user.is_authenticated: return forum = topic.forum try: forum_track = ForumReadTrack.objects.get(forum=forum, user=user) except ForumReadTrack.DoesNotExist: forum_tra...
[ "def", "mark_topic_read", "(", "self", ",", "topic", ",", "user", ")", ":", "if", "not", "user", ".", "is_authenticated", ":", "return", "forum", "=", "topic", ".", "forum", "try", ":", "forum_track", "=", "ForumReadTrack", ".", "objects", ".", "get", "(...
Marks a topic as read.
[ "Marks", "a", "topic", "as", "read", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_tracking/handler.py#L116-L166
train
ellmetha/django-machina
machina/apps/forum/abstract_models.py
AbstractForum.clean
def clean(self): """ Validates the forum instance. """ super().clean() if self.parent and self.parent.is_link: raise ValidationError(_('A forum can not have a link forum as parent')) if self.is_category and self.parent and self.parent.is_category: raise Validati...
python
def clean(self): """ Validates the forum instance. """ super().clean() if self.parent and self.parent.is_link: raise ValidationError(_('A forum can not have a link forum as parent')) if self.is_category and self.parent and self.parent.is_category: raise Validati...
[ "def", "clean", "(", "self", ")", ":", "super", "(", ")", ".", "clean", "(", ")", "if", "self", ".", "parent", "and", "self", ".", "parent", ".", "is_link", ":", "raise", "ValidationError", "(", "_", "(", "'A forum can not have a link forum as parent'", ")...
Validates the forum instance.
[ "Validates", "the", "forum", "instance", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/abstract_models.py#L134-L145
train
ellmetha/django-machina
machina/apps/forum/abstract_models.py
AbstractForum.get_image_upload_to
def get_image_upload_to(self, filename): """ Returns the path to upload a new associated image to. """ dummy, ext = os.path.splitext(filename) return os.path.join( machina_settings.FORUM_IMAGE_UPLOAD_TO, '{id}{ext}'.format(id=str(uuid.uuid4()).replace('-', ''), ext=ext), ...
python
def get_image_upload_to(self, filename): """ Returns the path to upload a new associated image to. """ dummy, ext = os.path.splitext(filename) return os.path.join( machina_settings.FORUM_IMAGE_UPLOAD_TO, '{id}{ext}'.format(id=str(uuid.uuid4()).replace('-', ''), ext=ext), ...
[ "def", "get_image_upload_to", "(", "self", ",", "filename", ")", ":", "dummy", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "return", "os", ".", "path", ".", "join", "(", "machina_settings", ".", "FORUM_IMAGE_UPLOAD_TO", ",", ...
Returns the path to upload a new associated image to.
[ "Returns", "the", "path", "to", "upload", "a", "new", "associated", "image", "to", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/abstract_models.py#L147-L153
train
ellmetha/django-machina
machina/apps/forum/abstract_models.py
AbstractForum.save
def save(self, *args, **kwargs): """ Saves the forum instance. """ # It is vital to track the changes of the parent associated with a forum in order to # maintain counters up-to-date and to trigger other operations such as permissions updates. old_instance = None if self.pk: ...
python
def save(self, *args, **kwargs): """ Saves the forum instance. """ # It is vital to track the changes of the parent associated with a forum in order to # maintain counters up-to-date and to trigger other operations such as permissions updates. old_instance = None if self.pk: ...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# It is vital to track the changes of the parent associated with a forum in order to", "# maintain counters up-to-date and to trigger other operations such as permissions updates.", "old_instance", "=",...
Saves the forum instance.
[ "Saves", "the", "forum", "instance", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/abstract_models.py#L155-L173
train
ellmetha/django-machina
machina/apps/forum/abstract_models.py
AbstractForum.update_trackers
def update_trackers(self): """ Updates the denormalized trackers associated with the forum instance. """ direct_approved_topics = self.topics.filter(approved=True).order_by('-last_post_on') # Compute the direct topics count and the direct posts count. self.direct_topics_count = direct_a...
python
def update_trackers(self): """ Updates the denormalized trackers associated with the forum instance. """ direct_approved_topics = self.topics.filter(approved=True).order_by('-last_post_on') # Compute the direct topics count and the direct posts count. self.direct_topics_count = direct_a...
[ "def", "update_trackers", "(", "self", ")", ":", "direct_approved_topics", "=", "self", ".", "topics", ".", "filter", "(", "approved", "=", "True", ")", ".", "order_by", "(", "'-last_post_on'", ")", "# Compute the direct topics count and the direct posts count.", "sel...
Updates the denormalized trackers associated with the forum instance.
[ "Updates", "the", "denormalized", "trackers", "associated", "with", "the", "forum", "instance", "." ]
89ac083c1eaf1cfdeae6686ee094cc86362e8c69
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum/abstract_models.py#L175-L195
train