repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
assamite/creamas
creamas/grid.py
GridAgent.send
async def send(self, card, msg): """Send message *msg* to the neighboring agent in the *card* cardinal direction. :param str card: 'N', 'E', 'S', or 'W'. :param msg: Message to the agent. :returns: Response from the agent The method calls the neighboring agent's :meth:`...
python
async def send(self, card, msg): """Send message *msg* to the neighboring agent in the *card* cardinal direction. :param str card: 'N', 'E', 'S', or 'W'. :param msg: Message to the agent. :returns: Response from the agent The method calls the neighboring agent's :meth:`...
[ "async", "def", "send", "(", "self", ",", "card", ",", "msg", ")", ":", "addr", "=", "self", ".", "neighbors", "[", "card", "]", "if", "addr", "is", "None", ":", "return", "None", "try", ":", "r_agent", "=", "await", "self", ".", "env", ".", "con...
Send message *msg* to the neighboring agent in the *card* cardinal direction. :param str card: 'N', 'E', 'S', or 'W'. :param msg: Message to the agent. :returns: Response from the agent The method calls the neighboring agent's :meth:`rcv` with the message and returns an...
[ "Send", "message", "*", "msg", "*", "to", "the", "neighboring", "agent", "in", "the", "*", "card", "*", "cardinal", "direction", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L77-L100
train
Send a message to the neighboring agent in the given cardinal direction.
assamite/creamas
creamas/grid.py
GridEnvironment.is_full
def is_full(self): """:class:`GridEnvironment` is full when its **grid** is fully populated with agents. :returns: True if the grid is full, False otherwise. Will also return False for uninitialized grids with (0,0) grid size. """ if len(self.grid) == 0: ...
python
def is_full(self): """:class:`GridEnvironment` is full when its **grid** is fully populated with agents. :returns: True if the grid is full, False otherwise. Will also return False for uninitialized grids with (0,0) grid size. """ if len(self.grid) == 0: ...
[ "def", "is_full", "(", "self", ")", ":", "if", "len", "(", "self", ".", "grid", ")", "==", "0", ":", "return", "False", "for", "i", "in", "range", "(", "len", "(", "self", ".", "grid", ")", ")", ":", "for", "j", "in", "range", "(", "len", "("...
:class:`GridEnvironment` is full when its **grid** is fully populated with agents. :returns: True if the grid is full, False otherwise. Will also return False for uninitialized grids with (0,0) grid size.
[ ":", "class", ":", "GridEnvironment", "is", "full", "when", "its", "**", "grid", "**", "is", "fully", "populated", "with", "agents", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L186-L201
train
Returns True if the grid is fully populated with agents.
assamite/creamas
creamas/grid.py
GridEnvironment.add_to_grid
def add_to_grid(self, agent): '''Add agent to the next available spot in the grid. :returns: (x,y) of the agent in the grid. This is the agent's overall coordinate in the grand grid (i.e. the actual coordinate of the agent w.t.r **origin**). :raises: `ValueE...
python
def add_to_grid(self, agent): '''Add agent to the next available spot in the grid. :returns: (x,y) of the agent in the grid. This is the agent's overall coordinate in the grand grid (i.e. the actual coordinate of the agent w.t.r **origin**). :raises: `ValueE...
[ "def", "add_to_grid", "(", "self", ",", "agent", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "grid", ")", ")", ":", "for", "j", "in", "range", "(", "len", "(", "self", ".", "grid", "[", "0", "]", ")", ")", ":", "if", ...
Add agent to the next available spot in the grid. :returns: (x,y) of the agent in the grid. This is the agent's overall coordinate in the grand grid (i.e. the actual coordinate of the agent w.t.r **origin**). :raises: `ValueError` if the grid is full.
[ "Add", "agent", "to", "the", "next", "available", "spot", "in", "the", "grid", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L203-L222
train
Adds an agent to the next available spot in the grid.
assamite/creamas
creamas/grid.py
GridEnvironment.get_xy
def get_xy(self, xy, addr=True): """Get the agent with xy-coordinate in the grid. If *addr* is True, returns only the agent's address. If no such agent in the grid, returns None. :raises: :exc:`ValueError` if xy-coordinate is outside the environment's grid. ...
python
def get_xy(self, xy, addr=True): """Get the agent with xy-coordinate in the grid. If *addr* is True, returns only the agent's address. If no such agent in the grid, returns None. :raises: :exc:`ValueError` if xy-coordinate is outside the environment's grid. ...
[ "def", "get_xy", "(", "self", ",", "xy", ",", "addr", "=", "True", ")", ":", "x", "=", "xy", "[", "0", "]", "y", "=", "xy", "[", "1", "]", "if", "x", "<", "self", ".", "origin", "[", "0", "]", "or", "x", ">=", "self", ".", "origin", "[", ...
Get the agent with xy-coordinate in the grid. If *addr* is True, returns only the agent's address. If no such agent in the grid, returns None. :raises: :exc:`ValueError` if xy-coordinate is outside the environment's grid.
[ "Get", "the", "agent", "with", "xy", "-", "coordinate", "in", "the", "grid", ".", "If", "*", "addr", "*", "is", "True", "returns", "only", "the", "agent", "s", "address", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L224-L245
train
Get the agent with xy - coordinate in the environment s grid.
assamite/creamas
creamas/grid.py
GridEnvironment.set_agent_neighbors
async def set_agent_neighbors(self): '''Set neighbors for each agent in each cardinal direction. This method assumes that the neighboring :class:`GridEnvironment` of this grid environment have already been set. ''' for i in range(len(self.grid)): for j in range(len(s...
python
async def set_agent_neighbors(self): '''Set neighbors for each agent in each cardinal direction. This method assumes that the neighboring :class:`GridEnvironment` of this grid environment have already been set. ''' for i in range(len(self.grid)): for j in range(len(s...
[ "async", "def", "set_agent_neighbors", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "grid", ")", ")", ":", "for", "j", "in", "range", "(", "len", "(", "self", ".", "grid", "[", "0", "]", ")", ")", ":", "agent"...
Set neighbors for each agent in each cardinal direction. This method assumes that the neighboring :class:`GridEnvironment` of this grid environment have already been set.
[ "Set", "neighbors", "for", "each", "agent", "in", "each", "cardinal", "direction", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L254-L287
train
Set neighbors for each agent in each cardinal direction.
assamite/creamas
creamas/grid.py
GridEnvManager.spawn_n
async def spawn_n(self, agent_cls, n, *args, **kwargs): '''Spawn *n* agents to the managed environment. This is a convenience function so that one does not have to repeatedly make connections to the environment to spawn multiple agents with the same parameters. See :py:meth:`~creamas.mp...
python
async def spawn_n(self, agent_cls, n, *args, **kwargs): '''Spawn *n* agents to the managed environment. This is a convenience function so that one does not have to repeatedly make connections to the environment to spawn multiple agents with the same parameters. See :py:meth:`~creamas.mp...
[ "async", "def", "spawn_n", "(", "self", ",", "agent_cls", ",", "n", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "rets", "=", "[", "]", "for", "_", "in", "range", "(", "n", ")", ":", "ret", "=", "await", "self", ".", "spawn", "(", "ag...
Spawn *n* agents to the managed environment. This is a convenience function so that one does not have to repeatedly make connections to the environment to spawn multiple agents with the same parameters. See :py:meth:`~creamas.mp.EnvManager.spawn` for details.
[ "Spawn", "*", "n", "*", "agents", "to", "the", "managed", "environment", ".", "This", "is", "a", "convenience", "function", "so", "that", "one", "does", "not", "have", "to", "repeatedly", "make", "connections", "to", "the", "environment", "to", "spawn", "m...
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L294-L305
train
Spawn n agents to the managed environment.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.set_slave_params
async def set_slave_params(self): '''Set origin and grid size for each slave environment. This method needs to be called before slave environments are populated and agents' and slave environments' neighbors are set. ''' self._slave_origins = [] cur_x = self.origin[0] ...
python
async def set_slave_params(self): '''Set origin and grid size for each slave environment. This method needs to be called before slave environments are populated and agents' and slave environments' neighbors are set. ''' self._slave_origins = [] cur_x = self.origin[0] ...
[ "async", "def", "set_slave_params", "(", "self", ")", ":", "self", ".", "_slave_origins", "=", "[", "]", "cur_x", "=", "self", ".", "origin", "[", "0", "]", "for", "addr", "in", "self", ".", "addrs", ":", "new_origin", "=", "(", "cur_x", ",", "self",...
Set origin and grid size for each slave environment. This method needs to be called before slave environments are populated and agents' and slave environments' neighbors are set.
[ "Set", "origin", "and", "grid", "size", "for", "each", "slave", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L387-L401
train
Set origin and grid size for each slave environment.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.get_xy_environment
def get_xy_environment(self, xy): '''Get manager address for the environment which should have the agent with given *xy* coordinate, or None if no such environment is in this multi-environment. ''' x = xy[0] y = xy[1] for origin, addr in self._slave_origins: ...
python
def get_xy_environment(self, xy): '''Get manager address for the environment which should have the agent with given *xy* coordinate, or None if no such environment is in this multi-environment. ''' x = xy[0] y = xy[1] for origin, addr in self._slave_origins: ...
[ "def", "get_xy_environment", "(", "self", ",", "xy", ")", ":", "x", "=", "xy", "[", "0", "]", "y", "=", "xy", "[", "1", "]", "for", "origin", ",", "addr", "in", "self", ".", "_slave_origins", ":", "ox", "=", "origin", "[", "0", "]", "oy", "=", ...
Get manager address for the environment which should have the agent with given *xy* coordinate, or None if no such environment is in this multi-environment.
[ "Get", "manager", "address", "for", "the", "environment", "which", "should", "have", "the", "agent", "with", "given", "*", "xy", "*", "coordinate", "or", "None", "if", "no", "such", "environment", "is", "in", "this", "multi", "-", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L439-L451
train
Get the manager address for the environment which should have the agent with given xy coordinate.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.get_xy_address
async def get_xy_address(self, xy): '''Get address of the agent residing in *xy* coordinate, or ``None`` if no such agent is in this multi-environment. ''' manager_addr = self.get_xy_environment(xy) if manager_addr is None: return None else: r_agen...
python
async def get_xy_address(self, xy): '''Get address of the agent residing in *xy* coordinate, or ``None`` if no such agent is in this multi-environment. ''' manager_addr = self.get_xy_environment(xy) if manager_addr is None: return None else: r_agen...
[ "async", "def", "get_xy_address", "(", "self", ",", "xy", ")", ":", "manager_addr", "=", "self", ".", "get_xy_environment", "(", "xy", ")", "if", "manager_addr", "is", "None", ":", "return", "None", "else", ":", "r_agent", "=", "await", "self", ".", "_en...
Get address of the agent residing in *xy* coordinate, or ``None`` if no such agent is in this multi-environment.
[ "Get", "address", "of", "the", "agent", "residing", "in", "*", "xy", "*", "coordinate", "or", "None", "if", "no", "such", "agent", "is", "in", "this", "multi", "-", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L453-L463
train
Get address of the agent residing in xy * coordinate or None if no such agent is in this multi - environment.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.set_slave_neighbors
async def set_slave_neighbors(self): '''Set neighbor environments for all the slave environments. Assumes that :attr:`neighbors` are set for this multi-environment. ''' for i, elem in enumerate(self._slave_origins): o, addr = elem r_slave = await self.env.connect(...
python
async def set_slave_neighbors(self): '''Set neighbor environments for all the slave environments. Assumes that :attr:`neighbors` are set for this multi-environment. ''' for i, elem in enumerate(self._slave_origins): o, addr = elem r_slave = await self.env.connect(...
[ "async", "def", "set_slave_neighbors", "(", "self", ")", ":", "for", "i", ",", "elem", "in", "enumerate", "(", "self", ".", "_slave_origins", ")", ":", "o", ",", "addr", "=", "elem", "r_slave", "=", "await", "self", ".", "env", ".", "connect", "(", "...
Set neighbor environments for all the slave environments. Assumes that :attr:`neighbors` are set for this multi-environment.
[ "Set", "neighbor", "environments", "for", "all", "the", "slave", "environments", ".", "Assumes", "that", ":", "attr", ":", "neighbors", "are", "set", "for", "this", "multi", "-", "environment", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L465-L502
train
Set neighbor environments for all the slave environments. Assumes that self. neighbors is set for this multi - environment.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.set_agent_neighbors
async def set_agent_neighbors(self): '''Set neighbors for all the agents in all the slave environments. Assumes that all the slave environments have their neighbors set. ''' for addr in self.addrs: r_manager = await self.env.connect(addr) await r_manager.set_agent...
python
async def set_agent_neighbors(self): '''Set neighbors for all the agents in all the slave environments. Assumes that all the slave environments have their neighbors set. ''' for addr in self.addrs: r_manager = await self.env.connect(addr) await r_manager.set_agent...
[ "async", "def", "set_agent_neighbors", "(", "self", ")", ":", "for", "addr", "in", "self", ".", "addrs", ":", "r_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "addr", ")", "await", "r_manager", ".", "set_agent_neighbors", "(", ")" ]
Set neighbors for all the agents in all the slave environments. Assumes that all the slave environments have their neighbors set.
[ "Set", "neighbors", "for", "all", "the", "agents", "in", "all", "the", "slave", "environments", ".", "Assumes", "that", "all", "the", "slave", "environments", "have", "their", "neighbors", "set", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L504-L510
train
Set neighbors for all the agents in all the slave environments.
assamite/creamas
creamas/grid.py
GridMultiEnvironment.populate
async def populate(self, agent_cls, *args, **kwargs): '''Populate all the slave grid environments with agents. Assumes that no agents have been spawned yet to the slave environment grids. This excludes the slave environment managers as they are not in the grids.) ''' n = self.gs[...
python
async def populate(self, agent_cls, *args, **kwargs): '''Populate all the slave grid environments with agents. Assumes that no agents have been spawned yet to the slave environment grids. This excludes the slave environment managers as they are not in the grids.) ''' n = self.gs[...
[ "async", "def", "populate", "(", "self", ",", "agent_cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "n", "=", "self", ".", "gs", "[", "0", "]", "*", "self", ".", "gs", "[", "1", "]", "tasks", "=", "[", "]", "for", "addr", "in", ...
Populate all the slave grid environments with agents. Assumes that no agents have been spawned yet to the slave environment grids. This excludes the slave environment managers as they are not in the grids.)
[ "Populate", "all", "the", "slave", "grid", "environments", "with", "agents", ".", "Assumes", "that", "no", "agents", "have", "been", "spawned", "yet", "to", "the", "slave", "environment", "grids", ".", "This", "excludes", "the", "slave", "environment", "manage...
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L527-L540
train
Populate all the slave grid environments with agents. Assumes that agents have been spawned yet to the slave environment managers.
assamite/creamas
creamas/grid.py
GridMultiEnvManager.set_origin
async def set_origin(self, mgr_addr, origin): '''Set originating coordinates for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param origin: New origin of the grid environment, iterable with length 2. ...
python
async def set_origin(self, mgr_addr, origin): '''Set originating coordinates for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param origin: New origin of the grid environment, iterable with length 2. ...
[ "async", "def", "set_origin", "(", "self", ",", "mgr_addr", ",", "origin", ")", ":", "remote_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "mgr_addr", ")", "await", "remote_manager", ".", "set_origin", "(", "origin", ")" ]
Set originating coordinates for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param origin: New origin of the grid environment, iterable with length 2.
[ "Set", "originating", "coordinates", "for", ":", "py", ":", "class", ":", "GridEnvironment", "which", "manager", "is", "in", "given", "address", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L547-L557
train
Set originating coordinates for the which manager is in given address.
assamite/creamas
creamas/grid.py
GridMultiEnvManager.set_gs
async def set_gs(self, mgr_addr, gs): '''Set grid size for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param gs: New grid size of the grid environment, iterable with length 2. ''' remote_m...
python
async def set_gs(self, mgr_addr, gs): '''Set grid size for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param gs: New grid size of the grid environment, iterable with length 2. ''' remote_m...
[ "async", "def", "set_gs", "(", "self", ",", "mgr_addr", ",", "gs", ")", ":", "remote_manager", "=", "await", "self", ".", "env", ".", "connect", "(", "mgr_addr", ")", "await", "remote_manager", ".", "set_gs", "(", "gs", ")" ]
Set grid size for :py:class:`GridEnvironment` which manager is in given address. :param str mgr_addr: Address of the manager agent :param gs: New grid size of the grid environment, iterable with length 2.
[ "Set", "grid", "size", "for", ":", "py", ":", "class", ":", "GridEnvironment", "which", "manager", "is", "in", "given", "address", "." ]
54dc3e31c97a3f938e58272f8ab80b6bcafeff58
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/grid.py#L560-L570
train
Set the grid size for the manager in manager_addr.
safarijv/sbo-sphinx
sbo_sphinx/jsdoc.py
generate_docs
def generate_docs(app): """ Generate the reST documentation files for the JavaScript code """ # Figure out the correct directories to use config = app.config config_dir = app.env.srcdir javascript_root = os.path.join(config_dir, config.jsdoc_source_root) if javascript_root[-1] != os.path.sep: ...
python
def generate_docs(app): """ Generate the reST documentation files for the JavaScript code """ # Figure out the correct directories to use config = app.config config_dir = app.env.srcdir javascript_root = os.path.join(config_dir, config.jsdoc_source_root) if javascript_root[-1] != os.path.sep: ...
[ "def", "generate_docs", "(", "app", ")", ":", "# Figure out the correct directories to use", "config", "=", "app", ".", "config", "config_dir", "=", "app", ".", "env", ".", "srcdir", "javascript_root", "=", "os", ".", "path", ".", "join", "(", "config_dir", ",...
Generate the reST documentation files for the JavaScript code
[ "Generate", "the", "reST", "documentation", "files", "for", "the", "JavaScript", "code" ]
7a8efb7c49488131c90c19ef1a1563f595630a36
https://github.com/safarijv/sbo-sphinx/blob/7a8efb7c49488131c90c19ef1a1563f595630a36/sbo_sphinx/jsdoc.py#L42-L82
train
Generate the reST documentation files for the JavaScript code.
safarijv/sbo-sphinx
sbo_sphinx/jsdoc.py
setup
def setup(app): """Sphinx extension entry point""" app.add_config_value('jsdoc_source_root', '..', 'env') app.add_config_value('jsdoc_output_root', 'javascript', 'env') app.add_config_value('jsdoc_exclude', [], 'env') app.connect('builder-inited', generate_docs)
python
def setup(app): """Sphinx extension entry point""" app.add_config_value('jsdoc_source_root', '..', 'env') app.add_config_value('jsdoc_output_root', 'javascript', 'env') app.add_config_value('jsdoc_exclude', [], 'env') app.connect('builder-inited', generate_docs)
[ "def", "setup", "(", "app", ")", ":", "app", ".", "add_config_value", "(", "'jsdoc_source_root'", ",", "'..'", ",", "'env'", ")", "app", ".", "add_config_value", "(", "'jsdoc_output_root'", ",", "'javascript'", ",", "'env'", ")", "app", ".", "add_config_value"...
Sphinx extension entry point
[ "Sphinx", "extension", "entry", "point" ]
7a8efb7c49488131c90c19ef1a1563f595630a36
https://github.com/safarijv/sbo-sphinx/blob/7a8efb7c49488131c90c19ef1a1563f595630a36/sbo_sphinx/jsdoc.py#L94-L99
train
Sphinx extension entry point
projectshift/shift-boiler
boiler/cli/user.py
print_validation_errors
def print_validation_errors(result): """ Accepts validation result object and prints report (in red)""" click.echo(red('\nValidation failed:')) click.echo(red('-' * 40)) messages = result.get_messages() for property in messages.keys(): click.echo(yellow(property + ':')) for error in ...
python
def print_validation_errors(result): """ Accepts validation result object and prints report (in red)""" click.echo(red('\nValidation failed:')) click.echo(red('-' * 40)) messages = result.get_messages() for property in messages.keys(): click.echo(yellow(property + ':')) for error in ...
[ "def", "print_validation_errors", "(", "result", ")", ":", "click", ".", "echo", "(", "red", "(", "'\\nValidation failed:'", ")", ")", "click", ".", "echo", "(", "red", "(", "'-'", "*", "40", ")", ")", "messages", "=", "result", ".", "get_messages", "(",...
Accepts validation result object and prints report (in red)
[ "Accepts", "validation", "result", "object", "and", "prints", "report", "(", "in", "red", ")" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L7-L16
train
Prints validation errors to the console.
projectshift/shift-boiler
boiler/cli/user.py
find_user
def find_user(search_params): """ Find user Attempts to find a user by a set of search params. You must be in application context. """ user = None params = {prop: value for prop, value in search_params.items() if value} if 'id' in params or 'email' in params: user = user_service....
python
def find_user(search_params): """ Find user Attempts to find a user by a set of search params. You must be in application context. """ user = None params = {prop: value for prop, value in search_params.items() if value} if 'id' in params or 'email' in params: user = user_service....
[ "def", "find_user", "(", "search_params", ")", ":", "user", "=", "None", "params", "=", "{", "prop", ":", "value", "for", "prop", ",", "value", "in", "search_params", ".", "items", "(", ")", "if", "value", "}", "if", "'id'", "in", "params", "or", "'e...
Find user Attempts to find a user by a set of search params. You must be in application context.
[ "Find", "user", "Attempts", "to", "find", "a", "user", "by", "a", "set", "of", "search", "params", ".", "You", "must", "be", "in", "application", "context", "." ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L19-L29
train
Finds a user by a set of search params.
projectshift/shift-boiler
boiler/cli/user.py
create
def create(email, password): """ Creates a new user record """ with get_app().app_context(): user = User(email=email, password=password) result = user_service.save(user) if not isinstance(result, User): print_validation_errors(result) return click.echo(gr...
python
def create(email, password): """ Creates a new user record """ with get_app().app_context(): user = User(email=email, password=password) result = user_service.save(user) if not isinstance(result, User): print_validation_errors(result) return click.echo(gr...
[ "def", "create", "(", "email", ",", "password", ")", ":", "with", "get_app", "(", ")", ".", "app_context", "(", ")", ":", "user", "=", "User", "(", "email", "=", "email", ",", "password", "=", "password", ")", "result", "=", "user_service", ".", "sav...
Creates a new user record
[ "Creates", "a", "new", "user", "record" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L48-L59
train
Create a new user record
projectshift/shift-boiler
boiler/cli/user.py
find
def find(*_, **kwargs): """ Find user by id/email""" click.echo(green('\nFind user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(kwargs) if not user: click.echo(red('Not found\n')) return click.echo(str(user) + '\n') return
python
def find(*_, **kwargs): """ Find user by id/email""" click.echo(green('\nFind user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(kwargs) if not user: click.echo(red('Not found\n')) return click.echo(str(user) + '\n') return
[ "def", "find", "(", "*", "_", ",", "*", "*", "kwargs", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nFind user:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ")", "with", "get_app", "(", ")", ".", "app_c...
Find user by id/email
[ "Find", "user", "by", "id", "/", "email" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L65-L78
train
Find user by id or email
projectshift/shift-boiler
boiler/cli/user.py
change_password
def change_password(*_, user_id=None, password=None): """ Change user password """ click.echo(green('\nChange password:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
python
def change_password(*_, user_id=None, password=None): """ Change user password """ click.echo(green('\nChange password:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
[ "def", "change_password", "(", "*", "_", ",", "user_id", "=", "None", ",", "password", "=", "None", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nChange password:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ...
Change user password
[ "Change", "user", "password" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L84-L102
train
Change user password
projectshift/shift-boiler
boiler/cli/user.py
change_email
def change_email(*_, user_id=None, new_email=None): """ Change email for a user """ click.echo(green('\nChange email:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
python
def change_email(*_, user_id=None, new_email=None): """ Change email for a user """ click.echo(green('\nChange email:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
[ "def", "change_email", "(", "*", "_", ",", "user_id", "=", "None", ",", "new_email", "=", "None", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nChange email:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ")"...
Change email for a user
[ "Change", "email", "for", "a", "user" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L108-L128
train
Change email for a user
projectshift/shift-boiler
boiler/cli/user.py
create_role
def create_role(*_, **kwargs): """ Create user role """ click.echo(green('\nCreating new role:')) click.echo(green('-' * 40)) with get_app().app_context(): role = Role(**kwargs) result = role_service.save(role) if not isinstance(result, Role): print_validation_errors...
python
def create_role(*_, **kwargs): """ Create user role """ click.echo(green('\nCreating new role:')) click.echo(green('-' * 40)) with get_app().app_context(): role = Role(**kwargs) result = role_service.save(role) if not isinstance(result, Role): print_validation_errors...
[ "def", "create_role", "(", "*", "_", ",", "*", "*", "kwargs", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nCreating new role:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ")", "with", "get_app", "(", ")", ...
Create user role
[ "Create", "user", "role" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L135-L146
train
Create user role
projectshift/shift-boiler
boiler/cli/user.py
list_roles
def list_roles(): """ List existing roles """ click.echo(green('\nListing roles:')) click.echo(green('-' * 40)) with get_app().app_context(): roles = Role.query.all() if not roles: click.echo(red('No roles found')) return for index,role in enumerate(roles...
python
def list_roles(): """ List existing roles """ click.echo(green('\nListing roles:')) click.echo(green('-' * 40)) with get_app().app_context(): roles = Role.query.all() if not roles: click.echo(red('No roles found')) return for index,role in enumerate(roles...
[ "def", "list_roles", "(", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nListing roles:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ")", "with", "get_app", "(", ")", ".", "app_context", "(", ")", ":", "role...
List existing roles
[ "List", "existing", "roles" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L150-L167
train
List existing roles
projectshift/shift-boiler
boiler/cli/user.py
list_user_roles
def list_user_roles(*_, user_id): """ List user roles """ click.echo(green('\nListing user roles:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) return for i...
python
def list_user_roles(*_, user_id): """ List user roles """ click.echo(green('\nListing user roles:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) return for i...
[ "def", "list_user_roles", "(", "*", "_", ",", "user_id", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nListing user roles:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ")", "with", "get_app", "(", ")", ".", ...
List user roles
[ "List", "user", "roles" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L172-L189
train
List user roles
projectshift/shift-boiler
boiler/cli/user.py
add_role
def add_role(*_, role_handle=None, user_id=None): """ Add role to user """ click.echo(green('\nAdding role to user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ret...
python
def add_role(*_, role_handle=None, user_id=None): """ Add role to user """ click.echo(green('\nAdding role to user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ret...
[ "def", "add_role", "(", "*", "_", ",", "role_handle", "=", "None", ",", "user_id", "=", "None", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nAdding role to user:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ")", ...
Add role to user
[ "Add", "role", "to", "user" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L195-L213
train
Add a role to a user
projectshift/shift-boiler
boiler/cli/user.py
remove_role
def remove_role(*_, role_handle=None, user_id=None): """ Remove role from user """ click.echo(green('\nRemoving role from user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
python
def remove_role(*_, role_handle=None, user_id=None): """ Remove role from user """ click.echo(green('\nRemoving role from user:')) click.echo(green('-' * 40)) with get_app().app_context(): user = find_user(dict(id=user_id)) if not user: click.echo(red('User not found\n')) ...
[ "def", "remove_role", "(", "*", "_", ",", "role_handle", "=", "None", ",", "user_id", "=", "None", ")", ":", "click", ".", "echo", "(", "green", "(", "'\\nRemoving role from user:'", ")", ")", "click", ".", "echo", "(", "green", "(", "'-'", "*", "40", ...
Remove role from user
[ "Remove", "role", "from", "user" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/user.py#L219-L244
train
Remove a role from a user
cgrok/cr-async
crasync/models.py
Base.update
async def update(self): '''Update an object with current info.''' if self.client.session.closed: async with core.Client() as client: data = await client.request(self.url) else: data = await self.client.request(self.url) self.raw_data = data ...
python
async def update(self): '''Update an object with current info.''' if self.client.session.closed: async with core.Client() as client: data = await client.request(self.url) else: data = await self.client.request(self.url) self.raw_data = data ...
[ "async", "def", "update", "(", "self", ")", ":", "if", "self", ".", "client", ".", "session", ".", "closed", ":", "async", "with", "core", ".", "Client", "(", ")", "as", "client", ":", "data", "=", "await", "client", ".", "request", "(", "self", "....
Update an object with current info.
[ "Update", "an", "object", "with", "current", "info", "." ]
f65a968e54704168706d137d1ba662f55f8ab852
https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L57-L68
train
Update an object with current info.
cgrok/cr-async
crasync/models.py
Profile.clan_badge_url
def clan_badge_url(self): '''Returns clan badge url''' if self.clan_tag is None: return None url = self.raw_data.get('clan').get('badge').get('url') if not url: return None return "http://api.cr-api.com" + url
python
def clan_badge_url(self): '''Returns clan badge url''' if self.clan_tag is None: return None url = self.raw_data.get('clan').get('badge').get('url') if not url: return None return "http://api.cr-api.com" + url
[ "def", "clan_badge_url", "(", "self", ")", ":", "if", "self", ".", "clan_tag", "is", "None", ":", "return", "None", "url", "=", "self", ".", "raw_data", ".", "get", "(", "'clan'", ")", ".", "get", "(", "'badge'", ")", ".", "get", "(", "'url'", ")",...
Returns clan badge url
[ "Returns", "clan", "badge", "url" ]
f65a968e54704168706d137d1ba662f55f8ab852
https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L344-L351
train
Returns clan badge url
cgrok/cr-async
crasync/models.py
Profile.get_chest
def get_chest(self, index=0): '''Get your current chest +- the index''' index += self.chest_cycle.position if index == self.chest_cycle.super_magical: return 'Super Magical' if index == self.chest_cycle.epic: return 'Epic' if index == self.chest_...
python
def get_chest(self, index=0): '''Get your current chest +- the index''' index += self.chest_cycle.position if index == self.chest_cycle.super_magical: return 'Super Magical' if index == self.chest_cycle.epic: return 'Epic' if index == self.chest_...
[ "def", "get_chest", "(", "self", ",", "index", "=", "0", ")", ":", "index", "+=", "self", ".", "chest_cycle", ".", "position", "if", "index", "==", "self", ".", "chest_cycle", ".", "super_magical", ":", "return", "'Super Magical'", "if", "index", "==", "...
Get your current chest +- the index
[ "Get", "your", "current", "chest", "+", "-", "the", "index" ]
f65a968e54704168706d137d1ba662f55f8ab852
https://github.com/cgrok/cr-async/blob/f65a968e54704168706d137d1ba662f55f8ab852/crasync/models.py#L353-L365
train
Get your current chest + - the index
ronhanson/python-tbx
fabfile/virtualenv.py
init
def init(): """Execute init tasks for all components (virtualenv, pip).""" if not os.path.isdir('venv'): print(cyan('\nCreating the virtual env...')) local('pyvenv-3.4 venv') print(green('Virtual env created.')) print(green('Virtual Environment ready.'))
python
def init(): """Execute init tasks for all components (virtualenv, pip).""" if not os.path.isdir('venv'): print(cyan('\nCreating the virtual env...')) local('pyvenv-3.4 venv') print(green('Virtual env created.')) print(green('Virtual Environment ready.'))
[ "def", "init", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "'venv'", ")", ":", "print", "(", "cyan", "(", "'\\nCreating the virtual env...'", ")", ")", "local", "(", "'pyvenv-3.4 venv'", ")", "print", "(", "green", "(", "'Virtual en...
Execute init tasks for all components (virtualenv, pip).
[ "Execute", "init", "tasks", "for", "all", "components", "(", "virtualenv", "pip", ")", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/virtualenv.py#L9-L18
train
Execute init tasks for all components.
ronhanson/python-tbx
fabfile/virtualenv.py
update
def update(): """Update virtual env with requirements packages.""" with settings(warn_only=True): print(cyan('\nInstalling/Updating required packages...')) pip = local('venv/bin/pip install -U --allow-all-external --src libs -r requirements.txt', capture=True) if pip.failed: ...
python
def update(): """Update virtual env with requirements packages.""" with settings(warn_only=True): print(cyan('\nInstalling/Updating required packages...')) pip = local('venv/bin/pip install -U --allow-all-external --src libs -r requirements.txt', capture=True) if pip.failed: ...
[ "def", "update", "(", ")", ":", "with", "settings", "(", "warn_only", "=", "True", ")", ":", "print", "(", "cyan", "(", "'\\nInstalling/Updating required packages...'", ")", ")", "pip", "=", "local", "(", "'venv/bin/pip install -U --allow-all-external --src libs -r re...
Update virtual env with requirements packages.
[ "Update", "virtual", "env", "with", "requirements", "packages", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/fabfile/virtualenv.py#L22-L32
train
Update virtual env with requirements packages.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver._detect_devices
def _detect_devices(self) -> None: '''Detect whether devices connected.''' devices_num = len(self.devices_list) if devices_num == 0: raise DeviceConnectionException( 'No devices are connected. Please connect the device with USB or via WLAN and turn on the USB debuggin...
python
def _detect_devices(self) -> None: '''Detect whether devices connected.''' devices_num = len(self.devices_list) if devices_num == 0: raise DeviceConnectionException( 'No devices are connected. Please connect the device with USB or via WLAN and turn on the USB debuggin...
[ "def", "_detect_devices", "(", "self", ")", "->", "None", ":", "devices_num", "=", "len", "(", "self", ".", "devices_list", ")", "if", "devices_num", "==", "0", ":", "raise", "DeviceConnectionException", "(", "'No devices are connected. Please connect the device with ...
Detect whether devices connected.
[ "Detect", "whether", "devices", "connected", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L77-L90
train
Detect whether devices connected.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver._execute
def _execute(self, *args: str, **kwargs) -> tuple: '''Execute command.''' process = self.execute( args=args, options=merge_dict(self.options, kwargs)) command = ' '.join(process.args) if self._dev: output, error = process.communicate() print( ...
python
def _execute(self, *args: str, **kwargs) -> tuple: '''Execute command.''' process = self.execute( args=args, options=merge_dict(self.options, kwargs)) command = ' '.join(process.args) if self._dev: output, error = process.communicate() print( ...
[ "def", "_execute", "(", "self", ",", "*", "args", ":", "str", ",", "*", "*", "kwargs", ")", "->", "tuple", ":", "process", "=", "self", ".", "execute", "(", "args", "=", "args", ",", "options", "=", "merge_dict", "(", "self", ".", "options", ",", ...
Execute command.
[ "Execute", "command", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L104-L118
train
Execute command.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_device_model
def get_device_model(self) -> str: '''Show device model.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.product.model') return output.strip()
python
def get_device_model(self) -> str: '''Show device model.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.product.model') return output.strip()
[ "def", "get_device_model", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'getprop'", ",", "'ro.product.model'", ")", "return", "output", ".", "strip...
Show device model.
[ "Show", "device", "model", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L131-L135
train
Show device model.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_battery_info
def get_battery_info(self) -> dict: '''Show device battery information. Returns: A dict. For example: {'AC powered': 'false', 'Charge counter': '0', 'Max charging current': '0', 'Max charging voltage': '0', 'US...
python
def get_battery_info(self) -> dict: '''Show device battery information. Returns: A dict. For example: {'AC powered': 'false', 'Charge counter': '0', 'Max charging current': '0', 'Max charging voltage': '0', 'US...
[ "def", "get_battery_info", "(", "self", ")", "->", "dict", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'battery'", ")", "battery_status", "=", "re", ".", "sp...
Show device battery information. Returns: A dict. For example: {'AC powered': 'false', 'Charge counter': '0', 'Max charging current': '0', 'Max charging voltage': '0', 'USB powered': 'false', 'Wireless ...
[ "Show", "device", "battery", "information", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L137-L161
train
Show device battery information.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_resolution
def get_resolution(self) -> list: '''Show device resolution.''' output, _ = self._execute('-s', self.device_sn, 'shell', 'wm', 'size') return output.split()[2].split('x')
python
def get_resolution(self) -> list: '''Show device resolution.''' output, _ = self._execute('-s', self.device_sn, 'shell', 'wm', 'size') return output.split()[2].split('x')
[ "def", "get_resolution", "(", "self", ")", "->", "list", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'wm'", ",", "'size'", ")", "return", "output", ".", "split", "(", ")", ...
Show device resolution.
[ "Show", "device", "resolution", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L163-L166
train
Show device resolution.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_screen_density
def get_screen_density(self) -> str: '''Show device screen density (PPI).''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'wm', 'density') return output.split()[2]
python
def get_screen_density(self) -> str: '''Show device screen density (PPI).''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'wm', 'density') return output.split()[2]
[ "def", "get_screen_density", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'wm'", ",", "'density'", ")", "return", "output", ".", "split", "(", ...
Show device screen density (PPI).
[ "Show", "device", "screen", "density", "(", "PPI", ")", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L168-L172
train
Show device screen density ( PPI).'
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_displays_params
def get_displays_params(self) -> str: '''Show displays parameters.''' output, error = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'displays') return output
python
def get_displays_params(self) -> str: '''Show displays parameters.''' output, error = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'displays') return output
[ "def", "get_displays_params", "(", "self", ")", "->", "str", ":", "output", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'window'", ",", "'displays'", ")", "return", "outp...
Show displays parameters.
[ "Show", "displays", "parameters", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L174-L178
train
Show displays parameters.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_android_id
def get_android_id(self) -> str: '''Show Android ID.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'settings', 'get', 'secure', 'android_id') return output.strip()
python
def get_android_id(self) -> str: '''Show Android ID.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'settings', 'get', 'secure', 'android_id') return output.strip()
[ "def", "get_android_id", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'settings'", ",", "'get'", ",", "'secure'", ",", "'android_id'", ")", "retu...
Show Android ID.
[ "Show", "Android", "ID", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L180-L184
train
Show Android ID.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_android_version
def get_android_version(self) -> str: '''Show Android version.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.release') return output.strip()
python
def get_android_version(self) -> str: '''Show Android version.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.release') return output.strip()
[ "def", "get_android_version", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'getprop'", ",", "'ro.build.version.release'", ")", "return", "output", "....
Show Android version.
[ "Show", "Android", "version", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L186-L190
train
Show Android version.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_device_mac
def get_device_mac(self) -> str: '''Show device MAC.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/sys/class/net/wlan0/address') return output.strip()
python
def get_device_mac(self) -> str: '''Show device MAC.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/sys/class/net/wlan0/address') return output.strip()
[ "def", "get_device_mac", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'cat'", ",", "'/sys/class/net/wlan0/address'", ")", "return", "output", ".", ...
Show device MAC.
[ "Show", "device", "MAC", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L192-L196
train
Show device MAC.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_cpu_info
def get_cpu_info(self) -> str: '''Show device CPU information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo') return output
python
def get_cpu_info(self) -> str: '''Show device CPU information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/proc/cpuinfo') return output
[ "def", "get_cpu_info", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'cat'", ",", "'/proc/cpuinfo'", ")", "return", "output" ]
Show device CPU information.
[ "Show", "device", "CPU", "information", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L198-L202
train
Show device CPU information.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_memory_info
def get_memory_info(self) -> str: '''Show device memory information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/proc/meminfo') return output
python
def get_memory_info(self) -> str: '''Show device memory information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'cat', '/proc/meminfo') return output
[ "def", "get_memory_info", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'cat'", ",", "'/proc/meminfo'", ")", "return", "output" ]
Show device memory information.
[ "Show", "device", "memory", "information", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L204-L208
train
Show device memory information.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_sdk_version
def get_sdk_version(self) -> str: '''Show Android SDK version.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.sdk') return output.strip()
python
def get_sdk_version(self) -> str: '''Show Android SDK version.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'getprop', 'ro.build.version.sdk') return output.strip()
[ "def", "get_sdk_version", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'getprop'", ",", "'ro.build.version.sdk'", ")", "return", "output", ".", "st...
Show Android SDK version.
[ "Show", "Android", "SDK", "version", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L210-L214
train
Show Android SDK version.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.root
def root(self) -> None: '''Restart adbd with root permissions.''' output, _ = self._execute('-s', self.device_sn, 'root') if not output: raise PermissionError( f'{self.device_sn!r} does not have root permission.')
python
def root(self) -> None: '''Restart adbd with root permissions.''' output, _ = self._execute('-s', self.device_sn, 'root') if not output: raise PermissionError( f'{self.device_sn!r} does not have root permission.')
[ "def", "root", "(", "self", ")", "->", "None", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'root'", ")", "if", "not", "output", ":", "raise", "PermissionError", "(", "f'{self.device_sn!r} does ...
Restart adbd with root permissions.
[ "Restart", "adbd", "with", "root", "permissions", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L216-L221
train
Restart adbd with root permissions.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.tcpip
def tcpip(self, port: int or str = 5555) -> None: '''Restart adb server listening on TCP on PORT.''' self._execute('-s', self.device_sn, 'tcpip', str(port))
python
def tcpip(self, port: int or str = 5555) -> None: '''Restart adb server listening on TCP on PORT.''' self._execute('-s', self.device_sn, 'tcpip', str(port))
[ "def", "tcpip", "(", "self", ",", "port", ":", "int", "or", "str", "=", "5555", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'tcpip'", ",", "str", "(", "port", ")", ")" ]
Restart adb server listening on TCP on PORT.
[ "Restart", "adb", "server", "listening", "on", "TCP", "on", "PORT", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L227-L229
train
Restart adb server listening on TCP on PORT.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.get_ip_addr
def get_ip_addr(self) -> str: '''Show IP Address.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'ip', '-f', 'inet', 'addr', 'show', 'wlan0') ip_addr = re.findall( r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\...
python
def get_ip_addr(self) -> str: '''Show IP Address.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'ip', '-f', 'inet', 'addr', 'show', 'wlan0') ip_addr = re.findall( r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\...
[ "def", "get_ip_addr", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'ip'", ",", "'-f'", ",", "'inet'", ",", "'addr'", ",", "'show'", ",", "'wl...
Show IP Address.
[ "Show", "IP", "Address", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L231-L240
train
Show IP Address.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.auto_connect
def auto_connect(self, port: int or str =5555) -> None: '''Connect to a device via TCP/IP automatically.''' host = self.get_ip_addr() self.tcpip(port) self.connect(host, port) print('Now you can unplug the USB cable, and control your device via WLAN.')
python
def auto_connect(self, port: int or str =5555) -> None: '''Connect to a device via TCP/IP automatically.''' host = self.get_ip_addr() self.tcpip(port) self.connect(host, port) print('Now you can unplug the USB cable, and control your device via WLAN.')
[ "def", "auto_connect", "(", "self", ",", "port", ":", "int", "or", "str", "=", "5555", ")", "->", "None", ":", "host", "=", "self", ".", "get_ip_addr", "(", ")", "self", ".", "tcpip", "(", "port", ")", "self", ".", "connect", "(", "host", ",", "p...
Connect to a device via TCP/IP automatically.
[ "Connect", "to", "a", "device", "via", "TCP", "/", "IP", "automatically", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L242-L247
train
Connect to a device via TCP or IP automatically.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.push
def push(self, local: _PATH = 'LICENSE', remote: _PATH = '/sdcard/LICENSE') -> None: '''Copy local files/directories to device.''' if not os.path.exists(local): raise FileNotFoundError(f'Local {local!r} does not exist.') self._execute('-s', self.device_sn, 'push', local, remote)
python
def push(self, local: _PATH = 'LICENSE', remote: _PATH = '/sdcard/LICENSE') -> None: '''Copy local files/directories to device.''' if not os.path.exists(local): raise FileNotFoundError(f'Local {local!r} does not exist.') self._execute('-s', self.device_sn, 'push', local, remote)
[ "def", "push", "(", "self", ",", "local", ":", "_PATH", "=", "'LICENSE'", ",", "remote", ":", "_PATH", "=", "'/sdcard/LICENSE'", ")", "->", "None", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "local", ")", ":", "raise", "FileNotFoundError"...
Copy local files/directories to device.
[ "Copy", "local", "files", "/", "directories", "to", "device", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L249-L253
train
Copy local files to device.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.pull
def pull(self, remote: _PATH, local: _PATH) -> None: '''Copy files/directories from device.''' output, _ = self._execute('-s', self.device_sn, 'pull', remote, local) if 'error' in output: raise FileNotFoundError(f'Remote {remote!r} does not exist.')
python
def pull(self, remote: _PATH, local: _PATH) -> None: '''Copy files/directories from device.''' output, _ = self._execute('-s', self.device_sn, 'pull', remote, local) if 'error' in output: raise FileNotFoundError(f'Remote {remote!r} does not exist.')
[ "def", "pull", "(", "self", ",", "remote", ":", "_PATH", ",", "local", ":", "_PATH", ")", "->", "None", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'pull'", ",", "remote", ",", "local", ...
Copy files/directories from device.
[ "Copy", "files", "/", "directories", "from", "device", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L261-L265
train
Copy files and directories from device.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.sync
def sync(self, option: str = 'all') -> None: '''Sync a local build from $ANDROID_PRODUCT_OUT to the device (default all). Args: option: 'system', 'vendor', 'oem', 'data', 'all' ''' if option in ['system', 'vendor', 'oem', 'data', 'all']: self._execute('-s', self....
python
def sync(self, option: str = 'all') -> None: '''Sync a local build from $ANDROID_PRODUCT_OUT to the device (default all). Args: option: 'system', 'vendor', 'oem', 'data', 'all' ''' if option in ['system', 'vendor', 'oem', 'data', 'all']: self._execute('-s', self....
[ "def", "sync", "(", "self", ",", "option", ":", "str", "=", "'all'", ")", "->", "None", ":", "if", "option", "in", "[", "'system'", ",", "'vendor'", ",", "'oem'", ",", "'data'", ",", "'all'", "]", ":", "self", ".", "_execute", "(", "'-s'", ",", "...
Sync a local build from $ANDROID_PRODUCT_OUT to the device (default all). Args: option: 'system', 'vendor', 'oem', 'data', 'all'
[ "Sync", "a", "local", "build", "from", "$ANDROID_PRODUCT_OUT", "to", "the", "device", "(", "default", "all", ")", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L274-L283
train
Sync a local build from the device to the device.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.sync_l
def sync_l(self, option: str = 'all') -> None: '''List but don't copy. Args: option: 'system', 'vendor', 'oem', 'data', 'all' ''' if option in ['system', 'vendor', 'oem', 'data', 'all']: self._execute('-s', self.device_sn, 'sync', '-l', option) else: ...
python
def sync_l(self, option: str = 'all') -> None: '''List but don't copy. Args: option: 'system', 'vendor', 'oem', 'data', 'all' ''' if option in ['system', 'vendor', 'oem', 'data', 'all']: self._execute('-s', self.device_sn, 'sync', '-l', option) else: ...
[ "def", "sync_l", "(", "self", ",", "option", ":", "str", "=", "'all'", ")", "->", "None", ":", "if", "option", "in", "[", "'system'", ",", "'vendor'", ",", "'oem'", ",", "'data'", ",", "'all'", "]", ":", "self", ".", "_execute", "(", "'-s'", ",", ...
List but don't copy. Args: option: 'system', 'vendor', 'oem', 'data', 'all'
[ "List", "but", "don", "t", "copy", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L285-L294
train
List but don t copy.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.install
def install(self, package: str, option: str = '-r') -> None: '''Push package to the device and install it. Args: option: -l: forward lock application -r: replace existing application -t: allow test packages -s: install applicat...
python
def install(self, package: str, option: str = '-r') -> None: '''Push package to the device and install it. Args: option: -l: forward lock application -r: replace existing application -t: allow test packages -s: install applicat...
[ "def", "install", "(", "self", ",", "package", ":", "str", ",", "option", ":", "str", "=", "'-r'", ")", "->", "None", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "package", ")", ":", "raise", "FileNotFoundError", "(", "f'{package!r} does n...
Push package to the device and install it. Args: option: -l: forward lock application -r: replace existing application -t: allow test packages -s: install application on sdcard -d: allow version code downgrade (debuggab...
[ "Push", "package", "to", "the", "device", "and", "install", "it", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L297-L314
train
Push package to the device and install it.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.uninstall
def uninstall(self, package: str) -> None: '''Remove this app package from the device.''' if package not in self.view_packgets_list(): raise NoSuchPackageException( f'There is no such package {package!r}.') self._execute('-s', self.device_sn, 'uninstall', package)
python
def uninstall(self, package: str) -> None: '''Remove this app package from the device.''' if package not in self.view_packgets_list(): raise NoSuchPackageException( f'There is no such package {package!r}.') self._execute('-s', self.device_sn, 'uninstall', package)
[ "def", "uninstall", "(", "self", ",", "package", ":", "str", ")", "->", "None", ":", "if", "package", "not", "in", "self", ".", "view_packgets_list", "(", ")", ":", "raise", "NoSuchPackageException", "(", "f'There is no such package {package!r}.'", ")", "self", ...
Remove this app package from the device.
[ "Remove", "this", "app", "package", "from", "the", "device", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L338-L343
train
Remove this app package from the device.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_packgets_list
def view_packgets_list(self, option: str = '-e', keyword: str = '') -> list: '''Show all packages. Args: option: -f see their associated file -d filter to only show disabled packages -e filter to only show enabled packages -s f...
python
def view_packgets_list(self, option: str = '-e', keyword: str = '') -> list: '''Show all packages. Args: option: -f see their associated file -d filter to only show disabled packages -e filter to only show enabled packages -s f...
[ "def", "view_packgets_list", "(", "self", ",", "option", ":", "str", "=", "'-e'", ",", "keyword", ":", "str", "=", "''", ")", "->", "list", ":", "if", "option", "not", "in", "[", "'-f'", ",", "'-d'", ",", "'-e'", ",", "'-s'", ",", "'-3'", ",", "'...
Show all packages. Args: option: -f see their associated file -d filter to only show disabled packages -e filter to only show enabled packages -s filter to only show system packages -3 filter to only show third party pa...
[ "Show", "all", "packages", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L352-L370
train
Show all packages.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_package_path
def view_package_path(self, package: str) -> _PATH: '''Print the path to the APK of the given.''' if package not in self.view_packgets_list(): raise NoSuchPackageException( f'There is no such package {package!r}.') output, _ = self._execute( '-s', self.dev...
python
def view_package_path(self, package: str) -> _PATH: '''Print the path to the APK of the given.''' if package not in self.view_packgets_list(): raise NoSuchPackageException( f'There is no such package {package!r}.') output, _ = self._execute( '-s', self.dev...
[ "def", "view_package_path", "(", "self", ",", "package", ":", "str", ")", "->", "_PATH", ":", "if", "package", "not", "in", "self", ".", "view_packgets_list", "(", ")", ":", "raise", "NoSuchPackageException", "(", "f'There is no such package {package!r}.'", ")", ...
Print the path to the APK of the given.
[ "Print", "the", "path", "to", "the", "APK", "of", "the", "given", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L372-L379
train
Print the path to the APK of the given.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_focused_activity
def view_focused_activity(self) -> str: '''View focused activity.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'activity', 'activities') return re.findall(r'mFocusedActivity: .+(com[a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)', output)[0]
python
def view_focused_activity(self) -> str: '''View focused activity.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'activity', 'activities') return re.findall(r'mFocusedActivity: .+(com[a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)', output)[0]
[ "def", "view_focused_activity", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'activity'", ",", "'activities'", ")", "return", "re...
View focused activity.
[ "View", "focused", "activity", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L388-L392
train
View focused activity.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_running_services
def view_running_services(self, package: str='') -> str: '''View running services.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'activity', 'services', package) return output
python
def view_running_services(self, package: str='') -> str: '''View running services.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'activity', 'services', package) return output
[ "def", "view_running_services", "(", "self", ",", "package", ":", "str", "=", "''", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'activity'"...
View running services.
[ "View", "running", "services", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L394-L398
train
View running services.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_package_info
def view_package_info(self, package: str='') -> str: '''View package detail information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'package', package) return output
python
def view_package_info(self, package: str='') -> str: '''View package detail information.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'package', package) return output
[ "def", "view_package_info", "(", "self", ",", "package", ":", "str", "=", "''", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'package'", "...
View package detail information.
[ "View", "package", "detail", "information", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L400-L404
train
View package detail information.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_current_app_behavior
def view_current_app_behavior(self) -> str: '''View application behavior in the current window.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'windows') return re.findall(r'mCurrentFocus=.+(com[a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)', output)[0]
python
def view_current_app_behavior(self) -> str: '''View application behavior in the current window.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'windows') return re.findall(r'mCurrentFocus=.+(com[a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)', output)[0]
[ "def", "view_current_app_behavior", "(", "self", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'window'", ",", "'windows'", ")", "return", "re"...
View application behavior in the current window.
[ "View", "application", "behavior", "in", "the", "current", "window", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L406-L410
train
View application behavior in the current window.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.view_surface_app_activity
def view_surface_app_activity(self) -> str: '''Get package with activity of applications that are running in the foreground.''' output, error = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'w') return re.findall(r"name=([a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)", output)
python
def view_surface_app_activity(self) -> str: '''Get package with activity of applications that are running in the foreground.''' output, error = self._execute( '-s', self.device_sn, 'shell', 'dumpsys', 'window', 'w') return re.findall(r"name=([a-zA-Z0-9\.]+/.[a-zA-Z0-9\.]+)", output)
[ "def", "view_surface_app_activity", "(", "self", ")", "->", "str", ":", "output", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'dumpsys'", ",", "'window'", ",", "'w'", ")", "return", "re", ...
Get package with activity of applications that are running in the foreground.
[ "Get", "package", "with", "activity", "of", "applications", "that", "are", "running", "in", "the", "foreground", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L412-L416
train
Get package with activity of applications that are running in the foreground.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver._app_base_start
def _app_base_start(self, option: str, args: list or tuple) -> None: ''' Args: option: -a <ACTION> -c <CATEGORY> -n <COMPONENT> ''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', '...
python
def _app_base_start(self, option: str, args: list or tuple) -> None: ''' Args: option: -a <ACTION> -c <CATEGORY> -n <COMPONENT> ''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', '...
[ "def", "_app_base_start", "(", "self", ",", "option", ":", "str", ",", "args", ":", "list", "or", "tuple", ")", "->", "None", ":", "_", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'a...
Args: option: -a <ACTION> -c <CATEGORY> -n <COMPONENT>
[ "Args", ":", "option", ":", "-", "a", "<ACTION", ">", "-", "c", "<CATEGORY", ">", "-", "n", "<COMPONENT", ">" ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L419-L430
train
Start application base.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.app_start_service
def app_start_service(self, *args) -> None: '''Start a service.''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', 'startservice', *args) if error and error.startswith('Error'): raise ApplicationsException(error.split(':', 1)[-1].strip()...
python
def app_start_service(self, *args) -> None: '''Start a service.''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', 'startservice', *args) if error and error.startswith('Error'): raise ApplicationsException(error.split(':', 1)[-1].strip()...
[ "def", "app_start_service", "(", "self", ",", "*", "args", ")", "->", "None", ":", "_", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'am'", ",", "'startservice'", ",", "*", "args", ")",...
Start a service.
[ "Start", "a", "service", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L444-L449
train
Start a service.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.app_broadcast
def app_broadcast(self, *args) -> None: '''Send a broadcast.''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', 'broadcast', *args) if error: raise ApplicationsException(error.split(':', 1)[-1].strip())
python
def app_broadcast(self, *args) -> None: '''Send a broadcast.''' _, error = self._execute('-s', self.device_sn, 'shell', 'am', 'broadcast', *args) if error: raise ApplicationsException(error.split(':', 1)[-1].strip())
[ "def", "app_broadcast", "(", "self", ",", "*", "args", ")", "->", "None", ":", "_", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'am'", ",", "'broadcast'", ",", "*", "args", ")", "if"...
Send a broadcast.
[ "Send", "a", "broadcast", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L458-L463
train
Send a broadcast.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.app_trim_memory
def app_trim_memory(self, pid: int or str, level: str = 'RUNNING_LOW') -> None: '''Trim memory. Args: level: HIDDEN | RUNNING_MODERATE | BACKGROUNDRUNNING_LOW | \ MODERATE | RUNNING_CRITICAL | COMPLETE ''' _, error = self._execute('-s', self.device_sn, '...
python
def app_trim_memory(self, pid: int or str, level: str = 'RUNNING_LOW') -> None: '''Trim memory. Args: level: HIDDEN | RUNNING_MODERATE | BACKGROUNDRUNNING_LOW | \ MODERATE | RUNNING_CRITICAL | COMPLETE ''' _, error = self._execute('-s', self.device_sn, '...
[ "def", "app_trim_memory", "(", "self", ",", "pid", ":", "int", "or", "str", ",", "level", ":", "str", "=", "'RUNNING_LOW'", ")", "->", "None", ":", "_", ",", "error", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'...
Trim memory. Args: level: HIDDEN | RUNNING_MODERATE | BACKGROUNDRUNNING_LOW | \ MODERATE | RUNNING_CRITICAL | COMPLETE
[ "Trim", "memory", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L470-L480
train
Trim memory.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.app_start_up_time
def app_start_up_time(self, package: str) -> str: '''Get the time it took to launch your application.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'am', 'start', '-W', package) return re.findall('TotalTime: \d+', output)[0]
python
def app_start_up_time(self, package: str) -> str: '''Get the time it took to launch your application.''' output, _ = self._execute( '-s', self.device_sn, 'shell', 'am', 'start', '-W', package) return re.findall('TotalTime: \d+', output)[0]
[ "def", "app_start_up_time", "(", "self", ",", "package", ":", "str", ")", "->", "str", ":", "output", ",", "_", "=", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'am'", ",", "'start'", ",", "'-W'", ",", ...
Get the time it took to launch your application.
[ "Get", "the", "time", "it", "took", "to", "launch", "your", "application", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L482-L486
train
Get the time it took to launch your application.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.pull_screencap
def pull_screencap(self, remote: _PATH = '/sdcard/screencap.png', local: _PATH = 'screencap.png') -> None: '''Taking a screenshot of a device display, then copy it to your computer.''' self.screencap(remote) self.pull(remote, local)
python
def pull_screencap(self, remote: _PATH = '/sdcard/screencap.png', local: _PATH = 'screencap.png') -> None: '''Taking a screenshot of a device display, then copy it to your computer.''' self.screencap(remote) self.pull(remote, local)
[ "def", "pull_screencap", "(", "self", ",", "remote", ":", "_PATH", "=", "'/sdcard/screencap.png'", ",", "local", ":", "_PATH", "=", "'screencap.png'", ")", "->", "None", ":", "self", ".", "screencap", "(", "remote", ")", "self", ".", "pull", "(", "remote",...
Taking a screenshot of a device display, then copy it to your computer.
[ "Taking", "a", "screenshot", "of", "a", "device", "display", "then", "copy", "it", "to", "your", "computer", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L493-L496
train
Pulls a screenshot of a device display then copies it to your computer.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.screencap_exec
def screencap_exec(self, filename: _PATH = 'screencap.png') -> None: '''Taking a screenshot of a device display, then copy it to your computer.''' self._execute('-s', self.device_sn, 'exec-out', 'screencap', '-p', '>', filename, shell=True)
python
def screencap_exec(self, filename: _PATH = 'screencap.png') -> None: '''Taking a screenshot of a device display, then copy it to your computer.''' self._execute('-s', self.device_sn, 'exec-out', 'screencap', '-p', '>', filename, shell=True)
[ "def", "screencap_exec", "(", "self", ",", "filename", ":", "_PATH", "=", "'screencap.png'", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'exec-out'", ",", "'screencap'", ",", "'-p'", ",", "'>'", ",",...
Taking a screenshot of a device display, then copy it to your computer.
[ "Taking", "a", "screenshot", "of", "a", "device", "display", "then", "copy", "it", "to", "your", "computer", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L498-L501
train
Taking a screenshot of a device display then copy it to your computer.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.screenrecord
def screenrecord(self, bit_rate: int = 5000000, time_limit: int = 180, filename: _PATH = '/sdcard/demo.mp4') -> None: '''Recording the display of devices running Android 4.4 (API level 19) and higher. Args: bit_rate:You can increase the bit rate to improve video quality, but doing so result...
python
def screenrecord(self, bit_rate: int = 5000000, time_limit: int = 180, filename: _PATH = '/sdcard/demo.mp4') -> None: '''Recording the display of devices running Android 4.4 (API level 19) and higher. Args: bit_rate:You can increase the bit rate to improve video quality, but doing so result...
[ "def", "screenrecord", "(", "self", ",", "bit_rate", ":", "int", "=", "5000000", ",", "time_limit", ":", "int", "=", "180", ",", "filename", ":", "_PATH", "=", "'/sdcard/demo.mp4'", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "se...
Recording the display of devices running Android 4.4 (API level 19) and higher. Args: bit_rate:You can increase the bit rate to improve video quality, but doing so results in larger movie files. time_limit: Sets the maximum recording time, in seconds, and the maximum value is 180 (3 min...
[ "Recording", "the", "display", "of", "devices", "running", "Android", "4", ".", "4", "(", "API", "level", "19", ")", "and", "higher", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L503-L511
train
Recording the display of devices running Android 4. 4 and higher.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.pull_screenrecord
def pull_screenrecord(self, bit_rate: int = 5000000, time_limit: int = 180, remote: _PATH = '/sdcard/demo.mp4', local: _PATH = 'demo.mp4') -> None: '''Recording the display of devices running Android 4.4 (API level 19) and higher. Then copy it to your computer. Args: bit_rate:You can increa...
python
def pull_screenrecord(self, bit_rate: int = 5000000, time_limit: int = 180, remote: _PATH = '/sdcard/demo.mp4', local: _PATH = 'demo.mp4') -> None: '''Recording the display of devices running Android 4.4 (API level 19) and higher. Then copy it to your computer. Args: bit_rate:You can increa...
[ "def", "pull_screenrecord", "(", "self", ",", "bit_rate", ":", "int", "=", "5000000", ",", "time_limit", ":", "int", "=", "180", ",", "remote", ":", "_PATH", "=", "'/sdcard/demo.mp4'", ",", "local", ":", "_PATH", "=", "'demo.mp4'", ")", "->", "None", ":"...
Recording the display of devices running Android 4.4 (API level 19) and higher. Then copy it to your computer. Args: bit_rate:You can increase the bit rate to improve video quality, but doing so results in larger movie files. time_limit: Sets the maximum recording time, in seconds, and ...
[ "Recording", "the", "display", "of", "devices", "running", "Android", "4", ".", "4", "(", "API", "level", "19", ")", "and", "higher", ".", "Then", "copy", "it", "to", "your", "computer", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L513-L521
train
Pulls a screenrecord from the remote computer to the local computer.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.click
def click(self, x: int, y: int) -> None: '''Simulate finger click.''' self._execute('-s', self.device_sn, 'shell', 'input', 'tap', str(x), str(y))
python
def click(self, x: int, y: int) -> None: '''Simulate finger click.''' self._execute('-s', self.device_sn, 'shell', 'input', 'tap', str(x), str(y))
[ "def", "click", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'input'", ",", "'tap'", ",", "str", "(", "x", ")", ",", ...
Simulate finger click.
[ "Simulate", "finger", "click", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L523-L526
train
Simulate finger click.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.swipe
def swipe(self, x1: int, y1: int, x2: int, y2: int, duration: int = 100) -> None: '''Simulate finger swipe. (1000ms = 1s)''' self._execute('-s', self.device_sn, 'shell', 'input', 'swipe', str(x1), str(y1), str(x2), str(y2), str(duration))
python
def swipe(self, x1: int, y1: int, x2: int, y2: int, duration: int = 100) -> None: '''Simulate finger swipe. (1000ms = 1s)''' self._execute('-s', self.device_sn, 'shell', 'input', 'swipe', str(x1), str(y1), str(x2), str(y2), str(duration))
[ "def", "swipe", "(", "self", ",", "x1", ":", "int", ",", "y1", ":", "int", ",", "x2", ":", "int", ",", "y2", ":", "int", ",", "duration", ":", "int", "=", "100", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", ...
Simulate finger swipe. (1000ms = 1s)
[ "Simulate", "finger", "swipe", ".", "(", "1000ms", "=", "1s", ")" ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L528-L531
train
Simulate finger swipe.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.long_press
def long_press(self, x: int, y: int, duration: int = 1000) -> None: '''Simulate finger long press somewhere. (1000ms = 1s)''' self._execute('-s', self.device_sn, 'shell', 'input', 'swipe', str(x), str(y), str(x), str(y), str(duration))
python
def long_press(self, x: int, y: int, duration: int = 1000) -> None: '''Simulate finger long press somewhere. (1000ms = 1s)''' self._execute('-s', self.device_sn, 'shell', 'input', 'swipe', str(x), str(y), str(x), str(y), str(duration))
[ "def", "long_press", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "duration", ":", "int", "=", "1000", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'input'", "...
Simulate finger long press somewhere. (1000ms = 1s)
[ "Simulate", "finger", "long", "press", "somewhere", ".", "(", "1000ms", "=", "1s", ")" ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L533-L536
train
Simulate finger long press somewhere.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.send_keys
def send_keys(self, text: str = 'cerium') -> None: '''Simulates typing keys.''' for char in text: if '\u4e00' <= char <= '\u9fff': raise CharactersException( f'Text cannot contain non-English characters, such as {char!r}.') text = re.escape(text) ...
python
def send_keys(self, text: str = 'cerium') -> None: '''Simulates typing keys.''' for char in text: if '\u4e00' <= char <= '\u9fff': raise CharactersException( f'Text cannot contain non-English characters, such as {char!r}.') text = re.escape(text) ...
[ "def", "send_keys", "(", "self", ",", "text", ":", "str", "=", "'cerium'", ")", "->", "None", ":", "for", "char", "in", "text", ":", "if", "'\\u4e00'", "<=", "char", "<=", "'\\u9fff'", ":", "raise", "CharactersException", "(", "f'Text cannot contain non-Engl...
Simulates typing keys.
[ "Simulates", "typing", "keys", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L538-L546
train
Simulates typing keys.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.send_keyevents
def send_keyevents(self, keyevent: int) -> None: '''Simulates typing keyevents.''' self._execute('-s', self.device_sn, 'shell', 'input', 'keyevent', str(keyevent))
python
def send_keyevents(self, keyevent: int) -> None: '''Simulates typing keyevents.''' self._execute('-s', self.device_sn, 'shell', 'input', 'keyevent', str(keyevent))
[ "def", "send_keyevents", "(", "self", ",", "keyevent", ":", "int", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'input'", ",", "'keyevent'", ",", "str", "(", "keyevent", ")", ")" ]
Simulates typing keyevents.
[ "Simulates", "typing", "keyevents", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L548-L551
train
Simulates typing keyevents.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.send_keyevents_long_press
def send_keyevents_long_press(self, keyevent: int) -> None: '''Simulates typing keyevents long press.''' self._execute('-s', self.device_sn, 'shell', 'input', 'keyevent', '--longpress', str(keyevent))
python
def send_keyevents_long_press(self, keyevent: int) -> None: '''Simulates typing keyevents long press.''' self._execute('-s', self.device_sn, 'shell', 'input', 'keyevent', '--longpress', str(keyevent))
[ "def", "send_keyevents_long_press", "(", "self", ",", "keyevent", ":", "int", ")", "->", "None", ":", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ",", "'input'", ",", "'keyevent'", ",", "'--longpress'", ",", "str", ...
Simulates typing keyevents long press.
[ "Simulates", "typing", "keyevents", "long", "press", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L553-L556
train
Simulates typing keyevents long press.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.uidump
def uidump(self, local: _PATH = None) -> None: '''Get the current interface layout file.''' local = local if local else self._temp self._execute('-s', self.device_sn, 'shell', 'uiautomator', 'dump', '--compressed', '/data/local/tmp/uidump.xml') self.pull('/data/loca...
python
def uidump(self, local: _PATH = None) -> None: '''Get the current interface layout file.''' local = local if local else self._temp self._execute('-s', self.device_sn, 'shell', 'uiautomator', 'dump', '--compressed', '/data/local/tmp/uidump.xml') self.pull('/data/loca...
[ "def", "uidump", "(", "self", ",", "local", ":", "_PATH", "=", "None", ")", "->", "None", ":", "local", "=", "local", "if", "local", "else", "self", ".", "_temp", "self", ".", "_execute", "(", "'-s'", ",", "self", ".", "device_sn", ",", "'shell'", ...
Get the current interface layout file.
[ "Get", "the", "current", "interface", "layout", "file", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L574-L581
train
Get the current interface layout file.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_element
def find_element(self, value, by=By.ID, update=False) -> Elements: '''Find a element or the first element.''' if update or not self._nodes: self.uidump() for node in self._nodes: if node.attrib[by] == value: bounds = node.attrib['bounds'] c...
python
def find_element(self, value, by=By.ID, update=False) -> Elements: '''Find a element or the first element.''' if update or not self._nodes: self.uidump() for node in self._nodes: if node.attrib[by] == value: bounds = node.attrib['bounds'] c...
[ "def", "find_element", "(", "self", ",", "value", ",", "by", "=", "By", ".", "ID", ",", "update", "=", "False", ")", "->", "Elements", ":", "if", "update", "or", "not", "self", ".", "_nodes", ":", "self", ".", "uidump", "(", ")", "for", "node", "...
Find a element or the first element.
[ "Find", "a", "element", "or", "the", "first", "element", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L583-L594
train
Find a element or the first element.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_element_by_id
def find_element_by_id(self, id_, update=False) -> Elements: '''Finds an element by id. Args: id_: The id of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Raises: ...
python
def find_element_by_id(self, id_, update=False) -> Elements: '''Finds an element by id. Args: id_: The id of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Raises: ...
[ "def", "find_element_by_id", "(", "self", ",", "id_", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_element", "(", "by", "=", "By", ".", "ID", ",", "value", "=", "id_", ",", "update", "=", "update", ")" ]
Finds an element by id. Args: id_: The id of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Raises: NoSuchElementException - If the element wasn't found. ...
[ "Finds", "an", "element", "by", "id", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L613-L629
train
Finds an element by id.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_elements_by_id
def find_elements_by_id(self, id_, update=False) -> Elements: '''Finds multiple elements by id. Args: id_: The id of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was found. A...
python
def find_elements_by_id(self, id_, update=False) -> Elements: '''Finds multiple elements by id. Args: id_: The id of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was found. A...
[ "def", "find_elements_by_id", "(", "self", ",", "id_", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_elements", "(", "by", "=", "By", ".", "ID", ",", "value", "=", "id_", ",", "update", "=", "update", ")" ]
Finds multiple elements by id. Args: id_: The id of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was found. An empty list if not. Raises: NoSuchElementException ...
[ "Finds", "multiple", "elements", "by", "id", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L631-L647
train
Finds multiple elements by id.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_element_by_name
def find_element_by_name(self, name, update=False) -> Elements: '''Finds an element by name. Args: name: The name of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Rai...
python
def find_element_by_name(self, name, update=False) -> Elements: '''Finds an element by name. Args: name: The name of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Rai...
[ "def", "find_element_by_name", "(", "self", ",", "name", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_element", "(", "by", "=", "By", ".", "NAME", ",", "value", "=", "name", ",", "update", "=", "update", ")" ]
Finds an element by name. Args: name: The name of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Raises: NoSuchElementException - If the element wasn't found. ...
[ "Finds", "an", "element", "by", "name", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L649-L665
train
Finds an element by name.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_elements_by_name
def find_elements_by_name(self, name, update=False) -> Elements: '''Finds multiple elements by name. Args: name: The name of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was ...
python
def find_elements_by_name(self, name, update=False) -> Elements: '''Finds multiple elements by name. Args: name: The name of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was ...
[ "def", "find_elements_by_name", "(", "self", ",", "name", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_elements", "(", "by", "=", "By", ".", "NAME", ",", "value", "=", "name", ",", "update", "=", "update", ")" ]
Finds multiple elements by name. Args: name: The name of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was found. An empty list if not. Raises: NoSuchElementExcep...
[ "Finds", "multiple", "elements", "by", "name", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L667-L683
train
Finds multiple elements by name.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_element_by_class
def find_element_by_class(self, class_, update=False) -> Elements: '''Finds an element by class. Args: class_: The class of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. ...
python
def find_element_by_class(self, class_, update=False) -> Elements: '''Finds an element by class. Args: class_: The class of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. ...
[ "def", "find_element_by_class", "(", "self", ",", "class_", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_element", "(", "by", "=", "By", ".", "CLASS", ",", "value", "=", "class_", ",", "update", "=", "update", "...
Finds an element by class. Args: class_: The class of the element to be found. update: If the interface has changed, this option should be True. Returns: The element if it was found. Raises: NoSuchElementException - If the element wasn't found. ...
[ "Finds", "an", "element", "by", "class", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L685-L701
train
Finds an element by class.
fjwCode/cerium
cerium/androiddriver.py
BaseAndroidDriver.find_elements_by_class
def find_elements_by_class(self, class_, update=False) -> Elements: '''Finds multiple elements by class. Args: class_: The class of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if a...
python
def find_elements_by_class(self, class_, update=False) -> Elements: '''Finds multiple elements by class. Args: class_: The class of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if a...
[ "def", "find_elements_by_class", "(", "self", ",", "class_", ",", "update", "=", "False", ")", "->", "Elements", ":", "return", "self", ".", "find_elements", "(", "by", "=", "By", ".", "CLASS", ",", "value", "=", "class_", ",", "update", "=", "update", ...
Finds multiple elements by class. Args: class_: The class of the elements to be found. update: If the interface has changed, this option should be True. Returns: A list with elements if any was found. An empty list if not. Raises: NoSuchElementE...
[ "Finds", "multiple", "elements", "by", "class", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L703-L719
train
Finds multiple elements by class.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.unlock
def unlock(self, password, width=1080, length=1920) -> None: '''Unlock screen.''' self.wake() self.swipe_up(width, length) self.send_keys(str(password))
python
def unlock(self, password, width=1080, length=1920) -> None: '''Unlock screen.''' self.wake() self.swipe_up(width, length) self.send_keys(str(password))
[ "def", "unlock", "(", "self", ",", "password", ",", "width", "=", "1080", ",", "length", "=", "1920", ")", "->", "None", ":", "self", ".", "wake", "(", ")", "self", ".", "swipe_up", "(", "width", ",", "length", ")", "self", ".", "send_keys", "(", ...
Unlock screen.
[ "Unlock", "screen", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L755-L759
train
Unlock screen.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.make_a_call
def make_a_call(self, number: int or str = 18268237856) -> None: '''Make a call.''' self.app_start_action(Actions.CALL, '-d', 'tel:{}'.format(str(number)))
python
def make_a_call(self, number: int or str = 18268237856) -> None: '''Make a call.''' self.app_start_action(Actions.CALL, '-d', 'tel:{}'.format(str(number)))
[ "def", "make_a_call", "(", "self", ",", "number", ":", "int", "or", "str", "=", "18268237856", ")", "->", "None", ":", "self", ".", "app_start_action", "(", "Actions", ".", "CALL", ",", "'-d'", ",", "'tel:{}'", ".", "format", "(", "str", "(", "number",...
Make a call.
[ "Make", "a", "call", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L809-L811
train
Make a call.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.swipe_left
def swipe_left(self, width: int = 1080, length: int = 1920) -> None: '''Swipe left.''' self.swipe(0.8*width, 0.5*length, 0.2*width, 0.5*length)
python
def swipe_left(self, width: int = 1080, length: int = 1920) -> None: '''Swipe left.''' self.swipe(0.8*width, 0.5*length, 0.2*width, 0.5*length)
[ "def", "swipe_left", "(", "self", ",", "width", ":", "int", "=", "1080", ",", "length", ":", "int", "=", "1920", ")", "->", "None", ":", "self", ".", "swipe", "(", "0.8", "*", "width", ",", "0.5", "*", "length", ",", "0.2", "*", "width", ",", "...
Swipe left.
[ "Swipe", "left", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L817-L819
train
Swipe left.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.swipe_right
def swipe_right(self, width: int = 1080, length: int = 1920) -> None: '''Swipe right.''' self.swipe(0.2*width, 0.5*length, 0.8*width, 0.5*length)
python
def swipe_right(self, width: int = 1080, length: int = 1920) -> None: '''Swipe right.''' self.swipe(0.2*width, 0.5*length, 0.8*width, 0.5*length)
[ "def", "swipe_right", "(", "self", ",", "width", ":", "int", "=", "1080", ",", "length", ":", "int", "=", "1920", ")", "->", "None", ":", "self", ".", "swipe", "(", "0.2", "*", "width", ",", "0.5", "*", "length", ",", "0.8", "*", "width", ",", ...
Swipe right.
[ "Swipe", "right", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L821-L823
train
Swipe to the right.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.swipe_up
def swipe_up(self, width: int = 1080, length: int = 1920) -> None: '''Swipe up.''' self.swipe(0.5*width, 0.8*length, 0.5*width, 0.2*length)
python
def swipe_up(self, width: int = 1080, length: int = 1920) -> None: '''Swipe up.''' self.swipe(0.5*width, 0.8*length, 0.5*width, 0.2*length)
[ "def", "swipe_up", "(", "self", ",", "width", ":", "int", "=", "1080", ",", "length", ":", "int", "=", "1920", ")", "->", "None", ":", "self", ".", "swipe", "(", "0.5", "*", "width", ",", "0.8", "*", "length", ",", "0.5", "*", "width", ",", "0....
Swipe up.
[ "Swipe", "up", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L825-L827
train
Swipe up.
fjwCode/cerium
cerium/androiddriver.py
AndroidDriver.swipe_down
def swipe_down(self, width: int = 1080, length: int = 1920) -> None: '''Swipe down.''' self.swipe(0.5*width, 0.2*length, 0.5*width, 0.8*length)
python
def swipe_down(self, width: int = 1080, length: int = 1920) -> None: '''Swipe down.''' self.swipe(0.5*width, 0.2*length, 0.5*width, 0.8*length)
[ "def", "swipe_down", "(", "self", ",", "width", ":", "int", "=", "1080", ",", "length", ":", "int", "=", "1920", ")", "->", "None", ":", "self", ".", "swipe", "(", "0.5", "*", "width", ",", "0.2", "*", "length", ",", "0.5", "*", "width", ",", "...
Swipe down.
[ "Swipe", "down", "." ]
f6e06e0dcf83a0bc924828e9d6cb81383ed2364f
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/androiddriver.py#L829-L831
train
Swipe down.
mardix/Mocha
mocha/contrib/views/contact_us.py
Main._register
def _register(cls, app, **kwargs): """ Reset some params """ # nav nav = __options__.get("nav", {}) nav.setdefault("title", "Contact") nav.setdefault("visible", True) nav.setdefault("order", 100) title = nav.pop("title") render.nav.add(title, cls.page, **...
python
def _register(cls, app, **kwargs): """ Reset some params """ # nav nav = __options__.get("nav", {}) nav.setdefault("title", "Contact") nav.setdefault("visible", True) nav.setdefault("order", 100) title = nav.pop("title") render.nav.add(title, cls.page, **...
[ "def", "_register", "(", "cls", ",", "app", ",", "*", "*", "kwargs", ")", ":", "# nav", "nav", "=", "__options__", ".", "get", "(", "\"nav\"", ",", "{", "}", ")", "nav", ".", "setdefault", "(", "\"title\"", ",", "\"Contact\"", ")", "nav", ".", "set...
Reset some params
[ "Reset", "some", "params" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/views/contact_us.py#L37-L68
train
Register the class with the app.
eevee/classtools
classtools.py
keyed_ordering
def keyed_ordering(cls): """Class decorator to generate all six rich comparison methods, based on a ``__key__`` method. Many simple classes are wrappers for very simple data, and want to defer comparisons to that data. Rich comparison is very flexible and powerful, but makes this simple case tedio...
python
def keyed_ordering(cls): """Class decorator to generate all six rich comparison methods, based on a ``__key__`` method. Many simple classes are wrappers for very simple data, and want to defer comparisons to that data. Rich comparison is very flexible and powerful, but makes this simple case tedio...
[ "def", "keyed_ordering", "(", "cls", ")", ":", "if", "'__key__'", "not", "in", "cls", ".", "__dict__", ":", "raise", "TypeError", "(", "\"keyed_ordering requires a __key__ method\"", ")", "for", "name", "in", "(", "'__eq__'", ",", "'__ne__'", ",", "'__lt__'", ...
Class decorator to generate all six rich comparison methods, based on a ``__key__`` method. Many simple classes are wrappers for very simple data, and want to defer comparisons to that data. Rich comparison is very flexible and powerful, but makes this simple case tedious to set up. There's the stand...
[ "Class", "decorator", "to", "generate", "all", "six", "rich", "comparison", "methods", "based", "on", "a", "__key__", "method", "." ]
b53aec31a370801af6a73b0427f8458a1f82c70f
https://github.com/eevee/classtools/blob/b53aec31a370801af6a73b0427f8458a1f82c70f/classtools.py#L229-L296
train
A class decorator to generate all six rich comparison methods based on a simple class representing a single element of a sequence of time intervals.
mardix/Mocha
mocha/contrib/auth/decorators.py
login_required
def login_required(func): """ A wrapper around the flask_login.login_required. But it also checks the presence of the decorator: @login_not_required On a "@login_required" class, method containing "@login_not_required" will still be able to access without authentication :param func: :return:...
python
def login_required(func): """ A wrapper around the flask_login.login_required. But it also checks the presence of the decorator: @login_not_required On a "@login_required" class, method containing "@login_not_required" will still be able to access without authentication :param func: :return:...
[ "def", "login_required", "(", "func", ")", ":", "if", "inspect", ".", "isclass", "(", "func", ")", ":", "apply_function_to_members", "(", "func", ",", "login_required", ")", "return", "func", "else", ":", "@", "functools", ".", "wraps", "(", "func", ")", ...
A wrapper around the flask_login.login_required. But it also checks the presence of the decorator: @login_not_required On a "@login_required" class, method containing "@login_not_required" will still be able to access without authentication :param func: :return:
[ "A", "wrapper", "around", "the", "flask_login", ".", "login_required", ".", "But", "it", "also", "checks", "the", "presence", "of", "the", "decorator", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L20-L40
train
Decorator to mark a view as login_required.
mardix/Mocha
mocha/contrib/auth/decorators.py
login_not_required
def login_not_required(func): """ Dummy decorator. @login_required will inspect the method to look for this decorator Use this decorator when you want do not require login in a "@login_required" class/method :param func: :return: """ @functools.wraps(func) def decorated_view(*args, ...
python
def login_not_required(func): """ Dummy decorator. @login_required will inspect the method to look for this decorator Use this decorator when you want do not require login in a "@login_required" class/method :param func: :return: """ @functools.wraps(func) def decorated_view(*args, ...
[ "def", "login_not_required", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "decorated_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "r...
Dummy decorator. @login_required will inspect the method to look for this decorator Use this decorator when you want do not require login in a "@login_required" class/method :param func: :return:
[ "Dummy", "decorator", "." ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L43-L56
train
Decorator to make sure that login is not required
mardix/Mocha
mocha/contrib/auth/decorators.py
logout_user
def logout_user(f): """ Decorator to logout user :param f: :return: """ @functools.wraps(f) def deco(*a, **kw): signals.user_logout(lambda: flask_login.current_user) flask_login.logout_user() return f(*a, **kw) return deco
python
def logout_user(f): """ Decorator to logout user :param f: :return: """ @functools.wraps(f) def deco(*a, **kw): signals.user_logout(lambda: flask_login.current_user) flask_login.logout_user() return f(*a, **kw) return deco
[ "def", "logout_user", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "deco", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "signals", ".", "user_logout", "(", "lambda", ":", "flask_login", ".", "current_user", ")", "flask...
Decorator to logout user :param f: :return:
[ "Decorator", "to", "logout", "user", ":", "param", "f", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L59-L72
train
Decorator to logout user
mardix/Mocha
mocha/contrib/auth/decorators.py
require_login_allowed
def require_login_allowed(f): """ Decorator to abort if login is not allowed :param f: :return: """ @functools.wraps(f) def deco(*a, **kw): if not __options__.get("allow_login"): abort(403, "Login not allowed. Contact admin if it's a mistake") return f(*a, **kw) ...
python
def require_login_allowed(f): """ Decorator to abort if login is not allowed :param f: :return: """ @functools.wraps(f) def deco(*a, **kw): if not __options__.get("allow_login"): abort(403, "Login not allowed. Contact admin if it's a mistake") return f(*a, **kw) ...
[ "def", "require_login_allowed", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "deco", "(", "*", "a", ",", "*", "*", "kw", ")", ":", "if", "not", "__options__", ".", "get", "(", "\"allow_login\"", ")", ":", "abort", "(", ...
Decorator to abort if login is not allowed :param f: :return:
[ "Decorator", "to", "abort", "if", "login", "is", "not", "allowed", ":", "param", "f", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L79-L92
train
Decorator to abort if login is not allowed.
mardix/Mocha
mocha/contrib/auth/decorators.py
accepts_roles
def accepts_roles(*roles): """ A decorator to check if user has any of the roles specified @roles_accepted('superadmin', 'admin') def fn(): pass """ def wrapper(f): @functools.wraps(f) def wrapped(*args, **kwargs): if is_authenticated(): if n...
python
def accepts_roles(*roles): """ A decorator to check if user has any of the roles specified @roles_accepted('superadmin', 'admin') def fn(): pass """ def wrapper(f): @functools.wraps(f) def wrapped(*args, **kwargs): if is_authenticated(): if n...
[ "def", "accepts_roles", "(", "*", "roles", ")", ":", "def", "wrapper", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "is_authenticated", "(", ")", "...
A decorator to check if user has any of the roles specified @roles_accepted('superadmin', 'admin') def fn(): pass
[ "A", "decorator", "to", "check", "if", "user", "has", "any", "of", "the", "roles", "specified" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L128-L149
train
A decorator to check if user has any of the roles specified
mardix/Mocha
mocha/contrib/auth/decorators.py
accepts_admin_roles
def accepts_admin_roles(func): """ Decorator that accepts only admin roles :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, accepts_admin_roles) return func else: @functools.wraps(func) def decorator(*args, **kwargs): ...
python
def accepts_admin_roles(func): """ Decorator that accepts only admin roles :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, accepts_admin_roles) return func else: @functools.wraps(func) def decorator(*args, **kwargs): ...
[ "def", "accepts_admin_roles", "(", "func", ")", ":", "if", "inspect", ".", "isclass", "(", "func", ")", ":", "apply_function_to_members", "(", "func", ",", "accepts_admin_roles", ")", "return", "func", "else", ":", "@", "functools", ".", "wraps", "(", "func"...
Decorator that accepts only admin roles :param func: :return:
[ "Decorator", "that", "accepts", "only", "admin", "roles", ":", "param", "func", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L152-L166
train
Decorator that accepts only admin roles
mardix/Mocha
mocha/contrib/auth/decorators.py
accepts_manager_roles
def accepts_manager_roles(func): """ Decorator that accepts only manager roles :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, accepts_manager_roles) return func else: @functools.wraps(func) def decorator(*args, **kwargs): ...
python
def accepts_manager_roles(func): """ Decorator that accepts only manager roles :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, accepts_manager_roles) return func else: @functools.wraps(func) def decorator(*args, **kwargs): ...
[ "def", "accepts_manager_roles", "(", "func", ")", ":", "if", "inspect", ".", "isclass", "(", "func", ")", ":", "apply_function_to_members", "(", "func", ",", "accepts_manager_roles", ")", "return", "func", "else", ":", "@", "functools", ".", "wraps", "(", "f...
Decorator that accepts only manager roles :param func: :return:
[ "Decorator", "that", "accepts", "only", "manager", "roles", ":", "param", "func", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/decorators.py#L169-L183
train
Decorator that accepts only manager roles