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 listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
AtomHash/evernode | evernode/models/base_user_model.py | BaseUserModel.by_current_session | def by_current_session(cls):
""" Returns current user session """
session = Session.current_session()
if session is None:
return None
return cls.where_id(session.user_id) | python | def by_current_session(cls):
""" Returns current user session """
session = Session.current_session()
if session is None:
return None
return cls.where_id(session.user_id) | [
"def",
"by_current_session",
"(",
"cls",
")",
":",
"session",
"=",
"Session",
".",
"current_session",
"(",
")",
"if",
"session",
"is",
"None",
":",
"return",
"None",
"return",
"cls",
".",
"where_id",
"(",
"session",
".",
"user_id",
")"
] | Returns current user session | [
"Returns",
"current",
"user",
"session"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/base_user_model.py#L84-L89 | train | 57,900 |
PonteIneptique/flask-github-proxy | flask_github_proxy/models.py | ProxyError.AdvancedJsonify | def AdvancedJsonify(data, status_code):
""" Advanced Jsonify Response Maker
:param data: Data
:param status_code: Status_code
:return: Response
"""
response = jsonify(data)
response.status_code = status_code
return response | python | def AdvancedJsonify(data, status_code):
""" Advanced Jsonify Response Maker
:param data: Data
:param status_code: Status_code
:return: Response
"""
response = jsonify(data)
response.status_code = status_code
return response | [
"def",
"AdvancedJsonify",
"(",
"data",
",",
"status_code",
")",
":",
"response",
"=",
"jsonify",
"(",
"data",
")",
"response",
".",
"status_code",
"=",
"status_code",
"return",
"response"
] | Advanced Jsonify Response Maker
:param data: Data
:param status_code: Status_code
:return: Response | [
"Advanced",
"Jsonify",
"Response",
"Maker"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/models.py#L74-L83 | train | 57,901 |
PonteIneptique/flask-github-proxy | flask_github_proxy/models.py | ProxyError.response | def response(self, callback=None):
""" View representation of the object
:param callback: Function to represent the error in view. Default : flask.jsonify
:type callback: function
:return: View
"""
if not callback:
callback = type(self).AdvancedJsonify
... | python | def response(self, callback=None):
""" View representation of the object
:param callback: Function to represent the error in view. Default : flask.jsonify
:type callback: function
:return: View
"""
if not callback:
callback = type(self).AdvancedJsonify
... | [
"def",
"response",
"(",
"self",
",",
"callback",
"=",
"None",
")",
":",
"if",
"not",
"callback",
":",
"callback",
"=",
"type",
"(",
"self",
")",
".",
"AdvancedJsonify",
"resp",
"=",
"{",
"\"status\"",
":",
"\"error\"",
",",
"\"message\"",
":",
"self",
... | View representation of the object
:param callback: Function to represent the error in view. Default : flask.jsonify
:type callback: function
:return: View | [
"View",
"representation",
"of",
"the",
"object"
] | f0a60639342f7c0834360dc12a099bfc3a06d939 | https://github.com/PonteIneptique/flask-github-proxy/blob/f0a60639342f7c0834360dc12a099bfc3a06d939/flask_github_proxy/models.py#L85-L103 | train | 57,902 |
AtomHash/evernode | evernode/models/json_model.py | JsonModel.__json | def __json(self):
"""
Using the exclude lists, convert fields to a string.
"""
if self.exclude_list is None:
self.exclude_list = []
fields = {}
for key, item in vars(self).items():
if hasattr(self, '_sa_instance_state'):
# ... | python | def __json(self):
"""
Using the exclude lists, convert fields to a string.
"""
if self.exclude_list is None:
self.exclude_list = []
fields = {}
for key, item in vars(self).items():
if hasattr(self, '_sa_instance_state'):
# ... | [
"def",
"__json",
"(",
"self",
")",
":",
"if",
"self",
".",
"exclude_list",
"is",
"None",
":",
"self",
".",
"exclude_list",
"=",
"[",
"]",
"fields",
"=",
"{",
"}",
"for",
"key",
",",
"item",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
... | Using the exclude lists, convert fields to a string. | [
"Using",
"the",
"exclude",
"lists",
"convert",
"fields",
"to",
"a",
"string",
"."
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/models/json_model.py#L21-L40 | train | 57,903 |
helixyte/everest | everest/repositories/state.py | EntityState.manage | def manage(cls, entity, unit_of_work):
"""
Manages the given entity under the given Unit Of Work.
If `entity` is already managed by the given Unit Of Work, nothing
is done.
:raises ValueError: If the given entity is already under management
by a different Unit Of Work... | python | def manage(cls, entity, unit_of_work):
"""
Manages the given entity under the given Unit Of Work.
If `entity` is already managed by the given Unit Of Work, nothing
is done.
:raises ValueError: If the given entity is already under management
by a different Unit Of Work... | [
"def",
"manage",
"(",
"cls",
",",
"entity",
",",
"unit_of_work",
")",
":",
"if",
"hasattr",
"(",
"entity",
",",
"'__everest__'",
")",
":",
"if",
"not",
"unit_of_work",
"is",
"entity",
".",
"__everest__",
".",
"unit_of_work",
":",
"raise",
"ValueError",
"("... | Manages the given entity under the given Unit Of Work.
If `entity` is already managed by the given Unit Of Work, nothing
is done.
:raises ValueError: If the given entity is already under management
by a different Unit Of Work. | [
"Manages",
"the",
"given",
"entity",
"under",
"the",
"given",
"Unit",
"Of",
"Work",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L58-L73 | train | 57,904 |
helixyte/everest | everest/repositories/state.py | EntityState.release | def release(cls, entity, unit_of_work):
"""
Releases the given entity from management under the given Unit Of
Work.
:raises ValueError: If `entity` is not managed at all or is not
managed by the given Unit Of Work.
"""
if not hasattr(entity, '__everest__'):
... | python | def release(cls, entity, unit_of_work):
"""
Releases the given entity from management under the given Unit Of
Work.
:raises ValueError: If `entity` is not managed at all or is not
managed by the given Unit Of Work.
"""
if not hasattr(entity, '__everest__'):
... | [
"def",
"release",
"(",
"cls",
",",
"entity",
",",
"unit_of_work",
")",
":",
"if",
"not",
"hasattr",
"(",
"entity",
",",
"'__everest__'",
")",
":",
"raise",
"ValueError",
"(",
"'Trying to unregister an entity that has not '",
"'been registered yet!'",
")",
"elif",
... | Releases the given entity from management under the given Unit Of
Work.
:raises ValueError: If `entity` is not managed at all or is not
managed by the given Unit Of Work. | [
"Releases",
"the",
"given",
"entity",
"from",
"management",
"under",
"the",
"given",
"Unit",
"Of",
"Work",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L76-L90 | train | 57,905 |
helixyte/everest | everest/repositories/state.py | EntityState.get_state_data | def get_state_data(cls, entity):
"""
Returns the state data for the given entity.
This also works for unmanaged entities.
"""
attrs = get_domain_class_attribute_iterator(type(entity))
return dict([(attr,
get_nested_attribute(entity, attr.entity_attr... | python | def get_state_data(cls, entity):
"""
Returns the state data for the given entity.
This also works for unmanaged entities.
"""
attrs = get_domain_class_attribute_iterator(type(entity))
return dict([(attr,
get_nested_attribute(entity, attr.entity_attr... | [
"def",
"get_state_data",
"(",
"cls",
",",
"entity",
")",
":",
"attrs",
"=",
"get_domain_class_attribute_iterator",
"(",
"type",
"(",
"entity",
")",
")",
"return",
"dict",
"(",
"[",
"(",
"attr",
",",
"get_nested_attribute",
"(",
"entity",
",",
"attr",
".",
... | Returns the state data for the given entity.
This also works for unmanaged entities. | [
"Returns",
"the",
"state",
"data",
"for",
"the",
"given",
"entity",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L100-L110 | train | 57,906 |
helixyte/everest | everest/repositories/state.py | EntityState.set_state_data | def set_state_data(cls, entity, data):
"""
Sets the state data for the given entity to the given data.
This also works for unmanaged entities.
"""
attr_names = get_domain_class_attribute_names(type(entity))
nested_items = []
for attr, new_attr_value in iteritems_... | python | def set_state_data(cls, entity, data):
"""
Sets the state data for the given entity to the given data.
This also works for unmanaged entities.
"""
attr_names = get_domain_class_attribute_names(type(entity))
nested_items = []
for attr, new_attr_value in iteritems_... | [
"def",
"set_state_data",
"(",
"cls",
",",
"entity",
",",
"data",
")",
":",
"attr_names",
"=",
"get_domain_class_attribute_names",
"(",
"type",
"(",
"entity",
")",
")",
"nested_items",
"=",
"[",
"]",
"for",
"attr",
",",
"new_attr_value",
"in",
"iteritems_",
"... | Sets the state data for the given entity to the given data.
This also works for unmanaged entities. | [
"Sets",
"the",
"state",
"data",
"for",
"the",
"given",
"entity",
"to",
"the",
"given",
"data",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L113-L135 | train | 57,907 |
helixyte/everest | everest/repositories/state.py | EntityState.transfer_state_data | def transfer_state_data(cls, source_entity, target_entity):
"""
Transfers instance state data from the given source entity to the
given target entity.
"""
state_data = cls.get_state_data(source_entity)
cls.set_state_data(target_entity, state_data) | python | def transfer_state_data(cls, source_entity, target_entity):
"""
Transfers instance state data from the given source entity to the
given target entity.
"""
state_data = cls.get_state_data(source_entity)
cls.set_state_data(target_entity, state_data) | [
"def",
"transfer_state_data",
"(",
"cls",
",",
"source_entity",
",",
"target_entity",
")",
":",
"state_data",
"=",
"cls",
".",
"get_state_data",
"(",
"source_entity",
")",
"cls",
".",
"set_state_data",
"(",
"target_entity",
",",
"state_data",
")"
] | Transfers instance state data from the given source entity to the
given target entity. | [
"Transfers",
"instance",
"state",
"data",
"from",
"the",
"given",
"source",
"entity",
"to",
"the",
"given",
"target",
"entity",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L138-L144 | train | 57,908 |
helixyte/everest | everest/repositories/state.py | EntityState.__set_data | def __set_data(self, data):
"""
Sets the given state data on the given entity of the given class.
:param data: State data to set.
:type data: Dictionary mapping attributes to attribute values.
:param entity: Entity to receive the state data.
"""
ent = self.__enti... | python | def __set_data(self, data):
"""
Sets the given state data on the given entity of the given class.
:param data: State data to set.
:type data: Dictionary mapping attributes to attribute values.
:param entity: Entity to receive the state data.
"""
ent = self.__enti... | [
"def",
"__set_data",
"(",
"self",
",",
"data",
")",
":",
"ent",
"=",
"self",
".",
"__entity_ref",
"(",
")",
"self",
".",
"set_state_data",
"(",
"ent",
",",
"data",
")"
] | Sets the given state data on the given entity of the given class.
:param data: State data to set.
:type data: Dictionary mapping attributes to attribute values.
:param entity: Entity to receive the state data. | [
"Sets",
"the",
"given",
"state",
"data",
"on",
"the",
"given",
"entity",
"of",
"the",
"given",
"class",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L156-L165 | train | 57,909 |
Nekroze/partpy | partpy/partpyerror.py | PartpyError.pretty_print | def pretty_print(self, carrot=True):
"""Print the previous and current line with line numbers and
a carret under the current character position.
Will also print a message if one is given to this exception.
"""
output = ['\n']
output.extend([line.pretty_print() for line i... | python | def pretty_print(self, carrot=True):
"""Print the previous and current line with line numbers and
a carret under the current character position.
Will also print a message if one is given to this exception.
"""
output = ['\n']
output.extend([line.pretty_print() for line i... | [
"def",
"pretty_print",
"(",
"self",
",",
"carrot",
"=",
"True",
")",
":",
"output",
"=",
"[",
"'\\n'",
"]",
"output",
".",
"extend",
"(",
"[",
"line",
".",
"pretty_print",
"(",
")",
"for",
"line",
"in",
"self",
".",
"partpyobj",
".",
"get_surrounding_l... | Print the previous and current line with line numbers and
a carret under the current character position.
Will also print a message if one is given to this exception. | [
"Print",
"the",
"previous",
"and",
"current",
"line",
"with",
"line",
"numbers",
"and",
"a",
"carret",
"under",
"the",
"current",
"character",
"position",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/partpyerror.py#L17-L33 | train | 57,910 |
kapot65/python-df-parser | dfparser/rsh_parser.py | RshPackage.get_event | def get_event(self, num):
"""Extract event from dataset."""
if num < 0 or num >= self.params["events_num"]:
raise IndexError("Index out of range [0:%s]" %
(self.params["events_num"]))
ch_num = self.params['channel_number']
ev_size = self.params['... | python | def get_event(self, num):
"""Extract event from dataset."""
if num < 0 or num >= self.params["events_num"]:
raise IndexError("Index out of range [0:%s]" %
(self.params["events_num"]))
ch_num = self.params['channel_number']
ev_size = self.params['... | [
"def",
"get_event",
"(",
"self",
",",
"num",
")",
":",
"if",
"num",
"<",
"0",
"or",
"num",
">=",
"self",
".",
"params",
"[",
"\"events_num\"",
"]",
":",
"raise",
"IndexError",
"(",
"\"Index out of range [0:%s]\"",
"%",
"(",
"self",
".",
"params",
"[",
... | Extract event from dataset. | [
"Extract",
"event",
"from",
"dataset",
"."
] | bb3eec0fb7ca85d72cb1d9ed7415efe074594f26 | https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/rsh_parser.py#L351-L379 | train | 57,911 |
kapot65/python-df-parser | dfparser/rsh_parser.py | RshPackage.update_event_data | def update_event_data(self, num, data):
"""Update event data in dataset."""
if num < 0 or num >= self.params["events_num"]:
raise IndexError("Index out of range [0:%s]" %
(self.params["events_num"]))
if isinstance(data, np.ndarray):
raise Typ... | python | def update_event_data(self, num, data):
"""Update event data in dataset."""
if num < 0 or num >= self.params["events_num"]:
raise IndexError("Index out of range [0:%s]" %
(self.params["events_num"]))
if isinstance(data, np.ndarray):
raise Typ... | [
"def",
"update_event_data",
"(",
"self",
",",
"num",
",",
"data",
")",
":",
"if",
"num",
"<",
"0",
"or",
"num",
">=",
"self",
".",
"params",
"[",
"\"events_num\"",
"]",
":",
"raise",
"IndexError",
"(",
"\"Index out of range [0:%s]\"",
"%",
"(",
"self",
"... | Update event data in dataset. | [
"Update",
"event",
"data",
"in",
"dataset",
"."
] | bb3eec0fb7ca85d72cb1d9ed7415efe074594f26 | https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/rsh_parser.py#L381-L402 | train | 57,912 |
yougov/vr.common | vr/common/balancer/nginx.py | str_to_pool | def str_to_pool(upstream):
"""
Given a string containing an nginx upstream section, return the pool name
and list of nodes.
"""
name = re.search('upstream +(.*?) +{', upstream).group(1)
nodes = re.findall('server +(.*?);', upstream)
return name, nodes | python | def str_to_pool(upstream):
"""
Given a string containing an nginx upstream section, return the pool name
and list of nodes.
"""
name = re.search('upstream +(.*?) +{', upstream).group(1)
nodes = re.findall('server +(.*?);', upstream)
return name, nodes | [
"def",
"str_to_pool",
"(",
"upstream",
")",
":",
"name",
"=",
"re",
".",
"search",
"(",
"'upstream +(.*?) +{'",
",",
"upstream",
")",
".",
"group",
"(",
"1",
")",
"nodes",
"=",
"re",
".",
"findall",
"(",
"'server +(.*?);'",
",",
"upstream",
")",
"return"... | Given a string containing an nginx upstream section, return the pool name
and list of nodes. | [
"Given",
"a",
"string",
"containing",
"an",
"nginx",
"upstream",
"section",
"return",
"the",
"pool",
"name",
"and",
"list",
"of",
"nodes",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/balancer/nginx.py#L26-L33 | train | 57,913 |
asascience-open/paegan-transport | paegan/transport/models/behaviors/capability.py | Capability.calculate_vss | def calculate_vss(self, method=None):
"""
Calculate the vertical swimming speed of this behavior.
Takes into account the vertical swimming speed and the
variance.
Parameters:
method: "gaussian" (default) or "random"
"random" (vss - variance) < X... | python | def calculate_vss(self, method=None):
"""
Calculate the vertical swimming speed of this behavior.
Takes into account the vertical swimming speed and the
variance.
Parameters:
method: "gaussian" (default) or "random"
"random" (vss - variance) < X... | [
"def",
"calculate_vss",
"(",
"self",
",",
"method",
"=",
"None",
")",
":",
"if",
"self",
".",
"variance",
"==",
"float",
"(",
"0",
")",
":",
"return",
"self",
".",
"vss",
"else",
":",
"# Calculate gausian distribution and return",
"if",
"method",
"==",
"\"... | Calculate the vertical swimming speed of this behavior.
Takes into account the vertical swimming speed and the
variance.
Parameters:
method: "gaussian" (default) or "random"
"random" (vss - variance) < X < (vss + variance) | [
"Calculate",
"the",
"vertical",
"swimming",
"speed",
"of",
"this",
"behavior",
".",
"Takes",
"into",
"account",
"the",
"vertical",
"swimming",
"speed",
"and",
"the",
"variance",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/models/behaviors/capability.py#L27-L46 | train | 57,914 |
RI-imaging/qpformat | qpformat/file_formats/series_hdf5_hyperspy.py | SeriesHdf5HyperSpy._check_experiment | def _check_experiment(self, name):
"""Check the signal type of the experiment
Returns
-------
True, if the signal type is supported, False otherwise
Raises
------
Warning if the signal type is not supported
"""
with h5py.File(name=self.path, mode... | python | def _check_experiment(self, name):
"""Check the signal type of the experiment
Returns
-------
True, if the signal type is supported, False otherwise
Raises
------
Warning if the signal type is not supported
"""
with h5py.File(name=self.path, mode... | [
"def",
"_check_experiment",
"(",
"self",
",",
"name",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"name",
"=",
"self",
".",
"path",
",",
"mode",
"=",
"\"r\"",
")",
"as",
"h5",
":",
"sigpath",
"=",
"\"/Experiments/{}/metadata/Signal\"",
".",
"format",
"("... | Check the signal type of the experiment
Returns
-------
True, if the signal type is supported, False otherwise
Raises
------
Warning if the signal type is not supported | [
"Check",
"the",
"signal",
"type",
"of",
"the",
"experiment"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_hyperspy.py#L29-L48 | train | 57,915 |
RI-imaging/qpformat | qpformat/file_formats/series_hdf5_hyperspy.py | SeriesHdf5HyperSpy._get_experiments | def _get_experiments(self):
"""Get all experiments from the hdf5 file"""
explist = []
with h5py.File(name=self.path, mode="r") as h5:
if "Experiments" not in h5:
msg = "Group 'Experiments' not found in {}.".format(self.path)
raise HyperSpyNoDataFoundEr... | python | def _get_experiments(self):
"""Get all experiments from the hdf5 file"""
explist = []
with h5py.File(name=self.path, mode="r") as h5:
if "Experiments" not in h5:
msg = "Group 'Experiments' not found in {}.".format(self.path)
raise HyperSpyNoDataFoundEr... | [
"def",
"_get_experiments",
"(",
"self",
")",
":",
"explist",
"=",
"[",
"]",
"with",
"h5py",
".",
"File",
"(",
"name",
"=",
"self",
".",
"path",
",",
"mode",
"=",
"\"r\"",
")",
"as",
"h5",
":",
"if",
"\"Experiments\"",
"not",
"in",
"h5",
":",
"msg",... | Get all experiments from the hdf5 file | [
"Get",
"all",
"experiments",
"from",
"the",
"hdf5",
"file"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_hyperspy.py#L51-L68 | train | 57,916 |
RI-imaging/qpformat | qpformat/file_formats/series_hdf5_hyperspy.py | SeriesHdf5HyperSpy.verify | def verify(path):
"""Verify that `path` has the HyperSpy file format"""
valid = False
try:
h5 = h5py.File(path, mode="r")
except (OSError, IsADirectoryError):
pass
else:
if ("file_format" in h5.attrs and
h5.attrs["file_format"].... | python | def verify(path):
"""Verify that `path` has the HyperSpy file format"""
valid = False
try:
h5 = h5py.File(path, mode="r")
except (OSError, IsADirectoryError):
pass
else:
if ("file_format" in h5.attrs and
h5.attrs["file_format"].... | [
"def",
"verify",
"(",
"path",
")",
":",
"valid",
"=",
"False",
"try",
":",
"h5",
"=",
"h5py",
".",
"File",
"(",
"path",
",",
"mode",
"=",
"\"r\"",
")",
"except",
"(",
"OSError",
",",
"IsADirectoryError",
")",
":",
"pass",
"else",
":",
"if",
"(",
... | Verify that `path` has the HyperSpy file format | [
"Verify",
"that",
"path",
"has",
"the",
"HyperSpy",
"file",
"format"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/series_hdf5_hyperspy.py#L101-L113 | train | 57,917 |
shoprunback/openflow | openflow/datasource.py | DataSource.transform | def transform(self, df):
"""
Transforms a DataFrame in place. Computes all outputs of the DataFrame.
Args:
df (pandas.DataFrame): DataFrame to transform.
"""
for name, function in self.outputs:
df[name] = function(df) | python | def transform(self, df):
"""
Transforms a DataFrame in place. Computes all outputs of the DataFrame.
Args:
df (pandas.DataFrame): DataFrame to transform.
"""
for name, function in self.outputs:
df[name] = function(df) | [
"def",
"transform",
"(",
"self",
",",
"df",
")",
":",
"for",
"name",
",",
"function",
"in",
"self",
".",
"outputs",
":",
"df",
"[",
"name",
"]",
"=",
"function",
"(",
"df",
")"
] | Transforms a DataFrame in place. Computes all outputs of the DataFrame.
Args:
df (pandas.DataFrame): DataFrame to transform. | [
"Transforms",
"a",
"DataFrame",
"in",
"place",
".",
"Computes",
"all",
"outputs",
"of",
"the",
"DataFrame",
"."
] | 5bd739a0890cf09198e39bb141f987abf960ee8e | https://github.com/shoprunback/openflow/blob/5bd739a0890cf09198e39bb141f987abf960ee8e/openflow/datasource.py#L30-L38 | train | 57,918 |
helixyte/everest | everest/traversalpath.py | TraversalPath.pop | def pop(self):
"""
Removes the last traversal path node from this traversal path.
"""
node = self.nodes.pop()
self.__keys.remove(node.key) | python | def pop(self):
"""
Removes the last traversal path node from this traversal path.
"""
node = self.nodes.pop()
self.__keys.remove(node.key) | [
"def",
"pop",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"nodes",
".",
"pop",
"(",
")",
"self",
".",
"__keys",
".",
"remove",
"(",
"node",
".",
"key",
")"
] | Removes the last traversal path node from this traversal path. | [
"Removes",
"the",
"last",
"traversal",
"path",
"node",
"from",
"this",
"traversal",
"path",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversalpath.py#L51-L56 | train | 57,919 |
helixyte/everest | everest/traversalpath.py | TraversalPath.parent | def parent(self):
"""
Returns the proxy from the last node visited on the path, or `None`,
if no node has been visited yet.
"""
if len(self.nodes) > 0:
parent = self.nodes[-1].proxy
else:
parent = None
return parent | python | def parent(self):
"""
Returns the proxy from the last node visited on the path, or `None`,
if no node has been visited yet.
"""
if len(self.nodes) > 0:
parent = self.nodes[-1].proxy
else:
parent = None
return parent | [
"def",
"parent",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"nodes",
")",
">",
"0",
":",
"parent",
"=",
"self",
".",
"nodes",
"[",
"-",
"1",
"]",
".",
"proxy",
"else",
":",
"parent",
"=",
"None",
"return",
"parent"
] | Returns the proxy from the last node visited on the path, or `None`,
if no node has been visited yet. | [
"Returns",
"the",
"proxy",
"from",
"the",
"last",
"node",
"visited",
"on",
"the",
"path",
"or",
"None",
"if",
"no",
"node",
"has",
"been",
"visited",
"yet",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversalpath.py#L65-L74 | train | 57,920 |
helixyte/everest | everest/traversalpath.py | TraversalPath.relation_operation | def relation_operation(self):
"""
Returns the relation operation from the last node visited on the
path, or `None`, if no node has been visited yet.
"""
if len(self.nodes) > 0:
rel_op = self.nodes[-1].relation_operation
else:
rel_op = None
... | python | def relation_operation(self):
"""
Returns the relation operation from the last node visited on the
path, or `None`, if no node has been visited yet.
"""
if len(self.nodes) > 0:
rel_op = self.nodes[-1].relation_operation
else:
rel_op = None
... | [
"def",
"relation_operation",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"nodes",
")",
">",
"0",
":",
"rel_op",
"=",
"self",
".",
"nodes",
"[",
"-",
"1",
"]",
".",
"relation_operation",
"else",
":",
"rel_op",
"=",
"None",
"return",
"rel_op"... | Returns the relation operation from the last node visited on the
path, or `None`, if no node has been visited yet. | [
"Returns",
"the",
"relation",
"operation",
"from",
"the",
"last",
"node",
"visited",
"on",
"the",
"path",
"or",
"None",
"if",
"no",
"node",
"has",
"been",
"visited",
"yet",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversalpath.py#L77-L86 | train | 57,921 |
SeattleTestbed/seash | pyreadline/unicode_helper.py | ensure_unicode | def ensure_unicode(text):
u"""helper to ensure that text passed to WriteConsoleW is unicode"""
if isinstance(text, str):
try:
return text.decode(pyreadline_codepage, u"replace")
except (LookupError, TypeError):
return text.decode(u"ascii", u"replace")
return te... | python | def ensure_unicode(text):
u"""helper to ensure that text passed to WriteConsoleW is unicode"""
if isinstance(text, str):
try:
return text.decode(pyreadline_codepage, u"replace")
except (LookupError, TypeError):
return text.decode(u"ascii", u"replace")
return te... | [
"def",
"ensure_unicode",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"try",
":",
"return",
"text",
".",
"decode",
"(",
"pyreadline_codepage",
",",
"u\"replace\"",
")",
"except",
"(",
"LookupError",
",",
"TypeError",
")",
... | u"""helper to ensure that text passed to WriteConsoleW is unicode | [
"u",
"helper",
"to",
"ensure",
"that",
"text",
"passed",
"to",
"WriteConsoleW",
"is",
"unicode"
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/unicode_helper.py#L20-L27 | train | 57,922 |
SeattleTestbed/seash | pyreadline/unicode_helper.py | ensure_str | def ensure_str(text):
u"""Convert unicode to str using pyreadline_codepage"""
if isinstance(text, unicode):
try:
return text.encode(pyreadline_codepage, u"replace")
except (LookupError, TypeError):
return text.encode(u"ascii", u"replace")
return text | python | def ensure_str(text):
u"""Convert unicode to str using pyreadline_codepage"""
if isinstance(text, unicode):
try:
return text.encode(pyreadline_codepage, u"replace")
except (LookupError, TypeError):
return text.encode(u"ascii", u"replace")
return text | [
"def",
"ensure_str",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"unicode",
")",
":",
"try",
":",
"return",
"text",
".",
"encode",
"(",
"pyreadline_codepage",
",",
"u\"replace\"",
")",
"except",
"(",
"LookupError",
",",
"TypeError",
")",
... | u"""Convert unicode to str using pyreadline_codepage | [
"u",
"Convert",
"unicode",
"to",
"str",
"using",
"pyreadline_codepage"
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/unicode_helper.py#L29-L36 | train | 57,923 |
shaunvxc/unwrapper | unwrapper/application.py | unwrap_raw | def unwrap_raw(content):
""" unwraps the callback and returns the raw content
"""
starting_symbol = get_start_symbol(content)
ending_symbol = ']' if starting_symbol == '[' else '}'
start = content.find(starting_symbol, 0)
end = content.rfind(ending_symbol)
return content[start:end+1] | python | def unwrap_raw(content):
""" unwraps the callback and returns the raw content
"""
starting_symbol = get_start_symbol(content)
ending_symbol = ']' if starting_symbol == '[' else '}'
start = content.find(starting_symbol, 0)
end = content.rfind(ending_symbol)
return content[start:end+1] | [
"def",
"unwrap_raw",
"(",
"content",
")",
":",
"starting_symbol",
"=",
"get_start_symbol",
"(",
"content",
")",
"ending_symbol",
"=",
"']'",
"if",
"starting_symbol",
"==",
"'['",
"else",
"'}'",
"start",
"=",
"content",
".",
"find",
"(",
"starting_symbol",
",",... | unwraps the callback and returns the raw content | [
"unwraps",
"the",
"callback",
"and",
"returns",
"the",
"raw",
"content"
] | 2d08835f4cf4a2b3b75d5937399a42ac38ef38ea | https://github.com/shaunvxc/unwrapper/blob/2d08835f4cf4a2b3b75d5937399a42ac38ef38ea/unwrapper/application.py#L23-L30 | train | 57,924 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/text/text_util.py | combine_word_list | def combine_word_list(word_list):
"""
Combine word list into a bag-of-words.
Input: - word_list: This is a python list of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary.
"""
bag_of_words = collections.defaultdict(int)
... | python | def combine_word_list(word_list):
"""
Combine word list into a bag-of-words.
Input: - word_list: This is a python list of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary.
"""
bag_of_words = collections.defaultdict(int)
... | [
"def",
"combine_word_list",
"(",
"word_list",
")",
":",
"bag_of_words",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"word",
"in",
"word_list",
":",
"bag_of_words",
"[",
"word",
"]",
"+=",
"1",
"return",
"bag_of_words"
] | Combine word list into a bag-of-words.
Input: - word_list: This is a python list of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary. | [
"Combine",
"word",
"list",
"into",
"a",
"bag",
"-",
"of",
"-",
"words",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/text/text_util.py#L9-L22 | train | 57,925 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/text/text_util.py | reduce_list_of_bags_of_words | def reduce_list_of_bags_of_words(list_of_keyword_sets):
"""
Reduces a number of keyword sets to a bag-of-words.
Input: - list_of_keyword_sets: This is a python list of sets of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary.
... | python | def reduce_list_of_bags_of_words(list_of_keyword_sets):
"""
Reduces a number of keyword sets to a bag-of-words.
Input: - list_of_keyword_sets: This is a python list of sets of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary.
... | [
"def",
"reduce_list_of_bags_of_words",
"(",
"list_of_keyword_sets",
")",
":",
"bag_of_words",
"=",
"dict",
"(",
")",
"get_bag_of_words_keys",
"=",
"bag_of_words",
".",
"keys",
"for",
"keyword_set",
"in",
"list_of_keyword_sets",
":",
"for",
"keyword",
"in",
"keyword_se... | Reduces a number of keyword sets to a bag-of-words.
Input: - list_of_keyword_sets: This is a python list of sets of strings.
Output: - bag_of_words: This is the corresponding multi-set or bag-of-words, in the form of a python dictionary. | [
"Reduces",
"a",
"number",
"of",
"keyword",
"sets",
"to",
"a",
"bag",
"-",
"of",
"-",
"words",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/text/text_util.py#L25-L42 | train | 57,926 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/text/text_util.py | query_list_of_words | def query_list_of_words(target_word, list_of_words, edit_distance=1):
"""
Checks whether a target word is within editing distance of any one in a set of keywords.
Inputs: - target_word: A string containing the word we want to search in a list.
- list_of_words: A python list of words.
... | python | def query_list_of_words(target_word, list_of_words, edit_distance=1):
"""
Checks whether a target word is within editing distance of any one in a set of keywords.
Inputs: - target_word: A string containing the word we want to search in a list.
- list_of_words: A python list of words.
... | [
"def",
"query_list_of_words",
"(",
"target_word",
",",
"list_of_words",
",",
"edit_distance",
"=",
"1",
")",
":",
"# Initialize lists",
"new_list_of_words",
"=",
"list",
"(",
")",
"found_list_of_words",
"=",
"list",
"(",
")",
"append_left_keyword",
"=",
"new_list_of... | Checks whether a target word is within editing distance of any one in a set of keywords.
Inputs: - target_word: A string containing the word we want to search in a list.
- list_of_words: A python list of words.
- edit_distance: For larger words, we also check for similar words based on edit... | [
"Checks",
"whether",
"a",
"target",
"word",
"is",
"within",
"editing",
"distance",
"of",
"any",
"one",
"in",
"a",
"set",
"of",
"keywords",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/text/text_util.py#L86-L118 | train | 57,927 |
Cadasta/django-jsonattrs | jsonattrs/signals.py | fixup_instance | def fixup_instance(sender, **kwargs):
"""
Cache JSONAttributes data on instance and vice versa for convenience.
"""
instance = kwargs['instance']
for model_field in instance._meta.fields:
if not isinstance(model_field, JSONAttributeField):
continue
if hasattr(instance, ... | python | def fixup_instance(sender, **kwargs):
"""
Cache JSONAttributes data on instance and vice versa for convenience.
"""
instance = kwargs['instance']
for model_field in instance._meta.fields:
if not isinstance(model_field, JSONAttributeField):
continue
if hasattr(instance, ... | [
"def",
"fixup_instance",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
"[",
"'instance'",
"]",
"for",
"model_field",
"in",
"instance",
".",
"_meta",
".",
"fields",
":",
"if",
"not",
"isinstance",
"(",
"model_field",
",",
"J... | Cache JSONAttributes data on instance and vice versa for convenience. | [
"Cache",
"JSONAttributes",
"data",
"on",
"instance",
"and",
"vice",
"versa",
"for",
"convenience",
"."
] | 5149e08ec84da00dd73bd3fe548bc52fd361667c | https://github.com/Cadasta/django-jsonattrs/blob/5149e08ec84da00dd73bd3fe548bc52fd361667c/jsonattrs/signals.py#L12-L42 | train | 57,928 |
MostAwesomeDude/blackjack | blackjack.py | Node.size | def size(self):
"""
Recursively find size of a tree. Slow.
"""
if self is NULL:
return 0
return 1 + self.left.size() + self.right.size() | python | def size(self):
"""
Recursively find size of a tree. Slow.
"""
if self is NULL:
return 0
return 1 + self.left.size() + self.right.size() | [
"def",
"size",
"(",
"self",
")",
":",
"if",
"self",
"is",
"NULL",
":",
"return",
"0",
"return",
"1",
"+",
"self",
".",
"left",
".",
"size",
"(",
")",
"+",
"self",
".",
"right",
".",
"size",
"(",
")"
] | Recursively find size of a tree. Slow. | [
"Recursively",
"find",
"size",
"of",
"a",
"tree",
".",
"Slow",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L7-L14 | train | 57,929 |
MostAwesomeDude/blackjack | blackjack.py | Node.find_prekeyed | def find_prekeyed(self, value, key):
"""
Find a value in a node, using a key function. The value is already a
key.
"""
while self is not NULL:
direction = cmp(value, key(self.value))
if direction < 0:
self = self.left
elif dire... | python | def find_prekeyed(self, value, key):
"""
Find a value in a node, using a key function. The value is already a
key.
"""
while self is not NULL:
direction = cmp(value, key(self.value))
if direction < 0:
self = self.left
elif dire... | [
"def",
"find_prekeyed",
"(",
"self",
",",
"value",
",",
"key",
")",
":",
"while",
"self",
"is",
"not",
"NULL",
":",
"direction",
"=",
"cmp",
"(",
"value",
",",
"key",
"(",
"self",
".",
"value",
")",
")",
"if",
"direction",
"<",
"0",
":",
"self",
... | Find a value in a node, using a key function. The value is already a
key. | [
"Find",
"a",
"value",
"in",
"a",
"node",
"using",
"a",
"key",
"function",
".",
"The",
"value",
"is",
"already",
"a",
"key",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L30-L43 | train | 57,930 |
MostAwesomeDude/blackjack | blackjack.py | Node.rotate_left | def rotate_left(self):
"""
Rotate the node to the left.
"""
right = self.right
new = self._replace(right=self.right.left, red=True)
top = right._replace(left=new, red=self.red)
return top | python | def rotate_left(self):
"""
Rotate the node to the left.
"""
right = self.right
new = self._replace(right=self.right.left, red=True)
top = right._replace(left=new, red=self.red)
return top | [
"def",
"rotate_left",
"(",
"self",
")",
":",
"right",
"=",
"self",
".",
"right",
"new",
"=",
"self",
".",
"_replace",
"(",
"right",
"=",
"self",
".",
"right",
".",
"left",
",",
"red",
"=",
"True",
")",
"top",
"=",
"right",
".",
"_replace",
"(",
"... | Rotate the node to the left. | [
"Rotate",
"the",
"node",
"to",
"the",
"left",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L45-L53 | train | 57,931 |
MostAwesomeDude/blackjack | blackjack.py | Node.flip | def flip(self):
"""
Flip colors of a node and its children.
"""
left = self.left._replace(red=not self.left.red)
right = self.right._replace(red=not self.right.red)
top = self._replace(left=left, right=right, red=not self.red)
return top | python | def flip(self):
"""
Flip colors of a node and its children.
"""
left = self.left._replace(red=not self.left.red)
right = self.right._replace(red=not self.right.red)
top = self._replace(left=left, right=right, red=not self.red)
return top | [
"def",
"flip",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
".",
"_replace",
"(",
"red",
"=",
"not",
"self",
".",
"left",
".",
"red",
")",
"right",
"=",
"self",
".",
"right",
".",
"_replace",
"(",
"red",
"=",
"not",
"self",
".",
"ri... | Flip colors of a node and its children. | [
"Flip",
"colors",
"of",
"a",
"node",
"and",
"its",
"children",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L65-L73 | train | 57,932 |
MostAwesomeDude/blackjack | blackjack.py | Node.balance | def balance(self):
"""
Balance a node.
The balance is inductive and relies on all subtrees being balanced
recursively or by construction. If the subtrees are not balanced, then
this will not fix them.
"""
# Always lean left with red nodes.
if self.right.... | python | def balance(self):
"""
Balance a node.
The balance is inductive and relies on all subtrees being balanced
recursively or by construction. If the subtrees are not balanced, then
this will not fix them.
"""
# Always lean left with red nodes.
if self.right.... | [
"def",
"balance",
"(",
"self",
")",
":",
"# Always lean left with red nodes.",
"if",
"self",
".",
"right",
".",
"red",
":",
"self",
"=",
"self",
".",
"rotate_left",
"(",
")",
"# Never permit red nodes to have red children. Note that if the left-hand",
"# node is NULL, it ... | Balance a node.
The balance is inductive and relies on all subtrees being balanced
recursively or by construction. If the subtrees are not balanced, then
this will not fix them. | [
"Balance",
"a",
"node",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L75-L99 | train | 57,933 |
MostAwesomeDude/blackjack | blackjack.py | Node.insert | def insert(self, value, key):
"""
Insert a value into a tree rooted at the given node, and return
whether this was an insertion or update.
Balances the tree during insertion.
An update is performed instead of an insertion if a value in the tree
compares equal to the new... | python | def insert(self, value, key):
"""
Insert a value into a tree rooted at the given node, and return
whether this was an insertion or update.
Balances the tree during insertion.
An update is performed instead of an insertion if a value in the tree
compares equal to the new... | [
"def",
"insert",
"(",
"self",
",",
"value",
",",
"key",
")",
":",
"# Base case: Insertion into the empty tree is just creating a new node",
"# with no children.",
"if",
"self",
"is",
"NULL",
":",
"return",
"Node",
"(",
"value",
",",
"NULL",
",",
"NULL",
",",
"True... | Insert a value into a tree rooted at the given node, and return
whether this was an insertion or update.
Balances the tree during insertion.
An update is performed instead of an insertion if a value in the tree
compares equal to the new value. | [
"Insert",
"a",
"value",
"into",
"a",
"tree",
"rooted",
"at",
"the",
"given",
"node",
"and",
"return",
"whether",
"this",
"was",
"an",
"insertion",
"or",
"update",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L101-L133 | train | 57,934 |
MostAwesomeDude/blackjack | blackjack.py | Node.move_red_left | def move_red_left(self):
"""
Shuffle red to the left of a tree.
"""
self = self.flip()
if self.right is not NULL and self.right.left.red:
self = self._replace(right=self.right.rotate_right())
self = self.rotate_left().flip()
return self | python | def move_red_left(self):
"""
Shuffle red to the left of a tree.
"""
self = self.flip()
if self.right is not NULL and self.right.left.red:
self = self._replace(right=self.right.rotate_right())
self = self.rotate_left().flip()
return self | [
"def",
"move_red_left",
"(",
"self",
")",
":",
"self",
"=",
"self",
".",
"flip",
"(",
")",
"if",
"self",
".",
"right",
"is",
"not",
"NULL",
"and",
"self",
".",
"right",
".",
"left",
".",
"red",
":",
"self",
"=",
"self",
".",
"_replace",
"(",
"rig... | Shuffle red to the left of a tree. | [
"Shuffle",
"red",
"to",
"the",
"left",
"of",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L135-L145 | train | 57,935 |
MostAwesomeDude/blackjack | blackjack.py | Node.move_red_right | def move_red_right(self):
"""
Shuffle red to the right of a tree.
"""
self = self.flip()
if self.left is not NULL and self.left.left.red:
self = self.rotate_right().flip()
return self | python | def move_red_right(self):
"""
Shuffle red to the right of a tree.
"""
self = self.flip()
if self.left is not NULL and self.left.left.red:
self = self.rotate_right().flip()
return self | [
"def",
"move_red_right",
"(",
"self",
")",
":",
"self",
"=",
"self",
".",
"flip",
"(",
")",
"if",
"self",
".",
"left",
"is",
"not",
"NULL",
"and",
"self",
".",
"left",
".",
"left",
".",
"red",
":",
"self",
"=",
"self",
".",
"rotate_right",
"(",
"... | Shuffle red to the right of a tree. | [
"Shuffle",
"red",
"to",
"the",
"right",
"of",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L147-L156 | train | 57,936 |
MostAwesomeDude/blackjack | blackjack.py | Node.delete_min | def delete_min(self):
"""
Delete the left-most value from a tree.
"""
# Base case: If there are no nodes lesser than this node, then this is the
# node to delete.
if self.left is NULL:
return NULL, self.value
# Acquire more reds if necessary to conti... | python | def delete_min(self):
"""
Delete the left-most value from a tree.
"""
# Base case: If there are no nodes lesser than this node, then this is the
# node to delete.
if self.left is NULL:
return NULL, self.value
# Acquire more reds if necessary to conti... | [
"def",
"delete_min",
"(",
"self",
")",
":",
"# Base case: If there are no nodes lesser than this node, then this is the",
"# node to delete.",
"if",
"self",
".",
"left",
"is",
"NULL",
":",
"return",
"NULL",
",",
"self",
".",
"value",
"# Acquire more reds if necessary to con... | Delete the left-most value from a tree. | [
"Delete",
"the",
"left",
"-",
"most",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L158-L178 | train | 57,937 |
MostAwesomeDude/blackjack | blackjack.py | Node.delete_max | def delete_max(self):
"""
Delete the right-most value from a tree.
"""
# Attempt to rotate left-leaning reds to the right.
if self.left.red:
self = self.rotate_right()
# Base case: If there are no selfs greater than this self, then this is
# the self... | python | def delete_max(self):
"""
Delete the right-most value from a tree.
"""
# Attempt to rotate left-leaning reds to the right.
if self.left.red:
self = self.rotate_right()
# Base case: If there are no selfs greater than this self, then this is
# the self... | [
"def",
"delete_max",
"(",
"self",
")",
":",
"# Attempt to rotate left-leaning reds to the right.",
"if",
"self",
".",
"left",
".",
"red",
":",
"self",
"=",
"self",
".",
"rotate_right",
"(",
")",
"# Base case: If there are no selfs greater than this self, then this is",
"#... | Delete the right-most value from a tree. | [
"Delete",
"the",
"right",
"-",
"most",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L180-L204 | train | 57,938 |
MostAwesomeDude/blackjack | blackjack.py | Node.delete | def delete(self, value, key):
"""
Delete a value from a tree.
"""
# Base case: The empty tree cannot possibly have the desired value.
if self is NULL:
raise KeyError(value)
direction = cmp(key(value), key(self.value))
# Because we lean to the left, ... | python | def delete(self, value, key):
"""
Delete a value from a tree.
"""
# Base case: The empty tree cannot possibly have the desired value.
if self is NULL:
raise KeyError(value)
direction = cmp(key(value), key(self.value))
# Because we lean to the left, ... | [
"def",
"delete",
"(",
"self",
",",
"value",
",",
"key",
")",
":",
"# Base case: The empty tree cannot possibly have the desired value.",
"if",
"self",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"value",
")",
"direction",
"=",
"cmp",
"(",
"key",
"(",
"value",
... | Delete a value from a tree. | [
"Delete",
"a",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L206-L264 | train | 57,939 |
MostAwesomeDude/blackjack | blackjack.py | BJ.pop_max | def pop_max(self):
"""
Remove the maximum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_max()
self._len -= 1
return value | python | def pop_max(self):
"""
Remove the maximum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_max()
self._len -= 1
return value | [
"def",
"pop_max",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"\"pop from an empty blackjack\"",
")",
"self",
".",
"root",
",",
"value",
"=",
"self",
".",
"root",
".",
"delete_max",
"(",
")",
"self",
"... | Remove the maximum value and return it. | [
"Remove",
"the",
"maximum",
"value",
"and",
"return",
"it",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L339-L349 | train | 57,940 |
MostAwesomeDude/blackjack | blackjack.py | BJ.pop_min | def pop_min(self):
"""
Remove the minimum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_min()
self._len -= 1
return value | python | def pop_min(self):
"""
Remove the minimum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_min()
self._len -= 1
return value | [
"def",
"pop_min",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"\"pop from an empty blackjack\"",
")",
"self",
".",
"root",
",",
"value",
"=",
"self",
".",
"root",
".",
"delete_min",
"(",
")",
"self",
"... | Remove the minimum value and return it. | [
"Remove",
"the",
"minimum",
"value",
"and",
"return",
"it",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L351-L361 | train | 57,941 |
SeattleTestbed/seash | pyreadline/console/console.py | install_readline | def install_readline(hook):
'''Set up things for the interpreter to call
our function like GNU readline.'''
global readline_hook, readline_ref
# save the hook so the wrapper can call it
readline_hook = hook
# get the address of PyOS_ReadlineFunctionPointer so we can update it
PyOS_RF... | python | def install_readline(hook):
'''Set up things for the interpreter to call
our function like GNU readline.'''
global readline_hook, readline_ref
# save the hook so the wrapper can call it
readline_hook = hook
# get the address of PyOS_ReadlineFunctionPointer so we can update it
PyOS_RF... | [
"def",
"install_readline",
"(",
"hook",
")",
":",
"global",
"readline_hook",
",",
"readline_ref",
"# save the hook so the wrapper can call it\r",
"readline_hook",
"=",
"hook",
"# get the address of PyOS_ReadlineFunctionPointer so we can update it\r",
"PyOS_RFP",
"=",
"c_void_p",
... | Set up things for the interpreter to call
our function like GNU readline. | [
"Set",
"up",
"things",
"for",
"the",
"interpreter",
"to",
"call",
"our",
"function",
"like",
"GNU",
"readline",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L803-L820 | train | 57,942 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.fixcoord | def fixcoord(self, x, y):
u'''Return a long with x and y packed inside,
also handle negative x and y.'''
if x < 0 or y < 0:
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if x < 0:
x = info.s... | python | def fixcoord(self, x, y):
u'''Return a long with x and y packed inside,
also handle negative x and y.'''
if x < 0 or y < 0:
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if x < 0:
x = info.s... | [
"def",
"fixcoord",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"x",
"<",
"0",
"or",
"y",
"<",
"0",
":",
"info",
"=",
"CONSOLE_SCREEN_BUFFER_INFO",
"(",
")",
"self",
".",
"GetConsoleScreenBufferInfo",
"(",
"self",
".",
"hout",
",",
"byref",
"(",
... | u'''Return a long with x and y packed inside,
also handle negative x and y. | [
"u",
"Return",
"a",
"long",
"with",
"x",
"and",
"y",
"packed",
"inside",
"also",
"handle",
"negative",
"x",
"and",
"y",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L239-L251 | train | 57,943 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.write_scrolling | def write_scrolling(self, text, attr=None):
u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I reme... | python | def write_scrolling(self, text, attr=None):
u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I reme... | [
"def",
"write_scrolling",
"(",
"self",
",",
"text",
",",
"attr",
"=",
"None",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"pos",
"(",
")",
"w",
",",
"h",
"=",
"self",
".",
"size",
"(",
")",
"scroll",
"=",
"0",
"# the result\r",
"# split the string i... | u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I remember the cursor position of the
prompt so th... | [
"u",
"write",
"text",
"at",
"current",
"cursor",
"position",
"while",
"watching",
"for",
"scrolling",
".",
"If",
"the",
"window",
"scrolls",
"because",
"you",
"are",
"at",
"the",
"bottom",
"of",
"the",
"screen",
"buffer",
"all",
"positions",
"that",
"you",
... | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L294-L348 | train | 57,944 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.page | def page(self, attr=None, fill=u' '):
u'''Fill the entire screen.'''
if attr is None:
attr = self.attr
if len(fill) != 1:
raise ValueError
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if info.d... | python | def page(self, attr=None, fill=u' '):
u'''Fill the entire screen.'''
if attr is None:
attr = self.attr
if len(fill) != 1:
raise ValueError
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if info.d... | [
"def",
"page",
"(",
"self",
",",
"attr",
"=",
"None",
",",
"fill",
"=",
"u' '",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"self",
".",
"attr",
"if",
"len",
"(",
"fill",
")",
"!=",
"1",
":",
"raise",
"ValueError",
"info",
"=",
"CON... | u'''Fill the entire screen. | [
"u",
"Fill",
"the",
"entire",
"screen",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L400-L419 | train | 57,945 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.scroll | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style... | python | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style... | [
"def",
"scroll",
"(",
"self",
",",
"rect",
",",
"dx",
",",
"dy",
",",
"attr",
"=",
"None",
",",
"fill",
"=",
"' '",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"self",
".",
"attr",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"re... | u'''Scroll a rectangle. | [
"u",
"Scroll",
"a",
"rectangle",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L453-L465 | train | 57,946 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.get | def get(self):
u'''Get next event from queue.'''
inputHookFunc = c_void_p.from_address(self.inputHookPtr).value
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
if inputHookFunc:
call_function(inputHookFunc, ())
status = self.Rea... | python | def get(self):
u'''Get next event from queue.'''
inputHookFunc = c_void_p.from_address(self.inputHookPtr).value
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
if inputHookFunc:
call_function(inputHookFunc, ())
status = self.Rea... | [
"def",
"get",
"(",
"self",
")",
":",
"inputHookFunc",
"=",
"c_void_p",
".",
"from_address",
"(",
"self",
".",
"inputHookPtr",
")",
".",
"value",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"while",
"1",
":",
"if",
"... | u'''Get next event from queue. | [
"u",
"Get",
"next",
"event",
"from",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L493-L506 | train | 57,947 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.getchar | def getchar(self):
u'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
status = self.ReadConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if (status and
... | python | def getchar(self):
u'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
status = self.ReadConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if (status and
... | [
"def",
"getchar",
"(",
"self",
")",
":",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"while",
"1",
":",
"status",
"=",
"self",
".",
"ReadConsoleInputW",
"(",
"self",
".",
"hin",
",",
"byref",
"(",
"Cevent",
")",
"... | u'''Get next character from queue. | [
"u",
"Get",
"next",
"character",
"from",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L526-L541 | train | 57,948 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.peek | def peek(self):
u'''Check event queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
status = self.PeekConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if status and count == 1:
return event(self, Cevent) | python | def peek(self):
u'''Check event queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
status = self.PeekConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if status and count == 1:
return event(self, Cevent) | [
"def",
"peek",
"(",
"self",
")",
":",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"status",
"=",
"self",
".",
"PeekConsoleInputW",
"(",
"self",
".",
"hin",
",",
"byref",
"(",
"Cevent",
")",
",",
"1",
",",
"byref",... | u'''Check event queue. | [
"u",
"Check",
"event",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L543-L550 | train | 57,949 |
SeattleTestbed/seash | pyreadline/console/console.py | Console.cursor | def cursor(self, visible=None, size=None):
u'''Set cursor on or off.'''
info = CONSOLE_CURSOR_INFO()
if self.GetConsoleCursorInfo(self.hout, byref(info)):
if visible is not None:
info.bVisible = visible
if size is not None:
info.dwSi... | python | def cursor(self, visible=None, size=None):
u'''Set cursor on or off.'''
info = CONSOLE_CURSOR_INFO()
if self.GetConsoleCursorInfo(self.hout, byref(info)):
if visible is not None:
info.bVisible = visible
if size is not None:
info.dwSi... | [
"def",
"cursor",
"(",
"self",
",",
"visible",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"info",
"=",
"CONSOLE_CURSOR_INFO",
"(",
")",
"if",
"self",
".",
"GetConsoleCursorInfo",
"(",
"self",
".",
"hout",
",",
"byref",
"(",
"info",
")",
")",
":"... | u'''Set cursor on or off. | [
"u",
"Set",
"cursor",
"on",
"or",
"off",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L580-L588 | train | 57,950 |
MisanthropicBit/colorise | colorise/decorators.py | inherit_docstrings | def inherit_docstrings(cls):
"""Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class.
"""
@functools.wraps(cls)
def _inherit_docstrings(cls):
if not isinstance(cls, (type, colorise.compat.ClassType)):
r... | python | def inherit_docstrings(cls):
"""Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class.
"""
@functools.wraps(cls)
def _inherit_docstrings(cls):
if not isinstance(cls, (type, colorise.compat.ClassType)):
r... | [
"def",
"inherit_docstrings",
"(",
"cls",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"cls",
")",
"def",
"_inherit_docstrings",
"(",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"(",
"type",
",",
"colorise",
".",
"compat",
".",
"Class... | Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class. | [
"Class",
"decorator",
"for",
"inheriting",
"docstrings",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/decorators.py#L12-L35 | train | 57,951 |
lsst-sqre/lander | lander/ltdclient.py | upload | def upload(config):
"""Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials.
"""
token = get_keeper_token(config['keeper_url'],
... | python | def upload(config):
"""Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials.
"""
token = get_keeper_token(config['keeper_url'],
... | [
"def",
"upload",
"(",
"config",
")",
":",
"token",
"=",
"get_keeper_token",
"(",
"config",
"[",
"'keeper_url'",
"]",
",",
"config",
"[",
"'keeper_user'",
"]",
",",
"config",
"[",
"'keeper_password'",
"]",
")",
"build_resource",
"=",
"register_build",
"(",
"c... | Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials. | [
"Upload",
"the",
"build",
"documentation",
"site",
"to",
"LSST",
"the",
"Docs",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/ltdclient.py#L8-L32 | train | 57,952 |
lsst-sqre/lander | lander/ltdclient.py | get_keeper_token | def get_keeper_token(base_url, username, password):
"""Get a temporary auth token from LTD Keeper."""
token_endpoint = base_url + '/token'
r = requests.get(token_endpoint, auth=(username, password))
if r.status_code != 200:
raise RuntimeError('Could not authenticate to {0}: error {1:d}\n{2}'.
... | python | def get_keeper_token(base_url, username, password):
"""Get a temporary auth token from LTD Keeper."""
token_endpoint = base_url + '/token'
r = requests.get(token_endpoint, auth=(username, password))
if r.status_code != 200:
raise RuntimeError('Could not authenticate to {0}: error {1:d}\n{2}'.
... | [
"def",
"get_keeper_token",
"(",
"base_url",
",",
"username",
",",
"password",
")",
":",
"token_endpoint",
"=",
"base_url",
"+",
"'/token'",
"r",
"=",
"requests",
".",
"get",
"(",
"token_endpoint",
",",
"auth",
"=",
"(",
"username",
",",
"password",
")",
")... | Get a temporary auth token from LTD Keeper. | [
"Get",
"a",
"temporary",
"auth",
"token",
"from",
"LTD",
"Keeper",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/ltdclient.py#L35-L42 | train | 57,953 |
ponty/confduino | confduino/examples/atmega88.py | install | def install(
board_id='atmega88',
mcu='atmega88',
f_cpu=20000000,
upload='usbasp',
core='arduino',
replace_existing=True,
):
"""install atmega88 board."""
board = AutoBunch()
board.name = TEMPL.format(mcu=mcu, f_cpu=f_cpu, upload=upload)
board.upload.using = upload
board.up... | python | def install(
board_id='atmega88',
mcu='atmega88',
f_cpu=20000000,
upload='usbasp',
core='arduino',
replace_existing=True,
):
"""install atmega88 board."""
board = AutoBunch()
board.name = TEMPL.format(mcu=mcu, f_cpu=f_cpu, upload=upload)
board.upload.using = upload
board.up... | [
"def",
"install",
"(",
"board_id",
"=",
"'atmega88'",
",",
"mcu",
"=",
"'atmega88'",
",",
"f_cpu",
"=",
"20000000",
",",
"upload",
"=",
"'usbasp'",
",",
"core",
"=",
"'arduino'",
",",
"replace_existing",
"=",
"True",
",",
")",
":",
"board",
"=",
"AutoBun... | install atmega88 board. | [
"install",
"atmega88",
"board",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/atmega88.py#L9-L32 | train | 57,954 |
RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData._compute_bgid | def _compute_bgid(self, bg=None):
"""Return a unique identifier for the background data"""
if bg is None:
bg = self._bgdata
if isinstance(bg, qpimage.QPImage):
# Single QPImage
if "identifier" in bg:
return bg["identifier"]
else:
... | python | def _compute_bgid(self, bg=None):
"""Return a unique identifier for the background data"""
if bg is None:
bg = self._bgdata
if isinstance(bg, qpimage.QPImage):
# Single QPImage
if "identifier" in bg:
return bg["identifier"]
else:
... | [
"def",
"_compute_bgid",
"(",
"self",
",",
"bg",
"=",
"None",
")",
":",
"if",
"bg",
"is",
"None",
":",
"bg",
"=",
"self",
".",
"_bgdata",
"if",
"isinstance",
"(",
"bg",
",",
"qpimage",
".",
"QPImage",
")",
":",
"# Single QPImage",
"if",
"\"identifier\""... | Return a unique identifier for the background data | [
"Return",
"a",
"unique",
"identifier",
"for",
"the",
"background",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L85-L112 | train | 57,955 |
RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.identifier | def identifier(self):
"""Return a unique identifier for the given data set"""
if self.background_identifier is None:
idsum = self._identifier_data()
else:
idsum = hash_obj([self._identifier_data(),
self.background_identifier])
return ... | python | def identifier(self):
"""Return a unique identifier for the given data set"""
if self.background_identifier is None:
idsum = self._identifier_data()
else:
idsum = hash_obj([self._identifier_data(),
self.background_identifier])
return ... | [
"def",
"identifier",
"(",
"self",
")",
":",
"if",
"self",
".",
"background_identifier",
"is",
"None",
":",
"idsum",
"=",
"self",
".",
"_identifier_data",
"(",
")",
"else",
":",
"idsum",
"=",
"hash_obj",
"(",
"[",
"self",
".",
"_identifier_data",
"(",
")"... | Return a unique identifier for the given data set | [
"Return",
"a",
"unique",
"identifier",
"for",
"the",
"given",
"data",
"set"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L141-L148 | train | 57,956 |
RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.get_time | def get_time(self, idx):
"""Return time of data at index `idx`
Returns nan if the time is not defined"""
# raw data
qpi = self.get_qpimage_raw(idx)
if "time" in qpi.meta:
thetime = qpi.meta["time"]
else:
thetime = np.nan
return thetime | python | def get_time(self, idx):
"""Return time of data at index `idx`
Returns nan if the time is not defined"""
# raw data
qpi = self.get_qpimage_raw(idx)
if "time" in qpi.meta:
thetime = qpi.meta["time"]
else:
thetime = np.nan
return thetime | [
"def",
"get_time",
"(",
"self",
",",
"idx",
")",
":",
"# raw data",
"qpi",
"=",
"self",
".",
"get_qpimage_raw",
"(",
"idx",
")",
"if",
"\"time\"",
"in",
"qpi",
".",
"meta",
":",
"thetime",
"=",
"qpi",
".",
"meta",
"[",
"\"time\"",
"]",
"else",
":",
... | Return time of data at index `idx`
Returns nan if the time is not defined | [
"Return",
"time",
"of",
"data",
"at",
"index",
"idx"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L166-L176 | train | 57,957 |
RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.set_bg | def set_bg(self, dataset):
"""Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
... | python | def set_bg(self, dataset):
"""Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
... | [
"def",
"set_bg",
"(",
"self",
",",
"dataset",
")",
":",
"if",
"isinstance",
"(",
"dataset",
",",
"qpimage",
".",
"QPImage",
")",
":",
"# Single QPImage",
"self",
".",
"_bgdata",
"=",
"[",
"dataset",
"]",
"elif",
"(",
"isinstance",
"(",
"dataset",
",",
... | Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
must be one and is used for al... | [
"Set",
"background",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L293-L324 | train | 57,958 |
RI-imaging/qpformat | qpformat/file_formats/dataset.py | SingleData.get_time | def get_time(self, idx=0):
"""Time of the data
Returns nan if the time is not defined
"""
thetime = super(SingleData, self).get_time(idx=0)
return thetime | python | def get_time(self, idx=0):
"""Time of the data
Returns nan if the time is not defined
"""
thetime = super(SingleData, self).get_time(idx=0)
return thetime | [
"def",
"get_time",
"(",
"self",
",",
"idx",
"=",
"0",
")",
":",
"thetime",
"=",
"super",
"(",
"SingleData",
",",
"self",
")",
".",
"get_time",
"(",
"idx",
"=",
"0",
")",
"return",
"thetime"
] | Time of the data
Returns nan if the time is not defined | [
"Time",
"of",
"the",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L374-L380 | train | 57,959 |
justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.do | def do(self, fn, message=None, *args, **kwargs):
"""Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail)
"""
self.items.put(ChainItem(fn, self.do, me... | python | def do(self, fn, message=None, *args, **kwargs):
"""Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail)
"""
self.items.put(ChainItem(fn, self.do, me... | [
"def",
"do",
"(",
"self",
",",
"fn",
",",
"message",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"items",
".",
"put",
"(",
"ChainItem",
"(",
"fn",
",",
"self",
".",
"do",
",",
"message",
",",
"*",
"args",
",... | Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail) | [
"Add",
"a",
"do",
"action",
"to",
"the",
"steps",
".",
"This",
"is",
"a",
"function",
"to",
"execute"
] | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L47-L54 | train | 57,960 |
justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.expect | def expect(self, value, message='Failed: "{actual} {operator} {expected}" after step "{step}"', operator='=='):
"""Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that ... | python | def expect(self, value, message='Failed: "{actual} {operator} {expected}" after step "{step}"', operator='=='):
"""Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that ... | [
"def",
"expect",
"(",
"self",
",",
"value",
",",
"message",
"=",
"'Failed: \"{actual} {operator} {expected}\" after step \"{step}\"'",
",",
"operator",
"=",
"'=='",
")",
":",
"if",
"operator",
"not",
"in",
"self",
".",
"valid_operators",
":",
"raise",
"ValueError",
... | Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that the first function will return 2
>>> AssertionChain().do(lambda: 1 + 1, 'add 1 + 1').expect(2)
This will c... | [
"Add",
"an",
"assertion",
"action",
"to",
"the",
"steps",
".",
"This",
"will",
"evaluate",
"the",
"return",
"value",
"of",
"the",
"last",
"do",
"step",
"and",
"compare",
"it",
"to",
"the",
"value",
"passed",
"here",
"using",
"the",
"specified",
"operator",... | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L56-L78 | train | 57,961 |
justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.perform | def perform(self):
"""Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed
"""
last_value = None
last_step = None
while self.items.qsize():
item = self.items.get()
if ... | python | def perform(self):
"""Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed
"""
last_value = None
last_step = None
while self.items.qsize():
item = self.items.get()
if ... | [
"def",
"perform",
"(",
"self",
")",
":",
"last_value",
"=",
"None",
"last_step",
"=",
"None",
"while",
"self",
".",
"items",
".",
"qsize",
"(",
")",
":",
"item",
"=",
"self",
".",
"items",
".",
"get",
"(",
")",
"if",
"item",
".",
"flag",
"==",
"s... | Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed | [
"Runs",
"through",
"all",
"of",
"the",
"steps",
"in",
"the",
"chain",
"and",
"runs",
"each",
"of",
"them",
"in",
"sequence",
"."
] | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L80-L114 | train | 57,962 |
rossdylan/sham | sham/storage/pools.py | StoragePool.get_volumes | def get_volumes(self):
"""
Return a list of all Volumes in this Storage Pool
"""
vols = [self.find_volume(name) for name in self.virsp.listVolumes()]
return vols | python | def get_volumes(self):
"""
Return a list of all Volumes in this Storage Pool
"""
vols = [self.find_volume(name) for name in self.virsp.listVolumes()]
return vols | [
"def",
"get_volumes",
"(",
"self",
")",
":",
"vols",
"=",
"[",
"self",
".",
"find_volume",
"(",
"name",
")",
"for",
"name",
"in",
"self",
".",
"virsp",
".",
"listVolumes",
"(",
")",
"]",
"return",
"vols"
] | Return a list of all Volumes in this Storage Pool | [
"Return",
"a",
"list",
"of",
"all",
"Volumes",
"in",
"this",
"Storage",
"Pool"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/storage/pools.py#L14-L19 | train | 57,963 |
ponty/confduino | confduino/examples/dapa.py | install | def install(replace_existing=False):
"""install dapa programmer."""
bunch = AutoBunch()
bunch.name = 'DAPA'
bunch.protocol = 'dapa'
bunch.force = 'true'
# bunch.delay=200
install_programmer('dapa', bunch, replace_existing=replace_existing) | python | def install(replace_existing=False):
"""install dapa programmer."""
bunch = AutoBunch()
bunch.name = 'DAPA'
bunch.protocol = 'dapa'
bunch.force = 'true'
# bunch.delay=200
install_programmer('dapa', bunch, replace_existing=replace_existing) | [
"def",
"install",
"(",
"replace_existing",
"=",
"False",
")",
":",
"bunch",
"=",
"AutoBunch",
"(",
")",
"bunch",
".",
"name",
"=",
"'DAPA'",
"bunch",
".",
"protocol",
"=",
"'dapa'",
"bunch",
".",
"force",
"=",
"'true'",
"# bunch.delay=200",
"install_programm... | install dapa programmer. | [
"install",
"dapa",
"programmer",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/dapa.py#L7-L15 | train | 57,964 |
helixyte/everest | everest/representers/dataelements.py | SimpleMemberDataElement.get_terminal_converted | def get_terminal_converted(self, attr):
"""
Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string.
... | python | def get_terminal_converted(self, attr):
"""
Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string.
... | [
"def",
"get_terminal_converted",
"(",
"self",
",",
"attr",
")",
":",
"value",
"=",
"self",
".",
"data",
".",
"get",
"(",
"attr",
".",
"repr_name",
")",
"return",
"self",
".",
"converter_registry",
".",
"convert_to_representation",
"(",
"value",
",",
"attr",
... | Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string. | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"attribute",
"converted",
"to",
"a",
"representation",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/dataelements.py#L256-L268 | train | 57,965 |
helixyte/everest | everest/representers/dataelements.py | SimpleMemberDataElement.set_terminal_converted | def set_terminal_converted(self, attr, repr_value):
"""
Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set.
"""
value = ... | python | def set_terminal_converted(self, attr, repr_value):
"""
Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set.
"""
value = ... | [
"def",
"set_terminal_converted",
"(",
"self",
",",
"attr",
",",
"repr_value",
")",
":",
"value",
"=",
"self",
".",
"converter_registry",
".",
"convert_from_representation",
"(",
"repr_value",
",",
"attr",
".",
"value_type",
")",
"self",
".",
"data",
"[",
"attr... | Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set. | [
"Converts",
"the",
"given",
"representation",
"value",
"and",
"sets",
"the",
"specified",
"attribute",
"value",
"to",
"the",
"converted",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/dataelements.py#L270-L281 | train | 57,966 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/efi_system/efi_system_volume.py | EfiSystemVolume.load | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume. \
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError:
self.logger.error('Unable to ... | python | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume. \
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError:
self.logger.error('Unable to ... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"try",
":",
"self",
".",
"offset",
"=",
"offset",
"# self.fd = open(filename, 'rb')",
"# self.fd.close()",
"except",
"IOError",
":",
"self",
".",
"logger",
".",
"error",
"(",
"'Unable to loa... | Will eventually load information for Apple_Boot volume. \
Not yet implemented | [
"Will",
"eventually",
"load",
"information",
"for",
"Apple_Boot",
"volume",
".",
"\\",
"Not",
"yet",
"implemented"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/efi_system/efi_system_volume.py#L15-L23 | train | 57,967 |
erikvw/django-collect-offline-files | django_collect_offline_files/transaction/transaction_file_sender.py | TransactionFileSender.send | def send(self, filenames=None):
"""Sends the file to the remote host and archives
the sent file locally.
"""
try:
with self.ssh_client.connect() as ssh_conn:
with self.sftp_client.connect(ssh_conn) as sftp_conn:
for filename in filenames:
... | python | def send(self, filenames=None):
"""Sends the file to the remote host and archives
the sent file locally.
"""
try:
with self.ssh_client.connect() as ssh_conn:
with self.sftp_client.connect(ssh_conn) as sftp_conn:
for filename in filenames:
... | [
"def",
"send",
"(",
"self",
",",
"filenames",
"=",
"None",
")",
":",
"try",
":",
"with",
"self",
".",
"ssh_client",
".",
"connect",
"(",
")",
"as",
"ssh_conn",
":",
"with",
"self",
".",
"sftp_client",
".",
"connect",
"(",
"ssh_conn",
")",
"as",
"sftp... | Sends the file to the remote host and archives
the sent file locally. | [
"Sends",
"the",
"file",
"to",
"the",
"remote",
"host",
"and",
"archives",
"the",
"sent",
"file",
"locally",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_file_sender.py#L39-L55 | train | 57,968 |
AtomHash/evernode | evernode/classes/render.py | Render.compile | def compile(self, name, folder=None, data=None):
"""
renders template_name + self.extension file with data using jinja
"""
template_name = name.replace(os.sep, "")
if folder is None:
folder = ""
full_name = os.path.join(
folder.strip(os.sep... | python | def compile(self, name, folder=None, data=None):
"""
renders template_name + self.extension file with data using jinja
"""
template_name = name.replace(os.sep, "")
if folder is None:
folder = ""
full_name = os.path.join(
folder.strip(os.sep... | [
"def",
"compile",
"(",
"self",
",",
"name",
",",
"folder",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"template_name",
"=",
"name",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"\"\"",
")",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"... | renders template_name + self.extension file with data using jinja | [
"renders",
"template_name",
"+",
"self",
".",
"extension",
"file",
"with",
"data",
"using",
"jinja"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/render.py#L46-L62 | train | 57,969 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.create_token | def create_token(self, data, token_valid_for=180) -> str:
""" Create encrypted JWT """
jwt_token = jwt.encode({
'data': data,
'exp': datetime.utcnow() + timedelta(seconds=token_valid_for)},
self.app_secret)
return Security.encrypt(jwt_token) | python | def create_token(self, data, token_valid_for=180) -> str:
""" Create encrypted JWT """
jwt_token = jwt.encode({
'data': data,
'exp': datetime.utcnow() + timedelta(seconds=token_valid_for)},
self.app_secret)
return Security.encrypt(jwt_token) | [
"def",
"create_token",
"(",
"self",
",",
"data",
",",
"token_valid_for",
"=",
"180",
")",
"->",
"str",
":",
"jwt_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"'data'",
":",
"data",
",",
"'exp'",
":",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"timedel... | Create encrypted JWT | [
"Create",
"encrypted",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L38-L44 | train | 57,970 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_token | def verify_token(self, token) -> bool:
""" Verify encrypted JWT """
try:
self.data = jwt.decode(Security.decrypt(token), self.app_secret)
return True
except (Exception, BaseException) as error:
self.errors.append(error)
return False
... | python | def verify_token(self, token) -> bool:
""" Verify encrypted JWT """
try:
self.data = jwt.decode(Security.decrypt(token), self.app_secret)
return True
except (Exception, BaseException) as error:
self.errors.append(error)
return False
... | [
"def",
"verify_token",
"(",
"self",
",",
"token",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"data",
"=",
"jwt",
".",
"decode",
"(",
"Security",
".",
"decrypt",
"(",
"token",
")",
",",
"self",
".",
"app_secret",
")",
"return",
"True",
"except",... | Verify encrypted JWT | [
"Verify",
"encrypted",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L46-L54 | train | 57,971 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_http_auth_token | def verify_http_auth_token(self) -> bool:
""" Use request information to validate JWT """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_token(authorization_token):
if self.data is not None:
sel... | python | def verify_http_auth_token(self) -> bool:
""" Use request information to validate JWT """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_token(authorization_token):
if self.data is not None:
sel... | [
"def",
"verify_http_auth_token",
"(",
"self",
")",
"->",
"bool",
":",
"authorization_token",
"=",
"self",
".",
"get_http_token",
"(",
")",
"if",
"authorization_token",
"is",
"not",
"None",
":",
"if",
"self",
".",
"verify_token",
"(",
"authorization_token",
")",
... | Use request information to validate JWT | [
"Use",
"request",
"information",
"to",
"validate",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L56-L67 | train | 57,972 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.create_token_with_refresh_token | def create_token_with_refresh_token(self, data, token_valid_for=180,
refresh_token_valid_for=86400):
""" Create an encrypted JWT with a refresh_token """
refresh_token = None
refresh_token = jwt.encode({
'exp':
datetime.ut... | python | def create_token_with_refresh_token(self, data, token_valid_for=180,
refresh_token_valid_for=86400):
""" Create an encrypted JWT with a refresh_token """
refresh_token = None
refresh_token = jwt.encode({
'exp':
datetime.ut... | [
"def",
"create_token_with_refresh_token",
"(",
"self",
",",
"data",
",",
"token_valid_for",
"=",
"180",
",",
"refresh_token_valid_for",
"=",
"86400",
")",
":",
"refresh_token",
"=",
"None",
"refresh_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"'exp'",
":",
"d... | Create an encrypted JWT with a refresh_token | [
"Create",
"an",
"encrypted",
"JWT",
"with",
"a",
"refresh_token"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L69-L83 | train | 57,973 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_refresh_token | def verify_refresh_token(self, expired_token) -> bool:
""" Use request information to validate refresh JWT """
try:
decoded_token = jwt.decode(
Security.decrypt(expired_token),
self.app_secret,
options={'verify_exp': False})
... | python | def verify_refresh_token(self, expired_token) -> bool:
""" Use request information to validate refresh JWT """
try:
decoded_token = jwt.decode(
Security.decrypt(expired_token),
self.app_secret,
options={'verify_exp': False})
... | [
"def",
"verify_refresh_token",
"(",
"self",
",",
"expired_token",
")",
"->",
"bool",
":",
"try",
":",
"decoded_token",
"=",
"jwt",
".",
"decode",
"(",
"Security",
".",
"decrypt",
"(",
"expired_token",
")",
",",
"self",
".",
"app_secret",
",",
"options",
"=... | Use request information to validate refresh JWT | [
"Use",
"request",
"information",
"to",
"validate",
"refresh",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L85-L104 | train | 57,974 |
AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_http_auth_refresh_token | def verify_http_auth_refresh_token(self) -> bool:
""" Use expired token to check refresh token information """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_refresh_token(authorization_token):
if self.data is not N... | python | def verify_http_auth_refresh_token(self) -> bool:
""" Use expired token to check refresh token information """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_refresh_token(authorization_token):
if self.data is not N... | [
"def",
"verify_http_auth_refresh_token",
"(",
"self",
")",
"->",
"bool",
":",
"authorization_token",
"=",
"self",
".",
"get_http_token",
"(",
")",
"if",
"authorization_token",
"is",
"not",
"None",
":",
"if",
"self",
".",
"verify_refresh_token",
"(",
"authorization... | Use expired token to check refresh token information | [
"Use",
"expired",
"token",
"to",
"check",
"refresh",
"token",
"information"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L106-L117 | train | 57,975 |
AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.status | def status(self, status_code=None):
""" Set status or Get Status """
if status_code is not None:
self.response_model.status = status_code
# return string for response support
return str(self.response_model.status) | python | def status(self, status_code=None):
""" Set status or Get Status """
if status_code is not None:
self.response_model.status = status_code
# return string for response support
return str(self.response_model.status) | [
"def",
"status",
"(",
"self",
",",
"status_code",
"=",
"None",
")",
":",
"if",
"status_code",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"status",
"=",
"status_code",
"# return string for response support\r",
"return",
"str",
"(",
"self",
".... | Set status or Get Status | [
"Set",
"status",
"or",
"Get",
"Status"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L28-L33 | train | 57,976 |
AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.message | def message(self, message=None):
""" Set response message """
if message is not None:
self.response_model.message = message
return self.response_model.message | python | def message(self, message=None):
""" Set response message """
if message is not None:
self.response_model.message = message
return self.response_model.message | [
"def",
"message",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"message",
"=",
"message",
"return",
"self",
".",
"response_model",
".",
"message"
] | Set response message | [
"Set",
"response",
"message"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L35-L39 | train | 57,977 |
AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.data | def data(self, data=None):
""" Set response data """
if data is not None:
self.response_model.data = data
return self.response_model.data | python | def data(self, data=None):
""" Set response data """
if data is not None:
self.response_model.data = data
return self.response_model.data | [
"def",
"data",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"data",
"=",
"data",
"return",
"self",
".",
"response_model",
".",
"data"
] | Set response data | [
"Set",
"response",
"data"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L41-L45 | train | 57,978 |
AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.quick_response | def quick_response(self, status_code):
""" Quickly construct response using a status code """
translator = Translator(environ=self.environ)
if status_code == 404:
self.status(404)
self.message(translator.trans('http_messages.404'))
elif status_code == 401:
... | python | def quick_response(self, status_code):
""" Quickly construct response using a status code """
translator = Translator(environ=self.environ)
if status_code == 404:
self.status(404)
self.message(translator.trans('http_messages.404'))
elif status_code == 401:
... | [
"def",
"quick_response",
"(",
"self",
",",
"status_code",
")",
":",
"translator",
"=",
"Translator",
"(",
"environ",
"=",
"self",
".",
"environ",
")",
"if",
"status_code",
"==",
"404",
":",
"self",
".",
"status",
"(",
"404",
")",
"self",
".",
"message",
... | Quickly construct response using a status code | [
"Quickly",
"construct",
"response",
"using",
"a",
"status",
"code"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L55-L69 | train | 57,979 |
Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | memoize | def memoize(func):
"""Cache forever."""
cache = {}
def memoizer():
if 0 not in cache:
cache[0] = func()
return cache[0]
return functools.wraps(func)(memoizer) | python | def memoize(func):
"""Cache forever."""
cache = {}
def memoizer():
if 0 not in cache:
cache[0] = func()
return cache[0]
return functools.wraps(func)(memoizer) | [
"def",
"memoize",
"(",
"func",
")",
":",
"cache",
"=",
"{",
"}",
"def",
"memoizer",
"(",
")",
":",
"if",
"0",
"not",
"in",
"cache",
":",
"cache",
"[",
"0",
"]",
"=",
"func",
"(",
")",
"return",
"cache",
"[",
"0",
"]",
"return",
"functools",
"."... | Cache forever. | [
"Cache",
"forever",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L9-L16 | train | 57,980 |
Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | getinputencoding | def getinputencoding(stream=None):
"""Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin.
"""
if stream is None:
stream = sys.stdin
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | python | def getinputencoding(stream=None):
"""Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin.
"""
if stream is None:
stream = sys.stdin
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | [
"def",
"getinputencoding",
"(",
"stream",
"=",
"None",
")",
":",
"if",
"stream",
"is",
"None",
":",
"stream",
"=",
"sys",
".",
"stdin",
"encoding",
"=",
"stream",
".",
"encoding",
"if",
"not",
"encoding",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
... | Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin. | [
"Return",
"preferred",
"encoding",
"for",
"reading",
"from",
"stream",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L34-L44 | train | 57,981 |
Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | getoutputencoding | def getoutputencoding(stream=None):
"""Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout.
"""
if stream is None:
stream = sys.stdout
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | python | def getoutputencoding(stream=None):
"""Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout.
"""
if stream is None:
stream = sys.stdout
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | [
"def",
"getoutputencoding",
"(",
"stream",
"=",
"None",
")",
":",
"if",
"stream",
"is",
"None",
":",
"stream",
"=",
"sys",
".",
"stdout",
"encoding",
"=",
"stream",
".",
"encoding",
"if",
"not",
"encoding",
":",
"encoding",
"=",
"getpreferredencoding",
"("... | Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout. | [
"Return",
"preferred",
"encoding",
"for",
"writing",
"to",
"stream",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L47-L57 | train | 57,982 |
Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | decode | def decode(string, encoding=None, errors=None):
"""Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getprefe... | python | def decode(string, encoding=None, errors=None):
"""Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getprefe... | [
"def",
"decode",
"(",
"string",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
")",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"getpreferrederr... | Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler. | [
"Decode",
"from",
"specified",
"encoding",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L60-L70 | train | 57,983 |
Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | encode | def encode(string, encoding=None, errors=None):
"""Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getpreferr... | python | def encode(string, encoding=None, errors=None):
"""Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getpreferr... | [
"def",
"encode",
"(",
"string",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
")",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"getpreferrederr... | Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler. | [
"Encode",
"to",
"specified",
"encoding",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L73-L83 | train | 57,984 |
helixyte/everest | everest/views/base.py | RepresentingResourceView._get_response_mime_type | def _get_response_mime_type(self):
"""
Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view.
"""
view_name = self.request.view_n... | python | def _get_response_mime_type(self):
"""
Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view.
"""
view_name = self.request.view_n... | [
"def",
"_get_response_mime_type",
"(",
"self",
")",
":",
"view_name",
"=",
"self",
".",
"request",
".",
"view_name",
"if",
"view_name",
"!=",
"''",
":",
"mime_type",
"=",
"get_registered_mime_type_for_name",
"(",
"view_name",
")",
"else",
":",
"mime_type",
"=",
... | Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view. | [
"Returns",
"the",
"reponse",
"MIME",
"type",
"for",
"this",
"view",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L175-L217 | train | 57,985 |
helixyte/everest | everest/views/base.py | RepresentingResourceView._get_result | def _get_result(self, resource):
"""
Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
... | python | def _get_result(self, resource):
"""
Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
... | [
"def",
"_get_result",
"(",
"self",
",",
"resource",
")",
":",
"if",
"self",
".",
"_convert_response",
":",
"self",
".",
"_update_response_body",
"(",
"resource",
")",
"result",
"=",
"self",
".",
"request",
".",
"response",
"else",
":",
"result",
"=",
"dict... | Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
:type resource: Object implementing
:cla... | [
"Converts",
"the",
"given",
"resource",
"to",
"a",
"result",
"to",
"be",
"returned",
"from",
"the",
"view",
".",
"Unless",
"a",
"custom",
"renderer",
"is",
"employed",
"this",
"will",
"involve",
"creating",
"a",
"representer",
"and",
"using",
"it",
"to",
"... | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L244-L262 | train | 57,986 |
helixyte/everest | everest/views/base.py | RepresentingResourceView._update_response_body | def _update_response_body(self, resource):
"""
Creates a representer and updates the response body with the byte
representation created for the given resource.
"""
rpr = self._get_response_representer(resource)
# Set content type and body of the response.
self.req... | python | def _update_response_body(self, resource):
"""
Creates a representer and updates the response body with the byte
representation created for the given resource.
"""
rpr = self._get_response_representer(resource)
# Set content type and body of the response.
self.req... | [
"def",
"_update_response_body",
"(",
"self",
",",
"resource",
")",
":",
"rpr",
"=",
"self",
".",
"_get_response_representer",
"(",
"resource",
")",
"# Set content type and body of the response.",
"self",
".",
"request",
".",
"response",
".",
"content_type",
"=",
"rp... | Creates a representer and updates the response body with the byte
representation created for the given resource. | [
"Creates",
"a",
"representer",
"and",
"updates",
"the",
"response",
"body",
"with",
"the",
"byte",
"representation",
"created",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L264-L274 | train | 57,987 |
helixyte/everest | everest/views/base.py | RepresentingResourceView._update_response_location_header | def _update_response_location_header(self, resource):
"""
Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource.
"""
location = resource_to_url(resource, request=self.request)
loc_hdr = ('Location', location)
... | python | def _update_response_location_header(self, resource):
"""
Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource.
"""
location = resource_to_url(resource, request=self.request)
loc_hdr = ('Location', location)
... | [
"def",
"_update_response_location_header",
"(",
"self",
",",
"resource",
")",
":",
"location",
"=",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"self",
".",
"request",
")",
"loc_hdr",
"=",
"(",
"'Location'",
",",
"location",
")",
"hdr_names",
"=",... | Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource. | [
"Adds",
"a",
"new",
"or",
"replaces",
"an",
"existing",
"Location",
"header",
"to",
"the",
"response",
"headers",
"pointing",
"to",
"the",
"URL",
"of",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L276-L292 | train | 57,988 |
helixyte/everest | everest/views/base.py | ModifyingResourceView._get_request_representer | def _get_request_representer(self):
"""
Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported.
"""
try:
mime_type = \
get_registered_mime_type_for_... | python | def _get_request_representer(self):
"""
Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported.
"""
try:
mime_type = \
get_registered_mime_type_for_... | [
"def",
"_get_request_representer",
"(",
"self",
")",
":",
"try",
":",
"mime_type",
"=",
"get_registered_mime_type_for_string",
"(",
"self",
".",
"request",
".",
"content_type",
")",
"except",
"KeyError",
":",
"# The client sent a content type we do not support (415).",
"r... | Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported. | [
"Returns",
"a",
"representer",
"for",
"the",
"content",
"type",
"specified",
"in",
"the",
"request",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L421-L434 | train | 57,989 |
helixyte/everest | everest/views/base.py | ModifyingResourceView._extract_request_data | def _extract_request_data(self):
"""
Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object imple... | python | def _extract_request_data(self):
"""
Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object imple... | [
"def",
"_extract_request_data",
"(",
"self",
")",
":",
"rpr",
"=",
"self",
".",
"_get_request_representer",
"(",
")",
"return",
"rpr",
".",
"data_from_bytes",
"(",
"self",
".",
"request",
".",
"body",
")"
] | Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object implementing the
:class:`everest.representers.inte... | [
"Extracts",
"the",
"data",
"from",
"the",
"representation",
"submitted",
"in",
"the",
"request",
"body",
"and",
"returns",
"it",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L436-L451 | train | 57,990 |
helixyte/everest | everest/views/base.py | ModifyingResourceView._handle_conflict | def _handle_conflict(self, name):
"""
Handles requests that triggered a conflict.
Respond with a 409 "Conflict"
"""
err = HTTPConflict('Member "%s" already exists!' % name).exception
return self.request.get_response(err) | python | def _handle_conflict(self, name):
"""
Handles requests that triggered a conflict.
Respond with a 409 "Conflict"
"""
err = HTTPConflict('Member "%s" already exists!' % name).exception
return self.request.get_response(err) | [
"def",
"_handle_conflict",
"(",
"self",
",",
"name",
")",
":",
"err",
"=",
"HTTPConflict",
"(",
"'Member \"%s\" already exists!'",
"%",
"name",
")",
".",
"exception",
"return",
"self",
".",
"request",
".",
"get_response",
"(",
"err",
")"
] | Handles requests that triggered a conflict.
Respond with a 409 "Conflict" | [
"Handles",
"requests",
"that",
"triggered",
"a",
"conflict",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L479-L486 | train | 57,991 |
helixyte/everest | everest/views/base.py | WarnAndResubmitUserMessageChecker.check | def check(self):
"""
Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed.
"""
... | python | def check(self):
"""
Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed.
"""
... | [
"def",
"check",
"(",
"self",
")",
":",
"request",
"=",
"get_current_request",
"(",
")",
"ignore_guid",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'ignore-message'",
")",
"coll",
"=",
"request",
".",
"root",
"[",
"'_messages'",
"]",
"vote",
"=",
"Fa... | Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed. | [
"Implements",
"user",
"message",
"checking",
"for",
"views",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L522-L538 | train | 57,992 |
helixyte/everest | everest/views/base.py | WarnAndResubmitUserMessageChecker.create_307_response | def create_307_response(self):
"""
Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request.
"""
request = get_current_request()
msg_mb = UserMessageMember(self.... | python | def create_307_response(self):
"""
Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request.
"""
request = get_current_request()
msg_mb = UserMessageMember(self.... | [
"def",
"create_307_response",
"(",
"self",
")",
":",
"request",
"=",
"get_current_request",
"(",
")",
"msg_mb",
"=",
"UserMessageMember",
"(",
"self",
".",
"message",
")",
"coll",
"=",
"request",
".",
"root",
"[",
"'_messages'",
"]",
"coll",
".",
"add",
"(... | Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request. | [
"Creates",
"a",
"307",
"Temporary",
"Redirect",
"response",
"including",
"a",
"HTTP",
"Warning",
"header",
"with",
"code",
"299",
"that",
"contains",
"the",
"user",
"message",
"received",
"during",
"processing",
"the",
"request",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L540-L560 | train | 57,993 |
CMUSTRUDEL/strudel.utils | stutils/sysutils.py | mkdir | def mkdir(*args):
"""Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True
"""
path = ''
for chunk in args:
path = os.path.join(path, chunk)
if not os.path.isdir(p... | python | def mkdir(*args):
"""Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True
"""
path = ''
for chunk in args:
path = os.path.join(path, chunk)
if not os.path.isdir(p... | [
"def",
"mkdir",
"(",
"*",
"args",
")",
":",
"path",
"=",
"''",
"for",
"chunk",
"in",
"args",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"chunk",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":"... | Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True | [
"Create",
"a",
"directory",
"specified",
"by",
"a",
"sequence",
"of",
"subdirectories"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/sysutils.py#L11-L24 | train | 57,994 |
CMUSTRUDEL/strudel.utils | stutils/sysutils.py | shell | def shell(cmd, *args, **kwargs):
# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]
""" Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
... | python | def shell(cmd, *args, **kwargs):
# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]
""" Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
... | [
"def",
"shell",
"(",
"cmd",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]",
"if",
"kwargs",
".",
"get",
"(",
"'rel_path'",
")",
"and",
"not",
"cmd",
".",
"startswith",
"(",
"\"/... | Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
rel_path (bool): execute relative to the path (default: `False`)
raise_on_status(bool): bool, raise exception if... | [
"Execute",
"shell",
"command",
"and",
"return",
"output"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/sysutils.py#L27-L64 | train | 57,995 |
Yipit/eventlib | eventlib/listener.py | listen_for_events | def listen_for_events():
"""Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play.
"""
import_event_modules()
conn = redis_connection.get_connection()
pubsub = conn.pubsub()
pubsub.subscribe("eventlib")
for message in pu... | python | def listen_for_events():
"""Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play.
"""
import_event_modules()
conn = redis_connection.get_connection()
pubsub = conn.pubsub()
pubsub.subscribe("eventlib")
for message in pu... | [
"def",
"listen_for_events",
"(",
")",
":",
"import_event_modules",
"(",
")",
"conn",
"=",
"redis_connection",
".",
"get_connection",
"(",
")",
"pubsub",
"=",
"conn",
".",
"pubsub",
"(",
")",
"pubsub",
".",
"subscribe",
"(",
"\"eventlib\"",
")",
"for",
"messa... | Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play. | [
"Pubsub",
"event",
"listener"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/listener.py#L21-L37 | train | 57,996 |
rajeevs1992/pyhealthvault | src/healthvaultlib/helpers/requestmanager.py | RequestManager.sendrequest | def sendrequest(self, request):
'''
Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py
'''
url = urlparse.urlparse(self.connection.healthserviceurl)
conn = None
if url.scheme == 'https':
... | python | def sendrequest(self, request):
'''
Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py
'''
url = urlparse.urlparse(self.connection.healthserviceurl)
conn = None
if url.scheme == 'https':
... | [
"def",
"sendrequest",
"(",
"self",
",",
"request",
")",
":",
"url",
"=",
"urlparse",
".",
"urlparse",
"(",
"self",
".",
"connection",
".",
"healthserviceurl",
")",
"conn",
"=",
"None",
"if",
"url",
".",
"scheme",
"==",
"'https'",
":",
"conn",
"=",
"htt... | Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py | [
"Recieves",
"a",
"request",
"xml",
"as",
"a",
"string",
"and",
"posts",
"it",
"to",
"the",
"health",
"service",
"url",
"specified",
"in",
"the",
"settings",
".",
"py"
] | 2b6fa7c1687300bcc2e501368883fbb13dc80495 | https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/helpers/requestmanager.py#L94-L117 | train | 57,997 |
helixyte/everest | everest/repositories/filesystem/repository.py | FileSystemRepository.commit | def commit(self, unit_of_work):
"""
Dump all resources that were modified by the given session back into
the repository.
"""
MemoryRepository.commit(self, unit_of_work)
if self.is_initialized:
entity_classes_to_dump = set()
for state in unit_of_wor... | python | def commit(self, unit_of_work):
"""
Dump all resources that were modified by the given session back into
the repository.
"""
MemoryRepository.commit(self, unit_of_work)
if self.is_initialized:
entity_classes_to_dump = set()
for state in unit_of_wor... | [
"def",
"commit",
"(",
"self",
",",
"unit_of_work",
")",
":",
"MemoryRepository",
".",
"commit",
"(",
"self",
",",
"unit_of_work",
")",
"if",
"self",
".",
"is_initialized",
":",
"entity_classes_to_dump",
"=",
"set",
"(",
")",
"for",
"state",
"in",
"unit_of_wo... | Dump all resources that were modified by the given session back into
the repository. | [
"Dump",
"all",
"resources",
"that",
"were",
"modified",
"by",
"the",
"given",
"session",
"back",
"into",
"the",
"repository",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/filesystem/repository.py#L44-L55 | train | 57,998 |
lsst-sqre/lander | lander/config.py | Configuration._validate_pdf_file | def _validate_pdf_file(self):
"""Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails.
"""
if self['pdf_path'] is None:
self._logger.error('--pdf argument must be set')
sys.exi... | python | def _validate_pdf_file(self):
"""Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails.
"""
if self['pdf_path'] is None:
self._logger.error('--pdf argument must be set')
sys.exi... | [
"def",
"_validate_pdf_file",
"(",
"self",
")",
":",
"if",
"self",
"[",
"'pdf_path'",
"]",
"is",
"None",
":",
"self",
".",
"_logger",
".",
"error",
"(",
"'--pdf argument must be set'",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"if",
"not",
"os",
".",
"pat... | Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails. | [
"Validate",
"that",
"the",
"pdf_path",
"configuration",
"is",
"set",
"and",
"the",
"referenced",
"file",
"exists",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L221-L232 | train | 57,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.