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
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.summarize
def summarize(self): """Summarize game.""" if not self._achievements_summarized: for _ in self.operations(): pass self._summarize() return self._summary
python
def summarize(self): """Summarize game.""" if not self._achievements_summarized: for _ in self.operations(): pass self._summarize() return self._summary
[ "def", "summarize", "(", "self", ")", ":", "if", "not", "self", ".", "_achievements_summarized", ":", "for", "_", "in", "self", ".", "operations", "(", ")", ":", "pass", "self", ".", "_summarize", "(", ")", "return", "self", ".", "_summary" ]
Summarize game.
[ "Summarize", "game", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L214-L220
train
Summarize game.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.is_nomad
def is_nomad(self): """Is this game nomad. TODO: Can we get from UP 1.4 achievements? """ nomad = self._header.initial.restore_time == 0 or None for i in range(1, self._header.replay.num_players): for obj in self._header.initial.players[i].objects: if...
python
def is_nomad(self): """Is this game nomad. TODO: Can we get from UP 1.4 achievements? """ nomad = self._header.initial.restore_time == 0 or None for i in range(1, self._header.replay.num_players): for obj in self._header.initial.players[i].objects: if...
[ "def", "is_nomad", "(", "self", ")", ":", "nomad", "=", "self", ".", "_header", ".", "initial", ".", "restore_time", "==", "0", "or", "None", "for", "i", "in", "range", "(", "1", ",", "self", ".", "_header", ".", "replay", ".", "num_players", ")", ...
Is this game nomad. TODO: Can we get from UP 1.4 achievements?
[ "Is", "this", "game", "nomad", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L222-L232
train
Is this game nomad?
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.is_regicide
def is_regicide(self): """Is this game regicide.""" for i in range(1, self._header.replay.num_players): for obj in self._header.initial.players[i].objects: if obj.type == 'unit' and obj.object_type == 'king': return True return False
python
def is_regicide(self): """Is this game regicide.""" for i in range(1, self._header.replay.num_players): for obj in self._header.initial.players[i].objects: if obj.type == 'unit' and obj.object_type == 'king': return True return False
[ "def", "is_regicide", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "self", ".", "_header", ".", "replay", ".", "num_players", ")", ":", "for", "obj", "in", "self", ".", "_header", ".", "initial", ".", "players", "[", "i", "]", ...
Is this game regicide.
[ "Is", "this", "game", "regicide", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L234-L240
train
Is this game regicide?
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._parse_chat
def _parse_chat(self, chat): """Parse a chat message.""" if chat.data['type'] == 'chat': if chat.data['player'] in [p.player_name for i, p in self._players()]: self._chat.append(chat.data) elif chat.data['type'] == 'ladder': self._ladder = chat.data['ladde...
python
def _parse_chat(self, chat): """Parse a chat message.""" if chat.data['type'] == 'chat': if chat.data['player'] in [p.player_name for i, p in self._players()]: self._chat.append(chat.data) elif chat.data['type'] == 'ladder': self._ladder = chat.data['ladde...
[ "def", "_parse_chat", "(", "self", ",", "chat", ")", ":", "if", "chat", ".", "data", "[", "'type'", "]", "==", "'chat'", ":", "if", "chat", ".", "data", "[", "'player'", "]", "in", "[", "p", ".", "player_name", "for", "i", ",", "p", "in", "self",...
Parse a chat message.
[ "Parse", "a", "chat", "message", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L253-L262
train
Parse a chat message.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._parse_player
def _parse_player(self, index, attributes, postgame, game_type): """Parse a player.""" try: voobly_user = voobly.user(self._voobly_session, attributes.player_name, ladder_ids=VOOBLY_LADDERS.values()) voobly_ladder = '{} {}'.format(game_type, ...
python
def _parse_player(self, index, attributes, postgame, game_type): """Parse a player.""" try: voobly_user = voobly.user(self._voobly_session, attributes.player_name, ladder_ids=VOOBLY_LADDERS.values()) voobly_ladder = '{} {}'.format(game_type, ...
[ "def", "_parse_player", "(", "self", ",", "index", ",", "attributes", ",", "postgame", ",", "game_type", ")", ":", "try", ":", "voobly_user", "=", "voobly", ".", "user", "(", "self", ".", "_voobly_session", ",", "attributes", ".", "player_name", ",", "ladd...
Parse a player.
[ "Parse", "a", "player", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L264-L338
train
Parse a single player.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._compass_position
def _compass_position(self, player_x, player_y): """Get compass position of player.""" map_dim = self._map.size_x third = map_dim * (1/3.0) for direction in mgz.const.COMPASS: point = mgz.const.COMPASS[direction] xlower = point[0] * map_dim xupper = (p...
python
def _compass_position(self, player_x, player_y): """Get compass position of player.""" map_dim = self._map.size_x third = map_dim * (1/3.0) for direction in mgz.const.COMPASS: point = mgz.const.COMPASS[direction] xlower = point[0] * map_dim xupper = (p...
[ "def", "_compass_position", "(", "self", ",", "player_x", ",", "player_y", ")", ":", "map_dim", "=", "self", ".", "_map", ".", "size_x", "third", "=", "map_dim", "*", "(", "1", "/", "3.0", ")", "for", "direction", "in", "mgz", ".", "const", ".", "COM...
Get compass position of player.
[ "Get", "compass", "position", "of", "player", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L340-L352
train
Get compass position of player.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._players
def _players(self): """Get player attributes with index. No Gaia.""" for i in range(1, self._header.replay.num_players): yield i, self._header.initial.players[i].attributes
python
def _players(self): """Get player attributes with index. No Gaia.""" for i in range(1, self._header.replay.num_players): yield i, self._header.initial.players[i].attributes
[ "def", "_players", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "self", ".", "_header", ".", "replay", ".", "num_players", ")", ":", "yield", "i", ",", "self", ".", "_header", ".", "initial", ".", "players", "[", "i", "]", "."...
Get player attributes with index. No Gaia.
[ "Get", "player", "attributes", "with", "index", ".", "No", "Gaia", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L354-L357
train
Get player attributes with index. No Gaia.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.players
def players(self, postgame, game_type): """Return parsed players.""" for i, attributes in self._players(): yield self._parse_player(i, attributes, postgame, game_type)
python
def players(self, postgame, game_type): """Return parsed players.""" for i, attributes in self._players(): yield self._parse_player(i, attributes, postgame, game_type)
[ "def", "players", "(", "self", ",", "postgame", ",", "game_type", ")", ":", "for", "i", ",", "attributes", "in", "self", ".", "_players", "(", ")", ":", "yield", "self", ".", "_parse_player", "(", "i", ",", "attributes", ",", "postgame", ",", "game_typ...
Return parsed players.
[ "Return", "parsed", "players", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L359-L362
train
Return parsed players.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame.teams
def teams(self): """Get list of teams.""" teams = {} default_team = 1 for i in range(1, self._header.replay.num_players): attributes = self._header.initial.players[i].attributes team = self._header.lobby.teams[i - 1] if team == 1: team ...
python
def teams(self): """Get list of teams.""" teams = {} default_team = 1 for i in range(1, self._header.replay.num_players): attributes = self._header.initial.players[i].attributes team = self._header.lobby.teams[i - 1] if team == 1: team ...
[ "def", "teams", "(", "self", ")", ":", "teams", "=", "{", "}", "default_team", "=", "1", "for", "i", "in", "range", "(", "1", ",", "self", ".", "_header", ".", "replay", ".", "num_players", ")", ":", "attributes", "=", "self", ".", "_header", ".", ...
Get list of teams.
[ "Get", "list", "of", "teams", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L364-L377
train
Get list of teams.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._compute_diplomacy
def _compute_diplomacy(self): """Compute diplomacy.""" self._diplomacy = { 'teams': self.teams(), 'ffa': len(self.teams()) == (self._player_num + self._computer_num and self._player_num + self._computer_num > 2), 'TG': len(sel...
python
def _compute_diplomacy(self): """Compute diplomacy.""" self._diplomacy = { 'teams': self.teams(), 'ffa': len(self.teams()) == (self._player_num + self._computer_num and self._player_num + self._computer_num > 2), 'TG': len(sel...
[ "def", "_compute_diplomacy", "(", "self", ")", ":", "self", ".", "_diplomacy", "=", "{", "'teams'", ":", "self", ".", "teams", "(", ")", ",", "'ffa'", ":", "len", "(", "self", ".", "teams", "(", ")", ")", "==", "(", "self", ".", "_player_num", "+",...
Compute diplomacy.
[ "Compute", "diplomacy", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L379-L396
train
Compute the diplomacy of the current object.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._won_in
def _won_in(self): """Get age the game was won in.""" if not self._summary['finished']: return starting_age = self._summary['settings']['starting_age'].lower() if starting_age == 'post imperial': starting_age = 'imperial' ages_reached = set([starting_age])...
python
def _won_in(self): """Get age the game was won in.""" if not self._summary['finished']: return starting_age = self._summary['settings']['starting_age'].lower() if starting_age == 'post imperial': starting_age = 'imperial' ages_reached = set([starting_age])...
[ "def", "_won_in", "(", "self", ")", ":", "if", "not", "self", ".", "_summary", "[", "'finished'", "]", ":", "return", "starting_age", "=", "self", ".", "_summary", "[", "'settings'", "]", "[", "'starting_age'", "]", ".", "lower", "(", ")", "if", "start...
Get age the game was won in.
[ "Get", "age", "the", "game", "was", "won", "in", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L398-L413
train
Get age the game was won in.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._rec_owner_number
def _rec_owner_number(self): """Get rec owner number.""" player = self._header.initial.players[self._header.replay.rec_player] return player.attributes.player_color + 1
python
def _rec_owner_number(self): """Get rec owner number.""" player = self._header.initial.players[self._header.replay.rec_player] return player.attributes.player_color + 1
[ "def", "_rec_owner_number", "(", "self", ")", ":", "player", "=", "self", ".", "_header", ".", "initial", ".", "players", "[", "self", ".", "_header", ".", "replay", ".", "rec_player", "]", "return", "player", ".", "attributes", ".", "player_color", "+", ...
Get rec owner number.
[ "Get", "rec", "owner", "number", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L415-L418
train
Get rec owner number.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._get_timestamp
def _get_timestamp(self): """Get modification timestamp from rec file.""" filename_date = _find_date(os.path.basename(self._path)) if filename_date: return filename_date
python
def _get_timestamp(self): """Get modification timestamp from rec file.""" filename_date = _find_date(os.path.basename(self._path)) if filename_date: return filename_date
[ "def", "_get_timestamp", "(", "self", ")", ":", "filename_date", "=", "_find_date", "(", "os", ".", "path", ".", "basename", "(", "self", ".", "_path", ")", ")", "if", "filename_date", ":", "return", "filename_date" ]
Get modification timestamp from rec file.
[ "Get", "modification", "timestamp", "from", "rec", "file", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L427-L431
train
Get modification timestamp from rec file.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._set_winning_team
def _set_winning_team(self): """Mark the winning team.""" if not self._summary['finished']: return for team in self._summary['diplomacy']['teams']: team['winner'] = False for player_number in team['player_numbers']: for player in self._summary[...
python
def _set_winning_team(self): """Mark the winning team.""" if not self._summary['finished']: return for team in self._summary['diplomacy']['teams']: team['winner'] = False for player_number in team['player_numbers']: for player in self._summary[...
[ "def", "_set_winning_team", "(", "self", ")", ":", "if", "not", "self", ".", "_summary", "[", "'finished'", "]", ":", "return", "for", "team", "in", "self", ".", "_summary", "[", "'diplomacy'", "]", "[", "'teams'", "]", ":", "team", "[", "'winner'", "]...
Mark the winning team.
[ "Mark", "the", "winning", "team", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L444-L454
train
Mark the winning team.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._map_hash
def _map_hash(self): """Compute a map hash based on a combination of map attributes. - Elevation - Map name - Player names, colors, and civilizations """ elevation_bytes = bytes([tile.elevation for tile in self._header.map_info.tile]) map_name_bytes = self._map.n...
python
def _map_hash(self): """Compute a map hash based on a combination of map attributes. - Elevation - Map name - Player names, colors, and civilizations """ elevation_bytes = bytes([tile.elevation for tile in self._header.map_info.tile]) map_name_bytes = self._map.n...
[ "def", "_map_hash", "(", "self", ")", ":", "elevation_bytes", "=", "bytes", "(", "[", "tile", ".", "elevation", "for", "tile", "in", "self", ".", "_header", ".", "map_info", ".", "tile", "]", ")", "map_name_bytes", "=", "self", ".", "_map", ".", "name"...
Compute a map hash based on a combination of map attributes. - Elevation - Map name - Player names, colors, and civilizations
[ "Compute", "a", "map", "hash", "based", "on", "a", "combination", "of", "map", "attributes", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L456-L470
train
Compute a map hash based on a combination of map attributes.
happyleavesaoc/aoc-mgz
mgz/recorded_game/__init__.py
RecordedGame._summarize
def _summarize(self): """Game summary implementation.""" self._achievements_summarized = True data = None if self._postgame: data = self._postgame.action game_type = 'DM' if self._header.lobby.game_type == 'DM' else 'RM' self._summary = { 'players'...
python
def _summarize(self): """Game summary implementation.""" self._achievements_summarized = True data = None if self._postgame: data = self._postgame.action game_type = 'DM' if self._header.lobby.game_type == 'DM' else 'RM' self._summary = { 'players'...
[ "def", "_summarize", "(", "self", ")", ":", "self", ".", "_achievements_summarized", "=", "True", "data", "=", "None", "if", "self", ".", "_postgame", ":", "data", "=", "self", ".", "_postgame", ".", "action", "game_type", "=", "'DM'", "if", "self", ".",...
Game summary implementation.
[ "Game", "summary", "implementation", "." ]
13fc379cc062d7640bfa028eed9c0d45d37a7b2b
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/recorded_game/__init__.py#L472-L552
train
A simple summary implementation.
kstaniek/condoor
condoor/device.py
Device.device_info
def device_info(self): """Return device info dict.""" return { 'family': self.family, 'platform': self.platform, 'os_type': self.os_type, 'os_version': self.os_version, 'udi': self.udi, # TODO(klstanie): add property to make driver ...
python
def device_info(self): """Return device info dict.""" return { 'family': self.family, 'platform': self.platform, 'os_type': self.os_type, 'os_version': self.os_version, 'udi': self.udi, # TODO(klstanie): add property to make driver ...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "'family'", ":", "self", ".", "family", ",", "'platform'", ":", "self", ".", "platform", ",", "'os_type'", ":", "self", ".", "os_type", ",", "'os_version'", ":", "self", ".", "os_version", ",", ...
Return device info dict.
[ "Return", "device", "info", "dict", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L65-L80
train
Return device info dict.
kstaniek/condoor
condoor/device.py
Device.clear_info
def clear_info(self): """Clear the device info.""" self._version_text = None self._inventory_text = None self._users_text = None self.os_version = None self.os_type = None self.family = None self.platform = None self.udi = None # self.is_co...
python
def clear_info(self): """Clear the device info.""" self._version_text = None self._inventory_text = None self._users_text = None self.os_version = None self.os_type = None self.family = None self.platform = None self.udi = None # self.is_co...
[ "def", "clear_info", "(", "self", ")", ":", "self", ".", "_version_text", "=", "None", "self", ".", "_inventory_text", "=", "None", "self", ".", "_users_text", "=", "None", "self", ".", "os_version", "=", "None", "self", ".", "os_type", "=", "None", "sel...
Clear the device info.
[ "Clear", "the", "device", "info", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L92-L104
train
Clear the device info.
kstaniek/condoor
condoor/device.py
Device.connect
def connect(self, ctrl): """Connect to the device.""" if self.prompt: self.prompt_re = self.driver.make_dynamic_prompt(self.prompt) else: self.prompt_re = self.driver.prompt_re self.ctrl = ctrl if self.protocol.connect(self.driver): if self.pr...
python
def connect(self, ctrl): """Connect to the device.""" if self.prompt: self.prompt_re = self.driver.make_dynamic_prompt(self.prompt) else: self.prompt_re = self.driver.prompt_re self.ctrl = ctrl if self.protocol.connect(self.driver): if self.pr...
[ "def", "connect", "(", "self", ",", "ctrl", ")", ":", "if", "self", ".", "prompt", ":", "self", ".", "prompt_re", "=", "self", ".", "driver", ".", "make_dynamic_prompt", "(", "self", ".", "prompt", ")", "else", ":", "self", ".", "prompt_re", "=", "se...
Connect to the device.
[ "Connect", "to", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L106-L141
train
Connect to the device.
kstaniek/condoor
condoor/device.py
Device.disconnect
def disconnect(self): """Disconnect the device.""" self.chain.connection.log("Disconnecting: {}".format(self)) if self.connected: if self.protocol: if self.is_console: while self.mode != 'global': try: ...
python
def disconnect(self): """Disconnect the device.""" self.chain.connection.log("Disconnecting: {}".format(self)) if self.connected: if self.protocol: if self.is_console: while self.mode != 'global': try: ...
[ "def", "disconnect", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Disconnecting: {}\"", ".", "format", "(", "self", ")", ")", "if", "self", ".", "connected", ":", "if", "self", ".", "protocol", ":", "if", "self", ...
Disconnect the device.
[ "Disconnect", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L182-L198
train
Disconnect the device.
kstaniek/condoor
condoor/device.py
Device.send
def send(self, cmd="", timeout=60, wait_for_string=None, password=False): """Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 60s wait_for_str...
python
def send(self, cmd="", timeout=60, wait_for_string=None, password=False): """Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 60s wait_for_str...
[ "def", "send", "(", "self", ",", "cmd", "=", "\"\"", ",", "timeout", "=", "60", ",", "wait_for_string", "=", "None", ",", "password", "=", "False", ")", ":", "if", "self", ".", "connected", ":", "output", "=", "''", "if", "password", ":", "self", "...
Send the command to the device and return the output. Args: cmd (str): Command string for execution. Defaults to empty string. timeout (int): Timeout in seconds. Defaults to 60s wait_for_string (str): This is optional string that driver waits for after comman...
[ "Send", "the", "command", "to", "the", "device", "and", "return", "the", "output", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L200-L243
train
Send a command to the device and return the output.
kstaniek/condoor
condoor/device.py
Device.execute_command
def execute_command(self, cmd, timeout, wait_for_string, password): """Execute command.""" try: self.last_command_result = None self.ctrl.send_command(cmd, password=password) if wait_for_string is None: wait_for_string = self.prompt_re # h...
python
def execute_command(self, cmd, timeout, wait_for_string, password): """Execute command.""" try: self.last_command_result = None self.ctrl.send_command(cmd, password=password) if wait_for_string is None: wait_for_string = self.prompt_re # h...
[ "def", "execute_command", "(", "self", ",", "cmd", ",", "timeout", ",", "wait_for_string", ",", "password", ")", ":", "try", ":", "self", ".", "last_command_result", "=", "None", "self", ".", "ctrl", ".", "send_command", "(", "cmd", ",", "password", "=", ...
Execute command.
[ "Execute", "command", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L245-L291
train
Execute command and return the output.
kstaniek/condoor
condoor/device.py
Device.make_driver
def make_driver(self, driver_name='generic'): """Make driver factory function.""" module_str = 'condoor.drivers.%s' % driver_name try: __import__(module_str) module = sys.modules[module_str] driver_class = getattr(module, 'Driver') except ImportError a...
python
def make_driver(self, driver_name='generic'): """Make driver factory function.""" module_str = 'condoor.drivers.%s' % driver_name try: __import__(module_str) module = sys.modules[module_str] driver_class = getattr(module, 'Driver') except ImportError a...
[ "def", "make_driver", "(", "self", ",", "driver_name", "=", "'generic'", ")", ":", "module_str", "=", "'condoor.drivers.%s'", "%", "driver_name", "try", ":", "__import__", "(", "module_str", ")", "module", "=", "sys", ".", "modules", "[", "module_str", "]", ...
Make driver factory function.
[ "Make", "driver", "factory", "function", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L310-L324
train
Make driver factory function.
kstaniek/condoor
condoor/device.py
Device.version_text
def version_text(self): """Return version text and collect if not collected.""" if self._version_text is None: self.chain.connection.log("Collecting version information") self._version_text = self.driver.get_version_text() if self._version_text: self.c...
python
def version_text(self): """Return version text and collect if not collected.""" if self._version_text is None: self.chain.connection.log("Collecting version information") self._version_text = self.driver.get_version_text() if self._version_text: self.c...
[ "def", "version_text", "(", "self", ")", ":", "if", "self", ".", "_version_text", "is", "None", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Collecting version information\"", ")", "self", ".", "_version_text", "=", "self", ".", "driver"...
Return version text and collect if not collected.
[ "Return", "version", "text", "and", "collect", "if", "not", "collected", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L331-L341
train
Return version text and collect if not collected.
kstaniek/condoor
condoor/device.py
Device.hostname_text
def hostname_text(self): """Return hostname text and collect if not collected.""" if self._hostname_text is None: self.chain.connection.log("Collecting hostname information") self._hostname_text = self.driver.get_hostname_text() if self._hostname_text: ...
python
def hostname_text(self): """Return hostname text and collect if not collected.""" if self._hostname_text is None: self.chain.connection.log("Collecting hostname information") self._hostname_text = self.driver.get_hostname_text() if self._hostname_text: ...
[ "def", "hostname_text", "(", "self", ")", ":", "if", "self", ".", "_hostname_text", "is", "None", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Collecting hostname information\"", ")", "self", ".", "_hostname_text", "=", "self", ".", "dri...
Return hostname text and collect if not collected.
[ "Return", "hostname", "text", "and", "collect", "if", "not", "collected", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L344-L353
train
Return hostname text and collect if not collected.
kstaniek/condoor
condoor/device.py
Device.inventory_text
def inventory_text(self): """Return inventory information and collect if not available.""" if self._inventory_text is None: self.chain.connection.log("Collecting inventory information") self._inventory_text = self.driver.get_inventory_text() if self._inventory_text: ...
python
def inventory_text(self): """Return inventory information and collect if not available.""" if self._inventory_text is None: self.chain.connection.log("Collecting inventory information") self._inventory_text = self.driver.get_inventory_text() if self._inventory_text: ...
[ "def", "inventory_text", "(", "self", ")", ":", "if", "self", ".", "_inventory_text", "is", "None", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Collecting inventory information\"", ")", "self", ".", "_inventory_text", "=", "self", ".", ...
Return inventory information and collect if not available.
[ "Return", "inventory", "information", "and", "collect", "if", "not", "available", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L356-L365
train
Return inventory information and collect if not available.
kstaniek/condoor
condoor/device.py
Device.users_text
def users_text(self): """Return connected users information and collect if not available.""" if self._users_text is None: self.chain.connection.log("Getting connected users text") self._users_text = self.driver.get_users_text() if self._users_text: sel...
python
def users_text(self): """Return connected users information and collect if not available.""" if self._users_text is None: self.chain.connection.log("Getting connected users text") self._users_text = self.driver.get_users_text() if self._users_text: sel...
[ "def", "users_text", "(", "self", ")", ":", "if", "self", ".", "_users_text", "is", "None", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Getting connected users text\"", ")", "self", ".", "_users_text", "=", "self", ".", "driver", ".",...
Return connected users information and collect if not available.
[ "Return", "connected", "users", "information", "and", "collect", "if", "not", "available", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L368-L377
train
Return connected users text and collect if not available.
kstaniek/condoor
condoor/device.py
Device.get_protocol_name
def get_protocol_name(self): """Provide protocol name based on node_info.""" protocol_name = self.node_info.protocol if self.is_console: protocol_name += '_console' return protocol_name
python
def get_protocol_name(self): """Provide protocol name based on node_info.""" protocol_name = self.node_info.protocol if self.is_console: protocol_name += '_console' return protocol_name
[ "def", "get_protocol_name", "(", "self", ")", ":", "protocol_name", "=", "self", ".", "node_info", ".", "protocol", "if", "self", ".", "is_console", ":", "protocol_name", "+=", "'_console'", "return", "protocol_name" ]
Provide protocol name based on node_info.
[ "Provide", "protocol", "name", "based", "on", "node_info", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L379-L384
train
Provide protocol name based on node_info.
kstaniek/condoor
condoor/device.py
Device.make_dynamic_prompt
def make_dynamic_prompt(self, prompt): """Extend prompt with flexible mode handling regexp.""" if prompt: self.prompt_re = self.driver.make_dynamic_prompt(prompt)
python
def make_dynamic_prompt(self, prompt): """Extend prompt with flexible mode handling regexp.""" if prompt: self.prompt_re = self.driver.make_dynamic_prompt(prompt)
[ "def", "make_dynamic_prompt", "(", "self", ",", "prompt", ")", ":", "if", "prompt", ":", "self", ".", "prompt_re", "=", "self", ".", "driver", ".", "make_dynamic_prompt", "(", "prompt", ")" ]
Extend prompt with flexible mode handling regexp.
[ "Extend", "prompt", "with", "flexible", "mode", "handling", "regexp", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L386-L389
train
Extend prompt with flexible mode handling regexp.
kstaniek/condoor
condoor/device.py
Device.update_udi
def update_udi(self): """Update udi.""" self.chain.connection.log("Parsing inventory") # TODO: Maybe validate if udi is complete self.udi = parse_inventory(self.inventory_text)
python
def update_udi(self): """Update udi.""" self.chain.connection.log("Parsing inventory") # TODO: Maybe validate if udi is complete self.udi = parse_inventory(self.inventory_text)
[ "def", "update_udi", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Parsing inventory\"", ")", "# TODO: Maybe validate if udi is complete", "self", ".", "udi", "=", "parse_inventory", "(", "self", ".", "inventory_text", ")" ]
Update udi.
[ "Update", "udi", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L391-L395
train
Update udi.
kstaniek/condoor
condoor/device.py
Device.update_config_mode
def update_config_mode(self, prompt=None): """Update config mode.""" # TODO: Fix the conflict with config mode attribute at connection if prompt: self.mode = self.driver.update_config_mode(prompt) else: self.mode = self.driver.update_config_mode(self.prompt)
python
def update_config_mode(self, prompt=None): """Update config mode.""" # TODO: Fix the conflict with config mode attribute at connection if prompt: self.mode = self.driver.update_config_mode(prompt) else: self.mode = self.driver.update_config_mode(self.prompt)
[ "def", "update_config_mode", "(", "self", ",", "prompt", "=", "None", ")", ":", "# TODO: Fix the conflict with config mode attribute at connection", "if", "prompt", ":", "self", ".", "mode", "=", "self", ".", "driver", ".", "update_config_mode", "(", "prompt", ")", ...
Update config mode.
[ "Update", "config", "mode", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L397-L403
train
Update config mode.
kstaniek/condoor
condoor/device.py
Device.update_driver
def update_driver(self, prompt): """Update driver based on new prompt.""" prompt = prompt.lstrip() self.chain.connection.log("({}): Prompt: '{}'".format(self.driver.platform, prompt)) self.prompt = prompt driver_name = self.driver.update_driver(prompt) if driver_name is N...
python
def update_driver(self, prompt): """Update driver based on new prompt.""" prompt = prompt.lstrip() self.chain.connection.log("({}): Prompt: '{}'".format(self.driver.platform, prompt)) self.prompt = prompt driver_name = self.driver.update_driver(prompt) if driver_name is N...
[ "def", "update_driver", "(", "self", ",", "prompt", ")", ":", "prompt", "=", "prompt", ".", "lstrip", "(", ")", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"({}): Prompt: '{}'\"", ".", "format", "(", "self", ".", "driver", ".", "platform"...
Update driver based on new prompt.
[ "Update", "driver", "based", "on", "new", "prompt", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L409-L418
train
Update the driver based on new prompt.
kstaniek/condoor
condoor/device.py
Device.prepare_terminal_session
def prepare_terminal_session(self): """Send commands to prepare terminal session configuration.""" for cmd in self.driver.prepare_terminal_session: try: self.send(cmd) except CommandSyntaxError: self.chain.connection.log("Command not supported or n...
python
def prepare_terminal_session(self): """Send commands to prepare terminal session configuration.""" for cmd in self.driver.prepare_terminal_session: try: self.send(cmd) except CommandSyntaxError: self.chain.connection.log("Command not supported or n...
[ "def", "prepare_terminal_session", "(", "self", ")", ":", "for", "cmd", "in", "self", ".", "driver", ".", "prepare_terminal_session", ":", "try", ":", "self", ".", "send", "(", "cmd", ")", "except", "CommandSyntaxError", ":", "self", ".", "chain", ".", "co...
Send commands to prepare terminal session configuration.
[ "Send", "commands", "to", "prepare", "terminal", "session", "configuration", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L420-L427
train
Send commands to prepare terminal session configuration.
kstaniek/condoor
condoor/device.py
Device.update_os_type
def update_os_type(self): """Update os_type attribute.""" self.chain.connection.log("Detecting os type") os_type = self.driver.get_os_type(self.version_text) if os_type: self.chain.connection.log("SW Type: {}".format(os_type)) self.os_type = os_type
python
def update_os_type(self): """Update os_type attribute.""" self.chain.connection.log("Detecting os type") os_type = self.driver.get_os_type(self.version_text) if os_type: self.chain.connection.log("SW Type: {}".format(os_type)) self.os_type = os_type
[ "def", "update_os_type", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting os type\"", ")", "os_type", "=", "self", ".", "driver", ".", "get_os_type", "(", "self", ".", "version_text", ")", "if", "os_type", ":", ...
Update os_type attribute.
[ "Update", "os_type", "attribute", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L429-L435
train
Update os_type attribute.
kstaniek/condoor
condoor/device.py
Device.update_os_version
def update_os_version(self): """Update os_version attribute.""" self.chain.connection.log("Detecting os version") os_version = self.driver.get_os_version(self.version_text) if os_version: self.chain.connection.log("SW Version: {}".format(os_version)) self.os_versi...
python
def update_os_version(self): """Update os_version attribute.""" self.chain.connection.log("Detecting os version") os_version = self.driver.get_os_version(self.version_text) if os_version: self.chain.connection.log("SW Version: {}".format(os_version)) self.os_versi...
[ "def", "update_os_version", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting os version\"", ")", "os_version", "=", "self", ".", "driver", ".", "get_os_version", "(", "self", ".", "version_text", ")", "if", "os_ve...
Update os_version attribute.
[ "Update", "os_version", "attribute", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L437-L443
train
Update os_version attribute.
kstaniek/condoor
condoor/device.py
Device.update_family
def update_family(self): """Update family attribute.""" self.chain.connection.log("Detecting hw family") family = self.driver.get_hw_family(self.version_text) if family: self.chain.connection.log("HW Family: {}".format(family)) self.family = family
python
def update_family(self): """Update family attribute.""" self.chain.connection.log("Detecting hw family") family = self.driver.get_hw_family(self.version_text) if family: self.chain.connection.log("HW Family: {}".format(family)) self.family = family
[ "def", "update_family", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting hw family\"", ")", "family", "=", "self", ".", "driver", ".", "get_hw_family", "(", "self", ".", "version_text", ")", "if", "family", ":",...
Update family attribute.
[ "Update", "family", "attribute", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L445-L451
train
Update family attribute.
kstaniek/condoor
condoor/device.py
Device.update_platform
def update_platform(self): """Update platform attribute.""" self.chain.connection.log("Detecting hw platform") platform = self.driver.get_hw_platform(self.udi) if platform: self.chain.connection.log("HW Platform: {}".format(platform)) self.platform = platform
python
def update_platform(self): """Update platform attribute.""" self.chain.connection.log("Detecting hw platform") platform = self.driver.get_hw_platform(self.udi) if platform: self.chain.connection.log("HW Platform: {}".format(platform)) self.platform = platform
[ "def", "update_platform", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting hw platform\"", ")", "platform", "=", "self", ".", "driver", ".", "get_hw_platform", "(", "self", ".", "udi", ")", "if", "platform", ":"...
Update platform attribute.
[ "Update", "platform", "attribute", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L453-L459
train
Update platform attribute.
kstaniek/condoor
condoor/device.py
Device.update_console
def update_console(self): """Update is_console whether connected via console.""" self.chain.connection.log("Detecting console connection") is_console = self.driver.is_console(self.users_text) if is_console is not None: self.is_console = is_console
python
def update_console(self): """Update is_console whether connected via console.""" self.chain.connection.log("Detecting console connection") is_console = self.driver.is_console(self.users_text) if is_console is not None: self.is_console = is_console
[ "def", "update_console", "(", "self", ")", ":", "self", ".", "chain", ".", "connection", ".", "log", "(", "\"Detecting console connection\"", ")", "is_console", "=", "self", ".", "driver", ".", "is_console", "(", "self", ".", "users_text", ")", "if", "is_con...
Update is_console whether connected via console.
[ "Update", "is_console", "whether", "connected", "via", "console", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L461-L466
train
Update is_console whether connected via console.
kstaniek/condoor
condoor/device.py
Device.reload
def reload(self, reload_timeout, save_config, no_reload_cmd): """Reload device.""" if not no_reload_cmd: self.ctrl.send_command(self.driver.reload_cmd) return self.driver.reload(reload_timeout, save_config)
python
def reload(self, reload_timeout, save_config, no_reload_cmd): """Reload device.""" if not no_reload_cmd: self.ctrl.send_command(self.driver.reload_cmd) return self.driver.reload(reload_timeout, save_config)
[ "def", "reload", "(", "self", ",", "reload_timeout", ",", "save_config", ",", "no_reload_cmd", ")", ":", "if", "not", "no_reload_cmd", ":", "self", ".", "ctrl", ".", "send_command", "(", "self", ".", "driver", ".", "reload_cmd", ")", "return", "self", ".",...
Reload device.
[ "Reload", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L476-L480
train
Reload device.
kstaniek/condoor
condoor/device.py
Device.run_fsm
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): """Wrap the FSM code.""" self.ctrl.send_command(command) return FSM(name, self, events, transitions, timeout=timeout, max_transitions=max_transitions).run()
python
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): """Wrap the FSM code.""" self.ctrl.send_command(command) return FSM(name, self, events, transitions, timeout=timeout, max_transitions=max_transitions).run()
[ "def", "run_fsm", "(", "self", ",", "name", ",", "command", ",", "events", ",", "transitions", ",", "timeout", ",", "max_transitions", "=", "20", ")", ":", "self", ".", "ctrl", ".", "send_command", "(", "command", ")", "return", "FSM", "(", "name", ","...
Wrap the FSM code.
[ "Wrap", "the", "FSM", "code", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L482-L485
train
Wrap the FSM code.
kstaniek/condoor
condoor/device.py
Device.config
def config(self, configlet, plane, **attributes): """Apply config to the device.""" try: config_text = configlet.format(**attributes) except KeyError as exp: raise CommandSyntaxError("Configuration template error: {}".format(str(exp))) return self.driver.config(c...
python
def config(self, configlet, plane, **attributes): """Apply config to the device.""" try: config_text = configlet.format(**attributes) except KeyError as exp: raise CommandSyntaxError("Configuration template error: {}".format(str(exp))) return self.driver.config(c...
[ "def", "config", "(", "self", ",", "configlet", ",", "plane", ",", "*", "*", "attributes", ")", ":", "try", ":", "config_text", "=", "configlet", ".", "format", "(", "*", "*", "attributes", ")", "except", "KeyError", "as", "exp", ":", "raise", "Command...
Apply config to the device.
[ "Apply", "config", "to", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L487-L494
train
Apply config to the device.
kstaniek/condoor
condoor/drivers/QNX.py
Driver.get_version_text
def get_version_text(self): """Return the version information from Unix host.""" version_text = None try: version_text = self.device.send('uname -sr', timeout=10) except CommandError as exc: exc.command = 'show version' raise exc return versi...
python
def get_version_text(self): """Return the version information from Unix host.""" version_text = None try: version_text = self.device.send('uname -sr', timeout=10) except CommandError as exc: exc.command = 'show version' raise exc return versi...
[ "def", "get_version_text", "(", "self", ")", ":", "version_text", "=", "None", "try", ":", "version_text", "=", "self", ".", "device", ".", "send", "(", "'uname -sr'", ",", "timeout", "=", "10", ")", "except", "CommandError", "as", "exc", ":", "exc", "."...
Return the version information from Unix host.
[ "Return", "the", "version", "information", "from", "Unix", "host", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/QNX.py#L22-L32
train
Return the version information from Unix host.
kstaniek/condoor
condoor/chain.py
device_gen
def device_gen(chain, urls): """Device object generator.""" itr = iter(urls) last = next(itr) for url in itr: yield Device(chain, make_hop_info_from_url(last), driver_name='jumphost', is_target=False) last = url yield Device(chain, make_hop_info_from_url(last), driver_name='generic',...
python
def device_gen(chain, urls): """Device object generator.""" itr = iter(urls) last = next(itr) for url in itr: yield Device(chain, make_hop_info_from_url(last), driver_name='jumphost', is_target=False) last = url yield Device(chain, make_hop_info_from_url(last), driver_name='generic',...
[ "def", "device_gen", "(", "chain", ",", "urls", ")", ":", "itr", "=", "iter", "(", "urls", ")", "last", "=", "next", "(", "itr", ")", "for", "url", "in", "itr", ":", "yield", "Device", "(", "chain", ",", "make_hop_info_from_url", "(", "last", ")", ...
Device object generator.
[ "Device", "object", "generator", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L12-L19
train
Device object generator.
kstaniek/condoor
condoor/chain.py
Chain.connect
def connect(self): """Connect to the target device using the intermediate jumphosts.""" device = None # logger.debug("Connecting to: {}".format(str(self))) for device in self.devices: if not device.connected: self.connection.emit_message("Connecting {}".format...
python
def connect(self): """Connect to the target device using the intermediate jumphosts.""" device = None # logger.debug("Connecting to: {}".format(str(self))) for device in self.devices: if not device.connected: self.connection.emit_message("Connecting {}".format...
[ "def", "connect", "(", "self", ")", ":", "device", "=", "None", "# logger.debug(\"Connecting to: {}\".format(str(self)))", "for", "device", "in", "self", ".", "devices", ":", "if", "not", "device", ".", "connected", ":", "self", ".", "connection", ".", "emit_mes...
Connect to the target device using the intermediate jumphosts.
[ "Connect", "to", "the", "target", "device", "using", "the", "intermediate", "jumphosts", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L40-L87
train
Connect to the target device using the intermediate jumphosts.
kstaniek/condoor
condoor/chain.py
Chain.disconnect
def disconnect(self): """Disconnect from the device.""" self.target_device.disconnect() self.ctrl.disconnect() self.tail_disconnect(-1)
python
def disconnect(self): """Disconnect from the device.""" self.target_device.disconnect() self.ctrl.disconnect() self.tail_disconnect(-1)
[ "def", "disconnect", "(", "self", ")", ":", "self", ".", "target_device", ".", "disconnect", "(", ")", "self", ".", "ctrl", ".", "disconnect", "(", ")", "self", ".", "tail_disconnect", "(", "-", "1", ")" ]
Disconnect from the device.
[ "Disconnect", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L89-L93
train
Disconnect from the device.
kstaniek/condoor
condoor/chain.py
Chain.is_discovered
def is_discovered(self): """Return if target device is discovered.""" if self.target_device is None: return False if None in (self.target_device.version_text, self.target_device.os_type, self.target_device.os_version, self.target_device.inventory_text, self.targe...
python
def is_discovered(self): """Return if target device is discovered.""" if self.target_device is None: return False if None in (self.target_device.version_text, self.target_device.os_type, self.target_device.os_version, self.target_device.inventory_text, self.targe...
[ "def", "is_discovered", "(", "self", ")", ":", "if", "self", ".", "target_device", "is", "None", ":", "return", "False", "if", "None", "in", "(", "self", ".", "target_device", ".", "version_text", ",", "self", ".", "target_device", ".", "os_type", ",", "...
Return if target device is discovered.
[ "Return", "if", "target", "device", "is", "discovered", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L113-L121
train
Return if target device is discovered.
kstaniek/condoor
condoor/chain.py
Chain.get_previous_prompts
def get_previous_prompts(self, device): """Return the list of intermediate prompts. All except target.""" device_index = self.devices.index(device) prompts = [re.compile("(?!x)x")] + \ [dev.prompt_re for dev in self.devices[:device_index] if dev.prompt_re is not None] r...
python
def get_previous_prompts(self, device): """Return the list of intermediate prompts. All except target.""" device_index = self.devices.index(device) prompts = [re.compile("(?!x)x")] + \ [dev.prompt_re for dev in self.devices[:device_index] if dev.prompt_re is not None] r...
[ "def", "get_previous_prompts", "(", "self", ",", "device", ")", ":", "device_index", "=", "self", ".", "devices", ".", "index", "(", "device", ")", "prompts", "=", "[", "re", ".", "compile", "(", "\"(?!x)x\"", ")", "]", "+", "[", "dev", ".", "prompt_re...
Return the list of intermediate prompts. All except target.
[ "Return", "the", "list", "of", "intermediate", "prompts", ".", "All", "except", "target", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L131-L136
train
Return the list of intermediate prompts. All except target.
kstaniek/condoor
condoor/chain.py
Chain.get_device_index_based_on_prompt
def get_device_index_based_on_prompt(self, prompt): """Return the device index in the chain based on prompt.""" conn_info = "" for device in self.devices: conn_info += str(device) + "->" if device.prompt == prompt: self.connection.log("Connected: {}".forma...
python
def get_device_index_based_on_prompt(self, prompt): """Return the device index in the chain based on prompt.""" conn_info = "" for device in self.devices: conn_info += str(device) + "->" if device.prompt == prompt: self.connection.log("Connected: {}".forma...
[ "def", "get_device_index_based_on_prompt", "(", "self", ",", "prompt", ")", ":", "conn_info", "=", "\"\"", "for", "device", "in", "self", ".", "devices", ":", "conn_info", "+=", "str", "(", "device", ")", "+", "\"->\"", "if", "device", ".", "prompt", "==",...
Return the device index in the chain based on prompt.
[ "Return", "the", "device", "index", "in", "the", "chain", "based", "on", "prompt", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L138-L147
train
Return the index of the first device in the chain based on prompt.
kstaniek/condoor
condoor/chain.py
Chain.tail_disconnect
def tail_disconnect(self, index): """Mark all devices disconnected except target in the chain.""" try: for device in self.devices[index + 1:]: device.connected = False except IndexError: pass
python
def tail_disconnect(self, index): """Mark all devices disconnected except target in the chain.""" try: for device in self.devices[index + 1:]: device.connected = False except IndexError: pass
[ "def", "tail_disconnect", "(", "self", ",", "index", ")", ":", "try", ":", "for", "device", "in", "self", ".", "devices", "[", "index", "+", "1", ":", "]", ":", "device", ".", "connected", "=", "False", "except", "IndexError", ":", "pass" ]
Mark all devices disconnected except target in the chain.
[ "Mark", "all", "devices", "disconnected", "except", "target", "in", "the", "chain", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L149-L155
train
Mark all devices disconnected except target in the chain.
kstaniek/condoor
condoor/chain.py
Chain.send
def send(self, cmd, timeout, wait_for_string, password): """Send command to the target device.""" return self.target_device.send(cmd, timeout=timeout, wait_for_string=wait_for_string, password=password)
python
def send(self, cmd, timeout, wait_for_string, password): """Send command to the target device.""" return self.target_device.send(cmd, timeout=timeout, wait_for_string=wait_for_string, password=password)
[ "def", "send", "(", "self", ",", "cmd", ",", "timeout", ",", "wait_for_string", ",", "password", ")", ":", "return", "self", ".", "target_device", ".", "send", "(", "cmd", ",", "timeout", "=", "timeout", ",", "wait_for_string", "=", "wait_for_string", ",",...
Send command to the target device.
[ "Send", "command", "to", "the", "target", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L157-L159
train
Send a command to the target device.
kstaniek/condoor
condoor/chain.py
Chain.update
def update(self, data): """Update the chain object with the predefined data.""" if data is None: for device in self.devices: device.clear_info() else: for device, device_info in zip(self.devices, data): device.device_info = device_info ...
python
def update(self, data): """Update the chain object with the predefined data.""" if data is None: for device in self.devices: device.clear_info() else: for device, device_info in zip(self.devices, data): device.device_info = device_info ...
[ "def", "update", "(", "self", ",", "data", ")", ":", "if", "data", "is", "None", ":", "for", "device", "in", "self", ".", "devices", ":", "device", ".", "clear_info", "(", ")", "else", ":", "for", "device", ",", "device_info", "in", "zip", "(", "se...
Update the chain object with the predefined data.
[ "Update", "the", "chain", "object", "with", "the", "predefined", "data", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/chain.py#L161-L169
train
Update the chain object with the predefined data.
kstaniek/condoor
condoor/fsm.py
action
def action(func): """Wrap the FSM action function providing extended logging information based on doc string.""" @wraps(func) def call_action(*args, **kwargs): """Wrap the function with logger debug.""" try: ctx = kwargs['ctx'] except KeyError: ctx = None ...
python
def action(func): """Wrap the FSM action function providing extended logging information based on doc string.""" @wraps(func) def call_action(*args, **kwargs): """Wrap the function with logger debug.""" try: ctx = kwargs['ctx'] except KeyError: ctx = None ...
[ "def", "action", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "call_action", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrap the function with logger debug.\"\"\"", "try", ":", "ctx", "=", "kwargs", "[", "'ctx'", "]", "e...
Wrap the FSM action function providing extended logging information based on doc string.
[ "Wrap", "the", "FSM", "action", "function", "providing", "extended", "logging", "information", "based", "on", "doc", "string", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/fsm.py#L12-L33
train
Wrap FSM action function providing extended logging information based on doc string.
kstaniek/condoor
condoor/fsm.py
FSM.run
def run(self): """Start the FSM. Returns: boolean: True if FSM reaches the last state or false if the exception or error message was raised """ ctx = FSM.Context(self.name, self.device) transition_counter = 0 timeout = self.timeout self.log("{} Start...
python
def run(self): """Start the FSM. Returns: boolean: True if FSM reaches the last state or false if the exception or error message was raised """ ctx = FSM.Context(self.name, self.device) transition_counter = 0 timeout = self.timeout self.log("{} Start...
[ "def", "run", "(", "self", ")", ":", "ctx", "=", "FSM", ".", "Context", "(", "self", ".", "name", ",", "self", ".", "device", ")", "transition_counter", "=", "0", "timeout", "=", "self", ".", "timeout", "self", ".", "log", "(", "\"{} Start\"", ".", ...
Start the FSM. Returns: boolean: True if FSM reaches the last state or false if the exception or error message was raised
[ "Start", "the", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/fsm.py#L152-L218
train
This method runs the FSM.
thomasjiangcy/django-rest-mock
rest_mock_server/builder.py
get_store
def get_store(url_details): """ The state of the mock server will be stored in the resulting object created here """ store = {} for detail in url_details: base_url = detail['url'].strip() # If a url detail has instances, it means that # we want to also create an endpoint...
python
def get_store(url_details): """ The state of the mock server will be stored in the resulting object created here """ store = {} for detail in url_details: base_url = detail['url'].strip() # If a url detail has instances, it means that # we want to also create an endpoint...
[ "def", "get_store", "(", "url_details", ")", ":", "store", "=", "{", "}", "for", "detail", "in", "url_details", ":", "base_url", "=", "detail", "[", "'url'", "]", ".", "strip", "(", ")", "# If a url detail has instances, it means that", "# we want to also create a...
The state of the mock server will be stored in the resulting object created here
[ "The", "state", "of", "the", "mock", "server", "will", "be", "stored", "in", "the", "resulting", "object", "created", "here" ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/builder.py#L14-L137
train
Returns a dictionary that represents the state of the mock server.
thomasjiangcy/django-rest-mock
rest_mock_server/builder.py
build
def build(port=8000, fixtures=None): """ Builds a server file. 1. Extract mock response details from all valid docstrings in existing views 2. Parse and generate mock values 3. Create a store of all endpoints and data 4. Construct server file """ extractor = Extractor() parser = Par...
python
def build(port=8000, fixtures=None): """ Builds a server file. 1. Extract mock response details from all valid docstrings in existing views 2. Parse and generate mock values 3. Create a store of all endpoints and data 4. Construct server file """ extractor = Extractor() parser = Par...
[ "def", "build", "(", "port", "=", "8000", ",", "fixtures", "=", "None", ")", ":", "extractor", "=", "Extractor", "(", ")", "parser", "=", "Parser", "(", "extractor", ".", "url_details", ",", "fixtures", ")", "parser", ".", "parse", "(", ")", "url_detai...
Builds a server file. 1. Extract mock response details from all valid docstrings in existing views 2. Parse and generate mock values 3. Create a store of all endpoints and data 4. Construct server file
[ "Builds", "a", "server", "file", "." ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/builder.py#L177-L245
train
Builds a server file.
OnroerendErfgoed/language-tags
language_tags/Subtag.py
Subtag.preferred
def preferred(self): """ Get the preferred subtag. :return: preferred :class:`language_tags.Subtag.Subtag` if exists, otherwise None. """ if 'Preferred-Value' in self.data['record']: preferred = self.data['record']['Preferred-Value'] type = self.data['typ...
python
def preferred(self): """ Get the preferred subtag. :return: preferred :class:`language_tags.Subtag.Subtag` if exists, otherwise None. """ if 'Preferred-Value' in self.data['record']: preferred = self.data['record']['Preferred-Value'] type = self.data['typ...
[ "def", "preferred", "(", "self", ")", ":", "if", "'Preferred-Value'", "in", "self", ".", "data", "[", "'record'", "]", ":", "preferred", "=", "self", ".", "data", "[", "'record'", "]", "[", "'Preferred-Value'", "]", "type", "=", "self", ".", "data", "[...
Get the preferred subtag. :return: preferred :class:`language_tags.Subtag.Subtag` if exists, otherwise None.
[ "Get", "the", "preferred", "subtag", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Subtag.py#L86-L98
train
Get the preferred subtag.
OnroerendErfgoed/language-tags
language_tags/Subtag.py
Subtag.format
def format(self): """ Get the subtag code conventional format according to RFC 5646 section 2.1.1. :return: string -- subtag code conventional format. """ subtag = self.data['subtag'] if self.data['type'] == 'region': return subtag.upper() if self.dat...
python
def format(self): """ Get the subtag code conventional format according to RFC 5646 section 2.1.1. :return: string -- subtag code conventional format. """ subtag = self.data['subtag'] if self.data['type'] == 'region': return subtag.upper() if self.dat...
[ "def", "format", "(", "self", ")", ":", "subtag", "=", "self", ".", "data", "[", "'subtag'", "]", "if", "self", ".", "data", "[", "'type'", "]", "==", "'region'", ":", "return", "subtag", ".", "upper", "(", ")", "if", "self", ".", "data", "[", "'...
Get the subtag code conventional format according to RFC 5646 section 2.1.1. :return: string -- subtag code conventional format.
[ "Get", "the", "subtag", "code", "conventional", "format", "according", "to", "RFC", "5646", "section", "2", ".", "1", ".", "1", "." ]
acb91e5458d22617f344e2eefaba9a9865373fdd
https://github.com/OnroerendErfgoed/language-tags/blob/acb91e5458d22617f344e2eefaba9a9865373fdd/language_tags/Subtag.py#L101-L112
train
Returns the subtag code conventional format according to RFC 5646 section 2. 1. 1.
freshbooks/refreshbooks
refreshbooks/api.py
AuthorizingClient
def AuthorizingClient( domain, auth, request_encoder, response_decoder, user_agent=None ): """Creates a Freshbooks client for a freshbooks domain, using an auth object. """ http_transport = transport.HttpTransport( api_url(domain), build_headers(auth, user_agent)...
python
def AuthorizingClient( domain, auth, request_encoder, response_decoder, user_agent=None ): """Creates a Freshbooks client for a freshbooks domain, using an auth object. """ http_transport = transport.HttpTransport( api_url(domain), build_headers(auth, user_agent)...
[ "def", "AuthorizingClient", "(", "domain", ",", "auth", ",", "request_encoder", ",", "response_decoder", ",", "user_agent", "=", "None", ")", ":", "http_transport", "=", "transport", ".", "HttpTransport", "(", "api_url", "(", "domain", ")", ",", "build_headers",...
Creates a Freshbooks client for a freshbooks domain, using an auth object.
[ "Creates", "a", "Freshbooks", "client", "for", "a", "freshbooks", "domain", "using", "an", "auth", "object", "." ]
cfd65ecd38cb6be3b61dbf6a01f93800603f34b1
https://github.com/freshbooks/refreshbooks/blob/cfd65ecd38cb6be3b61dbf6a01f93800603f34b1/refreshbooks/api.py#L72-L92
train
Creates a Freshbooks client for a freshbooks domain using an auth object.
freshbooks/refreshbooks
refreshbooks/api.py
TokenClient
def TokenClient( domain, token, user_agent=None, request_encoder=default_request_encoder, response_decoder=default_response_decoder, ): """Creates a Freshbooks client for a freshbooks domain, using token-based auth. The optional request_encoder and response_decoder parameters can be...
python
def TokenClient( domain, token, user_agent=None, request_encoder=default_request_encoder, response_decoder=default_response_decoder, ): """Creates a Freshbooks client for a freshbooks domain, using token-based auth. The optional request_encoder and response_decoder parameters can be...
[ "def", "TokenClient", "(", "domain", ",", "token", ",", "user_agent", "=", "None", ",", "request_encoder", "=", "default_request_encoder", ",", "response_decoder", "=", "default_response_decoder", ",", ")", ":", "return", "AuthorizingClient", "(", "domain", ",", "...
Creates a Freshbooks client for a freshbooks domain, using token-based auth. The optional request_encoder and response_decoder parameters can be passed the logging_request_encoder and logging_response_decoder objects from this module, or custom encoders, to aid debugging or change the behaviour...
[ "Creates", "a", "Freshbooks", "client", "for", "a", "freshbooks", "domain", "using", "token", "-", "based", "auth", ".", "The", "optional", "request_encoder", "and", "response_decoder", "parameters", "can", "be", "passed", "the", "logging_request_encoder", "and", ...
cfd65ecd38cb6be3b61dbf6a01f93800603f34b1
https://github.com/freshbooks/refreshbooks/blob/cfd65ecd38cb6be3b61dbf6a01f93800603f34b1/refreshbooks/api.py#L94-L120
train
Creates a Freshbooks client for a freshbooks domain using a token - based auth.
freshbooks/refreshbooks
refreshbooks/api.py
OAuthClient
def OAuthClient( domain, consumer_key, consumer_secret, token, token_secret, user_agent=None, request_encoder=default_request_encoder, response_decoder=default_response_decoder ): """Creates a Freshbooks client for a freshbooks domain, using OAuth. Token management is assumed to ...
python
def OAuthClient( domain, consumer_key, consumer_secret, token, token_secret, user_agent=None, request_encoder=default_request_encoder, response_decoder=default_response_decoder ): """Creates a Freshbooks client for a freshbooks domain, using OAuth. Token management is assumed to ...
[ "def", "OAuthClient", "(", "domain", ",", "consumer_key", ",", "consumer_secret", ",", "token", ",", "token_secret", ",", "user_agent", "=", "None", ",", "request_encoder", "=", "default_request_encoder", ",", "response_decoder", "=", "default_response_decoder", ")", ...
Creates a Freshbooks client for a freshbooks domain, using OAuth. Token management is assumed to have been handled out of band. The optional request_encoder and response_decoder parameters can be passed the logging_request_encoder and logging_response_decoder objects from this module, or custom enc...
[ "Creates", "a", "Freshbooks", "client", "for", "a", "freshbooks", "domain", "using", "OAuth", ".", "Token", "management", "is", "assumed", "to", "have", "been", "handled", "out", "of", "band", ".", "The", "optional", "request_encoder", "and", "response_decoder",...
cfd65ecd38cb6be3b61dbf6a01f93800603f34b1
https://github.com/freshbooks/refreshbooks/blob/cfd65ecd38cb6be3b61dbf6a01f93800603f34b1/refreshbooks/api.py#L122-L154
train
Creates a freshbooks client for a freshbooks domain using OAuth.
bfarr/kombine
examples/kepler/correlated_likelihood.py
generate_covariance
def generate_covariance(ts, sigma, tau): r"""Generates a covariance matrix according to an squared-exponential autocovariance .. math:: \left\langle x_i x_j \right\rangle = \sigma_0^2 \delta_{ij} + \sigma^2 \exp\left[ - \frac{\left| t_i - t_j\right|^2}{2 \tau^2} \right] """ ndim = ...
python
def generate_covariance(ts, sigma, tau): r"""Generates a covariance matrix according to an squared-exponential autocovariance .. math:: \left\langle x_i x_j \right\rangle = \sigma_0^2 \delta_{ij} + \sigma^2 \exp\left[ - \frac{\left| t_i - t_j\right|^2}{2 \tau^2} \right] """ ndim = ...
[ "def", "generate_covariance", "(", "ts", ",", "sigma", ",", "tau", ")", ":", "ndim", "=", "ts", ".", "shape", "[", "0", "]", "tis", "=", "ts", "[", ":", ",", "np", ".", "newaxis", "]", "tjs", "=", "ts", "[", "np", ".", "newaxis", ",", ":", "]...
r"""Generates a covariance matrix according to an squared-exponential autocovariance .. math:: \left\langle x_i x_j \right\rangle = \sigma_0^2 \delta_{ij} + \sigma^2 \exp\left[ - \frac{\left| t_i - t_j\right|^2}{2 \tau^2} \right]
[ "r", "Generates", "a", "covariance", "matrix", "according", "to", "an", "squared", "-", "exponential", "autocovariance", "..", "math", "::", "\\", "left", "\\", "langle", "x_i", "x_j", "\\", "right", "\\", "rangle", "=", "\\", "sigma_0^2", "\\", "delta_", ...
50c946dee5da33e7baab71d9bd6c265ff02ffb13
https://github.com/bfarr/kombine/blob/50c946dee5da33e7baab71d9bd6c265ff02ffb13/examples/kepler/correlated_likelihood.py#L8-L23
train
r Generates a covariance matrix according to an analytical autocovariance squared - exponential autocovariance
django-blog-zinnia/zinnia-wysiwyg-tinymce
zinnia_tinymce/admin.py
EntryAdminTinyMCEMixin._media
def _media(self): """ The medias needed to enhance the admin page. """ media = super(EntryAdminTinyMCEMixin, self).media media += TinyMCE().media + Media( js=[reverse('tinymce-js', args=['admin/zinnia/entry']), reverse('tinymce-filebrowser-callback')]...
python
def _media(self): """ The medias needed to enhance the admin page. """ media = super(EntryAdminTinyMCEMixin, self).media media += TinyMCE().media + Media( js=[reverse('tinymce-js', args=['admin/zinnia/entry']), reverse('tinymce-filebrowser-callback')]...
[ "def", "_media", "(", "self", ")", ":", "media", "=", "super", "(", "EntryAdminTinyMCEMixin", ",", "self", ")", ".", "media", "media", "+=", "TinyMCE", "(", ")", ".", "media", "+", "Media", "(", "js", "=", "[", "reverse", "(", "'tinymce-js'", ",", "a...
The medias needed to enhance the admin page.
[ "The", "medias", "needed", "to", "enhance", "the", "admin", "page", "." ]
2df91fd36cfd15ba172f0a17921757e537e76a1d
https://github.com/django-blog-zinnia/zinnia-wysiwyg-tinymce/blob/2df91fd36cfd15ba172f0a17921757e537e76a1d/zinnia_tinymce/admin.py#L18-L29
train
Returns the admin page s media.
freshbooks/refreshbooks
refreshbooks/adapters.py
encode_as_simple
def encode_as_simple(name, value): """Creates an etree element following the simple field convention. Values are assumed to be strs, unicodes, ints, floats, or Decimals: >>> element = encode_as_simple('foo', '5') >>> element.tag == 'foo' True >>> element.text == '5' ...
python
def encode_as_simple(name, value): """Creates an etree element following the simple field convention. Values are assumed to be strs, unicodes, ints, floats, or Decimals: >>> element = encode_as_simple('foo', '5') >>> element.tag == 'foo' True >>> element.text == '5' ...
[ "def", "encode_as_simple", "(", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "objectify", ".", "ObjectifiedDataElement", ")", ":", "return", "encode_as_simple", "(", "name", ",", "unicode", "(", "value", ")", ")", "if", "type", "(...
Creates an etree element following the simple field convention. Values are assumed to be strs, unicodes, ints, floats, or Decimals: >>> element = encode_as_simple('foo', '5') >>> element.tag == 'foo' True >>> element.text == '5' True >>> element = encode_as_simpl...
[ "Creates", "an", "etree", "element", "following", "the", "simple", "field", "convention", ".", "Values", "are", "assumed", "to", "be", "strs", "unicodes", "ints", "floats", "or", "Decimals", ":", ">>>", "element", "=", "encode_as_simple", "(", "foo", "5", ")...
cfd65ecd38cb6be3b61dbf6a01f93800603f34b1
https://github.com/freshbooks/refreshbooks/blob/cfd65ecd38cb6be3b61dbf6a01f93800603f34b1/refreshbooks/adapters.py#L28-L47
train
Encodes the value of a field into an etree element following the simple field convention.
kstaniek/condoor
condoor/drivers/eXR.py
Driver.wait_for_string
def wait_for_string(self, expected_string, timeout=60): """Wait for string FSM for XR 64 bit.""" ADMIN_USERNAME_PROMPT = re.compile("Admin Username:") ADMIN_PASSWORD_PROMPT = re.compile("Password:") # Big thanks to calvados developers for make this FSM such complex ;-) # ...
python
def wait_for_string(self, expected_string, timeout=60): """Wait for string FSM for XR 64 bit.""" ADMIN_USERNAME_PROMPT = re.compile("Admin Username:") ADMIN_PASSWORD_PROMPT = re.compile("Password:") # Big thanks to calvados developers for make this FSM such complex ;-) # ...
[ "def", "wait_for_string", "(", "self", ",", "expected_string", ",", "timeout", "=", "60", ")", ":", "ADMIN_USERNAME_PROMPT", "=", "re", ".", "compile", "(", "\"Admin Username:\"", ")", "ADMIN_PASSWORD_PROMPT", "=", "re", ".", "compile", "(", "\"Password:\"", ")"...
Wait for string FSM for XR 64 bit.
[ "Wait", "for", "string", "FSM", "for", "XR", "64", "bit", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/eXR.py#L83-L132
train
Wait for a string FSM for XR 64 bit.
kstaniek/condoor
condoor/drivers/eXR.py
Driver.reload
def reload(self, reload_timeout, save_config): """Reload the device.""" MAX_BOOT_TIME = 1800 # 30 minutes - TODO(klstanie): move to config RELOAD_PROMPT = re.compile(re.escape("Reload hardware module ? [no,yes]")) START_TO_BACKUP = re.compile("Status report.*START TO BACKUP") B...
python
def reload(self, reload_timeout, save_config): """Reload the device.""" MAX_BOOT_TIME = 1800 # 30 minutes - TODO(klstanie): move to config RELOAD_PROMPT = re.compile(re.escape("Reload hardware module ? [no,yes]")) START_TO_BACKUP = re.compile("Status report.*START TO BACKUP") B...
[ "def", "reload", "(", "self", ",", "reload_timeout", ",", "save_config", ")", ":", "MAX_BOOT_TIME", "=", "1800", "# 30 minutes - TODO(klstanie): move to config", "RELOAD_PROMPT", "=", "re", ".", "compile", "(", "re", ".", "escape", "(", "\"Reload hardware module ? [no...
Reload the device.
[ "Reload", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/eXR.py#L134-L182
train
Reload the device.
bfarr/kombine
examples/kepler/rv_model.py
rv_model
def rv_model(ts, K, e, omega, chi, P): """Returns the radial velocity measurements associated with the planets in parameters ps at times ts. The returned array has shape (Nts,).""" assert ts.ndim == 1, 'ts must be one-dimensional' return kp.rv_model(ts, K, e, omega, chi, P)
python
def rv_model(ts, K, e, omega, chi, P): """Returns the radial velocity measurements associated with the planets in parameters ps at times ts. The returned array has shape (Nts,).""" assert ts.ndim == 1, 'ts must be one-dimensional' return kp.rv_model(ts, K, e, omega, chi, P)
[ "def", "rv_model", "(", "ts", ",", "K", ",", "e", ",", "omega", ",", "chi", ",", "P", ")", ":", "assert", "ts", ".", "ndim", "==", "1", ",", "'ts must be one-dimensional'", "return", "kp", ".", "rv_model", "(", "ts", ",", "K", ",", "e", ",", "ome...
Returns the radial velocity measurements associated with the planets in parameters ps at times ts. The returned array has shape (Nts,).
[ "Returns", "the", "radial", "velocity", "measurements", "associated", "with", "the", "planets", "in", "parameters", "ps", "at", "times", "ts", ".", "The", "returned", "array", "has", "shape", "(", "Nts", ")", "." ]
50c946dee5da33e7baab71d9bd6c265ff02ffb13
https://github.com/bfarr/kombine/blob/50c946dee5da33e7baab71d9bd6c265ff02ffb13/examples/kepler/rv_model.py#L3-L10
train
Returns the radial velocity measurements associated with the planets in parameters ps at times ts.
theherk/figgypy
figgypy/decrypt.py
gpg_decrypt
def gpg_decrypt(cfg, gpg_config=None): """Decrypt GPG objects in configuration. Args: cfg (dict): configuration dictionary gpg_config (dict): gpg configuration dict of arguments for gpg including: homedir, binary, and keyring (require all if any) example:...
python
def gpg_decrypt(cfg, gpg_config=None): """Decrypt GPG objects in configuration. Args: cfg (dict): configuration dictionary gpg_config (dict): gpg configuration dict of arguments for gpg including: homedir, binary, and keyring (require all if any) example:...
[ "def", "gpg_decrypt", "(", "cfg", ",", "gpg_config", "=", "None", ")", ":", "def", "decrypt", "(", "obj", ")", ":", "\"\"\"Decrypt the object.\n\n It is an inner function because we must first verify that gpg\n is ready. If we did them in the same function we would end ...
Decrypt GPG objects in configuration. Args: cfg (dict): configuration dictionary gpg_config (dict): gpg configuration dict of arguments for gpg including: homedir, binary, and keyring (require all if any) example: gpg_config = {'homedir': '~/....
[ "Decrypt", "GPG", "objects", "in", "configuration", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/decrypt.py#L26-L119
train
Decrypt a dictionary of items in a configuration dictionary.
theherk/figgypy
figgypy/decrypt.py
kms_decrypt
def kms_decrypt(cfg, aws_config=None): """Decrypt KMS objects in configuration. Args: cfg (dict): configuration dictionary aws_config (dict): aws credentials dict of arguments passed into boto3 session example: aws_creds = {'aws_access_key_id': aws_access...
python
def kms_decrypt(cfg, aws_config=None): """Decrypt KMS objects in configuration. Args: cfg (dict): configuration dictionary aws_config (dict): aws credentials dict of arguments passed into boto3 session example: aws_creds = {'aws_access_key_id': aws_access...
[ "def", "kms_decrypt", "(", "cfg", ",", "aws_config", "=", "None", ")", ":", "def", "decrypt", "(", "obj", ")", ":", "\"\"\"Decrypt the object.\n\n It is an inner function because we must first configure our KMS\n client. Then we call this recursively on the object.\n ...
Decrypt KMS objects in configuration. Args: cfg (dict): configuration dictionary aws_config (dict): aws credentials dict of arguments passed into boto3 session example: aws_creds = {'aws_access_key_id': aws_access_key_id, 'aws_sec...
[ "Decrypt", "KMS", "objects", "in", "configuration", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/decrypt.py#L122-L191
train
Decrypt KMS objects in configuration dictionary cfg.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_version_text
def get_version_text(self): """Return the version information from the device.""" show_version_brief_not_supported = False version_text = None try: version_text = self.device.send("show version brief", timeout=120) except CommandError: show_version_brief_n...
python
def get_version_text(self): """Return the version information from the device.""" show_version_brief_not_supported = False version_text = None try: version_text = self.device.send("show version brief", timeout=120) except CommandError: show_version_brief_n...
[ "def", "get_version_text", "(", "self", ")", ":", "show_version_brief_not_supported", "=", "False", "version_text", "=", "None", "try", ":", "version_text", "=", "self", ".", "device", ".", "send", "(", "\"show version brief\"", ",", "timeout", "=", "120", ")", ...
Return the version information from the device.
[ "Return", "the", "version", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L63-L80
train
Return the version information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_inventory_text
def get_inventory_text(self): """Return the inventory information from the device.""" inventory_text = None if self.inventory_cmd: try: inventory_text = self.device.send(self.inventory_cmd, timeout=120) self.log('Inventory collected') excep...
python
def get_inventory_text(self): """Return the inventory information from the device.""" inventory_text = None if self.inventory_cmd: try: inventory_text = self.device.send(self.inventory_cmd, timeout=120) self.log('Inventory collected') excep...
[ "def", "get_inventory_text", "(", "self", ")", ":", "inventory_text", "=", "None", "if", "self", ".", "inventory_cmd", ":", "try", ":", "inventory_text", "=", "self", ".", "device", ".", "send", "(", "self", ".", "inventory_cmd", ",", "timeout", "=", "120"...
Return the inventory information from the device.
[ "Return", "the", "inventory", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L82-L93
train
Return the inventory information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_users_text
def get_users_text(self): """Return the users logged in information from the device.""" users_text = None if self.users_cmd: try: users_text = self.device.send(self.users_cmd, timeout=60) except CommandError: self.log('Unable to collect con...
python
def get_users_text(self): """Return the users logged in information from the device.""" users_text = None if self.users_cmd: try: users_text = self.device.send(self.users_cmd, timeout=60) except CommandError: self.log('Unable to collect con...
[ "def", "get_users_text", "(", "self", ")", ":", "users_text", "=", "None", "if", "self", ".", "users_cmd", ":", "try", ":", "users_text", "=", "self", ".", "device", ".", "send", "(", "self", ".", "users_cmd", ",", "timeout", "=", "60", ")", "except", ...
Return the users logged in information from the device.
[ "Return", "the", "users", "logged", "in", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L99-L109
train
Return the users logged in information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_os_type
def get_os_type(self, version_text): # pylint: disable=no-self-use """Return the OS type information from the device.""" os_type = None if version_text is None: return os_type match = re.search("(XR|XE|NX-OS)", version_text) if match: os_type = match.gro...
python
def get_os_type(self, version_text): # pylint: disable=no-self-use """Return the OS type information from the device.""" os_type = None if version_text is None: return os_type match = re.search("(XR|XE|NX-OS)", version_text) if match: os_type = match.gro...
[ "def", "get_os_type", "(", "self", ",", "version_text", ")", ":", "# pylint: disable=no-self-use", "os_type", "=", "None", "if", "version_text", "is", "None", ":", "return", "os_type", "match", "=", "re", ".", "search", "(", "\"(XR|XE|NX-OS)\"", ",", "version_te...
Return the OS type information from the device.
[ "Return", "the", "OS", "type", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L111-L130
train
Return the OS type information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_os_version
def get_os_version(self, version_text): """Return the OS version information from the device.""" os_version = None if version_text is None: return os_version match = re.search(self.version_re, version_text, re.MULTILINE) if match: os_version = match.group(...
python
def get_os_version(self, version_text): """Return the OS version information from the device.""" os_version = None if version_text is None: return os_version match = re.search(self.version_re, version_text, re.MULTILINE) if match: os_version = match.group(...
[ "def", "get_os_version", "(", "self", ",", "version_text", ")", ":", "os_version", "=", "None", "if", "version_text", "is", "None", ":", "return", "os_version", "match", "=", "re", ".", "search", "(", "self", ".", "version_re", ",", "version_text", ",", "r...
Return the OS version information from the device.
[ "Return", "the", "OS", "version", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L132-L141
train
Return the OS version information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_hw_family
def get_hw_family(self, version_text): """Return the HW family information from the device.""" family = None if version_text is None: return family match = re.search(self.platform_re, version_text, re.MULTILINE) if match: self.platform_string = match.grou...
python
def get_hw_family(self, version_text): """Return the HW family information from the device.""" family = None if version_text is None: return family match = re.search(self.platform_re, version_text, re.MULTILINE) if match: self.platform_string = match.grou...
[ "def", "get_hw_family", "(", "self", ",", "version_text", ")", ":", "family", "=", "None", "if", "version_text", "is", "None", ":", "return", "family", "match", "=", "re", ".", "search", "(", "self", ".", "platform_re", ",", "version_text", ",", "re", "....
Return the HW family information from the device.
[ "Return", "the", "HW", "family", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L143-L163
train
Return the HW family information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.get_hw_platform
def get_hw_platform(self, udi): """Return th HW platform information from the device.""" platform = None try: pid = udi['pid'] if pid == '': self.log("Empty PID. Use the hw family from the platform string.") return self.raw_family ...
python
def get_hw_platform(self, udi): """Return th HW platform information from the device.""" platform = None try: pid = udi['pid'] if pid == '': self.log("Empty PID. Use the hw family from the platform string.") return self.raw_family ...
[ "def", "get_hw_platform", "(", "self", ",", "udi", ")", ":", "platform", "=", "None", "try", ":", "pid", "=", "udi", "[", "'pid'", "]", "if", "pid", "==", "''", ":", "self", ".", "log", "(", "\"Empty PID. Use the hw family from the platform string.\"", ")", ...
Return th HW platform information from the device.
[ "Return", "th", "HW", "platform", "information", "from", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L165-L178
train
Return th HW platform information from the device.
kstaniek/condoor
condoor/drivers/generic.py
Driver.is_console
def is_console(self, users_text): """Return if device is connected over console.""" if users_text is None: self.log("Console information not collected") return None for line in users_text.split('\n'): if '*' in line: match = re.search(self.vty...
python
def is_console(self, users_text): """Return if device is connected over console.""" if users_text is None: self.log("Console information not collected") return None for line in users_text.split('\n'): if '*' in line: match = re.search(self.vty...
[ "def", "is_console", "(", "self", ",", "users_text", ")", ":", "if", "users_text", "is", "None", ":", "self", ".", "log", "(", "\"Console information not collected\"", ")", "return", "None", "for", "line", "in", "users_text", ".", "split", "(", "'\\n'", ")",...
Return if device is connected over console.
[ "Return", "if", "device", "is", "connected", "over", "console", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L180-L199
train
Return if device is connected over console.
kstaniek/condoor
condoor/drivers/generic.py
Driver.wait_for_string
def wait_for_string(self, expected_string, timeout=60): """Wait for string FSM.""" # 0 1 2 3 events = [self.syntax_error_re, self.connection_closed_re, expected_string, self.press_return_re, ...
python
def wait_for_string(self, expected_string, timeout=60): """Wait for string FSM.""" # 0 1 2 3 events = [self.syntax_error_re, self.connection_closed_re, expected_string, self.press_return_re, ...
[ "def", "wait_for_string", "(", "self", ",", "expected_string", ",", "timeout", "=", "60", ")", ":", "# 0 1 2 3", "events", "=", "[", "self", ".", "syntax_error_re", ",", "self", ".", ...
Wait for string FSM.
[ "Wait", "for", "string", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L206-L234
train
Wait for a string FSM.
kstaniek/condoor
condoor/drivers/generic.py
Driver.reload
def reload(self, reload_timeout=300, save_config=True): """Reload the device and waits for device to boot up. It posts the informational message to the log if not implemented by device driver. """ self.log("Reload not implemented on {} platform".format(self.platform))
python
def reload(self, reload_timeout=300, save_config=True): """Reload the device and waits for device to boot up. It posts the informational message to the log if not implemented by device driver. """ self.log("Reload not implemented on {} platform".format(self.platform))
[ "def", "reload", "(", "self", ",", "reload_timeout", "=", "300", ",", "save_config", "=", "True", ")", ":", "self", ".", "log", "(", "\"Reload not implemented on {} platform\"", ".", "format", "(", "self", ".", "platform", ")", ")" ]
Reload the device and waits for device to boot up. It posts the informational message to the log if not implemented by device driver.
[ "Reload", "the", "device", "and", "waits", "for", "device", "to", "boot", "up", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L282-L287
train
Reload the device and waits for device to boot up.
kstaniek/condoor
condoor/drivers/generic.py
Driver.base_prompt
def base_prompt(self, prompt): """Extract the base prompt pattern.""" if prompt is None: return None if not self.device.is_target: return prompt pattern = pattern_manager.pattern(self.platform, "prompt_dynamic", compiled=False) pattern = pattern.format(pro...
python
def base_prompt(self, prompt): """Extract the base prompt pattern.""" if prompt is None: return None if not self.device.is_target: return prompt pattern = pattern_manager.pattern(self.platform, "prompt_dynamic", compiled=False) pattern = pattern.format(pro...
[ "def", "base_prompt", "(", "self", ",", "prompt", ")", ":", "if", "prompt", "is", "None", ":", "return", "None", "if", "not", "self", ".", "device", ".", "is_target", ":", "return", "prompt", "pattern", "=", "pattern_manager", ".", "pattern", "(", "self"...
Extract the base prompt pattern.
[ "Extract", "the", "base", "prompt", "pattern", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L293-L308
train
Extract the base prompt pattern.
kstaniek/condoor
condoor/drivers/generic.py
Driver.update_config_mode
def update_config_mode(self, prompt): # pylint: disable=no-self-use """Update config mode based on the prompt analysis.""" mode = 'global' if prompt: if 'config' in prompt: mode = 'config' elif 'admin' in prompt: mode = 'admin' se...
python
def update_config_mode(self, prompt): # pylint: disable=no-self-use """Update config mode based on the prompt analysis.""" mode = 'global' if prompt: if 'config' in prompt: mode = 'config' elif 'admin' in prompt: mode = 'admin' se...
[ "def", "update_config_mode", "(", "self", ",", "prompt", ")", ":", "# pylint: disable=no-self-use", "mode", "=", "'global'", "if", "prompt", ":", "if", "'config'", "in", "prompt", ":", "mode", "=", "'config'", "elif", "'admin'", "in", "prompt", ":", "mode", ...
Update config mode based on the prompt analysis.
[ "Update", "config", "mode", "based", "on", "the", "prompt", "analysis", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L327-L337
train
Update config mode based on the prompt analysis.
kstaniek/condoor
condoor/drivers/generic.py
Driver.update_hostname
def update_hostname(self, prompt): """Update the hostname based on the prompt analysis.""" result = re.search(self.prompt_re, prompt) if result: hostname = result.group('hostname') self.log("Hostname detected: {}".format(hostname)) else: hostname = sel...
python
def update_hostname(self, prompt): """Update the hostname based on the prompt analysis.""" result = re.search(self.prompt_re, prompt) if result: hostname = result.group('hostname') self.log("Hostname detected: {}".format(hostname)) else: hostname = sel...
[ "def", "update_hostname", "(", "self", ",", "prompt", ")", ":", "result", "=", "re", ".", "search", "(", "self", ".", "prompt_re", ",", "prompt", ")", "if", "result", ":", "hostname", "=", "result", ".", "group", "(", "'hostname'", ")", "self", ".", ...
Update the hostname based on the prompt analysis.
[ "Update", "the", "hostname", "based", "on", "the", "prompt", "analysis", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L339-L348
train
Update the hostname based on the prompt analysis.
kstaniek/condoor
condoor/drivers/generic.py
Driver.enter_plane
def enter_plane(self, plane): """Enter the device plane. Enter the device plane a.k.a. mode, i.e. admin, qnx, calvados """ try: cmd = CONF['driver'][self.platform]['planes'][plane] self.plane = plane except KeyError: cmd = None if cmd...
python
def enter_plane(self, plane): """Enter the device plane. Enter the device plane a.k.a. mode, i.e. admin, qnx, calvados """ try: cmd = CONF['driver'][self.platform]['planes'][plane] self.plane = plane except KeyError: cmd = None if cmd...
[ "def", "enter_plane", "(", "self", ",", "plane", ")", ":", "try", ":", "cmd", "=", "CONF", "[", "'driver'", "]", "[", "self", ".", "platform", "]", "[", "'planes'", "]", "[", "plane", "]", "self", ".", "plane", "=", "plane", "except", "KeyError", "...
Enter the device plane. Enter the device plane a.k.a. mode, i.e. admin, qnx, calvados
[ "Enter", "the", "device", "plane", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/generic.py#L360-L373
train
Enter the device plane.
thomasjiangcy/django-rest-mock
rest_mock_server/core/factory.py
FixtureFactory.handle_other_factory_method
def handle_other_factory_method(attr, minimum, maximum): """ This is a temporary static method, when there are more factory methods, we can move this to another class or find a way to maintain it in a scalable manner """ if attr == 'percentage': if minimum: ...
python
def handle_other_factory_method(attr, minimum, maximum): """ This is a temporary static method, when there are more factory methods, we can move this to another class or find a way to maintain it in a scalable manner """ if attr == 'percentage': if minimum: ...
[ "def", "handle_other_factory_method", "(", "attr", ",", "minimum", ",", "maximum", ")", ":", "if", "attr", "==", "'percentage'", ":", "if", "minimum", ":", "minimum", "=", "ast", ".", "literal_eval", "(", "minimum", ")", "else", ":", "minimum", "=", "0", ...
This is a temporary static method, when there are more factory methods, we can move this to another class or find a way to maintain it in a scalable manner
[ "This", "is", "a", "temporary", "static", "method", "when", "there", "are", "more", "factory", "methods", "we", "can", "move", "this", "to", "another", "class", "or", "find", "a", "way", "to", "maintain", "it", "in", "a", "scalable", "manner" ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/core/factory.py#L82-L101
train
This is a temporary static method that can be used to handle the factory methods. It is a temporary static method that can be used to handle the factory methods.
thomasjiangcy/django-rest-mock
rest_mock_server/core/factory.py
FixtureFactory._replace_faker_attr
def _replace_faker_attr(self, matchobj): """ Callable used in re.sub to match, generate and replace the valid syntax found in the mock response specifications. """ attr = matchobj.group(0).replace('<', '').replace('>', '') # Prepare template to handle quotes # Fo...
python
def _replace_faker_attr(self, matchobj): """ Callable used in re.sub to match, generate and replace the valid syntax found in the mock response specifications. """ attr = matchobj.group(0).replace('<', '').replace('>', '') # Prepare template to handle quotes # Fo...
[ "def", "_replace_faker_attr", "(", "self", ",", "matchobj", ")", ":", "attr", "=", "matchobj", ".", "group", "(", "0", ")", ".", "replace", "(", "'<'", ",", "''", ")", ".", "replace", "(", "'>'", ",", "''", ")", "# Prepare template to handle quotes", "# ...
Callable used in re.sub to match, generate and replace the valid syntax found in the mock response specifications.
[ "Callable", "used", "in", "re", ".", "sub", "to", "match", "generate", "and", "replace", "the", "valid", "syntax", "found", "in", "the", "mock", "response", "specifications", "." ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/core/factory.py#L103-L232
train
This method is used in re. sub to match the attribute of a resource attribute in the mock response.
thomasjiangcy/django-rest-mock
rest_mock_server/core/factory.py
FixtureFactory._parse_syntax
def _parse_syntax(self, raw): """ Retrieves the syntax from the response and goes through each one to generate and replace it with mock values """ raw = str(raw) # treat the value as a string regardless of its actual data type has_syntax = re.findall(r'<(\^)?(fk__)?(\w+)...
python
def _parse_syntax(self, raw): """ Retrieves the syntax from the response and goes through each one to generate and replace it with mock values """ raw = str(raw) # treat the value as a string regardless of its actual data type has_syntax = re.findall(r'<(\^)?(fk__)?(\w+)...
[ "def", "_parse_syntax", "(", "self", ",", "raw", ")", ":", "raw", "=", "str", "(", "raw", ")", "# treat the value as a string regardless of its actual data type", "has_syntax", "=", "re", ".", "findall", "(", "r'<(\\^)?(fk__)?(\\w+)?([0-9]*[.]?[0-9]+?)?(\\:)?([0-9]*[.]?[0-9...
Retrieves the syntax from the response and goes through each one to generate and replace it with mock values
[ "Retrieves", "the", "syntax", "from", "the", "response", "and", "goes", "through", "each", "one", "to", "generate", "and", "replace", "it", "with", "mock", "values" ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/core/factory.py#L234-L256
train
Parses the syntax from the response and returns the value as a string.
thomasjiangcy/django-rest-mock
rest_mock_server/core/factory.py
FixtureFactory.count
def count(self, source, target): """ The 'count' relationship is used for listing endpoints where a specific attribute might hold the value to the number of instances of another attribute. """ try: source_value = self._response_holder[source] except KeyError: ...
python
def count(self, source, target): """ The 'count' relationship is used for listing endpoints where a specific attribute might hold the value to the number of instances of another attribute. """ try: source_value = self._response_holder[source] except KeyError: ...
[ "def", "count", "(", "self", ",", "source", ",", "target", ")", ":", "try", ":", "source_value", "=", "self", ".", "_response_holder", "[", "source", "]", "except", "KeyError", ":", "# Source value hasn't been determined yet, we need", "# to generate the source value ...
The 'count' relationship is used for listing endpoints where a specific attribute might hold the value to the number of instances of another attribute.
[ "The", "count", "relationship", "is", "used", "for", "listing", "endpoints", "where", "a", "specific", "attribute", "might", "hold", "the", "value", "to", "the", "number", "of", "instances", "of", "another", "attribute", "." ]
09e91de20d1a5efd5c47c6e3d7fe979443012e2c
https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/core/factory.py#L262-L294
train
Count the number of instances of another attribute in the store.
kstaniek/condoor
condoor/protocols/ssh.py
SSH.get_command
def get_command(self, version=2): """Return the SSH protocol specific command to connect.""" try: options = _C['options'] options_str = " -o ".join(options) if options_str: options_str = "-o " + options_str + " " except KeyError: op...
python
def get_command(self, version=2): """Return the SSH protocol specific command to connect.""" try: options = _C['options'] options_str = " -o ".join(options) if options_str: options_str = "-o " + options_str + " " except KeyError: op...
[ "def", "get_command", "(", "self", ",", "version", "=", "2", ")", ":", "try", ":", "options", "=", "_C", "[", "'options'", "]", "options_str", "=", "\" -o \"", ".", "join", "(", "options", ")", "if", "options_str", ":", "options_str", "=", "\"-o \"", "...
Return the SSH protocol specific command to connect.
[ "Return", "the", "SSH", "protocol", "specific", "command", "to", "connect", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L32-L52
train
Return the SSH protocol specific command to connect to the specified version.
kstaniek/condoor
condoor/protocols/ssh.py
SSH.connect
def connect(self, driver): """Connect using the SSH protocol specific FSM.""" # 0 1 2 events = [driver.password_re, self.device.prompt_re, driver.unable_to_connect_re, # 3 4 5 6 ...
python
def connect(self, driver): """Connect using the SSH protocol specific FSM.""" # 0 1 2 events = [driver.password_re, self.device.prompt_re, driver.unable_to_connect_re, # 3 4 5 6 ...
[ "def", "connect", "(", "self", ",", "driver", ")", ":", "# 0 1 2", "events", "=", "[", "driver", ".", "password_re", ",", "self", ".", "device", ".", "prompt_re", ",", "driver", ".", "unable_to_connect_re", ","...
Connect using the SSH protocol specific FSM.
[ "Connect", "using", "the", "SSH", "protocol", "specific", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L54-L83
train
Connect using the SSH protocol specific FSM.
kstaniek/condoor
condoor/protocols/ssh.py
SSH.authenticate
def authenticate(self, driver): """Authenticate using the SSH protocol specific FSM.""" # 0 1 2 3 events = [driver.press_return_re, driver.password_re, self.device.prompt_re, pexpect.TIMEOUT] transitions = [ ...
python
def authenticate(self, driver): """Authenticate using the SSH protocol specific FSM.""" # 0 1 2 3 events = [driver.press_return_re, driver.password_re, self.device.prompt_re, pexpect.TIMEOUT] transitions = [ ...
[ "def", "authenticate", "(", "self", ",", "driver", ")", ":", "# 0 1 2 3", "events", "=", "[", "driver", ".", "press_return_re", ",", "driver", ".", "password_re", ",", "self", ".", "device", ".", "pr...
Authenticate using the SSH protocol specific FSM.
[ "Authenticate", "using", "the", "SSH", "protocol", "specific", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L85-L102
train
Authenticate using the SSH protocol specific FSM.
kstaniek/condoor
condoor/protocols/ssh.py
SSH.disconnect
def disconnect(self, driver): """Disconnect using the protocol specific method.""" self.log("SSH disconnect") try: self.device.ctrl.sendline('\x03') self.device.ctrl.sendline('\x04') except OSError: self.log("Protocol already disconnected")
python
def disconnect(self, driver): """Disconnect using the protocol specific method.""" self.log("SSH disconnect") try: self.device.ctrl.sendline('\x03') self.device.ctrl.sendline('\x04') except OSError: self.log("Protocol already disconnected")
[ "def", "disconnect", "(", "self", ",", "driver", ")", ":", "self", ".", "log", "(", "\"SSH disconnect\"", ")", "try", ":", "self", ".", "device", ".", "ctrl", ".", "sendline", "(", "'\\x03'", ")", "self", ".", "device", ".", "ctrl", ".", "sendline", ...
Disconnect using the protocol specific method.
[ "Disconnect", "using", "the", "protocol", "specific", "method", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L104-L111
train
Disconnect using the protocol specific method.
kstaniek/condoor
condoor/protocols/ssh.py
SSH.fallback_to_sshv1
def fallback_to_sshv1(self, ctx): """Fallback to SSHv1.""" command = self.get_command(version=1) ctx.spawn_session(command) return True
python
def fallback_to_sshv1(self, ctx): """Fallback to SSHv1.""" command = self.get_command(version=1) ctx.spawn_session(command) return True
[ "def", "fallback_to_sshv1", "(", "self", ",", "ctx", ")", ":", "command", "=", "self", ".", "get_command", "(", "version", "=", "1", ")", "ctx", ".", "spawn_session", "(", "command", ")", "return", "True" ]
Fallback to SSHv1.
[ "Fallback", "to", "SSHv1", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/ssh.py#L115-L119
train
Fallback to SSHv1.
kstaniek/condoor
condoor/drivers/XE.py
Driver.reload
def reload(self, reload_timeout=300, save_config=True): """Reload the device. CSM_DUT#reload System configuration has been modified. Save? [yes/no]: yes Building configuration... [OK] Proceed with reload? [confirm] """ SAVE_CONFIG = re.compile(re.escape(...
python
def reload(self, reload_timeout=300, save_config=True): """Reload the device. CSM_DUT#reload System configuration has been modified. Save? [yes/no]: yes Building configuration... [OK] Proceed with reload? [confirm] """ SAVE_CONFIG = re.compile(re.escape(...
[ "def", "reload", "(", "self", ",", "reload_timeout", "=", "300", ",", "save_config", "=", "True", ")", ":", "SAVE_CONFIG", "=", "re", ".", "compile", "(", "re", ".", "escape", "(", "\"System configuration has been modified. Save? [yes/no]: \"", ")", ")", "PROCEE...
Reload the device. CSM_DUT#reload System configuration has been modified. Save? [yes/no]: yes Building configuration... [OK] Proceed with reload? [confirm]
[ "Reload", "the", "device", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/XE.py#L34-L73
train
Reload the device.
rs/domcheck
domcheck/strategies.py
check_dns_txt
def check_dns_txt(domain, prefix, code): """ Validates a domain by checking that {prefix}={code} is present in the TXT DNS record of the domain to check. Returns true if verification suceeded. """ token = '{}={}'.format(prefix, code) try: for rr in dns.resolver.query(domain, 'TXT'):...
python
def check_dns_txt(domain, prefix, code): """ Validates a domain by checking that {prefix}={code} is present in the TXT DNS record of the domain to check. Returns true if verification suceeded. """ token = '{}={}'.format(prefix, code) try: for rr in dns.resolver.query(domain, 'TXT'):...
[ "def", "check_dns_txt", "(", "domain", ",", "prefix", ",", "code", ")", ":", "token", "=", "'{}={}'", ".", "format", "(", "prefix", ",", "code", ")", "try", ":", "for", "rr", "in", "dns", ".", "resolver", ".", "query", "(", "domain", ",", "'TXT'", ...
Validates a domain by checking that {prefix}={code} is present in the TXT DNS record of the domain to check. Returns true if verification suceeded.
[ "Validates", "a", "domain", "by", "checking", "that", "{", "prefix", "}", "=", "{", "code", "}", "is", "present", "in", "the", "TXT", "DNS", "record", "of", "the", "domain", "to", "check", "." ]
43e10c345320564a1236778e8577e2b8ef825925
https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/strategies.py#L16-L30
train
Checks if a domain is present in the TXT DNS record . Returns True if verification suceeded False otherwise.
rs/domcheck
domcheck/strategies.py
check_dns_cname
def check_dns_cname(domain, prefix, code): """ Validates a domain by checking the existance of the CNAME record on the domain as: {prefix}-{code}.{domain} pointing to a domain (usually yours) which the host is {prefix} (i.e.: {prefix}.yourdomain.com). Returns true if verification suceeded. """ ...
python
def check_dns_cname(domain, prefix, code): """ Validates a domain by checking the existance of the CNAME record on the domain as: {prefix}-{code}.{domain} pointing to a domain (usually yours) which the host is {prefix} (i.e.: {prefix}.yourdomain.com). Returns true if verification suceeded. """ ...
[ "def", "check_dns_cname", "(", "domain", ",", "prefix", ",", "code", ")", ":", "fqdn", "=", "'{}-{}.{}'", ".", "format", "(", "prefix", ",", "code", ",", "domain", ")", "try", ":", "for", "rr", "in", "dns", ".", "resolver", ".", "query", "(", "fqdn",...
Validates a domain by checking the existance of the CNAME record on the domain as: {prefix}-{code}.{domain} pointing to a domain (usually yours) which the host is {prefix} (i.e.: {prefix}.yourdomain.com). Returns true if verification suceeded.
[ "Validates", "a", "domain", "by", "checking", "the", "existance", "of", "the", "CNAME", "record", "on", "the", "domain", "as", ":", "{", "prefix", "}", "-", "{", "code", "}", ".", "{", "domain", "}", "pointing", "to", "a", "domain", "(", "usually", "...
43e10c345320564a1236778e8577e2b8ef825925
https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/strategies.py#L33-L48
train
Checks if a domain is a valid CNAME record.
rs/domcheck
domcheck/strategies.py
search_meta_tag
def search_meta_tag(html_doc, prefix, code): """ Checks whether the html_doc contains a meta matching the prefix & code """ regex = '<meta\s+(?:name=([\'\"]){0}\\1\s+content=([\'\"]){1}\\2|content=([\'\"]){1}\\3\s+name=([\'\"]){0}\\4)\s*/?>'.format(prefix, code) meta = re.compile(regex, flags=re.MUL...
python
def search_meta_tag(html_doc, prefix, code): """ Checks whether the html_doc contains a meta matching the prefix & code """ regex = '<meta\s+(?:name=([\'\"]){0}\\1\s+content=([\'\"]){1}\\2|content=([\'\"]){1}\\3\s+name=([\'\"]){0}\\4)\s*/?>'.format(prefix, code) meta = re.compile(regex, flags=re.MUL...
[ "def", "search_meta_tag", "(", "html_doc", ",", "prefix", ",", "code", ")", ":", "regex", "=", "'<meta\\s+(?:name=([\\'\\\"]){0}\\\\1\\s+content=([\\'\\\"]){1}\\\\2|content=([\\'\\\"]){1}\\\\3\\s+name=([\\'\\\"]){0}\\\\4)\\s*/?>'", ".", "format", "(", "prefix", ",", "code", ")"...
Checks whether the html_doc contains a meta matching the prefix & code
[ "Checks", "whether", "the", "html_doc", "contains", "a", "meta", "matching", "the", "prefix", "&", "code" ]
43e10c345320564a1236778e8577e2b8ef825925
https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/strategies.py#L51-L62
train
Checks whether the html_doc contains a meta matching the prefix & code.
rs/domcheck
domcheck/strategies.py
check_meta_tag
def check_meta_tag(domain, prefix, code): """ Validates a domain by checking the existance of a <meta name="{prefix}" content="{code}"> tag in the <head> of the home page of the domain using either HTTP or HTTPs protocols. Returns true if verification suceeded. """ url = '://{}'.format(domain) ...
python
def check_meta_tag(domain, prefix, code): """ Validates a domain by checking the existance of a <meta name="{prefix}" content="{code}"> tag in the <head> of the home page of the domain using either HTTP or HTTPs protocols. Returns true if verification suceeded. """ url = '://{}'.format(domain) ...
[ "def", "check_meta_tag", "(", "domain", ",", "prefix", ",", "code", ")", ":", "url", "=", "'://{}'", ".", "format", "(", "domain", ")", "for", "proto", "in", "(", "'http'", ",", "'https'", ")", ":", "try", ":", "req", "=", "Request", "(", "proto", ...
Validates a domain by checking the existance of a <meta name="{prefix}" content="{code}"> tag in the <head> of the home page of the domain using either HTTP or HTTPs protocols. Returns true if verification suceeded.
[ "Validates", "a", "domain", "by", "checking", "the", "existance", "of", "a", "<meta", "name", "=", "{", "prefix", "}", "content", "=", "{", "code", "}", ">", "tag", "in", "the", "<head", ">", "of", "the", "home", "page", "of", "the", "domain", "using...
43e10c345320564a1236778e8577e2b8ef825925
https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/strategies.py#L65-L86
train
Checks if a domain has a meta tag with the given prefix and code.
AmanoTeam/amanobot
amanobot/__init__.py
Bot.sendDocument
def sendDocument(self, chat_id, document, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): """ See: https://cor...
python
def sendDocument(self, chat_id, document, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None): """ See: https://cor...
[ "def", "sendDocument", "(", "self", ",", "chat_id", ",", "document", ",", "thumb", "=", "None", ",", "caption", "=", "None", ",", "parse_mode", "=", "None", ",", "disable_notification", "=", "None", ",", "reply_to_message_id", "=", "None", ",", "reply_markup...
See: https://core.telegram.org/bots/api#senddocument :param document: Same as ``photo`` in :meth:`amanobot.Bot.sendPhoto`
[ "See", ":", "https", ":", "//", "core", ".", "telegram", ".", "org", "/", "bots", "/", "api#senddocument" ]
fe546e2e294eec88e637da0b2567c7e7e8662437
https://github.com/AmanoTeam/amanobot/blob/fe546e2e294eec88e637da0b2567c7e7e8662437/amanobot/__init__.py#L564-L577
train
Send a document to the specified chat.
AmanoTeam/amanobot
amanobot/__init__.py
Bot.sendVideo
def sendVideo(self, chat_id, video, duration=None, width=None, height=None, thumb=None, caption=None, parse_mode=None, supports_streaming=None, disable_notification=None, ...
python
def sendVideo(self, chat_id, video, duration=None, width=None, height=None, thumb=None, caption=None, parse_mode=None, supports_streaming=None, disable_notification=None, ...
[ "def", "sendVideo", "(", "self", ",", "chat_id", ",", "video", ",", "duration", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ",", "thumb", "=", "None", ",", "caption", "=", "None", ",", "parse_mode", "=", "None", ",", "supports...
See: https://core.telegram.org/bots/api#sendvideo :param video: Same as ``photo`` in :meth:`amanobot.Bot.sendPhoto`
[ "See", ":", "https", ":", "//", "core", ".", "telegram", ".", "org", "/", "bots", "/", "api#sendvideo" ]
fe546e2e294eec88e637da0b2567c7e7e8662437
https://github.com/AmanoTeam/amanobot/blob/fe546e2e294eec88e637da0b2567c7e7e8662437/amanobot/__init__.py#L579-L596
train
Send a video.
AmanoTeam/amanobot
amanobot/__init__.py
Bot.stopPoll
def stopPoll(self, msg_identifier, reply_markup=None): """ See: https://core.telegram.org/bots/api#stoppoll :param msg_identifier: a 2-tuple (``chat_id``, ``message_id``), a 1-tuple (``inline_message_id``), or simply ``inline_message_id``. ...
python
def stopPoll(self, msg_identifier, reply_markup=None): """ See: https://core.telegram.org/bots/api#stoppoll :param msg_identifier: a 2-tuple (``chat_id``, ``message_id``), a 1-tuple (``inline_message_id``), or simply ``inline_message_id``. ...
[ "def", "stopPoll", "(", "self", ",", "msg_identifier", ",", "reply_markup", "=", "None", ")", ":", "p", "=", "_strip", "(", "locals", "(", ")", ",", "more", "=", "[", "'msg_identifier'", "]", ")", "p", ".", "update", "(", "_dismantle_message_identifier", ...
See: https://core.telegram.org/bots/api#stoppoll :param msg_identifier: a 2-tuple (``chat_id``, ``message_id``), a 1-tuple (``inline_message_id``), or simply ``inline_message_id``. You may extract this value easily with :meth:`amanobot.message_identifier`
[ "See", ":", "https", ":", "//", "core", ".", "telegram", ".", "org", "/", "bots", "/", "api#stoppoll" ]
fe546e2e294eec88e637da0b2567c7e7e8662437
https://github.com/AmanoTeam/amanobot/blob/fe546e2e294eec88e637da0b2567c7e7e8662437/amanobot/__init__.py#L962-L975
train
Stop a poll for a specific message.
AmanoTeam/amanobot
amanobot/__init__.py
Bot.message_loop
def message_loop(self, callback=None, relax=0.1, timeout=20, allowed_updates=None, source=None, ordered=True, maxhold=3, run_forever=False): """ :deprecated: will be removed in future. Use :class:`.MessageLoop` instead. Spawn a thre...
python
def message_loop(self, callback=None, relax=0.1, timeout=20, allowed_updates=None, source=None, ordered=True, maxhold=3, run_forever=False): """ :deprecated: will be removed in future. Use :class:`.MessageLoop` instead. Spawn a thre...
[ "def", "message_loop", "(", "self", ",", "callback", "=", "None", ",", "relax", "=", "0.1", ",", "timeout", "=", "20", ",", "allowed_updates", "=", "None", ",", "source", "=", "None", ",", "ordered", "=", "True", ",", "maxhold", "=", "3", ",", "run_f...
:deprecated: will be removed in future. Use :class:`.MessageLoop` instead. Spawn a thread to constantly ``getUpdates`` or pull updates from a queue. Apply ``callback`` to every message received. Also starts the scheduler thread for internal events. :param callback: a functi...
[ ":", "deprecated", ":", "will", "be", "removed", "in", "future", ".", "Use", ":", "class", ":", ".", "MessageLoop", "instead", "." ]
fe546e2e294eec88e637da0b2567c7e7e8662437
https://github.com/AmanoTeam/amanobot/blob/fe546e2e294eec88e637da0b2567c7e7e8662437/amanobot/__init__.py#L1133-L1406
train
This method is used to run a message loop.