repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
alfred82santa/dirty-models | dirty_models/models.py | recover_dynamic_model_from_data | def recover_dynamic_model_from_data(model_class, original_data, modified_data, deleted_data, structure):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class()
model.__st... | python | def recover_dynamic_model_from_data(model_class, original_data, modified_data, deleted_data, structure):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class()
model.__st... | [
"def",
"recover_dynamic_model_from_data",
"(",
"model_class",
",",
"original_data",
",",
"modified_data",
",",
"deleted_data",
",",
"structure",
")",
":",
"model",
"=",
"model_class",
"(",
")",
"model",
".",
"__structure__",
"=",
"{",
"k",
":",
"d",
"[",
"0",
... | Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object | [
"Function",
"to",
"reconstruct",
"a",
"model",
"from",
"DirtyModel",
"basic",
"information",
":",
"original",
"data",
"the",
"modified",
"and",
"deleted",
"fields",
".",
"Necessary",
"for",
"pickle",
"an",
"object"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L779-L789 |
alfred82santa/dirty-models | dirty_models/models.py | recover_hashmap_model_from_data | def recover_hashmap_model_from_data(model_class, original_data, modified_data, deleted_data, field_type):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class(field_type=field... | python | def recover_hashmap_model_from_data(model_class, original_data, modified_data, deleted_data, field_type):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class(field_type=field... | [
"def",
"recover_hashmap_model_from_data",
"(",
"model_class",
",",
"original_data",
",",
"modified_data",
",",
"deleted_data",
",",
"field_type",
")",
":",
"model",
"=",
"model_class",
"(",
"field_type",
"=",
"field_type",
"[",
"0",
"]",
"(",
"*",
"*",
"field_ty... | Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object | [
"Function",
"to",
"reconstruct",
"a",
"model",
"from",
"DirtyModel",
"basic",
"information",
":",
"original",
"data",
"the",
"modified",
"and",
"deleted",
"fields",
".",
"Necessary",
"for",
"pickle",
"an",
"object"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L853-L860 |
alfred82santa/dirty-models | dirty_models/models.py | recover_fast_dynamic_model_from_data | def recover_fast_dynamic_model_from_data(model_class, original_data, modified_data, deleted_data, field_types):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class()
mod... | python | def recover_fast_dynamic_model_from_data(model_class, original_data, modified_data, deleted_data, field_types):
"""
Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object
"""
model = model_class()
mod... | [
"def",
"recover_fast_dynamic_model_from_data",
"(",
"model_class",
",",
"original_data",
",",
"modified_data",
",",
"deleted_data",
",",
"field_types",
")",
":",
"model",
"=",
"model_class",
"(",
")",
"model",
".",
"__field_types__",
"=",
"{",
"k",
":",
"d",
"["... | Function to reconstruct a model from DirtyModel basic information: original data, the modified and deleted
fields.
Necessary for pickle an object | [
"Function",
"to",
"reconstruct",
"a",
"model",
"from",
"DirtyModel",
"basic",
"information",
":",
"original",
"data",
"the",
"modified",
"and",
"deleted",
"fields",
".",
"Necessary",
"for",
"pickle",
"an",
"object"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L956-L966 |
alfred82santa/dirty-models | dirty_models/models.py | DirtyModelMeta.process_base_field | def process_base_field(cls, field, key):
"""
Preprocess field instances.
:param field: Field object
:param key: Key where field was found
"""
if not field.name:
field.name = key
elif key != field.name:
if not isinstance(field.alias, list):... | python | def process_base_field(cls, field, key):
"""
Preprocess field instances.
:param field: Field object
:param key: Key where field was found
"""
if not field.name:
field.name = key
elif key != field.name:
if not isinstance(field.alias, list):... | [
"def",
"process_base_field",
"(",
"cls",
",",
"field",
",",
"key",
")",
":",
"if",
"not",
"field",
".",
"name",
":",
"field",
".",
"name",
"=",
"key",
"elif",
"key",
"!=",
"field",
".",
"name",
":",
"if",
"not",
"isinstance",
"(",
"field",
".",
"al... | Preprocess field instances.
:param field: Field object
:param key: Key where field was found | [
"Preprocess",
"field",
"instances",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L62-L83 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.set_field_value | def set_field_value(self, name, value):
"""
Set the value to the field modified_data
"""
name = self.get_real_name(name)
if not name or not self._can_write_field(name):
return
if name in self.__deleted_fields__:
self.__deleted_fields__.remove(nam... | python | def set_field_value(self, name, value):
"""
Set the value to the field modified_data
"""
name = self.get_real_name(name)
if not name or not self._can_write_field(name):
return
if name in self.__deleted_fields__:
self.__deleted_fields__.remove(nam... | [
"def",
"set_field_value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"if",
"not",
"name",
"or",
"not",
"self",
".",
"_can_write_field",
"(",
"name",
")",
":",
"return",
"if",
"name",
... | Set the value to the field modified_data | [
"Set",
"the",
"value",
"to",
"the",
"field",
"modified_data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L203-L228 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.get_field_value | def get_field_value(self, name):
"""
Get the field value from the modified data or the original one
"""
name = self.get_real_name(name)
if not name or name in self.__deleted_fields__:
return None
modified = self.__modified_data__.get(name)
if modified... | python | def get_field_value(self, name):
"""
Get the field value from the modified data or the original one
"""
name = self.get_real_name(name)
if not name or name in self.__deleted_fields__:
return None
modified = self.__modified_data__.get(name)
if modified... | [
"def",
"get_field_value",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"if",
"not",
"name",
"or",
"name",
"in",
"self",
".",
"__deleted_fields__",
":",
"return",
"None",
"modified",
"=",
"self",
".",
... | Get the field value from the modified data or the original one | [
"Get",
"the",
"field",
"value",
"from",
"the",
"modified",
"data",
"or",
"the",
"original",
"one"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L230-L241 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.delete_field_value | def delete_field_value(self, name):
"""
Mark this field to be deleted
"""
name = self.get_real_name(name)
if name and self._can_write_field(name):
if name in self.__modified_data__:
self.__modified_data__.pop(name)
if name in self.__origi... | python | def delete_field_value(self, name):
"""
Mark this field to be deleted
"""
name = self.get_real_name(name)
if name and self._can_write_field(name):
if name in self.__modified_data__:
self.__modified_data__.pop(name)
if name in self.__origi... | [
"def",
"delete_field_value",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"if",
"name",
"and",
"self",
".",
"_can_write_field",
"(",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"__modified_data__... | Mark this field to be deleted | [
"Mark",
"this",
"field",
"to",
"be",
"deleted"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L243-L254 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.reset_field_value | def reset_field_value(self, name):
"""
Resets value of a field
"""
name = self.get_real_name(name)
if name and self._can_write_field(name):
if name in self.__modified_data__:
del self.__modified_data__[name]
if name in self.__deleted_fiel... | python | def reset_field_value(self, name):
"""
Resets value of a field
"""
name = self.get_real_name(name)
if name and self._can_write_field(name):
if name in self.__modified_data__:
del self.__modified_data__[name]
if name in self.__deleted_fiel... | [
"def",
"reset_field_value",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"if",
"name",
"and",
"self",
".",
"_can_write_field",
"(",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"__modified_data__"... | Resets value of a field | [
"Resets",
"value",
"of",
"a",
"field"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L256-L272 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.is_modified_field | def is_modified_field(self, name):
"""
Returns whether a field is modified or not
"""
name = self.get_real_name(name)
if name in self.__modified_data__ or name in self.__deleted_fields__:
return True
try:
return self.get_field_value(name).is_modi... | python | def is_modified_field(self, name):
"""
Returns whether a field is modified or not
"""
name = self.get_real_name(name)
if name in self.__modified_data__ or name in self.__deleted_fields__:
return True
try:
return self.get_field_value(name).is_modi... | [
"def",
"is_modified_field",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"if",
"name",
"in",
"self",
".",
"__modified_data__",
"or",
"name",
"in",
"self",
".",
"__deleted_fields__",
":",
"return",
"True",... | Returns whether a field is modified or not | [
"Returns",
"whether",
"a",
"field",
"is",
"modified",
"or",
"not"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L274-L286 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.import_data | def import_data(self, data):
"""
Set the fields established in data to the instance
"""
if self.get_read_only() and self.is_locked():
return
if isinstance(data, BaseModel):
data = data.export_data()
if not isinstance(data, (dict, Mapping)):
... | python | def import_data(self, data):
"""
Set the fields established in data to the instance
"""
if self.get_read_only() and self.is_locked():
return
if isinstance(data, BaseModel):
data = data.export_data()
if not isinstance(data, (dict, Mapping)):
... | [
"def",
"import_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"get_read_only",
"(",
")",
"and",
"self",
".",
"is_locked",
"(",
")",
":",
"return",
"if",
"isinstance",
"(",
"data",
",",
"BaseModel",
")",
":",
"data",
"=",
"data",
".",
... | Set the fields established in data to the instance | [
"Set",
"the",
"fields",
"established",
"in",
"data",
"to",
"the",
"instance"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L288-L301 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.import_deleted_fields | def import_deleted_fields(self, data):
"""
Set data fields to deleted
"""
if self.get_read_only() and self.is_locked():
return
if isinstance(data, str):
data = [data]
for key in data:
if hasattr(self, key):
delattr(se... | python | def import_deleted_fields(self, data):
"""
Set data fields to deleted
"""
if self.get_read_only() and self.is_locked():
return
if isinstance(data, str):
data = [data]
for key in data:
if hasattr(self, key):
delattr(se... | [
"def",
"import_deleted_fields",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"get_read_only",
"(",
")",
"and",
"self",
".",
"is_locked",
"(",
")",
":",
"return",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"[",
"data... | Set data fields to deleted | [
"Set",
"data",
"fields",
"to",
"deleted"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L319-L341 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.export_data | def export_data(self):
"""
Get the results with the modified_data
"""
result = {}
data = self.__original_data__.copy()
data.update(self.__modified_data__)
for key, value in data.items():
if key in self.__deleted_fields__:
continue
... | python | def export_data(self):
"""
Get the results with the modified_data
"""
result = {}
data = self.__original_data__.copy()
data.update(self.__modified_data__)
for key, value in data.items():
if key in self.__deleted_fields__:
continue
... | [
"def",
"export_data",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"data",
"=",
"self",
".",
"__original_data__",
".",
"copy",
"(",
")",
"data",
".",
"update",
"(",
"self",
".",
"__modified_data__",
")",
"for",
"key",
",",
"value",
"in",
"data",
"... | Get the results with the modified_data | [
"Get",
"the",
"results",
"with",
"the",
"modified_data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L343-L359 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.export_modified_data | def export_modified_data(self):
"""
Get the modified data
"""
# TODO: why None? Try to get a better flag
result = {key: None for key in self.__deleted_fields__}
for key, value in self.__modified_data__.items():
if key in result.keys():
continu... | python | def export_modified_data(self):
"""
Get the modified data
"""
# TODO: why None? Try to get a better flag
result = {key: None for key in self.__deleted_fields__}
for key, value in self.__modified_data__.items():
if key in result.keys():
continu... | [
"def",
"export_modified_data",
"(",
"self",
")",
":",
"# TODO: why None? Try to get a better flag",
"result",
"=",
"{",
"key",
":",
"None",
"for",
"key",
"in",
"self",
".",
"__deleted_fields__",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__modified_dat... | Get the modified data | [
"Get",
"the",
"modified",
"data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L361-L385 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.export_modifications | def export_modifications(self):
"""
Returns model modifications.
"""
result = {}
for key, value in self.__modified_data__.items():
try:
result[key] = value.export_data()
except AttributeError:
result[key] = value
... | python | def export_modifications(self):
"""
Returns model modifications.
"""
result = {}
for key, value in self.__modified_data__.items():
try:
result[key] = value.export_data()
except AttributeError:
result[key] = value
... | [
"def",
"export_modifications",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__modified_data__",
".",
"items",
"(",
")",
":",
"try",
":",
"result",
"[",
"key",
"]",
"=",
"value",
".",
"export_data",
"... | Returns model modifications. | [
"Returns",
"model",
"modifications",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L387-L415 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.get_original_field_value | def get_original_field_value(self, name):
"""
Returns original field value or None
"""
name = self.get_real_name(name)
try:
value = self.__original_data__[name]
except KeyError:
return None
try:
return value.export_original_da... | python | def get_original_field_value(self, name):
"""
Returns original field value or None
"""
name = self.get_real_name(name)
try:
value = self.__original_data__[name]
except KeyError:
return None
try:
return value.export_original_da... | [
"def",
"get_original_field_value",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"get_real_name",
"(",
"name",
")",
"try",
":",
"value",
"=",
"self",
".",
"__original_data__",
"[",
"name",
"]",
"except",
"KeyError",
":",
"return",
"None",
... | Returns original field value or None | [
"Returns",
"original",
"field",
"value",
"or",
"None"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L417-L431 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.export_original_data | def export_original_data(self):
"""
Get the original data
"""
return {key: self.get_original_field_value(key) for key in self.__original_data__.keys()} | python | def export_original_data(self):
"""
Get the original data
"""
return {key: self.get_original_field_value(key) for key in self.__original_data__.keys()} | [
"def",
"export_original_data",
"(",
"self",
")",
":",
"return",
"{",
"key",
":",
"self",
".",
"get_original_field_value",
"(",
"key",
")",
"for",
"key",
"in",
"self",
".",
"__original_data__",
".",
"keys",
"(",
")",
"}"
] | Get the original data | [
"Get",
"the",
"original",
"data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L433-L438 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.export_deleted_fields | def export_deleted_fields(self):
"""
Resturns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended.
"""
result = self.__deleted_fields__.copy()
for key, value in self.__original_data__.items():
if key ... | python | def export_deleted_fields(self):
"""
Resturns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended.
"""
result = self.__deleted_fields__.copy()
for key, value in self.__original_data__.items():
if key ... | [
"def",
"export_deleted_fields",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"__deleted_fields__",
".",
"copy",
"(",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__original_data__",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"result",
... | Resturns a list with any deleted fields form original data.
In tree models, deleted fields on children will be appended. | [
"Resturns",
"a",
"list",
"with",
"any",
"deleted",
"fields",
"form",
"original",
"data",
".",
"In",
"tree",
"models",
"deleted",
"fields",
"on",
"children",
"will",
"be",
"appended",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L440-L456 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.flat_data | def flat_data(self):
"""
Pass all the data from modified_data to original_data
"""
def flat_field(value):
"""
Flat field data
"""
try:
value.flat_data()
return value
except AttributeError:
... | python | def flat_data(self):
"""
Pass all the data from modified_data to original_data
"""
def flat_field(value):
"""
Flat field data
"""
try:
value.flat_data()
return value
except AttributeError:
... | [
"def",
"flat_data",
"(",
"self",
")",
":",
"def",
"flat_field",
"(",
"value",
")",
":",
"\"\"\"\n Flat field data\n \"\"\"",
"try",
":",
"value",
".",
"flat_data",
"(",
")",
"return",
"value",
"except",
"AttributeError",
":",
"return",
"value... | Pass all the data from modified_data to original_data | [
"Pass",
"all",
"the",
"data",
"from",
"modified_data",
"to",
"original_data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L458-L479 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.clear_modified_data | def clear_modified_data(self):
"""
Clears only the modified data
"""
self.__modified_data__ = {}
self.__deleted_fields__ = []
for value in self.__original_data__.values():
try:
value.clear_modified_data()
except AttributeError:
... | python | def clear_modified_data(self):
"""
Clears only the modified data
"""
self.__modified_data__ = {}
self.__deleted_fields__ = []
for value in self.__original_data__.values():
try:
value.clear_modified_data()
except AttributeError:
... | [
"def",
"clear_modified_data",
"(",
"self",
")",
":",
"self",
".",
"__modified_data__",
"=",
"{",
"}",
"self",
".",
"__deleted_fields__",
"=",
"[",
"]",
"for",
"value",
"in",
"self",
".",
"__original_data__",
".",
"values",
"(",
")",
":",
"try",
":",
"val... | Clears only the modified data | [
"Clears",
"only",
"the",
"modified",
"data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L481-L492 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.clear | def clear(self):
"""
Clears all the data in the object, keeping original data
"""
self.__modified_data__ = {}
self.__deleted_fields__ = [field for field in self.__original_data__.keys()] | python | def clear(self):
"""
Clears all the data in the object, keeping original data
"""
self.__modified_data__ = {}
self.__deleted_fields__ = [field for field in self.__original_data__.keys()] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"__modified_data__",
"=",
"{",
"}",
"self",
".",
"__deleted_fields__",
"=",
"[",
"field",
"for",
"field",
"in",
"self",
".",
"__original_data__",
".",
"keys",
"(",
")",
"]"
] | Clears all the data in the object, keeping original data | [
"Clears",
"all",
"the",
"data",
"in",
"the",
"object",
"keeping",
"original",
"data"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L494-L499 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.get_fields | def get_fields(self):
"""
Returns used fields of model
"""
result = [key for key in self.__original_data__.keys()
if key not in self.__deleted_fields__]
result.extend([key for key in self.__modified_data__.keys()
if key not in result and k... | python | def get_fields(self):
"""
Returns used fields of model
"""
result = [key for key in self.__original_data__.keys()
if key not in self.__deleted_fields__]
result.extend([key for key in self.__modified_data__.keys()
if key not in result and k... | [
"def",
"get_fields",
"(",
"self",
")",
":",
"result",
"=",
"[",
"key",
"for",
"key",
"in",
"self",
".",
"__original_data__",
".",
"keys",
"(",
")",
"if",
"key",
"not",
"in",
"self",
".",
"__deleted_fields__",
"]",
"result",
".",
"extend",
"(",
"[",
"... | Returns used fields of model | [
"Returns",
"used",
"fields",
"of",
"model"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L509-L518 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.is_modified | def is_modified(self):
"""
Returns whether model is modified or not
"""
if len(self.__modified_data__) or len(self.__deleted_fields__):
return True
for value in self.__original_data__.values():
try:
if value.is_modified():
... | python | def is_modified(self):
"""
Returns whether model is modified or not
"""
if len(self.__modified_data__) or len(self.__deleted_fields__):
return True
for value in self.__original_data__.values():
try:
if value.is_modified():
... | [
"def",
"is_modified",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"__modified_data__",
")",
"or",
"len",
"(",
"self",
".",
"__deleted_fields__",
")",
":",
"return",
"True",
"for",
"value",
"in",
"self",
".",
"__original_data__",
".",
"values",
... | Returns whether model is modified or not | [
"Returns",
"whether",
"model",
"is",
"modified",
"or",
"not"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L520-L534 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.get_attrs_by_path | def get_attrs_by_path(self, field_path, stop_first=False):
"""
It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
... | python | def get_attrs_by_path(self, field_path, stop_first=False):
"""
It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
... | [
"def",
"get_attrs_by_path",
"(",
"self",
",",
"field_path",
",",
"stop_first",
"=",
"False",
")",
":",
"fields",
",",
"next_field",
"=",
"self",
".",
"_get_fields_by_path",
"(",
"field_path",
")",
"values",
"=",
"[",
"]",
"for",
"field",
"in",
"fields",
":... | It returns list of values looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: list or None.
:param stop_first: Stop iteration on first value looked up. Default: Fals... | [
"It",
"returns",
"list",
"of",
"values",
"looked",
"up",
"by",
"field",
"path",
".",
"Field",
"path",
"is",
"dot",
"-",
"formatted",
"string",
"path",
":",
"parent_field",
".",
"child_field",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L593-L628 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.get_1st_attr_by_path | def get_1st_attr_by_path(self, field_path, **kwargs):
"""
It returns first value looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
:param defau... | python | def get_1st_attr_by_path(self, field_path, **kwargs):
"""
It returns first value looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
:param defau... | [
"def",
"get_1st_attr_by_path",
"(",
"self",
",",
"field_path",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"self",
".",
"get_attrs_by_path",
"(",
"field_path",
",",
"stop_first",
"=",
"True",
")",
"if",
"res",
"is",
"None",
":",
"try",
":",
"return",
... | It returns first value looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
:param default: Default value if field does not exist.
If it i... | [
"It",
"returns",
"first",
"value",
"looked",
"up",
"by",
"field",
"path",
".",
"Field",
"path",
"is",
"dot",
"-",
"formatted",
"string",
"path",
":",
"parent_field",
".",
"child_field",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L630-L648 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.delete_attr_by_path | def delete_attr_by_path(self, field_path):
"""
It deletes fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
"""
fields, next_fie... | python | def delete_attr_by_path(self, field_path):
"""
It deletes fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
"""
fields, next_fie... | [
"def",
"delete_attr_by_path",
"(",
"self",
",",
"field_path",
")",
":",
"fields",
",",
"next_field",
"=",
"self",
".",
"_get_fields_by_path",
"(",
"field_path",
")",
"for",
"field",
"in",
"fields",
":",
"if",
"next_field",
":",
"try",
":",
"self",
".",
"ge... | It deletes fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str | [
"It",
"deletes",
"fields",
"looked",
"up",
"by",
"field",
"path",
".",
"Field",
"path",
"is",
"dot",
"-",
"formatted",
"string",
"path",
":",
"parent_field",
".",
"child_field",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L650-L666 |
alfred82santa/dirty-models | dirty_models/models.py | BaseModel.reset_attr_by_path | def reset_attr_by_path(self, field_path):
"""
It restores original values for fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
"""
... | python | def reset_attr_by_path(self, field_path):
"""
It restores original values for fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str
"""
... | [
"def",
"reset_attr_by_path",
"(",
"self",
",",
"field_path",
")",
":",
"fields",
",",
"next_field",
"=",
"self",
".",
"_get_fields_by_path",
"(",
"field_path",
")",
"for",
"field",
"in",
"fields",
":",
"if",
"next_field",
":",
"try",
":",
"self",
".",
"get... | It restores original values for fields looked up by field path.
Field path is dot-formatted string path: ``parent_field.child_field``.
:param field_path: field path. It allows ``*`` as wildcard.
:type field_path: str | [
"It",
"restores",
"original",
"values",
"for",
"fields",
"looked",
"up",
"by",
"field",
"path",
".",
"Field",
"path",
"is",
"dot",
"-",
"formatted",
"string",
"path",
":",
"parent_field",
".",
"child_field",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L668-L684 |
alfred82santa/dirty-models | dirty_models/models.py | BaseDynamicModel._get_field_type | def _get_field_type(self, key, value):
"""
Helper to create field object based on value type
"""
if isinstance(value, bool):
return BooleanField(name=key)
elif isinstance(value, int):
return IntegerField(name=key)
elif isinstance(value, float):
... | python | def _get_field_type(self, key, value):
"""
Helper to create field object based on value type
"""
if isinstance(value, bool):
return BooleanField(name=key)
elif isinstance(value, int):
return IntegerField(name=key)
elif isinstance(value, float):
... | [
"def",
"_get_field_type",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"BooleanField",
"(",
"name",
"=",
"key",
")",
"elif",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"ret... | Helper to create field object based on value type | [
"Helper",
"to",
"create",
"field",
"object",
"based",
"on",
"value",
"type"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L726-L760 |
alfred82santa/dirty-models | dirty_models/models.py | BaseDynamicModel._import_data | def _import_data(self, data):
"""
Set the fields established in data to the instance
"""
for key, value in data.items():
if key.startswith('__'):
self._not_allowed_field(key)
continue
if not self.get_field_obj(key) and not self._d... | python | def _import_data(self, data):
"""
Set the fields established in data to the instance
"""
for key, value in data.items():
if key.startswith('__'):
self._not_allowed_field(key)
continue
if not self.get_field_obj(key) and not self._d... | [
"def",
"_import_data",
"(",
"self",
",",
"data",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"'__'",
")",
":",
"self",
".",
"_not_allowed_field",
"(",
"key",
")",
"continue",
... | Set the fields established in data to the instance | [
"Set",
"the",
"fields",
"established",
"in",
"data",
"to",
"the",
"instance"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L762-L776 |
alfred82santa/dirty-models | dirty_models/models.py | HashMapModel.copy | def copy(self):
"""
Creates a copy of model
"""
return self.__class__(field_type=self.get_field_type(), data=self.export_data()) | python | def copy(self):
"""
Creates a copy of model
"""
return self.__class__(field_type=self.get_field_type(), data=self.export_data()) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"field_type",
"=",
"self",
".",
"get_field_type",
"(",
")",
",",
"data",
"=",
"self",
".",
"export_data",
"(",
")",
")"
] | Creates a copy of model | [
"Creates",
"a",
"copy",
"of",
"model"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L885-L889 |
alfred82santa/dirty-models | dirty_models/models.py | HashMapModel.get_validated_object | def get_validated_object(self, value):
"""
Returns the value validated by the field_type
"""
try:
if self.get_field_type().check_value(value) or self.get_field_type().can_use_value(value):
data = self.get_field_type().use_value(value)
self._pre... | python | def get_validated_object(self, value):
"""
Returns the value validated by the field_type
"""
try:
if self.get_field_type().check_value(value) or self.get_field_type().can_use_value(value):
data = self.get_field_type().use_value(value)
self._pre... | [
"def",
"get_validated_object",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"if",
"self",
".",
"get_field_type",
"(",
")",
".",
"check_value",
"(",
"value",
")",
"or",
"self",
".",
"get_field_type",
"(",
")",
".",
"can_use_value",
"(",
"value",
")",
... | Returns the value validated by the field_type | [
"Returns",
"the",
"value",
"validated",
"by",
"the",
"field_type"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L891-L903 |
alfred82santa/dirty-models | dirty_models/models.py | FastDynamicModel.get_validated_object | def get_validated_object(self, field_type, value):
"""
Returns the value validated by the field_type
"""
if field_type.check_value(value) or field_type.can_use_value(value):
data = field_type.use_value(value)
self._prepare_child(data)
return data
... | python | def get_validated_object(self, field_type, value):
"""
Returns the value validated by the field_type
"""
if field_type.check_value(value) or field_type.can_use_value(value):
data = field_type.use_value(value)
self._prepare_child(data)
return data
... | [
"def",
"get_validated_object",
"(",
"self",
",",
"field_type",
",",
"value",
")",
":",
"if",
"field_type",
".",
"check_value",
"(",
"value",
")",
"or",
"field_type",
".",
"can_use_value",
"(",
"value",
")",
":",
"data",
"=",
"field_type",
".",
"use_value",
... | Returns the value validated by the field_type | [
"Returns",
"the",
"value",
"validated",
"by",
"the",
"field_type"
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L984-L993 |
alfred82santa/dirty-models | dirty_models/models.py | FastDynamicModel.get_current_structure | def get_current_structure(self):
"""
Returns a dictionary with model field objects.
:return: dict
"""
struct = self.__class__.get_structure()
struct.update(self.__field_types__)
return struct | python | def get_current_structure(self):
"""
Returns a dictionary with model field objects.
:return: dict
"""
struct = self.__class__.get_structure()
struct.update(self.__field_types__)
return struct | [
"def",
"get_current_structure",
"(",
"self",
")",
":",
"struct",
"=",
"self",
".",
"__class__",
".",
"get_structure",
"(",
")",
"struct",
".",
"update",
"(",
"self",
".",
"__field_types__",
")",
"return",
"struct"
] | Returns a dictionary with model field objects.
:return: dict | [
"Returns",
"a",
"dictionary",
"with",
"model",
"field",
"objects",
"."
] | train | https://github.com/alfred82santa/dirty-models/blob/354becdb751b21f673515eae928c256c7e923c50/dirty_models/models.py#L995-L1004 |
danielfrg/datasciencebox | datasciencebox/core/ssh.py | SSHClient.connect | def connect(self):
"""Connect to host
"""
try:
self.client.connect(self.host, username=self.username,
password=self.password, port=self.port,
pkey=self.pkey, timeout=self.timeout)
except sock_gaierror, ex:
rais... | python | def connect(self):
"""Connect to host
"""
try:
self.client.connect(self.host, username=self.username,
password=self.password, port=self.port,
pkey=self.pkey, timeout=self.timeout)
except sock_gaierror, ex:
rais... | [
"def",
"connect",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"connect",
"(",
"self",
".",
"host",
",",
"username",
"=",
"self",
".",
"username",
",",
"password",
"=",
"self",
".",
"password",
",",
"port",
"=",
"self",
".",
"port... | Connect to host | [
"Connect",
"to",
"host"
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/ssh.py#L35-L51 |
danielfrg/datasciencebox | datasciencebox/core/ssh.py | SSHClient.exec_command | def exec_command(self, command, sudo=False, **kwargs):
"""Wrapper to paramiko.SSHClient.exec_command
"""
channel = self.client.get_transport().open_session()
# stdin = channel.makefile('wb')
stdout = channel.makefile('rb')
stderr = channel.makefile_stderr('rb')
i... | python | def exec_command(self, command, sudo=False, **kwargs):
"""Wrapper to paramiko.SSHClient.exec_command
"""
channel = self.client.get_transport().open_session()
# stdin = channel.makefile('wb')
stdout = channel.makefile('rb')
stderr = channel.makefile_stderr('rb')
i... | [
"def",
"exec_command",
"(",
"self",
",",
"command",
",",
"sudo",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"channel",
"=",
"self",
".",
"client",
".",
"get_transport",
"(",
")",
".",
"open_session",
"(",
")",
"# stdin = channel.makefile('wb')",
"std... | Wrapper to paramiko.SSHClient.exec_command | [
"Wrapper",
"to",
"paramiko",
".",
"SSHClient",
".",
"exec_command"
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/ssh.py#L56-L78 |
danielfrg/datasciencebox | datasciencebox/core/ssh.py | SSHClient.make_sftp | def make_sftp(self):
"""Make SFTP client from open transport"""
transport = self.client.get_transport()
transport.open_session()
return paramiko.SFTPClient.from_transport(transport) | python | def make_sftp(self):
"""Make SFTP client from open transport"""
transport = self.client.get_transport()
transport.open_session()
return paramiko.SFTPClient.from_transport(transport) | [
"def",
"make_sftp",
"(",
"self",
")",
":",
"transport",
"=",
"self",
".",
"client",
".",
"get_transport",
"(",
")",
"transport",
".",
"open_session",
"(",
")",
"return",
"paramiko",
".",
"SFTPClient",
".",
"from_transport",
"(",
"transport",
")"
] | Make SFTP client from open transport | [
"Make",
"SFTP",
"client",
"from",
"open",
"transport"
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/ssh.py#L85-L89 |
danielfrg/datasciencebox | datasciencebox/core/ssh.py | SSHClient.put | def put(self, local, remote, sudo=False):
"""Copy local file to host via SFTP/SCP
Copy is done natively using SFTP/SCP version 2 protocol, no scp command
is used or required.
"""
if(os.path.isdir(local)):
self.put_dir(local, remote, sudo=sudo)
else:
... | python | def put(self, local, remote, sudo=False):
"""Copy local file to host via SFTP/SCP
Copy is done natively using SFTP/SCP version 2 protocol, no scp command
is used or required.
"""
if(os.path.isdir(local)):
self.put_dir(local, remote, sudo=sudo)
else:
... | [
"def",
"put",
"(",
"self",
",",
"local",
",",
"remote",
",",
"sudo",
"=",
"False",
")",
":",
"if",
"(",
"os",
".",
"path",
".",
"isdir",
"(",
"local",
")",
")",
":",
"self",
".",
"put_dir",
"(",
"local",
",",
"remote",
",",
"sudo",
"=",
"sudo",... | Copy local file to host via SFTP/SCP
Copy is done natively using SFTP/SCP version 2 protocol, no scp command
is used or required. | [
"Copy",
"local",
"file",
"to",
"host",
"via",
"SFTP",
"/",
"SCP"
] | train | https://github.com/danielfrg/datasciencebox/blob/6b7aa642c6616a46547035fcb815acc1de605a6f/datasciencebox/core/ssh.py#L114-L123 |
dcramer/django-static-compiler | src/static_compiler/templatetags/static_compiler.py | staticbundle | def staticbundle(bundle, mimetype=None, **attrs):
"""
>>> {% staticbundle 'bundlename.css' %}
>>> {% staticbundle 'bundlename.css' media='screen' %}
>>> {% staticbundle 'bundlename' mimetype='text/css' %}
"""
config = getattr(settings, 'STATIC_BUNDLES', {})
if settings.DEBUG and 'packages' ... | python | def staticbundle(bundle, mimetype=None, **attrs):
"""
>>> {% staticbundle 'bundlename.css' %}
>>> {% staticbundle 'bundlename.css' media='screen' %}
>>> {% staticbundle 'bundlename' mimetype='text/css' %}
"""
config = getattr(settings, 'STATIC_BUNDLES', {})
if settings.DEBUG and 'packages' ... | [
"def",
"staticbundle",
"(",
"bundle",
",",
"mimetype",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"config",
"=",
"getattr",
"(",
"settings",
",",
"'STATIC_BUNDLES'",
",",
"{",
"}",
")",
"if",
"settings",
".",
"DEBUG",
"and",
"'packages'",
"in",
"co... | >>> {% staticbundle 'bundlename.css' %}
>>> {% staticbundle 'bundlename.css' media='screen' %}
>>> {% staticbundle 'bundlename' mimetype='text/css' %} | [
">>>",
"{",
"%",
"staticbundle",
"bundlename",
".",
"css",
"%",
"}",
">>>",
"{",
"%",
"staticbundle",
"bundlename",
".",
"css",
"media",
"=",
"screen",
"%",
"}",
">>>",
"{",
"%",
"staticbundle",
"bundlename",
"mimetype",
"=",
"text",
"/",
"css",
"%",
"... | train | https://github.com/dcramer/django-static-compiler/blob/7218d30e1b4eb88b7a8683ae5748f6a71c502b81/src/static_compiler/templatetags/static_compiler.py#L35-L106 |
rodynnz/xccdf | src/xccdf/models/version.py | Version.str_to_time | def str_to_time(self):
"""
Formats a XCCDF dateTime string to a datetime object.
:returns: datetime object.
:rtype: datetime.datetime
"""
return datetime(*list(map(int, re.split(r'-|:|T', self.time)))) | python | def str_to_time(self):
"""
Formats a XCCDF dateTime string to a datetime object.
:returns: datetime object.
:rtype: datetime.datetime
"""
return datetime(*list(map(int, re.split(r'-|:|T', self.time)))) | [
"def",
"str_to_time",
"(",
"self",
")",
":",
"return",
"datetime",
"(",
"*",
"list",
"(",
"map",
"(",
"int",
",",
"re",
".",
"split",
"(",
"r'-|:|T'",
",",
"self",
".",
"time",
")",
")",
")",
")"
] | Formats a XCCDF dateTime string to a datetime object.
:returns: datetime object.
:rtype: datetime.datetime | [
"Formats",
"a",
"XCCDF",
"dateTime",
"string",
"to",
"a",
"datetime",
"object",
"."
] | train | https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/version.py#L75-L83 |
rodynnz/xccdf | src/xccdf/models/version.py | Version.update_xml_element | def update_xml_element(self):
"""
Updates the xml element contents to matches the instance contents
:returns: Updated XML element
:rtype: lxml.etree._Element
"""
if not hasattr(self, 'xml_element'):
self.xml_element = etree.Element(self.name, nsmap=NSMAP)
... | python | def update_xml_element(self):
"""
Updates the xml element contents to matches the instance contents
:returns: Updated XML element
:rtype: lxml.etree._Element
"""
if not hasattr(self, 'xml_element'):
self.xml_element = etree.Element(self.name, nsmap=NSMAP)
... | [
"def",
"update_xml_element",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'xml_element'",
")",
":",
"self",
".",
"xml_element",
"=",
"etree",
".",
"Element",
"(",
"self",
".",
"name",
",",
"nsmap",
"=",
"NSMAP",
")",
"if",
"hasattr... | Updates the xml element contents to matches the instance contents
:returns: Updated XML element
:rtype: lxml.etree._Element | [
"Updates",
"the",
"xml",
"element",
"contents",
"to",
"matches",
"the",
"instance",
"contents"
] | train | https://github.com/rodynnz/xccdf/blob/1b9dc2f06b5cce8db2a54c5f95a8f6bcf5cb6981/src/xccdf/models/version.py#L85-L102 |
metagriffin/globre | globre/__init__.py | compile | def compile(pattern, flags=0, sep=None, split_prefix=False):
'''
Converts a glob-matching pattern (using Apache Cocoon style rules)
to a regular expression, which basically means that the following
characters have special meanings:
* ``?``: matches any single character excluding the separator character
... | python | def compile(pattern, flags=0, sep=None, split_prefix=False):
'''
Converts a glob-matching pattern (using Apache Cocoon style rules)
to a regular expression, which basically means that the following
characters have special meanings:
* ``?``: matches any single character excluding the separator character
... | [
"def",
"compile",
"(",
"pattern",
",",
"flags",
"=",
"0",
",",
"sep",
"=",
"None",
",",
"split_prefix",
"=",
"False",
")",
":",
"prefix",
"=",
"None",
"expr",
"=",
"''",
"if",
"sep",
"is",
"None",
":",
"sep",
"=",
"'/'",
"if",
"not",
"sep",
":",
... | Converts a glob-matching pattern (using Apache Cocoon style rules)
to a regular expression, which basically means that the following
characters have special meanings:
* ``?``: matches any single character excluding the separator character
* ``*``: matches zero or more characters excluding the separator... | [
"Converts",
"a",
"glob",
"-",
"matching",
"pattern",
"(",
"using",
"Apache",
"Cocoon",
"style",
"rules",
")",
"to",
"a",
"regular",
"expression",
"which",
"basically",
"means",
"that",
"the",
"following",
"characters",
"have",
"special",
"meanings",
":"
] | train | https://github.com/metagriffin/globre/blob/d4b0ffb352b0b7d5e221d2357d4094e390d4fbeb/globre/__init__.py#L120-L216 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_value | def parse_value(type: str, val: str):
"""
Parses a given OBD value of a given type (PID)
and returns the parsed value.
If the PID is unknown / not implemented a PIDParserUnknownError
will be raised including the type which was unknown
:param type:
:param val:
:return:
"""
if type... | python | def parse_value(type: str, val: str):
"""
Parses a given OBD value of a given type (PID)
and returns the parsed value.
If the PID is unknown / not implemented a PIDParserUnknownError
will be raised including the type which was unknown
:param type:
:param val:
:return:
"""
if type... | [
"def",
"parse_value",
"(",
"type",
":",
"str",
",",
"val",
":",
"str",
")",
":",
"if",
"type",
".",
"upper",
"(",
")",
"in",
"PARSER_MAP",
":",
"#prep_val = prepare_value(val)",
"out",
"=",
"PARSER_MAP",
"[",
"type",
"]",
"(",
"val",
")",
"log",
".",
... | Parses a given OBD value of a given type (PID)
and returns the parsed value.
If the PID is unknown / not implemented a PIDParserUnknownError
will be raised including the type which was unknown
:param type:
:param val:
:return: | [
"Parses",
"a",
"given",
"OBD",
"value",
"of",
"a",
"given",
"type",
"(",
"PID",
")",
"and",
"returns",
"the",
"parsed",
"value",
".",
"If",
"the",
"PID",
"is",
"unknown",
"/",
"not",
"implemented",
"a",
"PIDParserUnknownError",
"will",
"be",
"raised",
"i... | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L83-L99 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_obj | def parse_obj(o):
"""
Parses a given dictionary with the key being the OBD PID and the value its
returned value by the OBD interface
:param dict o:
:return:
"""
r = {}
for k, v in o.items():
if is_unable_to_connect(v):
r[k] = None
try:
r[k] = pars... | python | def parse_obj(o):
"""
Parses a given dictionary with the key being the OBD PID and the value its
returned value by the OBD interface
:param dict o:
:return:
"""
r = {}
for k, v in o.items():
if is_unable_to_connect(v):
r[k] = None
try:
r[k] = pars... | [
"def",
"parse_obj",
"(",
"o",
")",
":",
"r",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"o",
".",
"items",
"(",
")",
":",
"if",
"is_unable_to_connect",
"(",
"v",
")",
":",
"r",
"[",
"k",
"]",
"=",
"None",
"try",
":",
"r",
"[",
"k",
"]",
"... | Parses a given dictionary with the key being the OBD PID and the value its
returned value by the OBD interface
:param dict o:
:return: | [
"Parses",
"a",
"given",
"dictionary",
"with",
"the",
"key",
"being",
"the",
"OBD",
"PID",
"and",
"the",
"value",
"its",
"returned",
"value",
"by",
"the",
"OBD",
"interface",
":",
"param",
"dict",
"o",
":",
":",
"return",
":"
] | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L102-L118 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_0101 | def parse_0101(v):
"""
Parses the DTC status and returns two elements.
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_01
:param v:
:return bool, int:
"""
tv = trim_obd_value(v)
mil_status = None # type: bool
num_dtc = None # type: int
try:
byte_a = int(v[:2], 16)... | python | def parse_0101(v):
"""
Parses the DTC status and returns two elements.
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_01
:param v:
:return bool, int:
"""
tv = trim_obd_value(v)
mil_status = None # type: bool
num_dtc = None # type: int
try:
byte_a = int(v[:2], 16)... | [
"def",
"parse_0101",
"(",
"v",
")",
":",
"tv",
"=",
"trim_obd_value",
"(",
"v",
")",
"mil_status",
"=",
"None",
"# type: bool",
"num_dtc",
"=",
"None",
"# type: int",
"try",
":",
"byte_a",
"=",
"int",
"(",
"v",
"[",
":",
"2",
"]",
",",
"16",
")",
"... | Parses the DTC status and returns two elements.
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_01
:param v:
:return bool, int: | [
"Parses",
"the",
"DTC",
"status",
"and",
"returns",
"two",
"elements",
".",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"OBD",
"-",
"II_PIDs#Mode_1_PID_01",
":",
"param",
"v",
":",
":",
"return",
"bool",
"int",
":"
] | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L145-L164 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_0103 | def parse_0103(v):
"""
Parses the fuel system status and returns an array with two elements (one for
each fuel system).
The returned values are converted to decimal integers and returned as is.
The fuel system values are described here:
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03
... | python | def parse_0103(v):
"""
Parses the fuel system status and returns an array with two elements (one for
each fuel system).
The returned values are converted to decimal integers and returned as is.
The fuel system values are described here:
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03
... | [
"def",
"parse_0103",
"(",
"v",
")",
":",
"tv",
"=",
"trim_obd_value",
"(",
"v",
")",
"# trimmed value",
"status_1",
",",
"status_2",
"=",
"None",
",",
"None",
"try",
":",
"status_1",
"=",
"int",
"(",
"v",
"[",
":",
"2",
"]",
",",
"16",
")",
"except... | Parses the fuel system status and returns an array with two elements (one for
each fuel system).
The returned values are converted to decimal integers and returned as is.
The fuel system values are described here:
https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03
1 Open loop due to insuffici... | [
"Parses",
"the",
"fuel",
"system",
"status",
"and",
"returns",
"an",
"array",
"with",
"two",
"elements",
"(",
"one",
"for",
"each",
"fuel",
"system",
")",
".",
"The",
"returned",
"values",
"are",
"converted",
"to",
"decimal",
"integers",
"and",
"returned",
... | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L167-L200 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_010c | def parse_010c(v) -> int:
"""
Parses Engine RPM and returns it in [RPM] as a float from 0 - 16383.75
:param str v:
:return int:
"""
try:
val = int(trim_obd_value(v), 16)
return int(val / 4)
except ValueError:
return None | python | def parse_010c(v) -> int:
"""
Parses Engine RPM and returns it in [RPM] as a float from 0 - 16383.75
:param str v:
:return int:
"""
try:
val = int(trim_obd_value(v), 16)
return int(val / 4)
except ValueError:
return None | [
"def",
"parse_010c",
"(",
"v",
")",
"->",
"int",
":",
"try",
":",
"val",
"=",
"int",
"(",
"trim_obd_value",
"(",
"v",
")",
",",
"16",
")",
"return",
"int",
"(",
"val",
"/",
"4",
")",
"except",
"ValueError",
":",
"return",
"None"
] | Parses Engine RPM and returns it in [RPM] as a float from 0 - 16383.75
:param str v:
:return int: | [
"Parses",
"Engine",
"RPM",
"and",
"returns",
"it",
"in",
"[",
"RPM",
"]",
"as",
"a",
"float",
"from",
"0",
"-",
"16383",
".",
"75",
":",
"param",
"str",
"v",
":",
":",
"return",
"int",
":"
] | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L228-L238 |
rGunti/CarPi-OBDDaemon | obddaemon/custom/Obd2DataParser.py | parse_0134_013b | def parse_0134_013b(v):
"""
Parses the O2 Sensor Value (0134 - 013B) and returns two values parsed from it:
1. Fuel-Air Equivalence [Ratio] as a float from 0 - 2
2. Current in [mA] as a float from -128 - 128
:param str v:
:return tuple of float, float:
"""
try:
trim_val = trim_ob... | python | def parse_0134_013b(v):
"""
Parses the O2 Sensor Value (0134 - 013B) and returns two values parsed from it:
1. Fuel-Air Equivalence [Ratio] as a float from 0 - 2
2. Current in [mA] as a float from -128 - 128
:param str v:
:return tuple of float, float:
"""
try:
trim_val = trim_ob... | [
"def",
"parse_0134_013b",
"(",
"v",
")",
":",
"try",
":",
"trim_val",
"=",
"trim_obd_value",
"(",
"v",
")",
"val_ab",
"=",
"int",
"(",
"trim_val",
"[",
"0",
":",
"2",
"]",
",",
"16",
")",
"val_cd",
"=",
"int",
"(",
"trim_val",
"[",
"2",
":",
"4",... | Parses the O2 Sensor Value (0134 - 013B) and returns two values parsed from it:
1. Fuel-Air Equivalence [Ratio] as a float from 0 - 2
2. Current in [mA] as a float from -128 - 128
:param str v:
:return tuple of float, float: | [
"Parses",
"the",
"O2",
"Sensor",
"Value",
"(",
"0134",
"-",
"013B",
")",
"and",
"returns",
"two",
"values",
"parsed",
"from",
"it",
":",
"1",
".",
"Fuel",
"-",
"Air",
"Equivalence",
"[",
"Ratio",
"]",
"as",
"a",
"float",
"from",
"0",
"-",
"2",
"2",... | train | https://github.com/rGunti/CarPi-OBDDaemon/blob/6831c477b2a00617a0d2ea98b28f3bc5c1ba8e5f/obddaemon/custom/Obd2DataParser.py#L266-L280 |
ttinies/sc2gameLobby | sc2gameLobby/getGameData.py | run | def run(debug=False):
"""PURPOSE: start a starcraft2 process using the defined the config parameters"""
FLAGS(sys.argv)
config = gameConfig.Config(
version=None, # vers is None... unless a specific game version is desired
themap=selectMap(ladder=True), # pick a random ladder map
play... | python | def run(debug=False):
"""PURPOSE: start a starcraft2 process using the defined the config parameters"""
FLAGS(sys.argv)
config = gameConfig.Config(
version=None, # vers is None... unless a specific game version is desired
themap=selectMap(ladder=True), # pick a random ladder map
play... | [
"def",
"run",
"(",
"debug",
"=",
"False",
")",
":",
"FLAGS",
"(",
"sys",
".",
"argv",
")",
"config",
"=",
"gameConfig",
".",
"Config",
"(",
"version",
"=",
"None",
",",
"# vers is None... unless a specific game version is desired",
"themap",
"=",
"selectMap",
... | PURPOSE: start a starcraft2 process using the defined the config parameters | [
"PURPOSE",
":",
"start",
"a",
"starcraft2",
"process",
"using",
"the",
"defined",
"the",
"config",
"parameters"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/getGameData.py#L47-L97 |
klen/makesite | makesite/core.py | get_project_templates | def get_project_templates(path):
" Get list of installed templates. "
try:
return open(op.join(path, TPLNAME)).read().strip().split(',')
except IOError:
raise MakesiteException("Invalid makesite-project: %s" % path) | python | def get_project_templates(path):
" Get list of installed templates. "
try:
return open(op.join(path, TPLNAME)).read().strip().split(',')
except IOError:
raise MakesiteException("Invalid makesite-project: %s" % path) | [
"def",
"get_project_templates",
"(",
"path",
")",
":",
"try",
":",
"return",
"open",
"(",
"op",
".",
"join",
"(",
"path",
",",
"TPLNAME",
")",
")",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
".",
"split",
"(",
"','",
")",
"except",
"IOError",
... | Get list of installed templates. | [
"Get",
"list",
"of",
"installed",
"templates",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L100-L106 |
klen/makesite | makesite/core.py | get_base_modules | def get_base_modules():
" Get list of installed modules. "
return sorted(filter(
lambda x: op.isdir(op.join(MOD_DIR, x)),
listdir(MOD_DIR))) | python | def get_base_modules():
" Get list of installed modules. "
return sorted(filter(
lambda x: op.isdir(op.join(MOD_DIR, x)),
listdir(MOD_DIR))) | [
"def",
"get_base_modules",
"(",
")",
":",
"return",
"sorted",
"(",
"filter",
"(",
"lambda",
"x",
":",
"op",
".",
"isdir",
"(",
"op",
".",
"join",
"(",
"MOD_DIR",
",",
"x",
")",
")",
",",
"listdir",
"(",
"MOD_DIR",
")",
")",
")"
] | Get list of installed modules. | [
"Get",
"list",
"of",
"installed",
"modules",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L109-L114 |
klen/makesite | makesite/core.py | get_base_templates | def get_base_templates():
" Get list of installed templates. "
return sorted(filter(
lambda x: op.isdir(op.join(TPL_DIR, x)),
listdir(TPL_DIR))) | python | def get_base_templates():
" Get list of installed templates. "
return sorted(filter(
lambda x: op.isdir(op.join(TPL_DIR, x)),
listdir(TPL_DIR))) | [
"def",
"get_base_templates",
"(",
")",
":",
"return",
"sorted",
"(",
"filter",
"(",
"lambda",
"x",
":",
"op",
".",
"isdir",
"(",
"op",
".",
"join",
"(",
"TPL_DIR",
",",
"x",
")",
")",
",",
"listdir",
"(",
"TPL_DIR",
")",
")",
")"
] | Get list of installed templates. | [
"Get",
"list",
"of",
"installed",
"templates",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L117-L122 |
klen/makesite | makesite/core.py | print_header | def print_header(msg, sep='='):
" More strong message "
LOGGER.info("\n%s\n%s" % (msg, ''.join(sep for _ in msg))) | python | def print_header(msg, sep='='):
" More strong message "
LOGGER.info("\n%s\n%s" % (msg, ''.join(sep for _ in msg))) | [
"def",
"print_header",
"(",
"msg",
",",
"sep",
"=",
"'='",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"\\n%s\\n%s\"",
"%",
"(",
"msg",
",",
"''",
".",
"join",
"(",
"sep",
"for",
"_",
"in",
"msg",
")",
")",
")"
] | More strong message | [
"More",
"strong",
"message"
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L125-L128 |
klen/makesite | makesite/core.py | which | def which(program):
" Check program is exists. "
head, _ = op.split(program)
if head:
if is_exe(program):
return program
else:
for path in environ["PATH"].split(pathsep):
exe_file = op.join(path, program)
if is_exe(exe_file):
return e... | python | def which(program):
" Check program is exists. "
head, _ = op.split(program)
if head:
if is_exe(program):
return program
else:
for path in environ["PATH"].split(pathsep):
exe_file = op.join(path, program)
if is_exe(exe_file):
return e... | [
"def",
"which",
"(",
"program",
")",
":",
"head",
",",
"_",
"=",
"op",
".",
"split",
"(",
"program",
")",
"if",
"head",
":",
"if",
"is_exe",
"(",
"program",
")",
":",
"return",
"program",
"else",
":",
"for",
"path",
"in",
"environ",
"[",
"\"PATH\""... | Check program is exists. | [
"Check",
"program",
"is",
"exists",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L131-L144 |
klen/makesite | makesite/core.py | call | def call(cmd, shell=True, **kwargs):
" Run shell command. "
LOGGER.debug("Cmd: %s" % cmd)
check_call(cmd, shell=shell, stdout=LOGFILE_HANDLER.stream, **kwargs) | python | def call(cmd, shell=True, **kwargs):
" Run shell command. "
LOGGER.debug("Cmd: %s" % cmd)
check_call(cmd, shell=shell, stdout=LOGFILE_HANDLER.stream, **kwargs) | [
"def",
"call",
"(",
"cmd",
",",
"shell",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Cmd: %s\"",
"%",
"cmd",
")",
"check_call",
"(",
"cmd",
",",
"shell",
"=",
"shell",
",",
"stdout",
"=",
"LOGFILE_HANDLER",
".",
... | Run shell command. | [
"Run",
"shell",
"command",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L147-L151 |
klen/makesite | makesite/core.py | gen_template_files | def gen_template_files(path):
" Generate relative template pathes. "
path = path.rstrip(op.sep)
for root, _, files in walk(path):
for f in filter(lambda x: not x in (TPLNAME, CFGNAME), files):
yield op.relpath(op.join(root, f), path) | python | def gen_template_files(path):
" Generate relative template pathes. "
path = path.rstrip(op.sep)
for root, _, files in walk(path):
for f in filter(lambda x: not x in (TPLNAME, CFGNAME), files):
yield op.relpath(op.join(root, f), path) | [
"def",
"gen_template_files",
"(",
"path",
")",
":",
"path",
"=",
"path",
".",
"rstrip",
"(",
"op",
".",
"sep",
")",
"for",
"root",
",",
"_",
",",
"files",
"in",
"walk",
"(",
"path",
")",
":",
"for",
"f",
"in",
"filter",
"(",
"lambda",
"x",
":",
... | Generate relative template pathes. | [
"Generate",
"relative",
"template",
"pathes",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L168-L174 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | get_config | def get_config( config_path=CONFIG_PATH ):
"""
Get the config
"""
parser = SafeConfigParser()
parser.read( config_path )
config_dir = os.path.dirname(config_path)
immutable_key = False
key_id = None
blockchain_id = None
hostname = socket.gethostname()
wallet = None
... | python | def get_config( config_path=CONFIG_PATH ):
"""
Get the config
"""
parser = SafeConfigParser()
parser.read( config_path )
config_dir = os.path.dirname(config_path)
immutable_key = False
key_id = None
blockchain_id = None
hostname = socket.gethostname()
wallet = None
... | [
"def",
"get_config",
"(",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"parser",
"=",
"SafeConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"config_path",
")",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"immutable_key"... | Get the config | [
"Get",
"the",
"config"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L62-L107 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_key_lookup | def file_key_lookup( blockchain_id, index, hostname, key_id=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Get the file-encryption GPG key for the given blockchain ID, by index.
if index == 0, then give back the current key
if index > 0, then give back an older (revoked) key.
if key_id is g... | python | def file_key_lookup( blockchain_id, index, hostname, key_id=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Get the file-encryption GPG key for the given blockchain ID, by index.
if index == 0, then give back the current key
if index > 0, then give back an older (revoked) key.
if key_id is g... | [
"def",
"file_key_lookup",
"(",
"blockchain_id",
",",
"index",
",",
"hostname",
",",
"key_id",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\"lookup '%s' key for %s (index %s, key_id = %s... | Get the file-encryption GPG key for the given blockchain ID, by index.
if index == 0, then give back the current key
if index > 0, then give back an older (revoked) key.
if key_id is given, index and hostname will be ignored
Return {'status': True, 'key_data': ..., 'key_id': key_id, OPTIONAL['stale_ke... | [
"Get",
"the",
"file",
"-",
"encryption",
"GPG",
"key",
"for",
"the",
"given",
"blockchain",
"ID",
"by",
"index",
"."
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L140-L211 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_key_retire | def file_key_retire( blockchain_id, file_key, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Retire the given key. Move it to the head of the old key bundle list
@file_key should be data returned by file_key_lookup
Return {'status': True} on success
Return {'error': ...} on error
"""
con... | python | def file_key_retire( blockchain_id, file_key, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Retire the given key. Move it to the head of the old key bundle list
@file_key should be data returned by file_key_lookup
Return {'status': True} on success
Return {'error': ...} on error
"""
con... | [
"def",
"file_key_retire",
"(",
"blockchain_id",
",",
"file_key",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"url",
"=",
"file_url_expired_key... | Retire the given key. Move it to the head of the old key bundle list
@file_key should be data returned by file_key_lookup
Return {'status': True} on success
Return {'error': ...} on error | [
"Retire",
"the",
"given",
"key",
".",
"Move",
"it",
"to",
"the",
"head",
"of",
"the",
"old",
"key",
"bundle",
"list"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L214-L246 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_key_regenerate | def file_key_regenerate( blockchain_id, hostname, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Generate a new encryption key.
Retire the existing key, if it exists.
Return {'status': True} on success
Return {'error': ...} on error
"""
config_dir = os.path.dirname(config_path)
cu... | python | def file_key_regenerate( blockchain_id, hostname, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Generate a new encryption key.
Retire the existing key, if it exists.
Return {'status': True} on success
Return {'error': ...} on error
"""
config_dir = os.path.dirname(config_path)
cu... | [
"def",
"file_key_regenerate",
"(",
"blockchain_id",
",",
"hostname",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"current_key",
"=",
"file_key... | Generate a new encryption key.
Retire the existing key, if it exists.
Return {'status': True} on success
Return {'error': ...} on error | [
"Generate",
"a",
"new",
"encryption",
"key",
".",
"Retire",
"the",
"existing",
"key",
"if",
"it",
"exists",
".",
"Return",
"{",
"status",
":",
"True",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L249-L273 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_encrypt | def file_encrypt( blockchain_id, hostname, recipient_blockchain_id_and_hosts, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Encrypt a file for a set of recipients.
@recipient_blockchain_id_and_hosts must contain a list of (blockchain_id, hostname)
Return {'st... | python | def file_encrypt( blockchain_id, hostname, recipient_blockchain_id_and_hosts, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Encrypt a file for a set of recipients.
@recipient_blockchain_id_and_hosts must contain a list of (blockchain_id, hostname)
Return {'st... | [
"def",
"file_encrypt",
"(",
"blockchain_id",
",",
"hostname",
",",
"recipient_blockchain_id_and_hosts",
",",
"input_path",
",",
"output_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"confi... | Encrypt a file for a set of recipients.
@recipient_blockchain_id_and_hosts must contain a list of (blockchain_id, hostname)
Return {'status': True, 'sender_key_id': ...} on success, and write ciphertext to output_path
Return {'error': ...} on error | [
"Encrypt",
"a",
"file",
"for",
"a",
"set",
"of",
"recipients",
"."
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L276-L313 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_decrypt_from_key_info | def file_decrypt_from_key_info( sender_key_info, blockchain_id, key_index, hostname, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Try to decrypt data with one of the receiver's keys
Return {'status': True} if we succeeded
Return {'error': ..., 'status': Fals... | python | def file_decrypt_from_key_info( sender_key_info, blockchain_id, key_index, hostname, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Try to decrypt data with one of the receiver's keys
Return {'status': True} if we succeeded
Return {'error': ..., 'status': Fals... | [
"def",
"file_decrypt_from_key_info",
"(",
"sender_key_info",
",",
"blockchain_id",
",",
"key_index",
",",
"hostname",
",",
"input_path",
",",
"output_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")... | Try to decrypt data with one of the receiver's keys
Return {'status': True} if we succeeded
Return {'error': ..., 'status': False} if we failed permanently
Return {'error': ..., 'status': True} if the key failed, and we should try the next one. | [
"Try",
"to",
"decrypt",
"data",
"with",
"one",
"of",
"the",
"receiver",
"s",
"keys",
"Return",
"{",
"status",
":",
"True",
"}",
"if",
"we",
"succeeded",
"Return",
"{",
"error",
":",
"...",
"status",
":",
"False",
"}",
"if",
"we",
"failed",
"permanently... | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L316-L345 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_decrypt | def file_decrypt( blockchain_id, hostname, sender_blockchain_id, sender_key_id, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Decrypt a file from a sender's blockchain ID.
Try our current key, and then the old keys
(but warn if there are revoked keys)
Ret... | python | def file_decrypt( blockchain_id, hostname, sender_blockchain_id, sender_key_id, input_path, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Decrypt a file from a sender's blockchain ID.
Try our current key, and then the old keys
(but warn if there are revoked keys)
Ret... | [
"def",
"file_decrypt",
"(",
"blockchain_id",
",",
"hostname",
",",
"sender_blockchain_id",
",",
"sender_key_id",
",",
"input_path",
",",
"output_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
... | Decrypt a file from a sender's blockchain ID.
Try our current key, and then the old keys
(but warn if there are revoked keys)
Return {'status': True} on success, and write plaintext to output_path
Return {'error': ...} on failure | [
"Decrypt",
"a",
"file",
"from",
"a",
"sender",
"s",
"blockchain",
"ID",
".",
"Try",
"our",
"current",
"key",
"and",
"then",
"the",
"old",
"keys",
"(",
"but",
"warn",
"if",
"there",
"are",
"revoked",
"keys",
")",
"Return",
"{",
"status",
":",
"True",
... | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L348-L416 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_sign | def file_sign( blockchain_id, hostname, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Sign a file with the current blockchain ID's host's public key.
@config_path should be for the *client*, not blockstack-file
Return {'status': True, 'sender_key_id': ..., 'sig': ...} on ... | python | def file_sign( blockchain_id, hostname, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Sign a file with the current blockchain ID's host's public key.
@config_path should be for the *client*, not blockstack-file
Return {'status': True, 'sender_key_id': ..., 'sig': ...} on ... | [
"def",
"file_sign",
"(",
"blockchain_id",
",",
"hostname",
",",
"input_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"con... | Sign a file with the current blockchain ID's host's public key.
@config_path should be for the *client*, not blockstack-file
Return {'status': True, 'sender_key_id': ..., 'sig': ...} on success, and write ciphertext to output_path
Return {'error': ...} on error | [
"Sign",
"a",
"file",
"with",
"the",
"current",
"blockchain",
"ID",
"s",
"host",
"s",
"public",
"key",
"."
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L419-L439 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_verify | def file_verify( sender_blockchain_id, sender_key_id, input_path, sig, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Verify that a file was signed with the given blockchain ID
@config_path should be for the *client*, not blockstack-file
Return {'status': True} on succes
Return {'error': ...} on e... | python | def file_verify( sender_blockchain_id, sender_key_id, input_path, sig, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Verify that a file was signed with the given blockchain ID
@config_path should be for the *client*, not blockstack-file
Return {'status': True} on succes
Return {'error': ...} on e... | [
"def",
"file_verify",
"(",
"sender_blockchain_id",
",",
"sender_key_id",
",",
"input_path",
",",
"sig",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",... | Verify that a file was signed with the given blockchain ID
@config_path should be for the *client*, not blockstack-file
Return {'status': True} on succes
Return {'error': ...} on error | [
"Verify",
"that",
"a",
"file",
"was",
"signed",
"with",
"the",
"given",
"blockchain",
"ID"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L442-L470 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_list_hosts | def file_list_hosts( blockchain_id, wallet_keys=None, config_path=CONFIG_PATH ):
"""
Given a blockchain ID, find out the hosts the blockchain ID owner has registered keys for.
Return {'status': True, 'hosts': hostnames} on success
Return {'error': ...} on failure
"""
config_dir = os.path.dirname... | python | def file_list_hosts( blockchain_id, wallet_keys=None, config_path=CONFIG_PATH ):
"""
Given a blockchain ID, find out the hosts the blockchain ID owner has registered keys for.
Return {'status': True, 'hosts': hostnames} on success
Return {'error': ...} on failure
"""
config_dir = os.path.dirname... | [
"def",
"file_list_hosts",
"(",
"blockchain_id",
",",
"wallet_keys",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"try",
":",
"ret",
"=",
"blockstack_gpg",
".",
... | Given a blockchain ID, find out the hosts the blockchain ID owner has registered keys for.
Return {'status': True, 'hosts': hostnames} on success
Return {'error': ...} on failure | [
"Given",
"a",
"blockchain",
"ID",
"find",
"out",
"the",
"hosts",
"the",
"blockchain",
"ID",
"owner",
"has",
"registered",
"keys",
"for",
".",
"Return",
"{",
"status",
":",
"True",
"hosts",
":",
"hostnames",
"}",
"on",
"success",
"Return",
"{",
"error",
"... | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L473-L494 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_put | def file_put( blockchain_id, hostname, recipient_blockchain_ids, data_name, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts... | python | def file_put( blockchain_id, hostname, recipient_blockchain_ids, data_name, input_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts... | [
"def",
"file_put",
"(",
"blockchain_id",
",",
"hostname",
",",
"recipient_blockchain_ids",
",",
"data_name",
",",
"input_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"fd",
",",
"outpu... | Send a file to the given recipient, encrypted and signed with the
given blockchain ID.
Allow each recipient to receive the data on each of their hosts.
Return {'status': True} on success, and upload to cloud storage
Return {'error': ...} on error | [
"Send",
"a",
"file",
"to",
"the",
"given",
"recipient",
"encrypted",
"and",
"signed",
"with",
"the",
"given",
"blockchain",
"ID",
".",
"Allow",
"each",
"recipient",
"to",
"receive",
"the",
"data",
"on",
"each",
"of",
"their",
"hosts",
".",
"Return",
"{",
... | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L497-L560 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_get | def file_get( blockchain_id, hostname, sender_blockchain_id, data_name, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Get a file from a known sender.
Store it to output_path
Return {'status': True} on success
Return {'error': error} on failure
"""
config_d... | python | def file_get( blockchain_id, hostname, sender_blockchain_id, data_name, output_path, passphrase=None, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Get a file from a known sender.
Store it to output_path
Return {'status': True} on success
Return {'error': error} on failure
"""
config_d... | [
"def",
"file_get",
"(",
"blockchain_id",
",",
"hostname",
",",
"sender_blockchain_id",
",",
"data_name",
",",
"output_path",
",",
"passphrase",
"=",
"None",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"... | Get a file from a known sender.
Store it to output_path
Return {'status': True} on success
Return {'error': error} on failure | [
"Get",
"a",
"file",
"from",
"a",
"known",
"sender",
".",
"Store",
"it",
"to",
"output_path",
"Return",
"{",
"status",
":",
"True",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"error",
"}",
"on",
"failure"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L563-L601 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_delete | def file_delete( blockchain_id, data_name, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Remove a file
Return {'status': True} on success
Return {'error': error} on failure
"""
config_dir = os.path.dirname(config_path)
client_config_path = os.path.join(config_dir, blockstack_client.CONFI... | python | def file_delete( blockchain_id, data_name, config_path=CONFIG_PATH, wallet_keys=None ):
"""
Remove a file
Return {'status': True} on success
Return {'error': error} on failure
"""
config_dir = os.path.dirname(config_path)
client_config_path = os.path.join(config_dir, blockstack_client.CONFI... | [
"def",
"file_delete",
"(",
"blockchain_id",
",",
"data_name",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"client_config_path",
"=",
"os",
"... | Remove a file
Return {'status': True} on success
Return {'error': error} on failure | [
"Remove",
"a",
"file",
"Return",
"{",
"status",
":",
"True",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"error",
"}",
"on",
"failure"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L604-L621 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | file_list | def file_list( blockchain_id, config_path=CONFIG_PATH, wallet_keys=None ):
"""
List all files uploaded to a particular blockchain ID
Return {'status': True, 'listing': list} on success
Return {'error': ...} on error
"""
config_dir = os.path.dirname(config_path)
client_config_path = os.path.... | python | def file_list( blockchain_id, config_path=CONFIG_PATH, wallet_keys=None ):
"""
List all files uploaded to a particular blockchain ID
Return {'status': True, 'listing': list} on success
Return {'error': ...} on error
"""
config_dir = os.path.dirname(config_path)
client_config_path = os.path.... | [
"def",
"file_list",
"(",
"blockchain_id",
",",
"config_path",
"=",
"CONFIG_PATH",
",",
"wallet_keys",
"=",
"None",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"config_path",
")",
"client_config_path",
"=",
"os",
".",
"path",
".",
"... | List all files uploaded to a particular blockchain ID
Return {'status': True, 'listing': list} on success
Return {'error': ...} on error | [
"List",
"all",
"files",
"uploaded",
"to",
"a",
"particular",
"blockchain",
"ID",
"Return",
"{",
"status",
":",
"True",
"listing",
":",
"list",
"}",
"on",
"success",
"Return",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L624-L649 |
blockstack/blockstack-files | blockstack_file/blockstack_file.py | main | def main():
"""
Entry point for the CLI interface
"""
argparser = argparse.ArgumentParser(
description='Blockstack-file version {}'.format(__version__))
subparsers = argparser.add_subparsers(
dest='action', help='The file command to take [get/put/delete]')
parser = ... | python | def main():
"""
Entry point for the CLI interface
"""
argparser = argparse.ArgumentParser(
description='Blockstack-file version {}'.format(__version__))
subparsers = argparser.add_subparsers(
dest='action', help='The file command to take [get/put/delete]')
parser = ... | [
"def",
"main",
"(",
")",
":",
"argparser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Blockstack-file version {}'",
".",
"format",
"(",
"__version__",
")",
")",
"subparsers",
"=",
"argparser",
".",
"add_subparsers",
"(",
"dest",
"=",
"'... | Entry point for the CLI interface | [
"Entry",
"point",
"for",
"the",
"CLI",
"interface"
] | train | https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L652-L866 |
ttinies/sc2gameLobby | sc2gameLobby/connectToServer.py | cancelMatchRequest | def cancelMatchRequest(cfg):
"""obtain information housed on the ladder about playerName"""
payload = json.dumps([cfg.thePlayer])
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "cancelmatch"),
data = payload,
#headers=headers,
... | python | def cancelMatchRequest(cfg):
"""obtain information housed on the ladder about playerName"""
payload = json.dumps([cfg.thePlayer])
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "cancelmatch"),
data = payload,
#headers=headers,
... | [
"def",
"cancelMatchRequest",
"(",
"cfg",
")",
":",
"payload",
"=",
"json",
".",
"dumps",
"(",
"[",
"cfg",
".",
"thePlayer",
"]",
")",
"ladder",
"=",
"cfg",
".",
"ladder",
"return",
"requests",
".",
"post",
"(",
"url",
"=",
"c",
".",
"URL_BASE",
"%",
... | obtain information housed on the ladder about playerName | [
"obtain",
"information",
"housed",
"on",
"the",
"ladder",
"about",
"playerName"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/connectToServer.py#L33-L41 |
ttinies/sc2gameLobby | sc2gameLobby/connectToServer.py | ladderPlayerInfo | def ladderPlayerInfo(cfg, playerName, getMatchHistory=False):
"""obtain information housed on the ladder about playerName"""
payload = json.dumps([playerName, getMatchHistory]) # if playerName == None, info on all players is retrieved
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(... | python | def ladderPlayerInfo(cfg, playerName, getMatchHistory=False):
"""obtain information housed on the ladder about playerName"""
payload = json.dumps([playerName, getMatchHistory]) # if playerName == None, info on all players is retrieved
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(... | [
"def",
"ladderPlayerInfo",
"(",
"cfg",
",",
"playerName",
",",
"getMatchHistory",
"=",
"False",
")",
":",
"payload",
"=",
"json",
".",
"dumps",
"(",
"[",
"playerName",
",",
"getMatchHistory",
"]",
")",
"# if playerName == None, info on all players is retrieved",
"la... | obtain information housed on the ladder about playerName | [
"obtain",
"information",
"housed",
"on",
"the",
"ladder",
"about",
"playerName"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/connectToServer.py#L45-L53 |
ttinies/sc2gameLobby | sc2gameLobby/connectToServer.py | reportMatchCompletion | def reportMatchCompletion(cfg, results, replayData):
"""send information back to the server about the match's winners/losers"""
payload = json.dumps([cfg.flatten(), results, replayData])
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "matchfinis... | python | def reportMatchCompletion(cfg, results, replayData):
"""send information back to the server about the match's winners/losers"""
payload = json.dumps([cfg.flatten(), results, replayData])
ladder = cfg.ladder
return requests.post(
url = c.URL_BASE%(ladder.ipAddress, ladder.serverPort, "matchfinis... | [
"def",
"reportMatchCompletion",
"(",
"cfg",
",",
"results",
",",
"replayData",
")",
":",
"payload",
"=",
"json",
".",
"dumps",
"(",
"[",
"cfg",
".",
"flatten",
"(",
")",
",",
"results",
",",
"replayData",
"]",
")",
"ladder",
"=",
"cfg",
".",
"ladder",
... | send information back to the server about the match's winners/losers | [
"send",
"information",
"back",
"to",
"the",
"server",
"about",
"the",
"match",
"s",
"winners",
"/",
"losers"
] | train | https://github.com/ttinies/sc2gameLobby/blob/5352d51d53ddeb4858e92e682da89c4434123e52/sc2gameLobby/connectToServer.py#L57-L65 |
ox-it/django-conneg | django_conneg/support/middleware.py | BasicAuthMiddleware.process_response | def process_response(self, request, response):
"""
Adds WWW-Authenticate: Basic headers to 401 responses, and rewrites
redirects the login page to be 401 responses if it's a non-browser
agent.
"""
process = False
# Don't do anything for unsecure requests, unless ... | python | def process_response(self, request, response):
"""
Adds WWW-Authenticate: Basic headers to 401 responses, and rewrites
redirects the login page to be 401 responses if it's a non-browser
agent.
"""
process = False
# Don't do anything for unsecure requests, unless ... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"process",
"=",
"False",
"# Don't do anything for unsecure requests, unless DEBUG is on",
"if",
"not",
"self",
".",
"allow_http",
"and",
"not",
"request",
".",
"is_secure",
"(",
")",
... | Adds WWW-Authenticate: Basic headers to 401 responses, and rewrites
redirects the login page to be 401 responses if it's a non-browser
agent. | [
"Adds",
"WWW",
"-",
"Authenticate",
":",
"Basic",
"headers",
"to",
"401",
"responses",
"and",
"rewrites",
"redirects",
"the",
"login",
"page",
"to",
"be",
"401",
"responses",
"if",
"it",
"s",
"a",
"non",
"-",
"browser",
"agent",
"."
] | train | https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/support/middleware.py#L76-L111 |
astroswego/plotypus | src/plotypus/utils.py | verbose_print | def verbose_print(message, *, operation, verbosity):
"""
Prints *message* to stderr only if the given *operation* is in the list
*verbosity*. If "all" is in *verbosity*, all operations are printed.
**Parameters**
message : str
The message to print.
operation : str
The type of o... | python | def verbose_print(message, *, operation, verbosity):
"""
Prints *message* to stderr only if the given *operation* is in the list
*verbosity*. If "all" is in *verbosity*, all operations are printed.
**Parameters**
message : str
The message to print.
operation : str
The type of o... | [
"def",
"verbose_print",
"(",
"message",
",",
"*",
",",
"operation",
",",
"verbosity",
")",
":",
"if",
"(",
"verbosity",
"is",
"not",
"None",
")",
"and",
"(",
"(",
"operation",
"in",
"verbosity",
")",
"or",
"(",
"\"all\"",
"in",
"verbosity",
")",
")",
... | Prints *message* to stderr only if the given *operation* is in the list
*verbosity*. If "all" is in *verbosity*, all operations are printed.
**Parameters**
message : str
The message to print.
operation : str
The type of operation being performed.
verbosity : [str] or None
T... | [
"Prints",
"*",
"message",
"*",
"to",
"stderr",
"only",
"if",
"the",
"given",
"*",
"operation",
"*",
"is",
"in",
"the",
"list",
"*",
"verbosity",
"*",
".",
"If",
"all",
"is",
"in",
"*",
"verbosity",
"*",
"all",
"operations",
"are",
"printed",
"."
] | train | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/utils.py#L19-L41 |
astroswego/plotypus | src/plotypus/utils.py | pmap | def pmap(func, args, processes=None, callback=lambda *_, **__: None, **kwargs):
"""pmap(func, args, processes=None, callback=do_nothing, **kwargs)
Parallel equivalent of ``map(func, args)``, with the additional ability of
providing keyword arguments to func, and a callback function which is
applied to ... | python | def pmap(func, args, processes=None, callback=lambda *_, **__: None, **kwargs):
"""pmap(func, args, processes=None, callback=do_nothing, **kwargs)
Parallel equivalent of ``map(func, args)``, with the additional ability of
providing keyword arguments to func, and a callback function which is
applied to ... | [
"def",
"pmap",
"(",
"func",
",",
"args",
",",
"processes",
"=",
"None",
",",
"callback",
"=",
"lambda",
"*",
"_",
",",
"*",
"*",
"__",
":",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"processes",
"is",
"1",
":",
"results",
"=",
"[",
"]",
... | pmap(func, args, processes=None, callback=do_nothing, **kwargs)
Parallel equivalent of ``map(func, args)``, with the additional ability of
providing keyword arguments to func, and a callback function which is
applied to each element in the returned list. Unlike map, the output is a
non-lazy list. If *p... | [
"pmap",
"(",
"func",
"args",
"processes",
"=",
"None",
"callback",
"=",
"do_nothing",
"**",
"kwargs",
")"
] | train | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/utils.py#L44-L86 |
astroswego/plotypus | src/plotypus/utils.py | mad | def mad(data, axis=None):
"""
Computes the median absolute deviation of *data* along a given *axis*.
See `link <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_ for
details.
**Parameters**
data : array-like
**Returns**
mad : number or array-like
"""
return median(ab... | python | def mad(data, axis=None):
"""
Computes the median absolute deviation of *data* along a given *axis*.
See `link <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_ for
details.
**Parameters**
data : array-like
**Returns**
mad : number or array-like
"""
return median(ab... | [
"def",
"mad",
"(",
"data",
",",
"axis",
"=",
"None",
")",
":",
"return",
"median",
"(",
"absolute",
"(",
"data",
"-",
"median",
"(",
"data",
",",
"axis",
")",
")",
",",
"axis",
")"
] | Computes the median absolute deviation of *data* along a given *axis*.
See `link <https://en.wikipedia.org/wiki/Median_absolute_deviation>`_ for
details.
**Parameters**
data : array-like
**Returns**
mad : number or array-like | [
"Computes",
"the",
"median",
"absolute",
"deviation",
"of",
"*",
"data",
"*",
"along",
"a",
"given",
"*",
"axis",
"*",
".",
"See",
"link",
"<https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Median_absolute_deviation",
">",
"_",
... | train | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/utils.py#L172-L186 |
astroswego/plotypus | src/plotypus/utils.py | autocorrelation | def autocorrelation(X, lag=1):
"""
Computes the autocorrelation of *X* with the given *lag*.
Autocorrelation is simply
autocovariance(X) / covariance(X-mean, X-mean),
where autocovariance is simply
covariance((X-mean)[:-lag], (X-mean)[lag:]).
See `link <https://en.wikipedia.org/wiki/Autocor... | python | def autocorrelation(X, lag=1):
"""
Computes the autocorrelation of *X* with the given *lag*.
Autocorrelation is simply
autocovariance(X) / covariance(X-mean, X-mean),
where autocovariance is simply
covariance((X-mean)[:-lag], (X-mean)[lag:]).
See `link <https://en.wikipedia.org/wiki/Autocor... | [
"def",
"autocorrelation",
"(",
"X",
",",
"lag",
"=",
"1",
")",
":",
"differences",
"=",
"X",
"-",
"X",
".",
"mean",
"(",
")",
"products",
"=",
"differences",
"*",
"concatenate",
"(",
"(",
"differences",
"[",
"lag",
":",
"]",
",",
"differences",
"[",
... | Computes the autocorrelation of *X* with the given *lag*.
Autocorrelation is simply
autocovariance(X) / covariance(X-mean, X-mean),
where autocovariance is simply
covariance((X-mean)[:-lag], (X-mean)[lag:]).
See `link <https://en.wikipedia.org/wiki/Autocorrelation>`_ for details.
**Parameters*... | [
"Computes",
"the",
"autocorrelation",
"of",
"*",
"X",
"*",
"with",
"the",
"given",
"*",
"lag",
"*",
".",
"Autocorrelation",
"is",
"simply",
"autocovariance",
"(",
"X",
")",
"/",
"covariance",
"(",
"X",
"-",
"mean",
"X",
"-",
"mean",
")",
"where",
"auto... | train | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/utils.py#L189-L210 |
astroswego/plotypus | src/plotypus/utils.py | sanitize_latex | def sanitize_latex(string):
"""
Sanitize a string for input to LaTeX.
Replacements taken from `Stack Overflow
<http://stackoverflow.com/questions/2627135/how-do-i-sanitize-latex-input>`_
**Parameters**
string: str
**Returns**
sanitized_string: str
"""
sanitized_string = stri... | python | def sanitize_latex(string):
"""
Sanitize a string for input to LaTeX.
Replacements taken from `Stack Overflow
<http://stackoverflow.com/questions/2627135/how-do-i-sanitize-latex-input>`_
**Parameters**
string: str
**Returns**
sanitized_string: str
"""
sanitized_string = stri... | [
"def",
"sanitize_latex",
"(",
"string",
")",
":",
"sanitized_string",
"=",
"string",
"for",
"old",
",",
"new",
"in",
"_latex_replacements",
":",
"sanitized_string",
"=",
"sanitized_string",
".",
"replace",
"(",
"old",
",",
"new",
")",
"return",
"sanitized_string... | Sanitize a string for input to LaTeX.
Replacements taken from `Stack Overflow
<http://stackoverflow.com/questions/2627135/how-do-i-sanitize-latex-input>`_
**Parameters**
string: str
**Returns**
sanitized_string: str | [
"Sanitize",
"a",
"string",
"for",
"input",
"to",
"LaTeX",
"."
] | train | https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/utils.py#L228-L246 |
ox-it/django-conneg | django_conneg/conneg.py | Conneg.get_renderers | def get_renderers(self, request, context=None, template_name=None,
accept_header=None, formats=None, default_format=None, fallback_formats=None,
early=False):
"""
Returns a list of renderer functions in the order they should be tried.
Tries th... | python | def get_renderers(self, request, context=None, template_name=None,
accept_header=None, formats=None, default_format=None, fallback_formats=None,
early=False):
"""
Returns a list of renderer functions in the order they should be tried.
Tries th... | [
"def",
"get_renderers",
"(",
"self",
",",
"request",
",",
"context",
"=",
"None",
",",
"template_name",
"=",
"None",
",",
"accept_header",
"=",
"None",
",",
"formats",
"=",
"None",
",",
"default_format",
"=",
"None",
",",
"fallback_formats",
"=",
"None",
"... | Returns a list of renderer functions in the order they should be tried.
Tries the format override parameter first, then the Accept header. If
neither is present, attempt to fall back to self._default_format. If
a fallback format has been specified, we try that last.
If ... | [
"Returns",
"a",
"list",
"of",
"renderer",
"functions",
"in",
"the",
"order",
"they",
"should",
"be",
"tried",
".",
"Tries",
"the",
"format",
"override",
"parameter",
"first",
"then",
"the",
"Accept",
"header",
".",
"If",
"neither",
"is",
"present",
"attempt"... | train | https://github.com/ox-it/django-conneg/blob/4f103932322b3e151fcfdf279f1353dad2049d1f/django_conneg/conneg.py#L82-L119 |
klen/makesite | makesite/modules/flask/base/auth/__init__.py | register_app | def register_app(app):
" Configure application. "
from .views import users
app.register_blueprint(users)
from .oauth import config_oauth
config_oauth(app) | python | def register_app(app):
" Configure application. "
from .views import users
app.register_blueprint(users)
from .oauth import config_oauth
config_oauth(app) | [
"def",
"register_app",
"(",
"app",
")",
":",
"from",
".",
"views",
"import",
"users",
"app",
".",
"register_blueprint",
"(",
"users",
")",
"from",
".",
"oauth",
"import",
"config_oauth",
"config_oauth",
"(",
"app",
")"
] | Configure application. | [
"Configure",
"application",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/modules/flask/base/auth/__init__.py#L4-L11 |
payplug/payplug-python | payplug/__init__.py | set_secret_key | def set_secret_key(token):
"""
Initializes a Authentication and sets it as the new default global authentication.
It also performs some checks before saving the authentication.
:Example
>>> # Expected format for secret key:
>>> import payplug
>>> payplug.set_secret_key('sk_test_somerandomc... | python | def set_secret_key(token):
"""
Initializes a Authentication and sets it as the new default global authentication.
It also performs some checks before saving the authentication.
:Example
>>> # Expected format for secret key:
>>> import payplug
>>> payplug.set_secret_key('sk_test_somerandomc... | [
"def",
"set_secret_key",
"(",
"token",
")",
":",
"if",
"not",
"isinstance",
"(",
"token",
",",
"string_types",
")",
":",
"raise",
"exceptions",
".",
"ConfigurationError",
"(",
"'Expected string value for token.'",
")",
"config",
".",
"secret_key",
"=",
"token"
] | Initializes a Authentication and sets it as the new default global authentication.
It also performs some checks before saving the authentication.
:Example
>>> # Expected format for secret key:
>>> import payplug
>>> payplug.set_secret_key('sk_test_somerandomcharacters')
:param token: your sec... | [
"Initializes",
"a",
"Authentication",
"and",
"sets",
"it",
"as",
"the",
"new",
"default",
"global",
"authentication",
".",
"It",
"also",
"performs",
"some",
"checks",
"before",
"saving",
"the",
"authentication",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L12-L29 |
payplug/payplug-python | payplug/__init__.py | Payment.retrieve | def retrieve(payment_id):
"""
Retrieve a payment from its id.
:param payment_id: The payment id
:type payment_id: string
:return: The payment resource
:rtype: resources.Payment
"""
http_client = HttpClient()
response, __ = http_client.get(routes.... | python | def retrieve(payment_id):
"""
Retrieve a payment from its id.
:param payment_id: The payment id
:type payment_id: string
:return: The payment resource
:rtype: resources.Payment
"""
http_client = HttpClient()
response, __ = http_client.get(routes.... | [
"def",
"retrieve",
"(",
"payment_id",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"__",
"=",
"http_client",
".",
"get",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"PAYMENT_RESOURCE",
",",
"resource_id",
"=",
"payment_id",
")"... | Retrieve a payment from its id.
:param payment_id: The payment id
:type payment_id: string
:return: The payment resource
:rtype: resources.Payment | [
"Retrieve",
"a",
"payment",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L37-L49 |
payplug/payplug-python | payplug/__init__.py | Payment.abort | def abort(payment):
"""
Abort a payment from its id.
:param payment: The payment id or payment object
:type payment: string|Payment
:return: The payment resource
:rtype: resources.Payment
"""
if isinstance(payment, resources.Payment):
payment... | python | def abort(payment):
"""
Abort a payment from its id.
:param payment: The payment id or payment object
:type payment: string|Payment
:return: The payment resource
:rtype: resources.Payment
"""
if isinstance(payment, resources.Payment):
payment... | [
"def",
"abort",
"(",
"payment",
")",
":",
"if",
"isinstance",
"(",
"payment",
",",
"resources",
".",
"Payment",
")",
":",
"payment",
"=",
"payment",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"__",
"=",
"http_client",
".",
... | Abort a payment from its id.
:param payment: The payment id or payment object
:type payment: string|Payment
:return: The payment resource
:rtype: resources.Payment | [
"Abort",
"a",
"payment",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L52-L67 |
payplug/payplug-python | payplug/__init__.py | Payment.create | def create(**data):
"""
Create a Payment request.
:param data: data required to create the payment
:return: The payment resource
:rtype resources.Payment
"""
http_client = HttpClient()
response, _ = http_client.post(routes.url(routes.PAYMENT_RESOURCE), d... | python | def create(**data):
"""
Create a Payment request.
:param data: data required to create the payment
:return: The payment resource
:rtype resources.Payment
"""
http_client = HttpClient()
response, _ = http_client.post(routes.url(routes.PAYMENT_RESOURCE), d... | [
"def",
"create",
"(",
"*",
"*",
"data",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
"http_client",
".",
"post",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"PAYMENT_RESOURCE",
")",
",",
"data",
")",
"return",
"... | Create a Payment request.
:param data: data required to create the payment
:return: The payment resource
:rtype resources.Payment | [
"Create",
"a",
"Payment",
"request",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L70-L81 |
payplug/payplug-python | payplug/__init__.py | Payment.list | def list(per_page=None, page=None):
"""
List of payments. You have to handle pagination manually
:param page: the page number
:type page: int|None
:param per_page: number of payment per page. It's a good practice to increase this number if you know that you
will need a l... | python | def list(per_page=None, page=None):
"""
List of payments. You have to handle pagination manually
:param page: the page number
:type page: int|None
:param per_page: number of payment per page. It's a good practice to increase this number if you know that you
will need a l... | [
"def",
"list",
"(",
"per_page",
"=",
"None",
",",
"page",
"=",
"None",
")",
":",
"# Comprehension dict are not supported in Python 2.6-. You can use this commented line instead of the current",
"# line when you drop support for Python 2.6.",
"# pagination = {key: value for (key, value) i... | List of payments. You have to handle pagination manually
:param page: the page number
:type page: int|None
:param per_page: number of payment per page. It's a good practice to increase this number if you know that you
will need a lot of payments.
:type per_page: int|None
... | [
"List",
"of",
"payments",
".",
"You",
"have",
"to",
"handle",
"pagination",
"manually"
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L84-L104 |
payplug/payplug-python | payplug/__init__.py | Refund.retrieve | def retrieve(payment, refund_id):
"""
Retrieve a refund from a payment and the refund id.
:param payment: The payment id or the payment object
:type payment: resources.Payment|string
:param refund_id: The refund id
:type refund_id: string
:return: The refund res... | python | def retrieve(payment, refund_id):
"""
Retrieve a refund from a payment and the refund id.
:param payment: The payment id or the payment object
:type payment: resources.Payment|string
:param refund_id: The refund id
:type refund_id: string
:return: The refund res... | [
"def",
"retrieve",
"(",
"payment",
",",
"refund_id",
")",
":",
"if",
"isinstance",
"(",
"payment",
",",
"resources",
".",
"Payment",
")",
":",
"payment",
"=",
"payment",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
... | Retrieve a refund from a payment and the refund id.
:param payment: The payment id or the payment object
:type payment: resources.Payment|string
:param refund_id: The refund id
:type refund_id: string
:return: The refund resource
:rtype: resources.Refund | [
"Retrieve",
"a",
"refund",
"from",
"a",
"payment",
"and",
"the",
"refund",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L112-L129 |
payplug/payplug-python | payplug/__init__.py | Refund.create | def create(payment, **data):
"""
Create a refund on a payment.
:param payment: Either the payment object or the payment id you want to refund.
:type payment: resources.Payment|string
:param data: data required to create the refund
:return: The refund resource
:r... | python | def create(payment, **data):
"""
Create a refund on a payment.
:param payment: Either the payment object or the payment id you want to refund.
:type payment: resources.Payment|string
:param data: data required to create the refund
:return: The refund resource
:r... | [
"def",
"create",
"(",
"payment",
",",
"*",
"*",
"data",
")",
":",
"if",
"isinstance",
"(",
"payment",
",",
"resources",
".",
"Payment",
")",
":",
"payment",
"=",
"payment",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
... | Create a refund on a payment.
:param payment: Either the payment object or the payment id you want to refund.
:type payment: resources.Payment|string
:param data: data required to create the refund
:return: The refund resource
:rtype resources.Refund | [
"Create",
"a",
"refund",
"on",
"a",
"payment",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L132-L148 |
payplug/payplug-python | payplug/__init__.py | Refund.list | def list(payment):
"""
List all the refunds for a payment.
:param payment: The payment object or the payment id
:type payment: resources.Payment|string
:return: A collection of refunds
:rtype resources.APIResourceCollection
"""
if isinstance(payment, res... | python | def list(payment):
"""
List all the refunds for a payment.
:param payment: The payment object or the payment id
:type payment: resources.Payment|string
:return: A collection of refunds
:rtype resources.APIResourceCollection
"""
if isinstance(payment, res... | [
"def",
"list",
"(",
"payment",
")",
":",
"if",
"isinstance",
"(",
"payment",
",",
"resources",
".",
"Payment",
")",
":",
"payment",
"=",
"payment",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
"http_client",
".",
"g... | List all the refunds for a payment.
:param payment: The payment object or the payment id
:type payment: resources.Payment|string
:return: A collection of refunds
:rtype resources.APIResourceCollection | [
"List",
"all",
"the",
"refunds",
"for",
"a",
"payment",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L151-L166 |
payplug/payplug-python | payplug/__init__.py | Customer.retrieve | def retrieve(customer_id):
"""
Retrieve a customer from its id.
:param customer_id: The customer id
:type customer_id: string
:return: The customer resource
:rtype: resources.Customer
"""
http_client = HttpClient()
response, __ = http_client.get(... | python | def retrieve(customer_id):
"""
Retrieve a customer from its id.
:param customer_id: The customer id
:type customer_id: string
:return: The customer resource
:rtype: resources.Customer
"""
http_client = HttpClient()
response, __ = http_client.get(... | [
"def",
"retrieve",
"(",
"customer_id",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"__",
"=",
"http_client",
".",
"get",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"CUSTOMER_RESOURCE",
",",
"resource_id",
"=",
"customer_id",
... | Retrieve a customer from its id.
:param customer_id: The customer id
:type customer_id: string
:return: The customer resource
:rtype: resources.Customer | [
"Retrieve",
"a",
"customer",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L174-L186 |
payplug/payplug-python | payplug/__init__.py | Customer.delete | def delete(customer):
"""
Delete a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer
"""
if isinstance(customer, resources.Customer):
customer = customer.id
http_client = HttpClient()
http_client... | python | def delete(customer):
"""
Delete a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer
"""
if isinstance(customer, resources.Customer):
customer = customer.id
http_client = HttpClient()
http_client... | [
"def",
"delete",
"(",
"customer",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"http_client",
".",
"delete",
"(",
"routes",
... | Delete a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer | [
"Delete",
"a",
"customer",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L189-L200 |
payplug/payplug-python | payplug/__init__.py | Customer.update | def update(customer, **data):
"""
Update a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param data: The data you want to update
:return: The customer resource
:rtype resources.Customer
"""
if i... | python | def update(customer, **data):
"""
Update a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param data: The data you want to update
:return: The customer resource
:rtype resources.Customer
"""
if i... | [
"def",
"update",
"(",
"customer",
",",
"*",
"*",
"data",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_... | Update a customer from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param data: The data you want to update
:return: The customer resource
:rtype resources.Customer | [
"Update",
"a",
"customer",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L203-L219 |
payplug/payplug-python | payplug/__init__.py | Customer.create | def create(**data):
"""
Create a customer.
:param data: data required to create the customer
:return: The customer resource
:rtype resources.Customer
"""
http_client = HttpClient()
response, _ = http_client.post(routes.url(routes.CUSTOMER_RESOURCE), data... | python | def create(**data):
"""
Create a customer.
:param data: data required to create the customer
:return: The customer resource
:rtype resources.Customer
"""
http_client = HttpClient()
response, _ = http_client.post(routes.url(routes.CUSTOMER_RESOURCE), data... | [
"def",
"create",
"(",
"*",
"*",
"data",
")",
":",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_",
"=",
"http_client",
".",
"post",
"(",
"routes",
".",
"url",
"(",
"routes",
".",
"CUSTOMER_RESOURCE",
")",
",",
"data",
")",
"return",
... | Create a customer.
:param data: data required to create the customer
:return: The customer resource
:rtype resources.Customer | [
"Create",
"a",
"customer",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L222-L233 |
payplug/payplug-python | payplug/__init__.py | Card.retrieve | def retrieve(customer, card_id):
"""
Retrieve a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card_id: The card id
:type card_id: string
:return: The customer resource
:rtype: resources.Card
"... | python | def retrieve(customer, card_id):
"""
Retrieve a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card_id: The card id
:type card_id: string
:return: The customer resource
:rtype: resources.Card
"... | [
"def",
"retrieve",
"(",
"customer",
",",
"card_id",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"__",
"="... | Retrieve a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card_id: The card id
:type card_id: string
:return: The customer resource
:rtype: resources.Card | [
"Retrieve",
"a",
"card",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L264-L281 |
payplug/payplug-python | payplug/__init__.py | Card.delete | def delete(customer, card):
"""
Delete a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card: The card id or object
:type card: string|Card
"""
if isinstance(customer, resources.Customer):
c... | python | def delete(customer, card):
"""
Delete a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card: The card id or object
:type card: string|Card
"""
if isinstance(customer, resources.Customer):
c... | [
"def",
"delete",
"(",
"customer",
",",
"card",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"if",
"isinstance",
"(",
"card",
",",
"resources",
".",
"Card",
")",
":",... | Delete a card from its id.
:param customer: The customer id or object
:type customer: string|Customer
:param card: The card id or object
:type card: string|Card | [
"Delete",
"a",
"card",
"from",
"its",
"id",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L284-L299 |
payplug/payplug-python | payplug/__init__.py | Card.create | def create(customer, **data):
"""
Create a card instance.
:param customer: the customer id or object
:type customer: string|Customer
:param data: data required to create the card
:return: The card resource
:rtype resources.Card
"""
if isinstance(... | python | def create(customer, **data):
"""
Create a card instance.
:param customer: the customer id or object
:type customer: string|Customer
:param data: data required to create the card
:return: The card resource
:rtype resources.Card
"""
if isinstance(... | [
"def",
"create",
"(",
"customer",
",",
"*",
"*",
"data",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"http_client",
"=",
"HttpClient",
"(",
")",
"response",
",",
"_... | Create a card instance.
:param customer: the customer id or object
:type customer: string|Customer
:param data: data required to create the card
:return: The card resource
:rtype resources.Card | [
"Create",
"a",
"card",
"instance",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L302-L318 |
payplug/payplug-python | payplug/__init__.py | Card.list | def list(customer, per_page=None, page=None):
"""
List of cards. You have to handle pagination manually for the moment.
:param customer: the customer id or object
:type customer: string|Customer
:param page: the page number
:type page: int|None
:param per_page: n... | python | def list(customer, per_page=None, page=None):
"""
List of cards. You have to handle pagination manually for the moment.
:param customer: the customer id or object
:type customer: string|Customer
:param page: the page number
:type page: int|None
:param per_page: n... | [
"def",
"list",
"(",
"customer",
",",
"per_page",
"=",
"None",
",",
"page",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"customer",
",",
"resources",
".",
"Customer",
")",
":",
"customer",
"=",
"customer",
".",
"id",
"# Comprehension dict are not supporte... | List of cards. You have to handle pagination manually for the moment.
:param customer: the customer id or object
:type customer: string|Customer
:param page: the page number
:type page: int|None
:param per_page: number of customers per page. It's a good practice to increase this... | [
"List",
"of",
"cards",
".",
"You",
"have",
"to",
"handle",
"pagination",
"manually",
"for",
"the",
"moment",
"."
] | train | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/__init__.py#L321-L346 |
unistra/django-rest-framework-custom-filters | rest_framework_custom_filters/filters.py | IsoDateTimeField.strptime | def strptime(self, value, format):
"""
By default, parse datetime with TZ.
If TZ is False, convert datetime to local time and disable TZ
"""
value = force_str(value)
if format == ISO_8601:
try:
parsed = parse_datetime(value)
if... | python | def strptime(self, value, format):
"""
By default, parse datetime with TZ.
If TZ is False, convert datetime to local time and disable TZ
"""
value = force_str(value)
if format == ISO_8601:
try:
parsed = parse_datetime(value)
if... | [
"def",
"strptime",
"(",
"self",
",",
"value",
",",
"format",
")",
":",
"value",
"=",
"force_str",
"(",
"value",
")",
"if",
"format",
"==",
"ISO_8601",
":",
"try",
":",
"parsed",
"=",
"parse_datetime",
"(",
"value",
")",
"if",
"not",
"settings",
".",
... | By default, parse datetime with TZ.
If TZ is False, convert datetime to local time and disable TZ | [
"By",
"default",
"parse",
"datetime",
"with",
"TZ",
".",
"If",
"TZ",
"is",
"False",
"convert",
"datetime",
"to",
"local",
"time",
"and",
"disable",
"TZ"
] | train | https://github.com/unistra/django-rest-framework-custom-filters/blob/0479cc4f24e1d4d6ddf2a077fe45bb6b5a7afaeb/rest_framework_custom_filters/filters.py#L20-L41 |
revarbat/pymuv | setup.py | find_data_files | def find_data_files(source, target, patterns):
"""
Locates the specified data-files and returns the matches
in a data_files compatible format.
source is the root of the source data tree.
Use '' or '.' for current directory.
target is the root of the target data tree.
Use '' or '.' f... | python | def find_data_files(source, target, patterns):
"""
Locates the specified data-files and returns the matches
in a data_files compatible format.
source is the root of the source data tree.
Use '' or '.' for current directory.
target is the root of the target data tree.
Use '' or '.' f... | [
"def",
"find_data_files",
"(",
"source",
",",
"target",
",",
"patterns",
")",
":",
"if",
"glob",
".",
"has_magic",
"(",
"source",
")",
"or",
"glob",
".",
"has_magic",
"(",
"target",
")",
":",
"raise",
"ValueError",
"(",
"\"Magic not allowed in src, target\"",
... | Locates the specified data-files and returns the matches
in a data_files compatible format.
source is the root of the source data tree.
Use '' or '.' for current directory.
target is the root of the target data tree.
Use '' or '.' for the distribution directory.
patterns is a sequence o... | [
"Locates",
"the",
"specified",
"data",
"-",
"files",
"and",
"returns",
"the",
"matches",
"in",
"a",
"data_files",
"compatible",
"format",
"."
] | train | https://github.com/revarbat/pymuv/blob/cefa2f2d35fc32054b9595da5f3393f6cceee5e0/setup.py#L10-L34 |
jgorset/facebook | facebook/entity.py | Entity.cache | def cache(self):
"""Query or return the Graph API representation of this resource."""
if not self._cache:
self._cache = self.graph.get('%s' % self.id)
return self._cache | python | def cache(self):
"""Query or return the Graph API representation of this resource."""
if not self._cache:
self._cache = self.graph.get('%s' % self.id)
return self._cache | [
"def",
"cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cache",
":",
"self",
".",
"_cache",
"=",
"self",
".",
"graph",
".",
"get",
"(",
"'%s'",
"%",
"self",
".",
"id",
")",
"return",
"self",
".",
"_cache"
] | Query or return the Graph API representation of this resource. | [
"Query",
"or",
"return",
"the",
"Graph",
"API",
"representation",
"of",
"this",
"resource",
"."
] | train | https://github.com/jgorset/facebook/blob/90f035ae1828e4eeb7af428964fedf0ee99ec2ad/facebook/entity.py#L29-L34 |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | capakey_rest_gateway_request | def capakey_rest_gateway_request(url, headers={}, params={}):
'''
Utility function that helps making requests to the CAPAKEY REST service.
:param string url: URL to request.
:param dict headers: Headers to send with the URL.
:param dict params: Parameters to send with the URL.
:returns: Result ... | python | def capakey_rest_gateway_request(url, headers={}, params={}):
'''
Utility function that helps making requests to the CAPAKEY REST service.
:param string url: URL to request.
:param dict headers: Headers to send with the URL.
:param dict params: Parameters to send with the URL.
:returns: Result ... | [
"def",
"capakey_rest_gateway_request",
"(",
"url",
",",
"headers",
"=",
"{",
"}",
",",
"params",
"=",
"{",
"}",
")",
":",
"try",
":",
"res",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"headers",
",",
"params",
"=",
"params",
")",
... | Utility function that helps making requests to the CAPAKEY REST service.
:param string url: URL to request.
:param dict headers: Headers to send with the URL.
:param dict params: Parameters to send with the URL.
:returns: Result of the call. | [
"Utility",
"function",
"that",
"helps",
"making",
"requests",
"to",
"the",
"CAPAKEY",
"REST",
"service",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L26-L50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.