repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
lsst-sqre/documenteer
documenteer/stackdocs/build.py
remove_existing_links
def remove_existing_links(root_dir): """Delete any symlinks present at the root of a directory. Parameters ---------- root_dir : `str` Directory that might contain symlinks. Notes ----- This function is used to remove any symlinks created by `link_directories`. Running ``remove...
python
def remove_existing_links(root_dir): """Delete any symlinks present at the root of a directory. Parameters ---------- root_dir : `str` Directory that might contain symlinks. Notes ----- This function is used to remove any symlinks created by `link_directories`. Running ``remove...
[ "def", "remove_existing_links", "(", "root_dir", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "for", "name", "in", "os", ".", "listdir", "(", "root_dir", ")", ":", "full_name", "=", "os", ".", "path", ".", "join", "(", "r...
Delete any symlinks present at the root of a directory. Parameters ---------- root_dir : `str` Directory that might contain symlinks. Notes ----- This function is used to remove any symlinks created by `link_directories`. Running ``remove_existing_links`` at the beginning of a buil...
[ "Delete", "any", "symlinks", "present", "at", "the", "root", "of", "a", "directory", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L434-L455
train
ehansis/ozelot
ozelot/orm/base.py
render_diagram
def render_diagram(out_base): """Render a data model diagram Included in the diagram are all classes from the model registry. For your project, write a small script that imports all models that you would like to have included and then calls this function. .. note:: This function requires the 'dot'...
python
def render_diagram(out_base): """Render a data model diagram Included in the diagram are all classes from the model registry. For your project, write a small script that imports all models that you would like to have included and then calls this function. .. note:: This function requires the 'dot'...
[ "def", "render_diagram", "(", "out_base", ")", ":", "import", "codecs", "import", "subprocess", "import", "sadisplay", "desc", "=", "sadisplay", ".", "describe", "(", "list", "(", "model_registry", ".", "values", "(", ")", ")", ",", "show_methods", "=", "Fal...
Render a data model diagram Included in the diagram are all classes from the model registry. For your project, write a small script that imports all models that you would like to have included and then calls this function. .. note:: This function requires the 'dot' executable from the GraphViz package...
[ "Render", "a", "data", "model", "diagram" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/orm/base.py#L187-L228
train
ehansis/ozelot
ozelot/orm/base.py
ExtendedBase.get_max_id
def get_max_id(cls, session): """Get the current max value of the ``id`` column. When creating and storing ORM objects in bulk, :mod:`sqlalchemy` does not automatically generate an incrementing primary key ``id``. To do this manually, one needs to know the current max ``id``. For ORM ob...
python
def get_max_id(cls, session): """Get the current max value of the ``id`` column. When creating and storing ORM objects in bulk, :mod:`sqlalchemy` does not automatically generate an incrementing primary key ``id``. To do this manually, one needs to know the current max ``id``. For ORM ob...
[ "def", "get_max_id", "(", "cls", ",", "session", ")", ":", "id_base", "=", "None", "for", "c", "in", "[", "cls", "]", "+", "list", "(", "cls", ".", "__bases__", ")", ":", "for", "base_class", "in", "c", ".", "__bases__", ":", "if", "base_class", "....
Get the current max value of the ``id`` column. When creating and storing ORM objects in bulk, :mod:`sqlalchemy` does not automatically generate an incrementing primary key ``id``. To do this manually, one needs to know the current max ``id``. For ORM object classes that are derived from other ...
[ "Get", "the", "current", "max", "value", "of", "the", "id", "column", "." ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/orm/base.py#L112-L146
train
ehansis/ozelot
ozelot/orm/base.py
ExtendedBase.truncate_to_field_length
def truncate_to_field_length(self, field, value): """Truncate the value of a string field to the field's max length. Use this in a validator to check/truncate values before inserting them into the database. Copy the below example code after ``@validates`` to your model class and replace ``field...
python
def truncate_to_field_length(self, field, value): """Truncate the value of a string field to the field's max length. Use this in a validator to check/truncate values before inserting them into the database. Copy the below example code after ``@validates`` to your model class and replace ``field...
[ "def", "truncate_to_field_length", "(", "self", ",", "field", ",", "value", ")", ":", "max_len", "=", "getattr", "(", "self", ".", "__class__", ",", "field", ")", ".", "prop", ".", "columns", "[", "0", "]", ".", "type", ".", "length", "if", "value", ...
Truncate the value of a string field to the field's max length. Use this in a validator to check/truncate values before inserting them into the database. Copy the below example code after ``@validates`` to your model class and replace ``field1`` and ``field2`` with your field name(s). ...
[ "Truncate", "the", "value", "of", "a", "string", "field", "to", "the", "field", "s", "max", "length", "." ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/orm/base.py#L148-L181
train
untwisted/untwisted
untwisted/tkinter.py
extern
def extern(obj, timeout=200): """ Tell Tkinter to process untnwisted event loop. It registers just once the update handle. """ global installed # Register it just once. if not installed: install_hook(obj, timeout) installed = True
python
def extern(obj, timeout=200): """ Tell Tkinter to process untnwisted event loop. It registers just once the update handle. """ global installed # Register it just once. if not installed: install_hook(obj, timeout) installed = True
[ "def", "extern", "(", "obj", ",", "timeout", "=", "200", ")", ":", "global", "installed", "if", "not", "installed", ":", "install_hook", "(", "obj", ",", "timeout", ")", "installed", "=", "True" ]
Tell Tkinter to process untnwisted event loop. It registers just once the update handle.
[ "Tell", "Tkinter", "to", "process", "untnwisted", "event", "loop", ".", "It", "registers", "just", "once", "the", "update", "handle", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/tkinter.py#L15-L25
train
untwisted/untwisted
untwisted/tkinter.py
intern
def intern(obj, timeout): """ Tell untwisted to process an extern event loop. """ core.gear.timeout = timeout core.gear.pool.append(obj)
python
def intern(obj, timeout): """ Tell untwisted to process an extern event loop. """ core.gear.timeout = timeout core.gear.pool.append(obj)
[ "def", "intern", "(", "obj", ",", "timeout", ")", ":", "core", ".", "gear", ".", "timeout", "=", "timeout", "core", ".", "gear", ".", "pool", ".", "append", "(", "obj", ")" ]
Tell untwisted to process an extern event loop.
[ "Tell", "untwisted", "to", "process", "an", "extern", "event", "loop", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/tkinter.py#L27-L34
train
lsst-sqre/documenteer
documenteer/sphinxext/jira.py
_make_ticket_node
def _make_ticket_node(ticket_id, config, options=None): """Construct a reference node for a JIRA ticket.""" options = options or {} ref = config.jira_uri_template.format(ticket=ticket_id) link = nodes.reference(text=ticket_id, refuri=ref, **options) return link
python
def _make_ticket_node(ticket_id, config, options=None): """Construct a reference node for a JIRA ticket.""" options = options or {} ref = config.jira_uri_template.format(ticket=ticket_id) link = nodes.reference(text=ticket_id, refuri=ref, **options) return link
[ "def", "_make_ticket_node", "(", "ticket_id", ",", "config", ",", "options", "=", "None", ")", ":", "options", "=", "options", "or", "{", "}", "ref", "=", "config", ".", "jira_uri_template", ".", "format", "(", "ticket", "=", "ticket_id", ")", "link", "=...
Construct a reference node for a JIRA ticket.
[ "Construct", "a", "reference", "node", "for", "a", "JIRA", "ticket", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/jira.py#L16-L21
train
lsst-sqre/documenteer
documenteer/sphinxext/jira.py
_oxford_comma_separator
def _oxford_comma_separator(i, length): """Make a separator for a prose-like list with `,` between items except for `, and` after the second to last item. """ if length == 1: return None elif length < 3 and i == 0: return ' and ' elif i < length - 2: return ', ' elif ...
python
def _oxford_comma_separator(i, length): """Make a separator for a prose-like list with `,` between items except for `, and` after the second to last item. """ if length == 1: return None elif length < 3 and i == 0: return ' and ' elif i < length - 2: return ', ' elif ...
[ "def", "_oxford_comma_separator", "(", "i", ",", "length", ")", ":", "if", "length", "==", "1", ":", "return", "None", "elif", "length", "<", "3", "and", "i", "==", "0", ":", "return", "' and '", "elif", "i", "<", "length", "-", "2", ":", "return", ...
Make a separator for a prose-like list with `,` between items except for `, and` after the second to last item.
[ "Make", "a", "separator", "for", "a", "prose", "-", "like", "list", "with", "between", "items", "except", "for", "and", "after", "the", "second", "to", "last", "item", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/jira.py#L37-L50
train
lsst-sqre/documenteer
documenteer/sphinxext/jira.py
jira_role
def jira_role(name, rawtext, text, lineno, inliner, options=None, content=None, oxford_comma=True): """Sphinx role for referencing a JIRA ticket. Examples:: :jira:`DM-6181` -> DM-6181 :jira:`DM-6181,DM-6181` -> DM-6180 and DM-6181 :jira:`DM-6181,DM-6181,DM-6182` -> DM-618...
python
def jira_role(name, rawtext, text, lineno, inliner, options=None, content=None, oxford_comma=True): """Sphinx role for referencing a JIRA ticket. Examples:: :jira:`DM-6181` -> DM-6181 :jira:`DM-6181,DM-6181` -> DM-6180 and DM-6181 :jira:`DM-6181,DM-6181,DM-6182` -> DM-618...
[ "def", "jira_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ",", "oxford_comma", "=", "True", ")", ":", "options", "=", "options", "or", "{", "}", "content", "...
Sphinx role for referencing a JIRA ticket. Examples:: :jira:`DM-6181` -> DM-6181 :jira:`DM-6181,DM-6181` -> DM-6180 and DM-6181 :jira:`DM-6181,DM-6181,DM-6182` -> DM-6180, DM-6181, and DM-6182
[ "Sphinx", "role", "for", "referencing", "a", "JIRA", "ticket", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/jira.py#L53-L83
train
lsst-sqre/documenteer
documenteer/sphinxext/jira.py
jira_bracket_role
def jira_bracket_role(name, rawtext, text, lineno, inliner, options=None, content=None, open_symbol='[', close_symbol=']'): """Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in braces. Useful for changelogs. Examples:: :jirab:`DM-...
python
def jira_bracket_role(name, rawtext, text, lineno, inliner, options=None, content=None, open_symbol='[', close_symbol=']'): """Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in braces. Useful for changelogs. Examples:: :jirab:`DM-...
[ "def", "jira_bracket_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ",", "open_symbol", "=", "'['", ",", "close_symbol", "=", "']'", ")", ":", "node_list", ",", ...
Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in braces. Useful for changelogs. Examples:: :jirab:`DM-6181` -> [DM-6181] :jirab:`DM-6181,DM-6181` -> [DM-6180, DM-6181] :jirab:`DM-6181,DM-6181,DM-6182` -> [DM-6180, DM-6181, DM-6182]
[ "Sphinx", "role", "for", "referencing", "a", "JIRA", "ticket", "with", "ticket", "numbers", "enclosed", "in", "braces", ".", "Useful", "for", "changelogs", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/jira.py#L86-L102
train
lsst-sqre/documenteer
documenteer/sphinxext/jira.py
jira_parens_role
def jira_parens_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in parentheses. Useful for changelogs. Examples:: :jirap:`DM-6181` -> (DM-6181) :jirap:`DM-6181,DM-6181` ->...
python
def jira_parens_role(name, rawtext, text, lineno, inliner, options=None, content=None): """Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in parentheses. Useful for changelogs. Examples:: :jirap:`DM-6181` -> (DM-6181) :jirap:`DM-6181,DM-6181` ->...
[ "def", "jira_parens_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "return", "jira_bracket_role", "(", "name", ",", "rawtext", ",", "text", ",", "lineno"...
Sphinx role for referencing a JIRA ticket with ticket numbers enclosed in parentheses. Useful for changelogs. Examples:: :jirap:`DM-6181` -> (DM-6181) :jirap:`DM-6181,DM-6181` -> (DM-6180, DM-6181) :jirap:`DM-6181,DM-6181,DM-6182` -> (DM-6180, DM-6181, DM-6182)
[ "Sphinx", "role", "for", "referencing", "a", "JIRA", "ticket", "with", "ticket", "numbers", "enclosed", "in", "parentheses", ".", "Useful", "for", "changelogs", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/jira.py#L105-L118
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyDataBase._method_call
def _method_call(self, method, category, **kwargs): """ Call API method. Generate request. Parse response. Process errors `method` str API method url for request. Contains parameters `params` dict parameters for method url """ session = requests.Session() try: ...
python
def _method_call(self, method, category, **kwargs): """ Call API method. Generate request. Parse response. Process errors `method` str API method url for request. Contains parameters `params` dict parameters for method url """ session = requests.Session() try: ...
[ "def", "_method_call", "(", "self", ",", "method", ",", "category", ",", "**", "kwargs", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "try", ":", "response", "=", "session", ".", "get", "(", "\"http://\"", "+", "self", ".", "_api_add...
Call API method. Generate request. Parse response. Process errors `method` str API method url for request. Contains parameters `params` dict parameters for method url
[ "Call", "API", "method", ".", "Generate", "request", ".", "Parse", "response", ".", "Process", "errors", "method", "str", "API", "method", "url", "for", "request", ".", "Contains", "parameters", "params", "dict", "parameters", "for", "method", "url" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L38-L70
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_projected_player_game_stats_by_player
def get_projected_player_game_stats_by_player(self, season, week, player_id): """ Projected Player Game Stats by Player """ result = self._method_call("PlayerGameProjectionStatsByPlayerID/{season}/{week}/{player_id}", "projections", season=season, week=week, player_id=player_id) ...
python
def get_projected_player_game_stats_by_player(self, season, week, player_id): """ Projected Player Game Stats by Player """ result = self._method_call("PlayerGameProjectionStatsByPlayerID/{season}/{week}/{player_id}", "projections", season=season, week=week, player_id=player_id) ...
[ "def", "get_projected_player_game_stats_by_player", "(", "self", ",", "season", ",", "week", ",", "player_id", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"PlayerGameProjectionStatsByPlayerID/{season}/{week}/{player_id}\"", ",", "\"projections\"", ",", "s...
Projected Player Game Stats by Player
[ "Projected", "Player", "Game", "Stats", "by", "Player" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L161-L166
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_projected_player_game_stats_by_team
def get_projected_player_game_stats_by_team(self, season, week, team_id): """ Projected Player Game Stats by Team """ result = self._method_call("PlayerGameProjectionStatsByTeam/{season}/{week}/{team_id}", "projections", season=season, week=week, team_id=team_id) return result
python
def get_projected_player_game_stats_by_team(self, season, week, team_id): """ Projected Player Game Stats by Team """ result = self._method_call("PlayerGameProjectionStatsByTeam/{season}/{week}/{team_id}", "projections", season=season, week=week, team_id=team_id) return result
[ "def", "get_projected_player_game_stats_by_team", "(", "self", ",", "season", ",", "week", ",", "team_id", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"PlayerGameProjectionStatsByTeam/{season}/{week}/{team_id}\"", ",", "\"projections\"", ",", "season", ...
Projected Player Game Stats by Team
[ "Projected", "Player", "Game", "Stats", "by", "Team" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L168-L173
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_projected_player_game_stats_by_week
def get_projected_player_game_stats_by_week(self, season, week): """ Projected Player Game Stats by Week """ result = self._method_call("PlayerGameProjectionStatsByWeek/{season}/{week}", "projections", season=season, week=week) return result
python
def get_projected_player_game_stats_by_week(self, season, week): """ Projected Player Game Stats by Week """ result = self._method_call("PlayerGameProjectionStatsByWeek/{season}/{week}", "projections", season=season, week=week) return result
[ "def", "get_projected_player_game_stats_by_week", "(", "self", ",", "season", ",", "week", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"PlayerGameProjectionStatsByWeek/{season}/{week}\"", ",", "\"projections\"", ",", "season", "=", "season", ",", "wee...
Projected Player Game Stats by Week
[ "Projected", "Player", "Game", "Stats", "by", "Week" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L175-L180
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_projected_fantasy_defense_game_stats_by_week
def get_projected_fantasy_defense_game_stats_by_week(self, season, week): """ Projected Fantasy Defense Game Stats by Week """ result = self._method_call("FantasyDefenseProjectionsByGame/{season}/{week}", "projections", season=season, week=week) return result
python
def get_projected_fantasy_defense_game_stats_by_week(self, season, week): """ Projected Fantasy Defense Game Stats by Week """ result = self._method_call("FantasyDefenseProjectionsByGame/{season}/{week}", "projections", season=season, week=week) return result
[ "def", "get_projected_fantasy_defense_game_stats_by_week", "(", "self", ",", "season", ",", "week", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"FantasyDefenseProjectionsByGame/{season}/{week}\"", ",", "\"projections\"", ",", "season", "=", "season", ",...
Projected Fantasy Defense Game Stats by Week
[ "Projected", "Fantasy", "Defense", "Game", "Stats", "by", "Week" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L182-L187
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_injuries
def get_injuries(self, season, week): """ Injuries by week """ result = self._method_call("Injuries/{season}/{week}", "stats", season=season, week=week) return result
python
def get_injuries(self, season, week): """ Injuries by week """ result = self._method_call("Injuries/{season}/{week}", "stats", season=season, week=week) return result
[ "def", "get_injuries", "(", "self", ",", "season", ",", "week", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"Injuries/{season}/{week}\"", ",", "\"stats\"", ",", "season", "=", "season", ",", "week", "=", "week", ")", "return", "result" ]
Injuries by week
[ "Injuries", "by", "week" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L232-L237
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_injuries_by_team
def get_injuries_by_team(self, season, week, team_id): """ Injuries by week and team """ result = self._method_call("Injuries/{season}/{week}/{team_id}", "stats", season=season, week=week, team_id=team_id) return result
python
def get_injuries_by_team(self, season, week, team_id): """ Injuries by week and team """ result = self._method_call("Injuries/{season}/{week}/{team_id}", "stats", season=season, week=week, team_id=team_id) return result
[ "def", "get_injuries_by_team", "(", "self", ",", "season", ",", "week", ",", "team_id", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"Injuries/{season}/{week}/{team_id}\"", ",", "\"stats\"", ",", "season", "=", "season", ",", "week", "=", "week...
Injuries by week and team
[ "Injuries", "by", "week", "and", "team" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L239-L244
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
FantasyData.get_box_score_by_team
def get_box_score_by_team(self, season, week, team_id): """ Box score by week and team """ result = self._method_call("BoxScoreV3/{season}/{week}/{team_id}", "stats", season=season, week=week, team_id=team_id) return result
python
def get_box_score_by_team(self, season, week, team_id): """ Box score by week and team """ result = self._method_call("BoxScoreV3/{season}/{week}/{team_id}", "stats", season=season, week=week, team_id=team_id) return result
[ "def", "get_box_score_by_team", "(", "self", ",", "season", ",", "week", ",", "team_id", ")", ":", "result", "=", "self", ".", "_method_call", "(", "\"BoxScoreV3/{season}/{week}/{team_id}\"", ",", "\"stats\"", ",", "season", "=", "season", ",", "week", "=", "w...
Box score by week and team
[ "Box", "score", "by", "week", "and", "team" ]
af90cac1e80d8356cffaa80621ee513201f6c661
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L246-L251
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser.authenticate
def authenticate(self, password): """ Authenticates against the LDAP directory and returns the corresponding User object if successful. Returns None on failure. """ user = None try: self._authenticate_user_dn(password) self._check_requirements() ...
python
def authenticate(self, password): """ Authenticates against the LDAP directory and returns the corresponding User object if successful. Returns None on failure. """ user = None try: self._authenticate_user_dn(password) self._check_requirements() ...
[ "def", "authenticate", "(", "self", ",", "password", ")", ":", "user", "=", "None", "try", ":", "self", ".", "_authenticate_user_dn", "(", "password", ")", "self", ".", "_check_requirements", "(", ")", "self", ".", "_get_or_create_user", "(", ")", "user", ...
Authenticates against the LDAP directory and returns the corresponding User object if successful. Returns None on failure.
[ "Authenticates", "against", "the", "LDAP", "directory", "and", "returns", "the", "corresponding", "User", "object", "if", "successful", ".", "Returns", "None", "on", "failure", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L325-L351
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser.get_group_permissions
def get_group_permissions(self): """ If allowed by the configuration, this returns the set of permissions defined by the user's LDAP group memberships. """ if self._group_permissions is None: self._group_permissions = set() if self.settings.FIND_GROUP_PER...
python
def get_group_permissions(self): """ If allowed by the configuration, this returns the set of permissions defined by the user's LDAP group memberships. """ if self._group_permissions is None: self._group_permissions = set() if self.settings.FIND_GROUP_PER...
[ "def", "get_group_permissions", "(", "self", ")", ":", "if", "self", ".", "_group_permissions", "is", "None", ":", "self", ".", "_group_permissions", "=", "set", "(", ")", "if", "self", ".", "settings", ".", "FIND_GROUP_PERMS", ":", "try", ":", "self", "."...
If allowed by the configuration, this returns the set of permissions defined by the user's LDAP group memberships.
[ "If", "allowed", "by", "the", "configuration", "this", "returns", "the", "set", "of", "permissions", "defined", "by", "the", "user", "s", "LDAP", "group", "memberships", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L353-L372
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser._populate_user
def _populate_user(self): """ Populates our User object with information from the LDAP directory. """ self._populate_user_from_attributes() self._populate_user_from_group_memberships() self._populate_user_from_dn_regex() self._populate_user_from_dn_regex_negation(...
python
def _populate_user(self): """ Populates our User object with information from the LDAP directory. """ self._populate_user_from_attributes() self._populate_user_from_group_memberships() self._populate_user_from_dn_regex() self._populate_user_from_dn_regex_negation(...
[ "def", "_populate_user", "(", "self", ")", ":", "self", ".", "_populate_user_from_attributes", "(", ")", "self", ".", "_populate_user_from_group_memberships", "(", ")", "self", ".", "_populate_user_from_dn_regex", "(", ")", "self", ".", "_populate_user_from_dn_regex_neg...
Populates our User object with information from the LDAP directory.
[ "Populates", "our", "User", "object", "with", "information", "from", "the", "LDAP", "directory", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L584-L591
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser._populate_and_save_user_profile
def _populate_and_save_user_profile(self): """ Populates a User profile object with fields from the LDAP directory. """ try: app_label, class_name = django.conf.settings.AUTH_PROFILE_MODULE.split('.') profile_model = apps.get_model(app_label, class_name) ...
python
def _populate_and_save_user_profile(self): """ Populates a User profile object with fields from the LDAP directory. """ try: app_label, class_name = django.conf.settings.AUTH_PROFILE_MODULE.split('.') profile_model = apps.get_model(app_label, class_name) ...
[ "def", "_populate_and_save_user_profile", "(", "self", ")", ":", "try", ":", "app_label", ",", "class_name", "=", "django", ".", "conf", ".", "settings", ".", "AUTH_PROFILE_MODULE", ".", "split", "(", "'.'", ")", "profile_model", "=", "apps", ".", "get_model",...
Populates a User profile object with fields from the LDAP directory.
[ "Populates", "a", "User", "profile", "object", "with", "fields", "from", "the", "LDAP", "directory", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L633-L658
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser._populate_profile_from_attributes
def _populate_profile_from_attributes(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_ATTR_MAP. Returns True if the profile was modified. """ save_profile = False for field, attr in self.settings.PROFILE_ATTR_MAP.items(): try: ...
python
def _populate_profile_from_attributes(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_ATTR_MAP. Returns True if the profile was modified. """ save_profile = False for field, attr in self.settings.PROFILE_ATTR_MAP.items(): try: ...
[ "def", "_populate_profile_from_attributes", "(", "self", ",", "profile", ")", ":", "save_profile", "=", "False", "for", "field", ",", "attr", "in", "self", ".", "settings", ".", "PROFILE_ATTR_MAP", ".", "items", "(", ")", ":", "try", ":", "setattr", "(", "...
Populate the given profile object from AUTH_LDAP_PROFILE_ATTR_MAP. Returns True if the profile was modified.
[ "Populate", "the", "given", "profile", "object", "from", "AUTH_LDAP_PROFILE_ATTR_MAP", ".", "Returns", "True", "if", "the", "profile", "was", "modified", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L660-L675
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser._populate_profile_from_group_memberships
def _populate_profile_from_group_memberships(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_FLAGS_BY_GROUP. Returns True if the profile was modified. """ save_profile = False for field, group_dns in self.settings.PROFILE_FLAGS_BY_GROUP.items...
python
def _populate_profile_from_group_memberships(self, profile): """ Populate the given profile object from AUTH_LDAP_PROFILE_FLAGS_BY_GROUP. Returns True if the profile was modified. """ save_profile = False for field, group_dns in self.settings.PROFILE_FLAGS_BY_GROUP.items...
[ "def", "_populate_profile_from_group_memberships", "(", "self", ",", "profile", ")", ":", "save_profile", "=", "False", "for", "field", ",", "group_dns", "in", "self", ".", "settings", ".", "PROFILE_FLAGS_BY_GROUP", ".", "items", "(", ")", ":", "if", "isinstance...
Populate the given profile object from AUTH_LDAP_PROFILE_FLAGS_BY_GROUP. Returns True if the profile was modified.
[ "Populate", "the", "given", "profile", "object", "from", "AUTH_LDAP_PROFILE_FLAGS_BY_GROUP", ".", "Returns", "True", "if", "the", "profile", "was", "modified", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L692-L706
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
_LDAPUser._load_group_permissions
def _load_group_permissions(self): """ Populates self._group_permissions based on LDAP group membership and Django group permissions. """ group_names = self._get_groups().get_group_names() perms = Permission.objects.filter(group__name__in=group_names) perms = per...
python
def _load_group_permissions(self): """ Populates self._group_permissions based on LDAP group membership and Django group permissions. """ group_names = self._get_groups().get_group_names() perms = Permission.objects.filter(group__name__in=group_names) perms = per...
[ "def", "_load_group_permissions", "(", "self", ")", ":", "group_names", "=", "self", ".", "_get_groups", "(", ")", ".", "get_group_names", "(", ")", "perms", "=", "Permission", ".", "objects", ".", "filter", "(", "group__name__in", "=", "group_names", ")", "...
Populates self._group_permissions based on LDAP group membership and Django group permissions.
[ "Populates", "self", ".", "_group_permissions", "based", "on", "LDAP", "group", "membership", "and", "Django", "group", "permissions", "." ]
4d2458bd90c4539353c5bfd5ea793c1e59780ee8
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L729-L740
train
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/message_request.py
WorkNoticeRequest.get_task_id
def get_task_id(self): """Method to get all department members.""" task_id = self.json_response.get("task_id", None) self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return task_id
python
def get_task_id(self): """Method to get all department members.""" task_id = self.json_response.get("task_id", None) self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return task_id
[ "def", "get_task_id", "(", "self", ")", ":", "task_id", "=", "self", ".", "json_response", ".", "get", "(", "\"task_id\"", ",", "None", ")", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "self", "...
Method to get all department members.
[ "Method", "to", "get", "all", "department", "members", "." ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/message_request.py#L24-L28
train
gmdzy2010/dingtalk_sdk_gmdzy2010
dingtalk_sdk_gmdzy2010/message_request.py
SendGroupChatRequest.get_message_id
def get_message_id(self): """Method to get messageId of group created.""" message_id = self.json_response.get("messageId", None) self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return message_id
python
def get_message_id(self): """Method to get messageId of group created.""" message_id = self.json_response.get("messageId", None) self.logger.info("%s\t%s" % (self.request_method, self.request_url)) return message_id
[ "def", "get_message_id", "(", "self", ")", ":", "message_id", "=", "self", ".", "json_response", ".", "get", "(", "\"messageId\"", ",", "None", ")", "self", ".", "logger", ".", "info", "(", "\"%s\\t%s\"", "%", "(", "self", ".", "request_method", ",", "se...
Method to get messageId of group created.
[ "Method", "to", "get", "messageId", "of", "group", "created", "." ]
b06cb1f78f89be9554dcb6101af8bc72718a9ecd
https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/message_request.py#L168-L172
train
brutus/wdiffhtml
tasks/__init__.py
change_dir
def change_dir(directory): """ Wraps a function to run in a given directory. """ def cd_decorator(func): @wraps(func) def wrapper(*args, **kwargs): org_path = os.getcwd() os.chdir(directory) func(*args, **kwargs) os.chdir(org_path) return wrapper return cd_decorator
python
def change_dir(directory): """ Wraps a function to run in a given directory. """ def cd_decorator(func): @wraps(func) def wrapper(*args, **kwargs): org_path = os.getcwd() os.chdir(directory) func(*args, **kwargs) os.chdir(org_path) return wrapper return cd_decorator
[ "def", "change_dir", "(", "directory", ")", ":", "def", "cd_decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "org_path", "=", "os", ".", "getcwd", "(", ")", "os", ...
Wraps a function to run in a given directory.
[ "Wraps", "a", "function", "to", "run", "in", "a", "given", "directory", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/tasks/__init__.py#L27-L40
train
brutus/wdiffhtml
tasks/__init__.py
build_css
def build_css(minimize=True): """ Builds CSS from SASS. """ print('Build CSS') args = {} args['style'] = 'compressed' if minimize else 'nested' cmd = CMD_SASS.format(**args) run(cmd)
python
def build_css(minimize=True): """ Builds CSS from SASS. """ print('Build CSS') args = {} args['style'] = 'compressed' if minimize else 'nested' cmd = CMD_SASS.format(**args) run(cmd)
[ "def", "build_css", "(", "minimize", "=", "True", ")", ":", "print", "(", "'Build CSS'", ")", "args", "=", "{", "}", "args", "[", "'style'", "]", "=", "'compressed'", "if", "minimize", "else", "'nested'", "cmd", "=", "CMD_SASS", ".", "format", "(", "**...
Builds CSS from SASS.
[ "Builds", "CSS", "from", "SASS", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/tasks/__init__.py#L45-L54
train
mojaie/chorus
chorus/util/debug.py
profile
def profile(func): """ Decorator Execute cProfile """ def _f(*args, **kwargs): print("\n<<<---") pr = cProfile.Profile() pr.enable() res = func(*args, **kwargs) p = pstats.Stats(pr) p.strip_dirs().sort_stats('cumtime').print_stats(20) print("\n--->...
python
def profile(func): """ Decorator Execute cProfile """ def _f(*args, **kwargs): print("\n<<<---") pr = cProfile.Profile() pr.enable() res = func(*args, **kwargs) p = pstats.Stats(pr) p.strip_dirs().sort_stats('cumtime').print_stats(20) print("\n--->...
[ "def", "profile", "(", "func", ")", ":", "def", "_f", "(", "*", "args", ",", "**", "kwargs", ")", ":", "print", "(", "\"\\n<<<---\"", ")", "pr", "=", "cProfile", ".", "Profile", "(", ")", "pr", ".", "enable", "(", ")", "res", "=", "func", "(", ...
Decorator Execute cProfile
[ "Decorator", "Execute", "cProfile" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/debug.py#L17-L30
train
mojaie/chorus
chorus/util/debug.py
total_size
def total_size(obj, verbose=False): """ Returns approximate memory size""" seen = set() def sizeof(o): if id(o) in seen: return 0 seen.add(id(o)) s = sys.getsizeof(o, default=0) if verbose: print(s, type(o), repr(o)) if isinstance(o, (tuple, l...
python
def total_size(obj, verbose=False): """ Returns approximate memory size""" seen = set() def sizeof(o): if id(o) in seen: return 0 seen.add(id(o)) s = sys.getsizeof(o, default=0) if verbose: print(s, type(o), repr(o)) if isinstance(o, (tuple, l...
[ "def", "total_size", "(", "obj", ",", "verbose", "=", "False", ")", ":", "seen", "=", "set", "(", ")", "def", "sizeof", "(", "o", ")", ":", "if", "id", "(", "o", ")", "in", "seen", ":", "return", "0", "seen", ".", "add", "(", "id", "(", "o", ...
Returns approximate memory size
[ "Returns", "approximate", "memory", "size" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/debug.py#L33-L52
train
mojaie/chorus
chorus/util/debug.py
mute
def mute(func): """ Decorator Make stdout silent """ def _f(*args, **kwargs): sys.stdout = open(os.devnull, 'w') res = func(*args, **kwargs) sys.stdout.close() sys.stdout = sys.__stdout__ return res return _f
python
def mute(func): """ Decorator Make stdout silent """ def _f(*args, **kwargs): sys.stdout = open(os.devnull, 'w') res = func(*args, **kwargs) sys.stdout.close() sys.stdout = sys.__stdout__ return res return _f
[ "def", "mute", "(", "func", ")", ":", "def", "_f", "(", "*", "args", ",", "**", "kwargs", ")", ":", "sys", ".", "stdout", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "res", "=", "func", "(", "*", "args", ",", "**", "kwargs", ")",...
Decorator Make stdout silent
[ "Decorator", "Make", "stdout", "silent" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/debug.py#L97-L107
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_html_configs
def _insert_html_configs(c, *, project_name, short_project_name): """Insert HTML theme configurations. """ # Use the lsst-sphinx-bootstrap-theme c['templates_path'] = [ '_templates', lsst_sphinx_bootstrap_theme.get_html_templates_path()] c['html_theme'] = 'lsst_sphinx_bootstrap_theme...
python
def _insert_html_configs(c, *, project_name, short_project_name): """Insert HTML theme configurations. """ # Use the lsst-sphinx-bootstrap-theme c['templates_path'] = [ '_templates', lsst_sphinx_bootstrap_theme.get_html_templates_path()] c['html_theme'] = 'lsst_sphinx_bootstrap_theme...
[ "def", "_insert_html_configs", "(", "c", ",", "*", ",", "project_name", ",", "short_project_name", ")", ":", "c", "[", "'templates_path'", "]", "=", "[", "'_templates'", ",", "lsst_sphinx_bootstrap_theme", ".", "get_html_templates_path", "(", ")", "]", "c", "[",...
Insert HTML theme configurations.
[ "Insert", "HTML", "theme", "configurations", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L71-L167
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_common_sphinx_configs
def _insert_common_sphinx_configs(c, *, project_name): """Add common core Sphinx configurations to the state. """ c['project'] = project_name # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: c['source_suffix'] = '.rst' # The encoding of source fi...
python
def _insert_common_sphinx_configs(c, *, project_name): """Add common core Sphinx configurations to the state. """ c['project'] = project_name # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: c['source_suffix'] = '.rst' # The encoding of source fi...
[ "def", "_insert_common_sphinx_configs", "(", "c", ",", "*", ",", "project_name", ")", ":", "c", "[", "'project'", "]", "=", "project_name", "c", "[", "'source_suffix'", "]", "=", "'.rst'", "c", "[", "'source_encoding'", "]", "=", "'utf-8-sig'", "c", "[", "...
Add common core Sphinx configurations to the state.
[ "Add", "common", "core", "Sphinx", "configurations", "to", "the", "state", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L170-L208
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_breathe_configs
def _insert_breathe_configs(c, *, project_name, doxygen_xml_dirname): """Add breathe extension configurations to the state. """ if doxygen_xml_dirname is not None: c['breathe_projects'] = {project_name: doxygen_xml_dirname} c['breathe_default_project'] = project_name return c
python
def _insert_breathe_configs(c, *, project_name, doxygen_xml_dirname): """Add breathe extension configurations to the state. """ if doxygen_xml_dirname is not None: c['breathe_projects'] = {project_name: doxygen_xml_dirname} c['breathe_default_project'] = project_name return c
[ "def", "_insert_breathe_configs", "(", "c", ",", "*", ",", "project_name", ",", "doxygen_xml_dirname", ")", ":", "if", "doxygen_xml_dirname", "is", "not", "None", ":", "c", "[", "'breathe_projects'", "]", "=", "{", "project_name", ":", "doxygen_xml_dirname", "}"...
Add breathe extension configurations to the state.
[ "Add", "breathe", "extension", "configurations", "to", "the", "state", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L211-L217
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_automodapi_configs
def _insert_automodapi_configs(c): """Add configurations related to automodapi, autodoc, and numpydoc to the state. """ # Don't show summaries of the members in each class along with the # class' docstring c['numpydoc_show_class_members'] = False c['autosummary_generate'] = True c['aut...
python
def _insert_automodapi_configs(c): """Add configurations related to automodapi, autodoc, and numpydoc to the state. """ # Don't show summaries of the members in each class along with the # class' docstring c['numpydoc_show_class_members'] = False c['autosummary_generate'] = True c['aut...
[ "def", "_insert_automodapi_configs", "(", "c", ")", ":", "c", "[", "'numpydoc_show_class_members'", "]", "=", "False", "c", "[", "'autosummary_generate'", "]", "=", "True", "c", "[", "'automodapi_toctreedirnm'", "]", "=", "'py-api'", "c", "[", "'automodsumm_inheri...
Add configurations related to automodapi, autodoc, and numpydoc to the state.
[ "Add", "configurations", "related", "to", "automodapi", "autodoc", "and", "numpydoc", "to", "the", "state", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L220-L254
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_matplotlib_configs
def _insert_matplotlib_configs(c): """Add configurations related to matplotlib's plot directive to the state. """ if 'extensions' not in c: c['extensions'] = [] try: import matplotlib.sphinxext.plot_directive c['extensions'] += [matplotlib.sphinxext.plot_directive.__name__] ...
python
def _insert_matplotlib_configs(c): """Add configurations related to matplotlib's plot directive to the state. """ if 'extensions' not in c: c['extensions'] = [] try: import matplotlib.sphinxext.plot_directive c['extensions'] += [matplotlib.sphinxext.plot_directive.__name__] ...
[ "def", "_insert_matplotlib_configs", "(", "c", ")", ":", "if", "'extensions'", "not", "in", "c", ":", "c", "[", "'extensions'", "]", "=", "[", "]", "try", ":", "import", "matplotlib", ".", "sphinxext", ".", "plot_directive", "c", "[", "'extensions'", "]", ...
Add configurations related to matplotlib's plot directive to the state.
[ "Add", "configurations", "related", "to", "matplotlib", "s", "plot", "directive", "to", "the", "state", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L257-L274
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_single_package_eups_version
def _insert_single_package_eups_version(c, eups_version): """Insert version information into the configuration namespace. Parameters ---------- eups_version The EUPS version string (as opposed to tag). This comes from the ``__version__`` attribute of individual modules and is only set f...
python
def _insert_single_package_eups_version(c, eups_version): """Insert version information into the configuration namespace. Parameters ---------- eups_version The EUPS version string (as opposed to tag). This comes from the ``__version__`` attribute of individual modules and is only set f...
[ "def", "_insert_single_package_eups_version", "(", "c", ",", "eups_version", ")", ":", "c", "[", "'release_eups_tag'", "]", "=", "'current'", "c", "[", "'release_git_ref'", "]", "=", "'master'", "c", "[", "'version'", "]", "=", "eups_version", "c", "[", "'rele...
Insert version information into the configuration namespace. Parameters ---------- eups_version The EUPS version string (as opposed to tag). This comes from the ``__version__`` attribute of individual modules and is only set for single package documentation builds that use the ...
[ "Insert", "version", "information", "into", "the", "configuration", "namespace", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L298-L333
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
_insert_eups_version
def _insert_eups_version(c): """Insert information about the current EUPS tag into the configuration namespace. The variables are: ``release_eups_tag`` The EUPS tag (obtained from the ``EUPS_TAG`` environment variable, falling back to ``d_latest`` if not available). ``version``, ``...
python
def _insert_eups_version(c): """Insert information about the current EUPS tag into the configuration namespace. The variables are: ``release_eups_tag`` The EUPS tag (obtained from the ``EUPS_TAG`` environment variable, falling back to ``d_latest`` if not available). ``version``, ``...
[ "def", "_insert_eups_version", "(", "c", ")", ":", "eups_tag", "=", "os", ".", "getenv", "(", "'EUPS_TAG'", ")", "if", "eups_tag", "is", "None", ":", "eups_tag", "=", "'d_latest'", "if", "eups_tag", "in", "(", "'d_latest'", ",", "'w_latest'", ",", "'curren...
Insert information about the current EUPS tag into the configuration namespace. The variables are: ``release_eups_tag`` The EUPS tag (obtained from the ``EUPS_TAG`` environment variable, falling back to ``d_latest`` if not available). ``version``, ``release`` Same as ``release_...
[ "Insert", "information", "about", "the", "current", "EUPS", "tag", "into", "the", "configuration", "namespace", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L336-L386
train
lsst-sqre/documenteer
documenteer/sphinxconfig/stackconf.py
build_pipelines_lsst_io_configs
def build_pipelines_lsst_io_configs(*, project_name, copyright=None): """Build a `dict` of Sphinx configurations that populate the ``conf.py`` of the main pipelines_lsst_io Sphinx project for LSST Science Pipelines documentation. The ``conf.py`` file can ingest these configurations via:: from d...
python
def build_pipelines_lsst_io_configs(*, project_name, copyright=None): """Build a `dict` of Sphinx configurations that populate the ``conf.py`` of the main pipelines_lsst_io Sphinx project for LSST Science Pipelines documentation. The ``conf.py`` file can ingest these configurations via:: from d...
[ "def", "build_pipelines_lsst_io_configs", "(", "*", ",", "project_name", ",", "copyright", "=", "None", ")", ":", "sys", ".", "setrecursionlimit", "(", "2000", ")", "c", "=", "{", "}", "c", "=", "_insert_common_sphinx_configs", "(", "c", ",", "project_name", ...
Build a `dict` of Sphinx configurations that populate the ``conf.py`` of the main pipelines_lsst_io Sphinx project for LSST Science Pipelines documentation. The ``conf.py`` file can ingest these configurations via:: from documenteer.sphinxconfig.stackconf import \ build_pipelines_lsst_io...
[ "Build", "a", "dict", "of", "Sphinx", "configurations", "that", "populate", "the", "conf", ".", "py", "of", "the", "main", "pipelines_lsst_io", "Sphinx", "project", "for", "LSST", "Science", "Pipelines", "documentation", "." ]
75f02901a80042b28d074df1cc1dca32eb8e38c8
https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/stackconf.py#L533-L647
train
klen/muffin-redis
muffin_redis.py
Plugin.setup
def setup(self, app): """Setup the plugin.""" super().setup(app) self.cfg.port = int(self.cfg.port) self.cfg.db = int(self.cfg.db) self.cfg.poolsize = int(self.cfg.poolsize)
python
def setup(self, app): """Setup the plugin.""" super().setup(app) self.cfg.port = int(self.cfg.port) self.cfg.db = int(self.cfg.db) self.cfg.poolsize = int(self.cfg.poolsize)
[ "def", "setup", "(", "self", ",", "app", ")", ":", "super", "(", ")", ".", "setup", "(", "app", ")", "self", ".", "cfg", ".", "port", "=", "int", "(", "self", ".", "cfg", ".", "port", ")", "self", ".", "cfg", ".", "db", "=", "int", "(", "se...
Setup the plugin.
[ "Setup", "the", "plugin", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L49-L54
train
klen/muffin-redis
muffin_redis.py
Plugin.startup
async def startup(self, app): """Connect to Redis.""" if self.cfg.fake: if not FakeConnection: raise PluginException('Install fakeredis for fake connections.') self.conn = await FakeConnection.create() if self.cfg.pubsub: self.pubsub_c...
python
async def startup(self, app): """Connect to Redis.""" if self.cfg.fake: if not FakeConnection: raise PluginException('Install fakeredis for fake connections.') self.conn = await FakeConnection.create() if self.cfg.pubsub: self.pubsub_c...
[ "async", "def", "startup", "(", "self", ",", "app", ")", ":", "if", "self", ".", "cfg", ".", "fake", ":", "if", "not", "FakeConnection", ":", "raise", "PluginException", "(", "'Install fakeredis for fake connections.'", ")", "self", ".", "conn", "=", "await"...
Connect to Redis.
[ "Connect", "to", "Redis", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L56-L92
train
klen/muffin-redis
muffin_redis.py
Plugin.cleanup
async def cleanup(self, app): """Close self connections.""" self.conn.close() if self.pubsub_conn: self.pubsub_reader.cancel() self.pubsub_conn.close() # give connections a chance to actually terminate # TODO: use better method once it will be added, ...
python
async def cleanup(self, app): """Close self connections.""" self.conn.close() if self.pubsub_conn: self.pubsub_reader.cancel() self.pubsub_conn.close() # give connections a chance to actually terminate # TODO: use better method once it will be added, ...
[ "async", "def", "cleanup", "(", "self", ",", "app", ")", ":", "self", ".", "conn", ".", "close", "(", ")", "if", "self", ".", "pubsub_conn", ":", "self", ".", "pubsub_reader", ".", "cancel", "(", ")", "self", ".", "pubsub_conn", ".", "close", "(", ...
Close self connections.
[ "Close", "self", "connections", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L94-L103
train
klen/muffin-redis
muffin_redis.py
Plugin.set
def set(self, key, value, *args, **kwargs): """Store the given value into Redis. :returns: a coroutine """ if self.cfg.jsonpickle: value = jsonpickle.encode(value) return self.conn.set(key, value, *args, **kwargs)
python
def set(self, key, value, *args, **kwargs): """Store the given value into Redis. :returns: a coroutine """ if self.cfg.jsonpickle: value = jsonpickle.encode(value) return self.conn.set(key, value, *args, **kwargs)
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "self", ".", "cfg", ".", "jsonpickle", ":", "value", "=", "jsonpickle", ".", "encode", "(", "value", ")", "return", "self", ".", "conn", "...
Store the given value into Redis. :returns: a coroutine
[ "Store", "the", "given", "value", "into", "Redis", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L105-L112
train
klen/muffin-redis
muffin_redis.py
Plugin.get
async def get(self, key): """Decode the value.""" value = await self.conn.get(key) if self.cfg.jsonpickle: if isinstance(value, bytes): return jsonpickle.decode(value.decode('utf-8')) if isinstance(value, str): return jsonpickle.decode(val...
python
async def get(self, key): """Decode the value.""" value = await self.conn.get(key) if self.cfg.jsonpickle: if isinstance(value, bytes): return jsonpickle.decode(value.decode('utf-8')) if isinstance(value, str): return jsonpickle.decode(val...
[ "async", "def", "get", "(", "self", ",", "key", ")", ":", "value", "=", "await", "self", ".", "conn", ".", "get", "(", "key", ")", "if", "self", ".", "cfg", ".", "jsonpickle", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "return...
Decode the value.
[ "Decode", "the", "value", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L114-L124
train
klen/muffin-redis
muffin_redis.py
Plugin.publish
def publish(self, channel, message): """Publish message to channel. :returns: a coroutine """ if self.cfg.jsonpickle: message = jsonpickle.encode(message) return self.conn.publish(channel, message)
python
def publish(self, channel, message): """Publish message to channel. :returns: a coroutine """ if self.cfg.jsonpickle: message = jsonpickle.encode(message) return self.conn.publish(channel, message)
[ "def", "publish", "(", "self", ",", "channel", ",", "message", ")", ":", "if", "self", ".", "cfg", ".", "jsonpickle", ":", "message", "=", "jsonpickle", ".", "encode", "(", "message", ")", "return", "self", ".", "conn", ".", "publish", "(", "channel", ...
Publish message to channel. :returns: a coroutine
[ "Publish", "message", "to", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L126-L133
train
klen/muffin-redis
muffin_redis.py
Plugin.start_subscribe
def start_subscribe(self): """Create a new Subscription context manager.""" if not self.conn: raise ValueError('Not connected') elif not self.pubsub_conn: raise ValueError('PubSub not enabled') # creates a new context manager return Subscription(self)
python
def start_subscribe(self): """Create a new Subscription context manager.""" if not self.conn: raise ValueError('Not connected') elif not self.pubsub_conn: raise ValueError('PubSub not enabled') # creates a new context manager return Subscription(self)
[ "def", "start_subscribe", "(", "self", ")", ":", "if", "not", "self", ".", "conn", ":", "raise", "ValueError", "(", "'Not connected'", ")", "elif", "not", "self", ".", "pubsub_conn", ":", "raise", "ValueError", "(", "'PubSub not enabled'", ")", "return", "Su...
Create a new Subscription context manager.
[ "Create", "a", "new", "Subscription", "context", "manager", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L135-L143
train
klen/muffin-redis
muffin_redis.py
Subscription._subscribe
async def _subscribe(self, channels, is_mask): """Subscribe to given channel.""" news = [] for channel in channels: key = channel, is_mask self._channels.append(key) if key in self._plugin._subscriptions: self._plugin._subscriptions[key].append...
python
async def _subscribe(self, channels, is_mask): """Subscribe to given channel.""" news = [] for channel in channels: key = channel, is_mask self._channels.append(key) if key in self._plugin._subscriptions: self._plugin._subscriptions[key].append...
[ "async", "def", "_subscribe", "(", "self", ",", "channels", ",", "is_mask", ")", ":", "news", "=", "[", "]", "for", "channel", "in", "channels", ":", "key", "=", "channel", ",", "is_mask", "self", ".", "_channels", ".", "append", "(", "key", ")", "if...
Subscribe to given channel.
[ "Subscribe", "to", "given", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L229-L241
train
klen/muffin-redis
muffin_redis.py
Subscription._unsubscribe
async def _unsubscribe(self, channels, is_mask): """Unsubscribe from given channel.""" vanished = [] if channels: for channel in channels: key = channel, is_mask self._channels.remove(key) self._plugin._subscriptions[key].remove(self._q...
python
async def _unsubscribe(self, channels, is_mask): """Unsubscribe from given channel.""" vanished = [] if channels: for channel in channels: key = channel, is_mask self._channels.remove(key) self._plugin._subscriptions[key].remove(self._q...
[ "async", "def", "_unsubscribe", "(", "self", ",", "channels", ",", "is_mask", ")", ":", "vanished", "=", "[", "]", "if", "channels", ":", "for", "channel", "in", "channels", ":", "key", "=", "channel", ",", "is_mask", "self", ".", "_channels", ".", "re...
Unsubscribe from given channel.
[ "Unsubscribe", "from", "given", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L243-L262
train
sfstpala/pcr
pcr/aes.py
AES.xor
def xor(a, b): """Bitwise xor on equal length bytearrays.""" return bytearray(i ^ j for i, j in zip(a, b))
python
def xor(a, b): """Bitwise xor on equal length bytearrays.""" return bytearray(i ^ j for i, j in zip(a, b))
[ "def", "xor", "(", "a", ",", "b", ")", ":", "return", "bytearray", "(", "i", "^", "j", "for", "i", ",", "j", "in", "zip", "(", "a", ",", "b", ")", ")" ]
Bitwise xor on equal length bytearrays.
[ "Bitwise", "xor", "on", "equal", "length", "bytearrays", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/aes.py#L110-L112
train
fkarb/xltable
xltable/expression.py
Expression.value
def value(self): """Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated. """ try: if isinstance(self.__value, Expression): return self....
python
def value(self): """Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated. """ try: if isinstance(self.__value, Expression): return self....
[ "def", "value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "value", "return", "self", ".", "__value", "except", "AttributeError", ":", "return", ...
Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated.
[ "Set", "a", "calculated", "value", "for", "this", "Expression", ".", "Used", "when", "writing", "formulas", "using", "XlsxWriter", "to", "give", "cells", "an", "initial", "value", "when", "the", "sheet", "is", "loaded", "without", "being", "calculated", "." ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L59-L69
train
fkarb/xltable
xltable/expression.py
Expression.has_value
def has_value(self): """return True if value has been set""" try: if isinstance(self.__value, Expression): return self.__value.has_value return True except AttributeError: return False
python
def has_value(self): """return True if value has been set""" try: if isinstance(self.__value, Expression): return self.__value.has_value return True except AttributeError: return False
[ "def", "has_value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "has_value", "return", "True", "except", "AttributeError", ":", "return", "False" ]
return True if value has been set
[ "return", "True", "if", "value", "has", "been", "set" ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L72-L79
train
zsimic/runez
src/runez/file.py
copy
def copy(source, destination, ignore=None, adapter=None, fatal=True, logger=LOG.debug): """Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored ...
python
def copy(source, destination, ignore=None, adapter=None, fatal=True, logger=LOG.debug): """Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored ...
[ "def", "copy", "(", "source", ",", "destination", ",", "ignore", "=", "None", ",", "adapter", "=", "None", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ",", "_c...
Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored adapter (callable | None): Optional function to call on 'source' before copy fatal (boo...
[ "Copy", "source", "-", ">", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L15-L29
train
zsimic/runez
src/runez/file.py
move
def move(source, destination, adapter=None, fatal=True, logger=LOG.debug): """ Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|...
python
def move(source, destination, adapter=None, fatal=True, logger=LOG.debug): """ Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|...
[ "def", "move", "(", "source", ",", "destination", ",", "adapter", "=", "None", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ",", "_move", ",", "adapter", ",", "...
Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger ...
[ "Move", "source", "-", ">", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L144-L155
train
zsimic/runez
src/runez/file.py
symlink
def symlink(source, destination, adapter=None, must_exist=True, fatal=True, logger=LOG.debug): """ Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' befor...
python
def symlink(source, destination, adapter=None, must_exist=True, fatal=True, logger=LOG.debug): """ Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' befor...
[ "def", "symlink", "(", "source", ",", "destination", ",", "adapter", "=", "None", ",", "must_exist", "=", "True", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ","...
Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool must_exist: If True, verify that source does indeed exist :param bool|None fatal...
[ "Symlink", "source", "<", "-", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L158-L170
train
jslang/responsys
responsys/types.py
InteractType.soap_attribute
def soap_attribute(self, name, value): """ Marks an attribute as being a part of the data defined by the soap datatype""" setattr(self, name, value) self._attributes.add(name)
python
def soap_attribute(self, name, value): """ Marks an attribute as being a part of the data defined by the soap datatype""" setattr(self, name, value) self._attributes.add(name)
[ "def", "soap_attribute", "(", "self", ",", "name", ",", "value", ")", ":", "setattr", "(", "self", ",", "name", ",", "value", ")", "self", ".", "_attributes", ".", "add", "(", "name", ")" ]
Marks an attribute as being a part of the data defined by the soap datatype
[ "Marks", "an", "attribute", "as", "being", "a", "part", "of", "the", "data", "defined", "by", "the", "soap", "datatype" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L32-L35
train
jslang/responsys
responsys/types.py
InteractType.get_soap_object
def get_soap_object(self, client): """ Create and return a soap service type defined for this instance """ def to_soap_attribute(attr): words = attr.split('_') words = words[:1] + [word.capitalize() for word in words[1:]] return ''.join(words) soap_object = c...
python
def get_soap_object(self, client): """ Create and return a soap service type defined for this instance """ def to_soap_attribute(attr): words = attr.split('_') words = words[:1] + [word.capitalize() for word in words[1:]] return ''.join(words) soap_object = c...
[ "def", "get_soap_object", "(", "self", ",", "client", ")", ":", "def", "to_soap_attribute", "(", "attr", ")", ":", "words", "=", "attr", ".", "split", "(", "'_'", ")", "words", "=", "words", "[", ":", "1", "]", "+", "[", "word", ".", "capitalize", ...
Create and return a soap service type defined for this instance
[ "Create", "and", "return", "a", "soap", "service", "type", "defined", "for", "this", "instance" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L37-L49
train
jslang/responsys
responsys/types.py
RecordData.get_soap_object
def get_soap_object(self, client): """ Override default get_soap_object behavior to account for child Record types """ record_data = super().get_soap_object(client) record_data.records = [Record(r).get_soap_object(client) for r in record_data.records] return record_data
python
def get_soap_object(self, client): """ Override default get_soap_object behavior to account for child Record types """ record_data = super().get_soap_object(client) record_data.records = [Record(r).get_soap_object(client) for r in record_data.records] return record_data
[ "def", "get_soap_object", "(", "self", ",", "client", ")", ":", "record_data", "=", "super", "(", ")", ".", "get_soap_object", "(", "client", ")", "record_data", ".", "records", "=", "[", "Record", "(", "r", ")", ".", "get_soap_object", "(", "client", ")...
Override default get_soap_object behavior to account for child Record types
[ "Override", "default", "get_soap_object", "behavior", "to", "account", "for", "child", "Record", "types" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L158-L162
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.handle_message_registered
def handle_message_registered(self, msg_data, host): """Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's meth...
python
def handle_message_registered(self, msg_data, host): """Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's meth...
[ "def", "handle_message_registered", "(", "self", ",", "msg_data", ",", "host", ")", ":", "response", "=", "None", "if", "msg_data", "[", "\"method\"", "]", "==", "\"EVENT\"", ":", "logger", ".", "debug", "(", "\"<%s> <euuid:%s> Event message \"", "\"received\"", ...
Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's method. host (tuple): The (address, host) tuple of the sou...
[ "Processes", "messages", "that", "have", "been", "delivered", "by", "a", "registered", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L272-L318
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.autodiscover
def autodiscover(self, message): """This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server res...
python
def autodiscover(self, message): """This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server res...
[ "def", "autodiscover", "(", "self", ",", "message", ")", ":", "if", "message", "[", "\"version\"", "]", "in", "self", ".", "allowed_versions", ":", "logger", ".", "debug", "(", "\"<%s> Client version matches server \"", "\"version.\"", "%", "message", "[", "\"cu...
This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server response with the server's version nu...
[ "This", "function", "simply", "returns", "the", "server", "version", "number", "as", "a", "response", "to", "the", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L321-L356
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.register
def register(self, message, host): """This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the...
python
def register(self, message, host): """This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the...
[ "def", "register", "(", "self", ",", "message", ",", "host", ")", ":", "cuuid", "=", "message", "[", "\"cuuid\"", "]", "if", "len", "(", "self", ".", "registry", ")", ">", "self", ".", "registration_limit", ":", "logger", ".", "warning", "(", "\"<%s> R...
This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the client who wants to register. ...
[ "This", "function", "will", "register", "a", "particular", "client", "in", "the", "server", "s", "registry", "dictionary", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L359-L429
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.is_registered
def is_registered(self, cuuid, host): """This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registe...
python
def is_registered(self, cuuid, host): """This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registe...
[ "def", "is_registered", "(", "self", ",", "cuuid", ",", "host", ")", ":", "if", "(", "cuuid", "in", "self", ".", "registry", ")", "and", "(", "self", ".", "registry", "[", "cuuid", "]", "[", "\"host\"", "]", "==", "host", ")", ":", "return", "True"...
This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registering. Returns: Will return Tru...
[ "This", "function", "will", "check", "to", "see", "if", "a", "given", "host", "with", "client", "uuid", "is", "currently", "registered", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L432-L451
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.event
def event(self, cuuid, host, euuid, event_data, timestamp, priority): """This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. e...
python
def event(self, cuuid, host, euuid, event_data, timestamp, priority): """This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. e...
[ "def", "event", "(", "self", ",", "cuuid", ",", "host", ",", "euuid", ",", "event_data", ",", "timestamp", ",", "priority", ")", ":", "response", "=", "None", "if", "host", "in", "self", ".", "encrypted_hosts", ":", "logger", ".", "debug", "(", "\"Encr...
This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. euuid (string): The event uuid of the specific event. event_data (any): ...
[ "This", "function", "will", "process", "event", "packets", "and", "send", "them", "to", "legal", "checks", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L454-L555
train
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.notify
def notify(self, cuuid, event_data): """This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addi...
python
def notify(self, cuuid, event_data): """This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addi...
[ "def", "notify", "(", "self", ",", "cuuid", ",", "event_data", ")", ":", "euuid", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "if", "\"encryption\"", "in", "self", ".", "registry", "[", "cuuid", "]", ":", "client_key", "=", "self", ".", "...
This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addition to this difference, NOTIFY messages...
[ "This", "function", "will", "send", "a", "NOTIFY", "event", "to", "a", "registered", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L558-L630
train
untwisted/untwisted
untwisted/wrappers.py
once
def once(dispatcher, event, handle, *args): """ Used to do a mapping like event -> handle but handle is called just once upon event. """ def shell(dispatcher, *args): try: handle(dispatcher, *args) except Exception as e: raise e finally: d...
python
def once(dispatcher, event, handle, *args): """ Used to do a mapping like event -> handle but handle is called just once upon event. """ def shell(dispatcher, *args): try: handle(dispatcher, *args) except Exception as e: raise e finally: d...
[ "def", "once", "(", "dispatcher", ",", "event", ",", "handle", ",", "*", "args", ")", ":", "def", "shell", "(", "dispatcher", ",", "*", "args", ")", ":", "try", ":", "handle", "(", "dispatcher", ",", "*", "args", ")", "except", "Exception", "as", "...
Used to do a mapping like event -> handle but handle is called just once upon event.
[ "Used", "to", "do", "a", "mapping", "like", "event", "-", ">", "handle", "but", "handle", "is", "called", "just", "once", "upon", "event", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/wrappers.py#L7-L20
train
untwisted/untwisted
untwisted/core.py
Gear.mainloop
def mainloop(self): """ This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop() """ while True: # It calls repeteadl...
python
def mainloop(self): """ This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop() """ while True: # It calls repeteadl...
[ "def", "mainloop", "(", "self", ")", ":", "while", "True", ":", "try", ":", "self", ".", "update", "(", ")", "except", "Kill", ":", "break", "except", "KeyboardInterrupt", ":", "print", "(", "self", ".", "base", ")", "raise" ]
This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop()
[ "This", "is", "the", "reactor", "mainloop", ".", "It", "is", "intented", "to", "be", "called", "when", "a", "reactor", "is", "installed", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/core.py#L41-L68
train
thorgate/django-esteid
esteid/digidocservice/service.py
DigiDocService.start_session
def start_session(self, b_hold_session, sig_doc_xml=None, datafile=None): """Start a DigidocService session :return: True if session was started and session code was stored in I{session_code} """ response = self.__invoke('StartSession', { 'bHoldSession': b_hold_session, ...
python
def start_session(self, b_hold_session, sig_doc_xml=None, datafile=None): """Start a DigidocService session :return: True if session was started and session code was stored in I{session_code} """ response = self.__invoke('StartSession', { 'bHoldSession': b_hold_session, ...
[ "def", "start_session", "(", "self", ",", "b_hold_session", ",", "sig_doc_xml", "=", "None", ",", "datafile", "=", "None", ")", ":", "response", "=", "self", ".", "__invoke", "(", "'StartSession'", ",", "{", "'bHoldSession'", ":", "b_hold_session", ",", "'Si...
Start a DigidocService session :return: True if session was started and session code was stored in I{session_code}
[ "Start", "a", "DigidocService", "session" ]
407ae513e357fedea0e3e42198df8eb9d9ff0646
https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/digidocservice/service.py#L153-L179
train
thorgate/django-esteid
esteid/digidocservice/service.py
DigiDocService.mobile_sign
def mobile_sign(self, id_code, country, phone_nr, language=None, signing_profile='LT_TM'): """ This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session """ if not (self.container and isinstance(self.container, PreviouslyCrea...
python
def mobile_sign(self, id_code, country, phone_nr, language=None, signing_profile='LT_TM'): """ This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session """ if not (self.container and isinstance(self.container, PreviouslyCrea...
[ "def", "mobile_sign", "(", "self", ",", "id_code", ",", "country", ",", "phone_nr", ",", "language", "=", "None", ",", "signing_profile", "=", "'LT_TM'", ")", ":", "if", "not", "(", "self", ".", "container", "and", "isinstance", "(", "self", ".", "contai...
This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session
[ "This", "can", "be", "used", "to", "add", "a", "signature", "to", "existing", "data", "files" ]
407ae513e357fedea0e3e42198df8eb9d9ff0646
https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/digidocservice/service.py#L299-L334
train
sfstpala/pcr
pcr/maths.py
is_prime
def is_prime(n, k=64): """ Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is...
python
def is_prime(n, k=64): """ Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is...
[ "def", "is_prime", "(", "n", ",", "k", "=", "64", ")", ":", "if", "n", "==", "2", ":", "return", "True", "if", "n", "<", "2", "or", "n", "%", "2", "==", "0", ":", "return", "False", "for", "i", "in", "range", "(", "3", ",", "2048", ")", "...
Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is recommended (error probability = 2...
[ "Test", "whether", "n", "is", "prime", "probabilisticly", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L34-L71
train
sfstpala/pcr
pcr/maths.py
get_prime
def get_prime(bits, k=64): """ Return a random prime up to a certain length. This function uses random.SystemRandom. """ if bits % 8 != 0 or bits == 0: raise ValueError("bits must be >= 0 and divisible by 8") while True: n = int.from_bytes(os.urandom(bits // 8), "big") ...
python
def get_prime(bits, k=64): """ Return a random prime up to a certain length. This function uses random.SystemRandom. """ if bits % 8 != 0 or bits == 0: raise ValueError("bits must be >= 0 and divisible by 8") while True: n = int.from_bytes(os.urandom(bits // 8), "big") ...
[ "def", "get_prime", "(", "bits", ",", "k", "=", "64", ")", ":", "if", "bits", "%", "8", "!=", "0", "or", "bits", "==", "0", ":", "raise", "ValueError", "(", "\"bits must be >= 0 and divisible by 8\"", ")", "while", "True", ":", "n", "=", "int", ".", ...
Return a random prime up to a certain length. This function uses random.SystemRandom.
[ "Return", "a", "random", "prime", "up", "to", "a", "certain", "length", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L74-L86
train
sfstpala/pcr
pcr/maths.py
make_rsa_keys
def make_rsa_keys(bits=2048, e=65537, k=64): """ Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test). """ p, q = None, None while p == q: p, q = get_pri...
python
def make_rsa_keys(bits=2048, e=65537, k=64): """ Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test). """ p, q = None, None while p == q: p, q = get_pri...
[ "def", "make_rsa_keys", "(", "bits", "=", "2048", ",", "e", "=", "65537", ",", "k", "=", "64", ")", ":", "p", ",", "q", "=", "None", ",", "None", "while", "p", "==", "q", ":", "p", ",", "q", "=", "get_prime", "(", "bits", "//", "2", ")", ",...
Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test).
[ "Create", "RSA", "key", "pair", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L119-L135
train
bluekeyes/sphinx-javalink
javalink/__init__.py
setup
def setup(app): """Register the extension with Sphinx. Args: app: The Sphinx application. """ for name, (default, rebuild, _) in ref.CONFIG_VALUES.iteritems(): app.add_config_value(name, default, rebuild) app.add_directive('javaimport', ref.JavarefImportDirective) app.add_role...
python
def setup(app): """Register the extension with Sphinx. Args: app: The Sphinx application. """ for name, (default, rebuild, _) in ref.CONFIG_VALUES.iteritems(): app.add_config_value(name, default, rebuild) app.add_directive('javaimport', ref.JavarefImportDirective) app.add_role...
[ "def", "setup", "(", "app", ")", ":", "for", "name", ",", "(", "default", ",", "rebuild", ",", "_", ")", "in", "ref", ".", "CONFIG_VALUES", ".", "iteritems", "(", ")", ":", "app", ".", "add_config_value", "(", "name", ",", "default", ",", "rebuild", ...
Register the extension with Sphinx. Args: app: The Sphinx application.
[ "Register", "the", "extension", "with", "Sphinx", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L9-L25
train
bluekeyes/sphinx-javalink
javalink/__init__.py
validate_env
def validate_env(app): """Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant val...
python
def validate_env(app): """Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant val...
[ "def", "validate_env", "(", "app", ")", ":", "if", "not", "hasattr", "(", "app", ".", "env", ",", "'javalink_config_cache'", ")", ":", "app", ".", "env", ".", "javalink_config_cache", "=", "{", "}", "for", "conf_attr", ",", "(", "_", ",", "_", ",", "...
Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant values in the environment in orde...
[ "Purge", "expired", "values", "from", "the", "environment", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L32-L58
train
bluekeyes/sphinx-javalink
javalink/__init__.py
find_rt_jar
def find_rt_jar(javahome=None): """Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value a...
python
def find_rt_jar(javahome=None): """Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value a...
[ "def", "find_rt_jar", "(", "javahome", "=", "None", ")", ":", "if", "not", "javahome", ":", "if", "'JAVA_HOME'", "in", "os", ".", "environ", ":", "javahome", "=", "os", ".", "environ", "[", "'JAVA_HOME'", "]", "elif", "sys", ".", "platform", "==", "'da...
Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value as the directory. 2. If the J...
[ "Find", "the", "path", "to", "the", "Java", "standard", "library", "jar", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L61-L95
train
blue-yonder/cee_syslog_handler
cee_syslog_handler/__init__.py
RegexFilter.filter
def filter(self, record): """ Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607 """ found = self._pattern.search(record.getMessage()) return not found
python
def filter(self, record): """ Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607 """ found = self._pattern.search(record.getMessage()) return not found
[ "def", "filter", "(", "self", ",", "record", ")", ":", "found", "=", "self", ".", "_pattern", ".", "search", "(", "record", ".", "getMessage", "(", ")", ")", "return", "not", "found" ]
Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607
[ "Returns", "True", "if", "the", "record", "shall", "be", "logged", ".", "False", "otherwise", "." ]
c6006b59d38d4d8dabfc1301c689c71f35e3b8b8
https://github.com/blue-yonder/cee_syslog_handler/blob/c6006b59d38d4d8dabfc1301c689c71f35e3b8b8/cee_syslog_handler/__init__.py#L266-L273
train
zsimic/runez
src/runez/convert.py
_get_value
def _get_value(obj, key): """Get a value for 'key' from 'obj', if possible""" if isinstance(obj, (list, tuple)): for item in obj: v = _find_value(key, item) if v is not None: return v return None if isinstance(obj, dict): return obj.get(key) ...
python
def _get_value(obj, key): """Get a value for 'key' from 'obj', if possible""" if isinstance(obj, (list, tuple)): for item in obj: v = _find_value(key, item) if v is not None: return v return None if isinstance(obj, dict): return obj.get(key) ...
[ "def", "_get_value", "(", "obj", ",", "key", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "item", "in", "obj", ":", "v", "=", "_find_value", "(", "key", ",", "item", ")", "if", "v", "is", "not"...
Get a value for 'key' from 'obj', if possible
[ "Get", "a", "value", "for", "key", "from", "obj", "if", "possible" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L262-L273
train
zsimic/runez
src/runez/convert.py
_find_value
def _find_value(key, *args): """Find a value for 'key' in any of the objects given as 'args'""" for arg in args: v = _get_value(arg, key) if v is not None: return v
python
def _find_value(key, *args): """Find a value for 'key' in any of the objects given as 'args'""" for arg in args: v = _get_value(arg, key) if v is not None: return v
[ "def", "_find_value", "(", "key", ",", "*", "args", ")", ":", "for", "arg", "in", "args", ":", "v", "=", "_get_value", "(", "arg", ",", "key", ")", "if", "v", "is", "not", "None", ":", "return", "v" ]
Find a value for 'key' in any of the objects given as 'args
[ "Find", "a", "value", "for", "key", "in", "any", "of", "the", "objects", "given", "as", "args" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L276-L281
train
abantos/bolt
bolt/_btutils.py
add_search_path
def add_search_path(*path_tokens): """ Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the b...
python
def add_search_path(*path_tokens): """ Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the b...
[ "def", "add_search_path", "(", "*", "path_tokens", ")", ":", "full_path", "=", "os", ".", "path", ".", "join", "(", "*", "path_tokens", ")", "if", "full_path", "not", "in", "sys", ".", "path", ":", "sys", ".", "path", ".", "insert", "(", "0", ",", ...
Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the bulk of the implementation in separate utili...
[ "Adds", "a", "new", "search", "path", "from", "where", "modules", "can", "be", "loaded", ".", "This", "function", "is", "provided", "for", "test", "applications", "to", "add", "locations", "to", "the", "search", "path", "so", "any", "required", "functionalit...
8b6a911d4a7b1a6e870748a523c9b2b91997c773
https://github.com/abantos/bolt/blob/8b6a911d4a7b1a6e870748a523c9b2b91997c773/bolt/_btutils.py#L8-L22
train
abantos/bolt
bolt/_btutils.py
load_script
def load_script(filename): """ Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specifi...
python
def load_script(filename): """ Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specifi...
[ "def", "load_script", "(", "filename", ")", ":", "path", ",", "module_name", ",", "ext", "=", "_extract_script_components", "(", "filename", ")", "add_search_path", "(", "path", ")", "return", "_load_module", "(", "module_name", ")" ]
Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specified file.
[ "Loads", "a", "python", "script", "as", "a", "module", "." ]
8b6a911d4a7b1a6e870748a523c9b2b91997c773
https://github.com/abantos/bolt/blob/8b6a911d4a7b1a6e870748a523c9b2b91997c773/bolt/_btutils.py#L26-L40
train
potash/drain
drain/util.py
parse_dates
def parse_dates(df, inplace=True, *args, **kwargs): """ Parse all datetime.date and datetime.datetime columns """ if not inplace: df = df.copy() for c in df.columns: i = df[c].first_valid_index() if i is not None and type(df[c].ix[i]) in (date, datetime): df[c] =...
python
def parse_dates(df, inplace=True, *args, **kwargs): """ Parse all datetime.date and datetime.datetime columns """ if not inplace: df = df.copy() for c in df.columns: i = df[c].first_valid_index() if i is not None and type(df[c].ix[i]) in (date, datetime): df[c] =...
[ "def", "parse_dates", "(", "df", ",", "inplace", "=", "True", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "not", "inplace", ":", "df", "=", "df", ".", "copy", "(", ")", "for", "c", "in", "df", ".", "columns", ":", "i", "=", "df", "...
Parse all datetime.date and datetime.datetime columns
[ "Parse", "all", "datetime", ".", "date", "and", "datetime", ".", "datetime", "columns" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L45-L58
train
potash/drain
drain/util.py
to_float
def to_float(*args): """ cast numpy arrays to float32 if there's more than one, return an array """ floats = [np.array(a, dtype=np.float32) for a in args] return floats[0] if len(floats) == 1 else floats
python
def to_float(*args): """ cast numpy arrays to float32 if there's more than one, return an array """ floats = [np.array(a, dtype=np.float32) for a in args] return floats[0] if len(floats) == 1 else floats
[ "def", "to_float", "(", "*", "args", ")", ":", "floats", "=", "[", "np", ".", "array", "(", "a", ",", "dtype", "=", "np", ".", "float32", ")", "for", "a", "in", "args", "]", "return", "floats", "[", "0", "]", "if", "len", "(", "floats", ")", ...
cast numpy arrays to float32 if there's more than one, return an array
[ "cast", "numpy", "arrays", "to", "float32", "if", "there", "s", "more", "than", "one", "return", "an", "array" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L83-L89
train
potash/drain
drain/util.py
get_attr
def get_attr(name): """ get a class or function by name """ i = name.rfind('.') cls = str(name[i+1:]) module = str(name[:i]) mod = __import__(module, fromlist=[cls]) return getattr(mod, cls)
python
def get_attr(name): """ get a class or function by name """ i = name.rfind('.') cls = str(name[i+1:]) module = str(name[:i]) mod = __import__(module, fromlist=[cls]) return getattr(mod, cls)
[ "def", "get_attr", "(", "name", ")", ":", "i", "=", "name", ".", "rfind", "(", "'.'", ")", "cls", "=", "str", "(", "name", "[", "i", "+", "1", ":", "]", ")", "module", "=", "str", "(", "name", "[", ":", "i", "]", ")", "mod", "=", "__import_...
get a class or function by name
[ "get", "a", "class", "or", "function", "by", "name" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L131-L140
train
potash/drain
drain/util.py
drop_constant_column_levels
def drop_constant_column_levels(df): """ drop the levels of a multi-level column dataframe which are constant operates in place """ columns = df.columns constant_levels = [i for i, level in enumerate(columns.levels) if len(level) <= 1] constant_levels.reverse() for i in constant_levels:...
python
def drop_constant_column_levels(df): """ drop the levels of a multi-level column dataframe which are constant operates in place """ columns = df.columns constant_levels = [i for i, level in enumerate(columns.levels) if len(level) <= 1] constant_levels.reverse() for i in constant_levels:...
[ "def", "drop_constant_column_levels", "(", "df", ")", ":", "columns", "=", "df", ".", "columns", "constant_levels", "=", "[", "i", "for", "i", ",", "level", "in", "enumerate", "(", "columns", ".", "levels", ")", "if", "len", "(", "level", ")", "<=", "1...
drop the levels of a multi-level column dataframe which are constant operates in place
[ "drop", "the", "levels", "of", "a", "multi", "-", "level", "column", "dataframe", "which", "are", "constant", "operates", "in", "place" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L214-L225
train
potash/drain
drain/util.py
dict_diff
def dict_diff(dicts): """ Subset dictionaries to keys which map to multiple values """ diff_keys = set() for k in union(set(d.keys()) for d in dicts): values = [] for d in dicts: if k not in d: diff_keys.add(k) break else: ...
python
def dict_diff(dicts): """ Subset dictionaries to keys which map to multiple values """ diff_keys = set() for k in union(set(d.keys()) for d in dicts): values = [] for d in dicts: if k not in d: diff_keys.add(k) break else: ...
[ "def", "dict_diff", "(", "dicts", ")", ":", "diff_keys", "=", "set", "(", ")", "for", "k", "in", "union", "(", "set", "(", "d", ".", "keys", "(", ")", ")", "for", "d", "in", "dicts", ")", ":", "values", "=", "[", "]", "for", "d", "in", "dicts...
Subset dictionaries to keys which map to multiple values
[ "Subset", "dictionaries", "to", "keys", "which", "map", "to", "multiple", "values" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L273-L291
train
potash/drain
drain/util.py
dict_update_union
def dict_update_union(d1, d2): """ update a set-valued dictionary when key exists, union sets """ for k in d2: if k in d1: d1[k].update(d2[k]) else: d1[k] = d2[k]
python
def dict_update_union(d1, d2): """ update a set-valued dictionary when key exists, union sets """ for k in d2: if k in d1: d1[k].update(d2[k]) else: d1[k] = d2[k]
[ "def", "dict_update_union", "(", "d1", ",", "d2", ")", ":", "for", "k", "in", "d2", ":", "if", "k", "in", "d1", ":", "d1", "[", "k", "]", ".", "update", "(", "d2", "[", "k", "]", ")", "else", ":", "d1", "[", "k", "]", "=", "d2", "[", "k",...
update a set-valued dictionary when key exists, union sets
[ "update", "a", "set", "-", "valued", "dictionary", "when", "key", "exists", "union", "sets" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L350-L359
train
sonic182/libsasscompiler
libsasscompiler/__init__.py
LibSassCompiler.compile_file
def compile_file(self, infile, outfile, outdated=False, force=False): """Process sass file.""" myfile = codecs.open(outfile, 'w', 'utf-8') if settings.DEBUG: myfile.write(sass.compile(filename=infile)) else: myfile.write(sass.compile(filename=infile, ...
python
def compile_file(self, infile, outfile, outdated=False, force=False): """Process sass file.""" myfile = codecs.open(outfile, 'w', 'utf-8') if settings.DEBUG: myfile.write(sass.compile(filename=infile)) else: myfile.write(sass.compile(filename=infile, ...
[ "def", "compile_file", "(", "self", ",", "infile", ",", "outfile", ",", "outdated", "=", "False", ",", "force", "=", "False", ")", ":", "myfile", "=", "codecs", ".", "open", "(", "outfile", ",", "'w'", ",", "'utf-8'", ")", "if", "settings", ".", "DEB...
Process sass file.
[ "Process", "sass", "file", "." ]
067c2324bbed9d22966fe63d87e5b3687510bc26
https://github.com/sonic182/libsasscompiler/blob/067c2324bbed9d22966fe63d87e5b3687510bc26/libsasscompiler/__init__.py#L22-L31
train
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.from_task
def from_task(cls, task): """Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target insta...
python
def from_task(cls, task): """Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target insta...
[ "def", "from_task", "(", "cls", ",", "task", ")", ":", "target", "=", "cls", "(", "name", "=", "task", ".", "get_name", "(", ")", ",", "params", "=", "task", ".", "get_param_string", "(", ")", ")", "return", "target" ]
Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target instance
[ "Create", "a", "new", "target", "representing", "a", "task", "and", "its", "parameters" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L21-L34
train
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget._base_query
def _base_query(self, session): """Base query for a target. Args: session: database session to query in """ return session.query(ORMTargetMarker) \ .filter(ORMTargetMarker.name == self.name) \ .filter(ORMTargetMarker.params == self.params)
python
def _base_query(self, session): """Base query for a target. Args: session: database session to query in """ return session.query(ORMTargetMarker) \ .filter(ORMTargetMarker.name == self.name) \ .filter(ORMTargetMarker.params == self.params)
[ "def", "_base_query", "(", "self", ",", "session", ")", ":", "return", "session", ".", "query", "(", "ORMTargetMarker", ")", ".", "filter", "(", "ORMTargetMarker", ".", "name", "==", "self", ".", "name", ")", ".", "filter", "(", "ORMTargetMarker", ".", "...
Base query for a target. Args: session: database session to query in
[ "Base", "query", "for", "a", "target", "." ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L36-L44
train
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.exists
def exists(self): """Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise ...
python
def exists(self): """Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise ...
[ "def", "exists", "(", "self", ")", ":", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "ret", "=", "self", ".", "_base_query", "(", "session", ")", ".", "count", "(", ")", ">", "0", "session", ".", "close", ...
Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise
[ "Check", "if", "a", "target", "exists" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L46-L63
train
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.create
def create(self): """Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: ...
python
def create(self): """Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: ...
[ "def", "create", "(", "self", ")", ":", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "if", "not", "self", ".", "_base_query", "(", "session", ")", ".", "count", "(", ")", ">", "0", ":", "marker", "=", "ORM...
Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created.
[ "Create", "an", "instance", "of", "the", "current", "target", "in", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L65-L79
train
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.remove
def remove(self): """Remove a target Raises a ``RuntimeError`` if the target does not exist. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: session.close() raise RuntimeError("Target does not exist, name=...
python
def remove(self): """Remove a target Raises a ``RuntimeError`` if the target does not exist. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: session.close() raise RuntimeError("Target does not exist, name=...
[ "def", "remove", "(", "self", ")", ":", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "if", "not", "self", ".", "_base_query", "(", "session", ")", ".", "count", "(", ")", ">", "0", ":", "session", ".", "cl...
Remove a target Raises a ``RuntimeError`` if the target does not exist.
[ "Remove", "a", "target" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L81-L97
train
dchaplinsky/translit-ua
translitua/translit.py
add_uppercase
def add_uppercase(table): """ Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True ...
python
def add_uppercase(table): """ Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True ...
[ "def", "add_uppercase", "(", "table", ")", ":", "orig", "=", "table", ".", "copy", "(", ")", "orig", ".", "update", "(", "dict", "(", "(", "k", ".", "capitalize", "(", ")", ",", "v", ".", "capitalize", "(", ")", ")", "for", "k", ",", "v", "in",...
Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True >>> print(len(add_uppercase({"а": "a"...
[ "Extend", "the", "table", "with", "uppercase", "options" ]
14e634492c7ce937d77436772fa32d2de5707a9b
https://github.com/dchaplinsky/translit-ua/blob/14e634492c7ce937d77436772fa32d2de5707a9b/translitua/translit.py#L12-L35
train
dchaplinsky/translit-ua
translitua/translit.py
translit
def translit(src, table=UkrainianKMU, preserve_case=True): u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: tr...
python
def translit(src, table=UkrainianKMU, preserve_case=True): u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: tr...
[ "def", "translit", "(", "src", ",", "table", "=", "UkrainianKMU", ",", "preserve_case", "=", "True", ")", ":", "u", "src", "=", "text_type", "(", "src", ")", "src_is_upper", "=", "src", ".", "isupper", "(", ")", "if", "hasattr", "(", "table", ",", "\...
u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: transliteration table :type table: transliteration table obje...
[ "u", "Transliterates", "given", "unicode", "src", "text", "to", "transliterated", "variant", "according", "to", "a", "given", "transliteration", "table", ".", "Official", "ukrainian", "transliteration", "is", "used", "by", "default" ]
14e634492c7ce937d77436772fa32d2de5707a9b
https://github.com/dchaplinsky/translit-ua/blob/14e634492c7ce937d77436772fa32d2de5707a9b/translitua/translit.py#L1043-L1156
train
ehansis/ozelot
examples/leonardo/leonardo/kvstore/pipeline.py
EntityCreatorMixin.store
def store(self, df, attribute_columns): """Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes """ # ID start values...
python
def store(self, df, attribute_columns): """Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes """ # ID start values...
[ "def", "store", "(", "self", ",", "df", ",", "attribute_columns", ")", ":", "entity_id_start", "=", "models", ".", "Entity", ".", "get_max_id", "(", "self", ".", "session", ")", "+", "1", "attribute_id_start", "=", "models", ".", "Attribute", ".", "get_max...
Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes
[ "Store", "entities", "and", "their", "attributes" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/kvstore/pipeline.py#L49-L86
train
ehansis/ozelot
examples/leonardo/leonardo/kvstore/pipeline.py
LoadPaintings.run
def run(self): """Load all paintings into the database """ df = PaintingsInputData().load() # rename columns df.rename(columns={'paintingLabel': 'name'}, inplace=True) # get artist IDs, map via artist wiki ID artists = models.Entity.query_with_attributes('artis...
python
def run(self): """Load all paintings into the database """ df = PaintingsInputData().load() # rename columns df.rename(columns={'paintingLabel': 'name'}, inplace=True) # get artist IDs, map via artist wiki ID artists = models.Entity.query_with_attributes('artis...
[ "def", "run", "(", "self", ")", ":", "df", "=", "PaintingsInputData", "(", ")", ".", "load", "(", ")", "df", ".", "rename", "(", "columns", "=", "{", "'paintingLabel'", ":", "'name'", "}", ",", "inplace", "=", "True", ")", "artists", "=", "models", ...
Load all paintings into the database
[ "Load", "all", "paintings", "into", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/kvstore/pipeline.py#L149-L168
train
ShadowBlip/Neteria
neteria/core.py
serialize_data
def serialize_data(data, compression=False, encryption=False, public_key=None): """Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur addi...
python
def serialize_data(data, compression=False, encryption=False, public_key=None): """Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur addi...
[ "def", "serialize_data", "(", "data", ",", "compression", "=", "False", ",", "encryption", "=", "False", ",", "public_key", "=", "None", ")", ":", "message", "=", "json", ".", "dumps", "(", "data", ")", "if", "compression", ":", "message", "=", "zlib", ...
Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur additional overhead. Args: data (dict): The data to convert into plain text usin...
[ "Serializes", "normal", "Python", "datatypes", "into", "plaintext", "using", "json", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L44-L76
train
ShadowBlip/Neteria
neteria/core.py
unserialize_data
def unserialize_data(data, compression=False, encryption=False): """Unserializes the packet data and converts it from json format to normal Python datatypes. If you choose to enable encryption and/or compression when serializing data, you MUST enable the same options when unserializing data. Args:...
python
def unserialize_data(data, compression=False, encryption=False): """Unserializes the packet data and converts it from json format to normal Python datatypes. If you choose to enable encryption and/or compression when serializing data, you MUST enable the same options when unserializing data. Args:...
[ "def", "unserialize_data", "(", "data", ",", "compression", "=", "False", ",", "encryption", "=", "False", ")", ":", "try", ":", "if", "encryption", ":", "data", "=", "encryption", ".", "decrypt", "(", "data", ")", "except", "Exception", "as", "err", ":"...
Unserializes the packet data and converts it from json format to normal Python datatypes. If you choose to enable encryption and/or compression when serializing data, you MUST enable the same options when unserializing data. Args: data (str): The raw, serialized packet data delivered from the tr...
[ "Unserializes", "the", "packet", "data", "and", "converts", "it", "from", "json", "format", "to", "normal", "Python", "datatypes", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L78-L119
train
ShadowBlip/Neteria
neteria/core.py
ListenerUDP.listen
def listen(self): """Starts the listen loop. If threading is enabled, then the loop will be started in its own thread. Args: None Returns: None """ self.listening = True if self.threading: from threading import Thread ...
python
def listen(self): """Starts the listen loop. If threading is enabled, then the loop will be started in its own thread. Args: None Returns: None """ self.listening = True if self.threading: from threading import Thread ...
[ "def", "listen", "(", "self", ")", ":", "self", ".", "listening", "=", "True", "if", "self", ".", "threading", ":", "from", "threading", "import", "Thread", "self", ".", "listen_thread", "=", "Thread", "(", "target", "=", "self", ".", "listen_loop", ")",...
Starts the listen loop. If threading is enabled, then the loop will be started in its own thread. Args: None Returns: None
[ "Starts", "the", "listen", "loop", ".", "If", "threading", "is", "enabled", "then", "the", "loop", "will", "be", "started", "in", "its", "own", "thread", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L192-L216
train
ShadowBlip/Neteria
neteria/core.py
ListenerUDP.listen_loop
def listen_loop(self): """Starts the listen loop and executes the receieve_datagram method whenever a packet is receieved. Args: None Returns: None """ while self.listening: try: data, address = self.sock.recvfrom(self.b...
python
def listen_loop(self): """Starts the listen loop and executes the receieve_datagram method whenever a packet is receieved. Args: None Returns: None """ while self.listening: try: data, address = self.sock.recvfrom(self.b...
[ "def", "listen_loop", "(", "self", ")", ":", "while", "self", ".", "listening", ":", "try", ":", "data", ",", "address", "=", "self", ".", "sock", ".", "recvfrom", "(", "self", ".", "bufsize", ")", "self", ".", "receive_datagram", "(", "data", ",", "...
Starts the listen loop and executes the receieve_datagram method whenever a packet is receieved. Args: None Returns: None
[ "Starts", "the", "listen", "loop", "and", "executes", "the", "receieve_datagram", "method", "whenever", "a", "packet", "is", "receieved", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L218-L242
train