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
rodionovd/machobot
machobot/common/macho_helpers.py
modify_macho_file_headers
def modify_macho_file_headers(macho_file_path, modificator_func): """ Modifies headers of a Mach-O file at the given path by calling the modificator function on each header. Returns True on success, otherwise rises an exeption (e.g. from macholib) """ if not os.path.isfile(macho_file_path): raise Exception("Yo...
python
def modify_macho_file_headers(macho_file_path, modificator_func): """ Modifies headers of a Mach-O file at the given path by calling the modificator function on each header. Returns True on success, otherwise rises an exeption (e.g. from macholib) """ if not os.path.isfile(macho_file_path): raise Exception("Yo...
[ "def", "modify_macho_file_headers", "(", "macho_file_path", ",", "modificator_func", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "macho_file_path", ")", ":", "raise", "Exception", "(", "\"You must specify a real executable path as a target\"", ")", "...
Modifies headers of a Mach-O file at the given path by calling the modificator function on each header. Returns True on success, otherwise rises an exeption (e.g. from macholib)
[ "Modifies", "headers", "of", "a", "Mach", "-", "O", "file", "at", "the", "given", "path", "by", "calling", "the", "modificator", "function", "on", "each", "header", ".", "Returns", "True", "on", "success", "otherwise", "rises", "an", "exeption", "(", "e", ...
train
https://github.com/rodionovd/machobot/blob/60e10b63c2538a73dc8ec3ce636b3ed5bf09f524/machobot/common/macho_helpers.py#L13-L26
mbrenig/SheetSync
sheetsync/__init__.py
ia_credentials_helper
def ia_credentials_helper(client_id, client_secret, credentials_cache_file="credentials.json", cache_key="default"): """Helper function to manage a credentials cache during testing. This function attempts to load and refresh a credentials object from a ...
python
def ia_credentials_helper(client_id, client_secret, credentials_cache_file="credentials.json", cache_key="default"): """Helper function to manage a credentials cache during testing. This function attempts to load and refresh a credentials object from a ...
[ "def", "ia_credentials_helper", "(", "client_id", ",", "client_secret", ",", "credentials_cache_file", "=", "\"credentials.json\"", ",", "cache_key", "=", "\"default\"", ")", ":", "def", "_load_credentials", "(", "key", ")", ":", "with", "open", "(", "credentials_ca...
Helper function to manage a credentials cache during testing. This function attempts to load and refresh a credentials object from a json cache file, using the cache_key and client_id as a lookup. If this isn't found then it starts an OAuth2 authentication flow, using the client_id and client_se...
[ "Helper", "function", "to", "manage", "a", "credentials", "cache", "during", "testing", ".", "This", "function", "attempts", "to", "load", "and", "refresh", "a", "credentials", "object", "from", "a", "json", "cache", "file", "using", "the", "cache_key", "and",...
train
https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L40-L106
mbrenig/SheetSync
sheetsync/__init__.py
Sheet.backup
def backup(self, backup_name, folder_key=None, folder_name=None): """Copies the google spreadsheet to the backup_name and folder specified. Args: backup_name (str): The name of the backup document to create. folder_key (Optional) (str): The key of a folder that the n...
python
def backup(self, backup_name, folder_key=None, folder_name=None): """Copies the google spreadsheet to the backup_name and folder specified. Args: backup_name (str): The name of the backup document to create. folder_key (Optional) (str): The key of a folder that the n...
[ "def", "backup", "(", "self", ",", "backup_name", ",", "folder_key", "=", "None", ",", "folder_name", "=", "None", ")", ":", "folder", "=", "self", ".", "_find_or_create_folder", "(", "folder_key", ",", "folder_name", ")", "drive_service", "=", "self", ".", ...
Copies the google spreadsheet to the backup_name and folder specified. Args: backup_name (str): The name of the backup document to create. folder_key (Optional) (str): The key of a folder that the new copy will be moved to. folder_name (Opti...
[ "Copies", "the", "google", "spreadsheet", "to", "the", "backup_name", "and", "folder", "specified", ".", "Args", ":", "backup_name", "(", "str", ")", ":", "The", "name", "of", "the", "backup", "document", "to", "create", ".", "folder_key", "(", "Optional", ...
train
https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L741-L769
mbrenig/SheetSync
sheetsync/__init__.py
Sheet.data
def data(self, as_cells=False): """ Reads the worksheet and returns an indexed dictionary of the row objects. For example: >>>print sheet.data() {'Miss Piggy': {'Color': 'Pink', 'Performer': 'Frank Oz'}, 'Kermit': {'Color': 'Green', 'Performer': 'Jim Henson'}} ...
python
def data(self, as_cells=False): """ Reads the worksheet and returns an indexed dictionary of the row objects. For example: >>>print sheet.data() {'Miss Piggy': {'Color': 'Pink', 'Performer': 'Frank Oz'}, 'Kermit': {'Color': 'Green', 'Performer': 'Jim Henson'}} ...
[ "def", "data", "(", "self", ",", "as_cells", "=", "False", ")", ":", "sheet_data", "=", "{", "}", "self", ".", "max_row", "=", "max", "(", "self", ".", "header_row_ix", ",", "self", ".", "formula_ref_row_ix", ")", "all_cells", "=", "self", ".", "_cell_...
Reads the worksheet and returns an indexed dictionary of the row objects. For example: >>>print sheet.data() {'Miss Piggy': {'Color': 'Pink', 'Performer': 'Frank Oz'}, 'Kermit': {'Color': 'Green', 'Performer': 'Jim Henson'}}
[ "Reads", "the", "worksheet", "and", "returns", "an", "indexed", "dictionary", "of", "the", "row", "objects", ".", "For", "example", ":", ">>>", "print", "sheet", ".", "data", "()", "{", "Miss", "Piggy", ":", "{", "Color", ":", "Pink", "Performer", ":", ...
train
https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L791-L853
mbrenig/SheetSync
sheetsync/__init__.py
Sheet.sync
def sync(self, raw_data, row_change_callback=None): """ Equivalent to the inject method but will delete rows from the google spreadsheet if their key is not found in the input (raw_data) dictionary. Args: raw_data (dict): See inject method row_change_...
python
def sync(self, raw_data, row_change_callback=None): """ Equivalent to the inject method but will delete rows from the google spreadsheet if their key is not found in the input (raw_data) dictionary. Args: raw_data (dict): See inject method row_change_...
[ "def", "sync", "(", "self", ",", "raw_data", ",", "row_change_callback", "=", "None", ")", ":", "return", "self", ".", "_update", "(", "raw_data", ",", "row_change_callback", ",", "delete_rows", "=", "True", ")" ]
Equivalent to the inject method but will delete rows from the google spreadsheet if their key is not found in the input (raw_data) dictionary. Args: raw_data (dict): See inject method row_change_callback (Optional) (func): See inject method Returns:...
[ "Equivalent", "to", "the", "inject", "method", "but", "will", "delete", "rows", "from", "the", "google", "spreadsheet", "if", "their", "key", "is", "not", "found", "in", "the", "input", "(", "raw_data", ")", "dictionary", ".", "Args", ":", "raw_data", "(",...
train
https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L867-L879
mbrenig/SheetSync
sheetsync/__init__.py
Sheet.inject
def inject(self, raw_data, row_change_callback=None): """ Use this function to add rows or update existing rows in the spreadsheet. Args: raw_data (dict): A dictionary of dictionaries. Where the keys of the outer dictionary uniquely identify each row of data, a...
python
def inject(self, raw_data, row_change_callback=None): """ Use this function to add rows or update existing rows in the spreadsheet. Args: raw_data (dict): A dictionary of dictionaries. Where the keys of the outer dictionary uniquely identify each row of data, a...
[ "def", "inject", "(", "self", ",", "raw_data", ",", "row_change_callback", "=", "None", ")", ":", "return", "self", ".", "_update", "(", "raw_data", ",", "row_change_callback", ",", "delete_rows", "=", "False", ")" ]
Use this function to add rows or update existing rows in the spreadsheet. Args: raw_data (dict): A dictionary of dictionaries. Where the keys of the outer dictionary uniquely identify each row of data, and the inner dictionaries represent the field,value p...
[ "Use", "this", "function", "to", "add", "rows", "or", "update", "existing", "rows", "in", "the", "spreadsheet", ".", "Args", ":", "raw_data", "(", "dict", ")", ":", "A", "dictionary", "of", "dictionaries", ".", "Where", "the", "keys", "of", "the", "outer...
train
https://github.com/mbrenig/SheetSync/blob/110e10c1f4388a91e5087cba6ea5517e04df8680/sheetsync/__init__.py#L881-L903
note35/sinon
sinon/lib/util/TypeHandler.py
is_module_function
def is_module_function(obj, prop): """ Checking and setting type to MODULE_FUNCTION Args: obj: ModuleType prop: FunctionType Return: Boolean Raise: prop_type_error: When the type of prop is not valid prop_in_obj_error: When prop is not in the obj(module/class)...
python
def is_module_function(obj, prop): """ Checking and setting type to MODULE_FUNCTION Args: obj: ModuleType prop: FunctionType Return: Boolean Raise: prop_type_error: When the type of prop is not valid prop_in_obj_error: When prop is not in the obj(module/class)...
[ "def", "is_module_function", "(", "obj", ",", "prop", ")", ":", "python_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "python_version", "==", "3", ":", "unicode", "=", "str", "if", "prop", "and", "(", "isinstance", "(", "prop", ",", "...
Checking and setting type to MODULE_FUNCTION Args: obj: ModuleType prop: FunctionType Return: Boolean Raise: prop_type_error: When the type of prop is not valid prop_in_obj_error: When prop is not in the obj(module/class) prop_is_func_error: When prop is not a...
[ "Checking", "and", "setting", "type", "to", "MODULE_FUNCTION", "Args", ":", "obj", ":", "ModuleType", "prop", ":", "FunctionType", "Return", ":", "Boolean", "Raise", ":", "prop_type_error", ":", "When", "the", "type", "of", "prop", "is", "not", "valid", "pro...
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/util/TypeHandler.py#L27-L60
note35/sinon
sinon/lib/util/TypeHandler.py
is_module
def is_module(obj): """ Checking and setting type to MODULE Args: obj: ModuleType / class Note: An instance will be treated as a Class Return: Boolean """ return True if obj and isinstance(obj, ModuleType) or inspect.isclass(obj) else False
python
def is_module(obj): """ Checking and setting type to MODULE Args: obj: ModuleType / class Note: An instance will be treated as a Class Return: Boolean """ return True if obj and isinstance(obj, ModuleType) or inspect.isclass(obj) else False
[ "def", "is_module", "(", "obj", ")", ":", "return", "True", "if", "obj", "and", "isinstance", "(", "obj", ",", "ModuleType", ")", "or", "inspect", ".", "isclass", "(", "obj", ")", "else", "False" ]
Checking and setting type to MODULE Args: obj: ModuleType / class Note: An instance will be treated as a Class Return: Boolean
[ "Checking", "and", "setting", "type", "to", "MODULE", "Args", ":", "obj", ":", "ModuleType", "/", "class", "Note", ":", "An", "instance", "will", "be", "treated", "as", "a", "Class", "Return", ":", "Boolean" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/util/TypeHandler.py#L72-L81
ff0000/scarlet
scarlet/versioning/management/commands/makemigrations.py
VersionedProjectState.from_apps
def from_apps(cls, apps): "Takes in an Apps and returns a VersionedProjectState matching it" app_models = {} for model in apps.get_models(include_swapped=True): model_state = VersionedModelState.from_model(model) app_models[(model_state.app_label, model_state.name.lower()...
python
def from_apps(cls, apps): "Takes in an Apps and returns a VersionedProjectState matching it" app_models = {} for model in apps.get_models(include_swapped=True): model_state = VersionedModelState.from_model(model) app_models[(model_state.app_label, model_state.name.lower()...
[ "def", "from_apps", "(", "cls", ",", "apps", ")", ":", "app_models", "=", "{", "}", "for", "model", "in", "apps", ".", "get_models", "(", "include_swapped", "=", "True", ")", ":", "model_state", "=", "VersionedModelState", ".", "from_model", "(", "model", ...
Takes in an Apps and returns a VersionedProjectState matching it
[ "Takes", "in", "an", "Apps", "and", "returns", "a", "VersionedProjectState", "matching", "it" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/management/commands/makemigrations.py#L55-L61
commonwealth-of-puerto-rico/libre
libre/apps/data_drivers/renderers.py
LeafletRenderer.render
def render(self, data, accepted_media_type=None, renderer_context=None): """ Renders data to HTML, using Django's standard template rendering. The template name is determined by (in order of preference): 1. An explicit .template_name set on the response. 2. An explicit .templat...
python
def render(self, data, accepted_media_type=None, renderer_context=None): """ Renders data to HTML, using Django's standard template rendering. The template name is determined by (in order of preference): 1. An explicit .template_name set on the response. 2. An explicit .templat...
[ "def", "render", "(", "self", ",", "data", ",", "accepted_media_type", "=", "None", ",", "renderer_context", "=", "None", ")", ":", "renderer_context", "=", "renderer_context", "or", "{", "}", "view", "=", "renderer_context", "[", "'view'", "]", "request", "...
Renders data to HTML, using Django's standard template rendering. The template name is determined by (in order of preference): 1. An explicit .template_name set on the response. 2. An explicit .template_name set on this class. 3. The return result of calling view.get_template_names().
[ "Renders", "data", "to", "HTML", "using", "Django", "s", "standard", "template", "rendering", "." ]
train
https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/renderers.py#L52-L131
ff0000/scarlet
scarlet/assets/managers.py
AssetManager.search_tags
def search_tags(self, tags): """ Search assets by passing a list of one or more tags. """ qs = self.filter(tags__name__in=tags).order_by('file').distinct() return qs
python
def search_tags(self, tags): """ Search assets by passing a list of one or more tags. """ qs = self.filter(tags__name__in=tags).order_by('file').distinct() return qs
[ "def", "search_tags", "(", "self", ",", "tags", ")", ":", "qs", "=", "self", ".", "filter", "(", "tags__name__in", "=", "tags", ")", ".", "order_by", "(", "'file'", ")", ".", "distinct", "(", ")", "return", "qs" ]
Search assets by passing a list of one or more tags.
[ "Search", "assets", "by", "passing", "a", "list", "of", "one", "or", "more", "tags", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/managers.py#L8-L13
ff0000/scarlet
scarlet/versioning/models.py
Cloneable._gather_reverses
def _gather_reverses(self): """ Get all the related objects that point to this object that we need to clone. Uses self.clone_related to find those objects. """ old_reverses = {'m2m': {}, 'reverse': {}} for reverse in self.clone_related: ctype, name, l...
python
def _gather_reverses(self): """ Get all the related objects that point to this object that we need to clone. Uses self.clone_related to find those objects. """ old_reverses = {'m2m': {}, 'reverse': {}} for reverse in self.clone_related: ctype, name, l...
[ "def", "_gather_reverses", "(", "self", ")", ":", "old_reverses", "=", "{", "'m2m'", ":", "{", "}", ",", "'reverse'", ":", "{", "}", "}", "for", "reverse", "in", "self", ".", "clone_related", ":", "ctype", ",", "name", ",", "l", "=", "self", ".", "...
Get all the related objects that point to this object that we need to clone. Uses self.clone_related to find those objects.
[ "Get", "all", "the", "related", "objects", "that", "point", "to", "this", "object", "that", "we", "need", "to", "clone", ".", "Uses", "self", ".", "clone_related", "to", "find", "those", "objects", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L87-L99
ff0000/scarlet
scarlet/versioning/models.py
Cloneable._set_m2ms
def _set_m2ms(self, old_m2ms): """ Creates the same m2m relationships that the old object had. """ for k, v in old_m2ms.items(): if v: setattr(self, k, v)
python
def _set_m2ms(self, old_m2ms): """ Creates the same m2m relationships that the old object had. """ for k, v in old_m2ms.items(): if v: setattr(self, k, v)
[ "def", "_set_m2ms", "(", "self", ",", "old_m2ms", ")", ":", "for", "k", ",", "v", "in", "old_m2ms", ".", "items", "(", ")", ":", "if", "v", ":", "setattr", "(", "self", ",", "k", ",", "v", ")" ]
Creates the same m2m relationships that the old object had.
[ "Creates", "the", "same", "m2m", "relationships", "that", "the", "old", "object", "had", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L101-L109
ff0000/scarlet
scarlet/versioning/models.py
Cloneable._clone_reverses
def _clone_reverses(self, old_reverses): """ Clones all the objects that were previously gathered. """ for ctype, reverses in old_reverses.items(): for parts in reverses.values(): sub_objs = parts[1] field_name = parts[0] attr...
python
def _clone_reverses(self, old_reverses): """ Clones all the objects that were previously gathered. """ for ctype, reverses in old_reverses.items(): for parts in reverses.values(): sub_objs = parts[1] field_name = parts[0] attr...
[ "def", "_clone_reverses", "(", "self", ",", "old_reverses", ")", ":", "for", "ctype", ",", "reverses", "in", "old_reverses", ".", "items", "(", ")", ":", "for", "parts", "in", "reverses", ".", "values", "(", ")", ":", "sub_objs", "=", "parts", "[", "1"...
Clones all the objects that were previously gathered.
[ "Clones", "all", "the", "objects", "that", "were", "previously", "gathered", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L111-L131
ff0000/scarlet
scarlet/versioning/models.py
Cloneable._clone
def _clone(self, **attrs): """ Makes a copy of an model instance. for every key in **attrs value will be set on the new instance. """ with xact(): # Gather objs we'll need save after old_m2ms = self._gather_m2ms() old_reverses = self....
python
def _clone(self, **attrs): """ Makes a copy of an model instance. for every key in **attrs value will be set on the new instance. """ with xact(): # Gather objs we'll need save after old_m2ms = self._gather_m2ms() old_reverses = self....
[ "def", "_clone", "(", "self", ",", "*", "*", "attrs", ")", ":", "with", "xact", "(", ")", ":", "# Gather objs we'll need save after", "old_m2ms", "=", "self", ".", "_gather_m2ms", "(", ")", "old_reverses", "=", "self", ".", "_gather_reverses", "(", ")", "f...
Makes a copy of an model instance. for every key in **attrs value will be set on the new instance.
[ "Makes", "a", "copy", "of", "an", "model", "instance", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L141-L169
ff0000/scarlet
scarlet/versioning/models.py
Cloneable._delete_reverses
def _delete_reverses(self): """ Delete all objects that would have been cloned on a clone command. This is done separately because there may be m2m and other relationships that would have not been deleted otherwise. """ for reverse in self.clone_related: ...
python
def _delete_reverses(self): """ Delete all objects that would have been cloned on a clone command. This is done separately because there may be m2m and other relationships that would have not been deleted otherwise. """ for reverse in self.clone_related: ...
[ "def", "_delete_reverses", "(", "self", ")", ":", "for", "reverse", "in", "self", ".", "clone_related", ":", "self", ".", "_delete_reverse", "(", "reverse", ")", "for", "field", "in", "self", ".", "_meta", ".", "local_many_to_many", ":", "if", "field", "."...
Delete all objects that would have been cloned on a clone command. This is done separately because there may be m2m and other relationships that would have not been deleted otherwise.
[ "Delete", "all", "objects", "that", "would", "have", "been", "cloned", "on", "a", "clone", "command", ".", "This", "is", "done", "separately", "because", "there", "may", "be", "m2m", "and", "other", "relationships", "that", "would", "have", "not", "been", ...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L171-L187
ff0000/scarlet
scarlet/versioning/models.py
Cloneable.delete
def delete(self, *args, **kwargs): """ Delete clonable relations first, since they may be objects that wouldn't otherwise be deleted. Calls super to actually delete the object. """ skip_reverses = kwargs.pop('skip_reverses', False) if not skip_reverses: ...
python
def delete(self, *args, **kwargs): """ Delete clonable relations first, since they may be objects that wouldn't otherwise be deleted. Calls super to actually delete the object. """ skip_reverses = kwargs.pop('skip_reverses', False) if not skip_reverses: ...
[ "def", "delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "skip_reverses", "=", "kwargs", ".", "pop", "(", "'skip_reverses'", ",", "False", ")", "if", "not", "skip_reverses", ":", "self", ".", "_delete_reverses", "(", ")", "ret...
Delete clonable relations first, since they may be objects that wouldn't otherwise be deleted. Calls super to actually delete the object.
[ "Delete", "clonable", "relations", "first", "since", "they", "may", "be", "objects", "that", "wouldn", "t", "otherwise", "be", "deleted", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L208-L219
ff0000/scarlet
scarlet/versioning/models.py
Cloneable.save
def save(self, *args, **kwargs): """ Takes an optional last_save keyword argument other wise last_save will be set to timezone.now() Calls super to actually save the object. """ self.last_save = kwargs.pop('last_save', timezone.now()) super(Cloneable, self).save(...
python
def save(self, *args, **kwargs): """ Takes an optional last_save keyword argument other wise last_save will be set to timezone.now() Calls super to actually save the object. """ self.last_save = kwargs.pop('last_save', timezone.now()) super(Cloneable, self).save(...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "last_save", "=", "kwargs", ".", "pop", "(", "'last_save'", ",", "timezone", ".", "now", "(", ")", ")", "super", "(", "Cloneable", ",", "self", ")", "."...
Takes an optional last_save keyword argument other wise last_save will be set to timezone.now() Calls super to actually save the object.
[ "Takes", "an", "optional", "last_save", "keyword", "argument", "other", "wise", "last_save", "will", "be", "set", "to", "timezone", ".", "now", "()" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L221-L229
ff0000/scarlet
scarlet/versioning/models.py
Cloneable.register_related
def register_related(cls, related_name): """ Register a related item that should be cloned when this model is. :param related_name: Use the name you would use in filtering i.e.: book not book_set. """ if not hasattr(cls, '_clone_related'): cls._c...
python
def register_related(cls, related_name): """ Register a related item that should be cloned when this model is. :param related_name: Use the name you would use in filtering i.e.: book not book_set. """ if not hasattr(cls, '_clone_related'): cls._c...
[ "def", "register_related", "(", "cls", ",", "related_name", ")", ":", "if", "not", "hasattr", "(", "cls", ",", "'_clone_related'", ")", ":", "cls", ".", "_clone_related", "=", "[", "]", "if", "type", "(", "cls", ".", "_clone_related", ")", "!=", "type", ...
Register a related item that should be cloned when this model is. :param related_name: Use the name you would use in filtering i.e.: book not book_set.
[ "Register", "a", "related", "item", "that", "should", "be", "cloned", "when", "this", "model", "is", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L236-L252
ff0000/scarlet
scarlet/versioning/models.py
VersionModelMeta.add_to_class
def add_to_class(cls, name, value): """ Django 1.10 doesn't allow us to modify `_base_manager` attr: https://docs.djangoproject.com/en/1.10/topics/db/managers/#django.db.models.Model._base_manager """ if name == '_base_manager': if not value.name: valu...
python
def add_to_class(cls, name, value): """ Django 1.10 doesn't allow us to modify `_base_manager` attr: https://docs.djangoproject.com/en/1.10/topics/db/managers/#django.db.models.Model._base_manager """ if name == '_base_manager': if not value.name: valu...
[ "def", "add_to_class", "(", "cls", ",", "name", ",", "value", ")", ":", "if", "name", "==", "'_base_manager'", ":", "if", "not", "value", ".", "name", ":", "value", ".", "name", "=", "name", "value", ".", "model", "=", "cls", "setattr", "(", "cls", ...
Django 1.10 doesn't allow us to modify `_base_manager` attr: https://docs.djangoproject.com/en/1.10/topics/db/managers/#django.db.models.Model._base_manager
[ "Django", "1", ".", "10", "doesn", "t", "allow", "us", "to", "modify", "_base_manager", "attr", ":", "https", ":", "//", "docs", ".", "djangoproject", ".", "com", "/", "en", "/", "1", ".", "10", "/", "topics", "/", "db", "/", "managers", "/", "#dja...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L492-L503
ff0000/scarlet
scarlet/versioning/models.py
BaseModel.get_version
def get_version(self, state=None, date=None): """ Get a particular version of an item :param state: The state you want to get. :param date: Get a version that was published before or on this date. """ version_model = self._meta._version_model q = version_model.o...
python
def get_version(self, state=None, date=None): """ Get a particular version of an item :param state: The state you want to get. :param date: Get a version that was published before or on this date. """ version_model = self._meta._version_model q = version_model.o...
[ "def", "get_version", "(", "self", ",", "state", "=", "None", ",", "date", "=", "None", ")", ":", "version_model", "=", "self", ".", "_meta", ".", "_version_model", "q", "=", "version_model", ".", "objects", ".", "filter", "(", "object_id", "=", "self", ...
Get a particular version of an item :param state: The state you want to get. :param date: Get a version that was published before or on this date.
[ "Get", "a", "particular", "version", "of", "an", "item" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L576-L597
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.unpublish
def unpublish(self): """ Unpublish this item. This will set and currently published versions to the archived state and delete all currently scheduled versions. """ assert self.state == self.DRAFT with xact(): self._publish(published=False) ...
python
def unpublish(self): """ Unpublish this item. This will set and currently published versions to the archived state and delete all currently scheduled versions. """ assert self.state == self.DRAFT with xact(): self._publish(published=False) ...
[ "def", "unpublish", "(", "self", ")", ":", "assert", "self", ".", "state", "==", "self", ".", "DRAFT", "with", "xact", "(", ")", ":", "self", ".", "_publish", "(", "published", "=", "False", ")", "# Delete all scheduled items", "klass", "=", "self", ".",...
Unpublish this item. This will set and currently published versions to the archived state and delete all currently scheduled versions.
[ "Unpublish", "this", "item", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L660-L676
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.publish
def publish(self, user=None, when=None): """ Publishes a item and any sub items. A new transaction will be started if we aren't already in a transaction. Should only be run on draft items """ assert self.state == self.DRAFT user_published = 'code' ...
python
def publish(self, user=None, when=None): """ Publishes a item and any sub items. A new transaction will be started if we aren't already in a transaction. Should only be run on draft items """ assert self.state == self.DRAFT user_published = 'code' ...
[ "def", "publish", "(", "self", ",", "user", "=", "None", ",", "when", "=", "None", ")", ":", "assert", "self", ".", "state", "==", "self", ".", "DRAFT", "user_published", "=", "'code'", "if", "user", ":", "user_published", "=", "user", ".", "username",...
Publishes a item and any sub items. A new transaction will be started if we aren't already in a transaction. Should only be run on draft items
[ "Publishes", "a", "item", "and", "any", "sub", "items", ".", "A", "new", "transaction", "will", "be", "started", "if", "we", "aren", "t", "already", "in", "a", "transaction", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L678-L727
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.make_draft
def make_draft(self): """ Make this version the draft """ assert self.__class__ == self.get_version_class() # If this is draft do nothing if self.state == self.DRAFT: return with xact(): # Delete whatever is currently this draft ...
python
def make_draft(self): """ Make this version the draft """ assert self.__class__ == self.get_version_class() # If this is draft do nothing if self.state == self.DRAFT: return with xact(): # Delete whatever is currently this draft ...
[ "def", "make_draft", "(", "self", ")", ":", "assert", "self", ".", "__class__", "==", "self", ".", "get_version_class", "(", ")", "# If this is draft do nothing", "if", "self", ".", "state", "==", "self", ".", "DRAFT", ":", "return", "with", "xact", "(", "...
Make this version the draft
[ "Make", "this", "version", "the", "draft" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L765-L789
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.purge_archives
def purge_archives(self): """ Delete older archived items. Use the class attribute NUM_KEEP_ARCHIVED to control how many items are kept. """ klass = self.get_version_class() qs = klass.normal.filter(object_id=self.object_id, stat...
python
def purge_archives(self): """ Delete older archived items. Use the class attribute NUM_KEEP_ARCHIVED to control how many items are kept. """ klass = self.get_version_class() qs = klass.normal.filter(object_id=self.object_id, stat...
[ "def", "purge_archives", "(", "self", ")", ":", "klass", "=", "self", ".", "get_version_class", "(", ")", "qs", "=", "klass", ".", "normal", ".", "filter", "(", "object_id", "=", "self", ".", "object_id", ",", "state", "=", "self", ".", "ARCHIVED", ")"...
Delete older archived items. Use the class attribute NUM_KEEP_ARCHIVED to control how many items are kept.
[ "Delete", "older", "archived", "items", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L833-L847
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.status_line
def status_line(self): """ Returns a status line for an item. Only really interesting when called for a draft item as it can tell you if the draft is the same as another version. """ date = self.date_published status = self.state.title() if self....
python
def status_line(self): """ Returns a status line for an item. Only really interesting when called for a draft item as it can tell you if the draft is the same as another version. """ date = self.date_published status = self.state.title() if self....
[ "def", "status_line", "(", "self", ")", ":", "date", "=", "self", ".", "date_published", "status", "=", "self", ".", "state", ".", "title", "(", ")", "if", "self", ".", "state", "==", "self", ".", "DRAFT", ":", "# Check if this item has changed since", "# ...
Returns a status line for an item. Only really interesting when called for a draft item as it can tell you if the draft is the same as another version.
[ "Returns", "a", "status", "line", "for", "an", "item", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L849-L889
ff0000/scarlet
scarlet/versioning/models.py
BaseVersionedModel.schedule
def schedule(self, when=None, action=None, **kwargs): """ Schedule this item to be published. :param when: Date/time when this item should go live. None means now. """ action = '_publish' super(BaseVersionedModel, self).schedule(when=when, action=action, ...
python
def schedule(self, when=None, action=None, **kwargs): """ Schedule this item to be published. :param when: Date/time when this item should go live. None means now. """ action = '_publish' super(BaseVersionedModel, self).schedule(when=when, action=action, ...
[ "def", "schedule", "(", "self", ",", "when", "=", "None", ",", "action", "=", "None", ",", "*", "*", "kwargs", ")", ":", "action", "=", "'_publish'", "super", "(", "BaseVersionedModel", ",", "self", ")", ".", "schedule", "(", "when", "=", "when", ","...
Schedule this item to be published. :param when: Date/time when this item should go live. None means now.
[ "Schedule", "this", "item", "to", "be", "published", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L891-L899
ff0000/scarlet
scarlet/versioning/models.py
VersionView.validate_unique
def validate_unique(self, *args, **kwargs): """ Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. This relies on using the public schema when running this ...
python
def validate_unique(self, *args, **kwargs): """ Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. This relies on using the public schema when running this ...
[ "def", "validate_unique", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "BaseVersionedModel", ",", "self", ")", ".", "validate_unique", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "hasattr", "(", "self", ",...
Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. This relies on using the public schema when running this check. These checks contain race conditions since i...
[ "Calls", "super", "validate_unique", "and", "after", "that", "is", "done", "runs", "through", "any", "field_names", "listed", "in", "self", ".", "versioned_unique", "and", "checks", "that", "this", "is", "the", "only", "item", "with", "this", "name", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L1025-L1047
ff0000/scarlet
scarlet/versioning/models.py
VersionModel.validate_unique
def validate_unique(self, *args, **kwargs): """ Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. These checks contain race conditions since it all happens ...
python
def validate_unique(self, *args, **kwargs): """ Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. These checks contain race conditions since it all happens ...
[ "def", "validate_unique", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "BaseVersionedModel", ",", "self", ")", ".", "validate_unique", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "hasattr", "(", "self", ",...
Calls super validate_unique and, after that is done, runs through any field_names listed in `self.versioned_unique` and checks that this is the only item with this name. These checks contain race conditions since it all happens before saves and so should not be relied upon for uniquenes...
[ "Calls", "super", "validate_unique", "and", "after", "that", "is", "done", "runs", "through", "any", "field_names", "listed", "in", "self", ".", "versioned_unique", "and", "checks", "that", "this", "is", "the", "only", "item", "with", "this", "name", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L1132-L1161
ff0000/scarlet
scarlet/versioning/models.py
VersionModel.save
def save(self, *args, **kwargs): """ Saves this item. Creates a default base if there isn't one already. """ with xact(): if not self.vid: self.state = self.DRAFT if not self.object_id: base = self._meta._b...
python
def save(self, *args, **kwargs): """ Saves this item. Creates a default base if there isn't one already. """ with xact(): if not self.vid: self.state = self.DRAFT if not self.object_id: base = self._meta._b...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "xact", "(", ")", ":", "if", "not", "self", ".", "vid", ":", "self", ".", "state", "=", "self", ".", "DRAFT", "if", "not", "self", ".", "object_id", ":", ...
Saves this item. Creates a default base if there isn't one already.
[ "Saves", "this", "item", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/models.py#L1163-L1179
inveniosoftware/invenio-collections
invenio_collections/utils.py
slugify
def slugify(text, delim='-'): """Generate an ASCII-only slug.""" result = [] for word in _punct_re.split((text or '').lower()): result.extend(codecs.encode(word, 'ascii', 'replace').split()) return delim.join([str(r) for r in result])
python
def slugify(text, delim='-'): """Generate an ASCII-only slug.""" result = [] for word in _punct_re.split((text or '').lower()): result.extend(codecs.encode(word, 'ascii', 'replace').split()) return delim.join([str(r) for r in result])
[ "def", "slugify", "(", "text", ",", "delim", "=", "'-'", ")", ":", "result", "=", "[", "]", "for", "word", "in", "_punct_re", ".", "split", "(", "(", "text", "or", "''", ")", ".", "lower", "(", ")", ")", ":", "result", ".", "extend", "(", "code...
Generate an ASCII-only slug.
[ "Generate", "an", "ASCII", "-", "only", "slug", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/utils.py#L39-L44
inveniosoftware/invenio-collections
invenio_collections/utils.py
parser
def parser(): """Return search query parser.""" query_parser = current_app.config['COLLECTIONS_QUERY_PARSER'] if isinstance(query_parser, six.string_types): query_parser = import_string(query_parser) return query_parser
python
def parser(): """Return search query parser.""" query_parser = current_app.config['COLLECTIONS_QUERY_PARSER'] if isinstance(query_parser, six.string_types): query_parser = import_string(query_parser) return query_parser
[ "def", "parser", "(", ")", ":", "query_parser", "=", "current_app", ".", "config", "[", "'COLLECTIONS_QUERY_PARSER'", "]", "if", "isinstance", "(", "query_parser", ",", "six", ".", "string_types", ")", ":", "query_parser", "=", "import_string", "(", "query_parse...
Return search query parser.
[ "Return", "search", "query", "parser", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/utils.py#L47-L52
inveniosoftware/invenio-collections
invenio_collections/utils.py
query_walkers
def query_walkers(): """Return query walker instances.""" return [ import_string(walker)() if isinstance(walker, six.string_types) else walker() for walker in current_app.config[ 'COLLECTIONS_QUERY_WALKERS'] ]
python
def query_walkers(): """Return query walker instances.""" return [ import_string(walker)() if isinstance(walker, six.string_types) else walker() for walker in current_app.config[ 'COLLECTIONS_QUERY_WALKERS'] ]
[ "def", "query_walkers", "(", ")", ":", "return", "[", "import_string", "(", "walker", ")", "(", ")", "if", "isinstance", "(", "walker", ",", "six", ".", "string_types", ")", "else", "walker", "(", ")", "for", "walker", "in", "current_app", ".", "config",...
Return query walker instances.
[ "Return", "query", "walker", "instances", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/utils.py#L55-L61
anomaly/vishnu
vishnu/cipher.py
AESCipher.pad
def pad(cls, data): """ Pads data to match AES block size """ if sys.version_info > (3, 0): try: data = data.encode("utf-8") except AttributeError: pass length = AES.block_size - (len(data) % AES.block_size) ...
python
def pad(cls, data): """ Pads data to match AES block size """ if sys.version_info > (3, 0): try: data = data.encode("utf-8") except AttributeError: pass length = AES.block_size - (len(data) % AES.block_size) ...
[ "def", "pad", "(", "cls", ",", "data", ")", ":", "if", "sys", ".", "version_info", ">", "(", "3", ",", "0", ")", ":", "try", ":", "data", "=", "data", ".", "encode", "(", "\"utf-8\"", ")", "except", "AttributeError", ":", "pass", "length", "=", "...
Pads data to match AES block size
[ "Pads", "data", "to", "match", "AES", "block", "size" ]
train
https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/cipher.py#L25-L39
anomaly/vishnu
vishnu/cipher.py
AESCipher.unpad
def unpad(cls, data): """ Unpads data that has been padded """ if sys.version_info > (3, 0): return data[:-ord(data[len(data)-1:])].decode() else: return data[:-ord(data[len(data)-1:])]
python
def unpad(cls, data): """ Unpads data that has been padded """ if sys.version_info > (3, 0): return data[:-ord(data[len(data)-1:])].decode() else: return data[:-ord(data[len(data)-1:])]
[ "def", "unpad", "(", "cls", ",", "data", ")", ":", "if", "sys", ".", "version_info", ">", "(", "3", ",", "0", ")", ":", "return", "data", "[", ":", "-", "ord", "(", "data", "[", "len", "(", "data", ")", "-", "1", ":", "]", ")", "]", ".", ...
Unpads data that has been padded
[ "Unpads", "data", "that", "has", "been", "padded" ]
train
https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/cipher.py#L42-L49
anomaly/vishnu
vishnu/cipher.py
AESCipher.encrypt
def encrypt(self, raw): """ Encrypts raw data using AES and then base64 encodes it. :param raw: :return: """ padded = AESCipher.pad(raw) init_vec = Random.new().read(AES.block_size) cipher = AES.new(self._key, AES.MODE_CBC, init_vec) return b64enco...
python
def encrypt(self, raw): """ Encrypts raw data using AES and then base64 encodes it. :param raw: :return: """ padded = AESCipher.pad(raw) init_vec = Random.new().read(AES.block_size) cipher = AES.new(self._key, AES.MODE_CBC, init_vec) return b64enco...
[ "def", "encrypt", "(", "self", ",", "raw", ")", ":", "padded", "=", "AESCipher", ".", "pad", "(", "raw", ")", "init_vec", "=", "Random", ".", "new", "(", ")", ".", "read", "(", "AES", ".", "block_size", ")", "cipher", "=", "AES", ".", "new", "(",...
Encrypts raw data using AES and then base64 encodes it. :param raw: :return:
[ "Encrypts", "raw", "data", "using", "AES", "and", "then", "base64", "encodes", "it", ".", ":", "param", "raw", ":", ":", "return", ":" ]
train
https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/cipher.py#L51-L60
anomaly/vishnu
vishnu/cipher.py
AESCipher.decrypt
def decrypt(self, encrypted): """ Base64 decodes the data and then decrypts using AES. :param encrypted: :return: """ decoded = b64decode(encrypted) init_vec = decoded[:AES.block_size] cipher = AES.new(self._key, AES.MODE_CBC, init_vec) return AES...
python
def decrypt(self, encrypted): """ Base64 decodes the data and then decrypts using AES. :param encrypted: :return: """ decoded = b64decode(encrypted) init_vec = decoded[:AES.block_size] cipher = AES.new(self._key, AES.MODE_CBC, init_vec) return AES...
[ "def", "decrypt", "(", "self", ",", "encrypted", ")", ":", "decoded", "=", "b64decode", "(", "encrypted", ")", "init_vec", "=", "decoded", "[", ":", "AES", ".", "block_size", "]", "cipher", "=", "AES", ".", "new", "(", "self", ".", "_key", ",", "AES"...
Base64 decodes the data and then decrypts using AES. :param encrypted: :return:
[ "Base64", "decodes", "the", "data", "and", "then", "decrypts", "using", "AES", ".", ":", "param", "encrypted", ":", ":", "return", ":" ]
train
https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/cipher.py#L62-L72
commonwealth-of-puerto-rico/libre
libre/apps/lock_manager/decorators.py
simple_locking
def simple_locking(lock_id, expiration=None): """ A decorator that wraps a function in a single lock getting algorithm """ def inner_decorator(function): def wrapper(*args, **kwargs): try: # Trying to acquire lock lock = Lock.acquire_lock(lock_id, expi...
python
def simple_locking(lock_id, expiration=None): """ A decorator that wraps a function in a single lock getting algorithm """ def inner_decorator(function): def wrapper(*args, **kwargs): try: # Trying to acquire lock lock = Lock.acquire_lock(lock_id, expi...
[ "def", "simple_locking", "(", "lock_id", ",", "expiration", "=", "None", ")", ":", "def", "inner_decorator", "(", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "# Trying to acquire lock", "lock", ...
A decorator that wraps a function in a single lock getting algorithm
[ "A", "decorator", "that", "wraps", "a", "function", "in", "a", "single", "lock", "getting", "algorithm" ]
train
https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/lock_manager/decorators.py#L10-L34
klahnakoski/pyLibrary
pyLibrary/env/rollover_index.py
fix
def fix(source_key, rownum, line, source, sample_only_filter, sample_size): """ :param rownum: :param line: :param source: :param sample_only_filter: :param sample_size: :return: (row, no_more_data) TUPLE WHERE row IS {"value":<data structure>} OR {"json":<text line>} """ value = js...
python
def fix(source_key, rownum, line, source, sample_only_filter, sample_size): """ :param rownum: :param line: :param source: :param sample_only_filter: :param sample_size: :return: (row, no_more_data) TUPLE WHERE row IS {"value":<data structure>} OR {"json":<text line>} """ value = js...
[ "def", "fix", "(", "source_key", ",", "rownum", ",", "line", ",", "source", ",", "sample_only_filter", ",", "sample_size", ")", ":", "value", "=", "json2value", "(", "line", ")", "if", "rownum", "==", "0", ":", "if", "len", "(", "line", ")", ">", "MA...
:param rownum: :param line: :param source: :param sample_only_filter: :param sample_size: :return: (row, no_more_data) TUPLE WHERE row IS {"value":<data structure>} OR {"json":<text line>}
[ ":", "param", "rownum", ":", ":", "param", "line", ":", ":", "param", "source", ":", ":", "param", "sample_only_filter", ":", ":", "param", "sample_size", ":", ":", "return", ":", "(", "row", "no_more_data", ")", "TUPLE", "WHERE", "row", "IS", "{", "va...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/rollover_index.py#L262-L290
klahnakoski/pyLibrary
pyLibrary/env/rollover_index.py
RolloverIndex.copy
def copy(self, keys, source, sample_only_filter=None, sample_size=None, done_copy=None): """ :param keys: THE KEYS TO LOAD FROM source :param source: THE SOURCE (USUALLY S3 BUCKET) :param sample_only_filter: SOME FILTER, IN CASE YOU DO NOT WANT TO SEND EVERYTHING :param sample_si...
python
def copy(self, keys, source, sample_only_filter=None, sample_size=None, done_copy=None): """ :param keys: THE KEYS TO LOAD FROM source :param source: THE SOURCE (USUALLY S3 BUCKET) :param sample_only_filter: SOME FILTER, IN CASE YOU DO NOT WANT TO SEND EVERYTHING :param sample_si...
[ "def", "copy", "(", "self", ",", "keys", ",", "source", ",", "sample_only_filter", "=", "None", ",", "sample_size", "=", "None", ",", "done_copy", "=", "None", ")", ":", "num_keys", "=", "0", "queue", "=", "None", "pending", "=", "[", "]", "# FOR WHEN ...
:param keys: THE KEYS TO LOAD FROM source :param source: THE SOURCE (USUALLY S3 BUCKET) :param sample_only_filter: SOME FILTER, IN CASE YOU DO NOT WANT TO SEND EVERYTHING :param sample_size: FOR RANDOM SAMPLE OF THE source DATA :param done_copy: CALLBACK, ADDED TO queue, TO FINISH THE TR...
[ ":", "param", "keys", ":", "THE", "KEYS", "TO", "LOAD", "FROM", "source", ":", "param", "source", ":", "THE", "SOURCE", "(", "USUALLY", "S3", "BUCKET", ")", ":", "param", "sample_only_filter", ":", "SOME", "FILTER", "IN", "CASE", "YOU", "DO", "NOT", "W...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/rollover_index.py#L185-L259
jmoiron/micromongo
micromongo/backend.py
from_env
def from_env(): """Get host/port settings from the environment.""" if 'MICROMONGO_URI' in os.environ: return (os.environ['MICROMONGO_URI'],) host = os.environ.get('MICROMONGO_HOST', 'localhost') port = int(os.environ.get('MICROMONGO_PORT', 27017)) return (host, port)
python
def from_env(): """Get host/port settings from the environment.""" if 'MICROMONGO_URI' in os.environ: return (os.environ['MICROMONGO_URI'],) host = os.environ.get('MICROMONGO_HOST', 'localhost') port = int(os.environ.get('MICROMONGO_PORT', 27017)) return (host, port)
[ "def", "from_env", "(", ")", ":", "if", "'MICROMONGO_URI'", "in", "os", ".", "environ", ":", "return", "(", "os", ".", "environ", "[", "'MICROMONGO_URI'", "]", ",", ")", "host", "=", "os", ".", "environ", ".", "get", "(", "'MICROMONGO_HOST'", ",", "'lo...
Get host/port settings from the environment.
[ "Get", "host", "/", "port", "settings", "from", "the", "environment", "." ]
train
https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/backend.py#L29-L35
jmoiron/micromongo
micromongo/backend.py
Cursor.order_by
def order_by(self, *fields): """An alternate to ``sort`` which allows you to specify a list of fields and use a leading - (minus) to specify DESCENDING.""" doc = [] for field in fields: if field.startswith('-'): doc.append((field.strip('-'), pymongo.DESCENDING...
python
def order_by(self, *fields): """An alternate to ``sort`` which allows you to specify a list of fields and use a leading - (minus) to specify DESCENDING.""" doc = [] for field in fields: if field.startswith('-'): doc.append((field.strip('-'), pymongo.DESCENDING...
[ "def", "order_by", "(", "self", ",", "*", "fields", ")", ":", "doc", "=", "[", "]", "for", "field", "in", "fields", ":", "if", "field", ".", "startswith", "(", "'-'", ")", ":", "doc", ".", "append", "(", "(", "field", ".", "strip", "(", "'-'", ...
An alternate to ``sort`` which allows you to specify a list of fields and use a leading - (minus) to specify DESCENDING.
[ "An", "alternate", "to", "sort", "which", "allows", "you", "to", "specify", "a", "list", "of", "fields", "and", "use", "a", "leading", "-", "(", "minus", ")", "to", "specify", "DESCENDING", "." ]
train
https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/backend.py#L99-L108
jmoiron/micromongo
micromongo/backend.py
Cursor.next
def next(self): """A `next` that caches the returned results. Together with the slightly different `__iter__`, these cursors can be iterated over more than once.""" if self.__tailable: return PymongoCursor.next(self) try: ret = PymongoCursor.next(self) ...
python
def next(self): """A `next` that caches the returned results. Together with the slightly different `__iter__`, these cursors can be iterated over more than once.""" if self.__tailable: return PymongoCursor.next(self) try: ret = PymongoCursor.next(self) ...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "__tailable", ":", "return", "PymongoCursor", ".", "next", "(", "self", ")", "try", ":", "ret", "=", "PymongoCursor", ".", "next", "(", "self", ")", "except", "StopIteration", ":", "self", ".", ...
A `next` that caches the returned results. Together with the slightly different `__iter__`, these cursors can be iterated over more than once.
[ "A", "next", "that", "caches", "the", "returned", "results", ".", "Together", "with", "the", "slightly", "different", "__iter__", "these", "cursors", "can", "be", "iterated", "over", "more", "than", "once", "." ]
train
https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/backend.py#L115-L127
tetframework/Tonnikala
tonnikala/expr.py
_strip_dollars_fast
def _strip_dollars_fast(text): """ Replace `$$` with `$`. raise immediately if `$` starting an interpolated expression is found. @param text: the source text @return: the text with dollars replaced, or raise HasExprException if there are interpolated expressions """ def _sub(m): ...
python
def _strip_dollars_fast(text): """ Replace `$$` with `$`. raise immediately if `$` starting an interpolated expression is found. @param text: the source text @return: the text with dollars replaced, or raise HasExprException if there are interpolated expressions """ def _sub(m): ...
[ "def", "_strip_dollars_fast", "(", "text", ")", ":", "def", "_sub", "(", "m", ")", ":", "if", "m", ".", "group", "(", "0", ")", "==", "'$$'", ":", "return", "'$'", "raise", "HasExprException", "(", ")", "return", "_dollar_strip_re", ".", "sub", "(", ...
Replace `$$` with `$`. raise immediately if `$` starting an interpolated expression is found. @param text: the source text @return: the text with dollars replaced, or raise HasExprException if there are interpolated expressions
[ "Replace", "$$", "with", "$", ".", "raise", "immediately", "if", "$", "starting", "an", "interpolated", "expression", "is", "found", "." ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/expr.py#L17-L32
tetframework/Tonnikala
tonnikala/languages/python/generator.py
adjust_locations
def adjust_locations(ast_node, first_lineno, first_offset): """ Adjust the locations of the ast nodes, offsetting them to the new lineno and column offset """ line_delta = first_lineno - 1 def _fix(node): if 'lineno' in node._attributes: lineno = node.lineno col...
python
def adjust_locations(ast_node, first_lineno, first_offset): """ Adjust the locations of the ast nodes, offsetting them to the new lineno and column offset """ line_delta = first_lineno - 1 def _fix(node): if 'lineno' in node._attributes: lineno = node.lineno col...
[ "def", "adjust_locations", "(", "ast_node", ",", "first_lineno", ",", "first_offset", ")", ":", "line_delta", "=", "first_lineno", "-", "1", "def", "_fix", "(", "node", ")", ":", "if", "'lineno'", "in", "node", ".", "_attributes", ":", "lineno", "=", "node...
Adjust the locations of the ast nodes, offsetting them to the new lineno and column offset
[ "Adjust", "the", "locations", "of", "the", "ast", "nodes", "offsetting", "them", "to", "the", "new", "lineno", "and", "column", "offset" ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/python/generator.py#L72-L97
tetframework/Tonnikala
tonnikala/languages/python/generator.py
coalesce_outputs
def coalesce_outputs(tree): """ Coalesce the constant output expressions __output__('foo') __output__('bar') __output__(baz) __output__('xyzzy') into __output__('foobar', baz, 'xyzzy') """ coalesce_all_outputs = True if coalesce_all_outputs: sh...
python
def coalesce_outputs(tree): """ Coalesce the constant output expressions __output__('foo') __output__('bar') __output__(baz) __output__('xyzzy') into __output__('foobar', baz, 'xyzzy') """ coalesce_all_outputs = True if coalesce_all_outputs: sh...
[ "def", "coalesce_outputs", "(", "tree", ")", ":", "coalesce_all_outputs", "=", "True", "if", "coalesce_all_outputs", ":", "should_coalesce", "=", "lambda", "n", ":", "True", "else", ":", "should_coalesce", "=", "lambda", "n", ":", "n", ".", "output_args", "[",...
Coalesce the constant output expressions __output__('foo') __output__('bar') __output__(baz) __output__('xyzzy') into __output__('foobar', baz, 'xyzzy')
[ "Coalesce", "the", "constant", "output", "expressions" ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/python/generator.py#L560-L651
tetframework/Tonnikala
tonnikala/languages/python/generator.py
remove_locations
def remove_locations(node): """ Removes locations from the given AST tree completely """ def fix(node): if 'lineno' in node._attributes and hasattr(node, 'lineno'): del node.lineno if 'col_offset' in node._attributes and hasattr(node, 'col_offset'): del node.col...
python
def remove_locations(node): """ Removes locations from the given AST tree completely """ def fix(node): if 'lineno' in node._attributes and hasattr(node, 'lineno'): del node.lineno if 'col_offset' in node._attributes and hasattr(node, 'col_offset'): del node.col...
[ "def", "remove_locations", "(", "node", ")", ":", "def", "fix", "(", "node", ")", ":", "if", "'lineno'", "in", "node", ".", "_attributes", "and", "hasattr", "(", "node", ",", "'lineno'", ")", ":", "del", "node", ".", "lineno", "if", "'col_offset'", "in...
Removes locations from the given AST tree completely
[ "Removes", "locations", "from", "the", "given", "AST", "tree", "completely" ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/python/generator.py#L654-L669
dantezhu/melon
melon/connection.py
Connection.dataReceived
def dataReceived(self, data): """ 当数据接受到时 :param data: :return: """ self._read_buffer += data while self._read_buffer: # 因为box后面还是要用的 box = self.factory.app.box_class() ret = box.unpack(self._read_buffer) if ret == ...
python
def dataReceived(self, data): """ 当数据接受到时 :param data: :return: """ self._read_buffer += data while self._read_buffer: # 因为box后面还是要用的 box = self.factory.app.box_class() ret = box.unpack(self._read_buffer) if ret == ...
[ "def", "dataReceived", "(", "self", ",", "data", ")", ":", "self", ".", "_read_buffer", "+=", "data", "while", "self", ".", "_read_buffer", ":", "# 因为box后面还是要用的", "box", "=", "self", ".", "factory", ".", "app", ".", "box_class", "(", ")", "ret", "=", "...
当数据接受到时 :param data: :return:
[ "当数据接受到时", ":", "param", "data", ":", ":", "return", ":" ]
train
https://github.com/dantezhu/melon/blob/44d859fa85fbfb2d77479e01eade925a0d26e4f7/melon/connection.py#L28-L53
dantezhu/melon
melon/connection.py
Connection._on_read_complete
def _on_read_complete(self, data, box): """ 完整数据接收完成 :param data: 原始数据 :param box: 解析之后的box :return: """ msg = dict( conn_id=id(self), address=self.address, data=data, ) # 获取映射的group_id group_id = self.f...
python
def _on_read_complete(self, data, box): """ 完整数据接收完成 :param data: 原始数据 :param box: 解析之后的box :return: """ msg = dict( conn_id=id(self), address=self.address, data=data, ) # 获取映射的group_id group_id = self.f...
[ "def", "_on_read_complete", "(", "self", ",", "data", ",", "box", ")", ":", "msg", "=", "dict", "(", "conn_id", "=", "id", "(", "self", ")", ",", "address", "=", "self", ".", "address", ",", "data", "=", "data", ",", ")", "# 获取映射的group_id", "group_id...
完整数据接收完成 :param data: 原始数据 :param box: 解析之后的box :return:
[ "完整数据接收完成", ":", "param", "data", ":", "原始数据", ":", "param", "box", ":", "解析之后的box", ":", "return", ":" ]
train
https://github.com/dantezhu/melon/blob/44d859fa85fbfb2d77479e01eade925a0d26e4f7/melon/connection.py#L55-L74
klahnakoski/pyLibrary
mo_collections/persistent_queue.py
PersistentQueue.pop
def pop(self, timeout=None): """ :param timeout: OPTIONAL DURATION :return: None, IF timeout PASSES """ with self.lock: while not self.please_stop: if self.db.status.end > self.start: value = self.db[str(self.start)] ...
python
def pop(self, timeout=None): """ :param timeout: OPTIONAL DURATION :return: None, IF timeout PASSES """ with self.lock: while not self.please_stop: if self.db.status.end > self.start: value = self.db[str(self.start)] ...
[ "def", "pop", "(", "self", ",", "timeout", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "while", "not", "self", ".", "please_stop", ":", "if", "self", ".", "db", ".", "status", ".", "end", ">", "self", ".", "start", ":", "value", "=",...
:param timeout: OPTIONAL DURATION :return: None, IF timeout PASSES
[ ":", "param", "timeout", ":", "OPTIONAL", "DURATION", ":", "return", ":", "None", "IF", "timeout", "PASSES" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/persistent_queue.py#L118-L139
klahnakoski/pyLibrary
mo_collections/persistent_queue.py
PersistentQueue.pop_all
def pop_all(self): """ NON-BLOCKING POP ALL IN QUEUE, IF ANY """ with self.lock: if self.please_stop: return [THREAD_STOP] if self.db.status.end == self.start: return [] output = [] for i in range(self.start...
python
def pop_all(self): """ NON-BLOCKING POP ALL IN QUEUE, IF ANY """ with self.lock: if self.please_stop: return [THREAD_STOP] if self.db.status.end == self.start: return [] output = [] for i in range(self.start...
[ "def", "pop_all", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "if", "self", ".", "please_stop", ":", "return", "[", "THREAD_STOP", "]", "if", "self", ".", "db", ".", "status", ".", "end", "==", "self", ".", "start", ":", "return", "[",...
NON-BLOCKING POP ALL IN QUEUE, IF ANY
[ "NON", "-", "BLOCKING", "POP", "ALL", "IN", "QUEUE", "IF", "ANY" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/persistent_queue.py#L141-L156
klahnakoski/pyLibrary
mo_parquet/__init__.py
rows_to_columns
def rows_to_columns(data, schema=None): """ :param data: array of objects :param schema: Known schema, will be extended to include all properties found in data :return: Table """ if not schema: schema = SchemaTree() all_schema = schema all_leaves = schema.leaves values = {ful...
python
def rows_to_columns(data, schema=None): """ :param data: array of objects :param schema: Known schema, will be extended to include all properties found in data :return: Table """ if not schema: schema = SchemaTree() all_schema = schema all_leaves = schema.leaves values = {ful...
[ "def", "rows_to_columns", "(", "data", ",", "schema", "=", "None", ")", ":", "if", "not", "schema", ":", "schema", "=", "SchemaTree", "(", ")", "all_schema", "=", "schema", "all_leaves", "=", "schema", ".", "leaves", "values", "=", "{", "full_name", ":",...
:param data: array of objects :param schema: Known schema, will be extended to include all properties found in data :return: Table
[ ":", "param", "data", ":", "array", "of", "objects", ":", "param", "schema", ":", "Known", "schema", "will", "be", "extended", "to", "include", "all", "properties", "found", "in", "data", ":", "return", ":", "Table" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_parquet/__init__.py#L20-L132
Galarzaa90/tibia.py
tibiapy/character.py
Character.from_content
def from_content(cls, content): """Creates an instance of the class from the html content of the character's page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`Character` The character ...
python
def from_content(cls, content): """Creates an instance of the class from the html content of the character's page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`Character` The character ...
[ "def", "from_content", "(", "cls", ",", "content", ")", ":", "parsed_content", "=", "parse_tibiacom_content", "(", "content", ")", "tables", "=", "cls", ".", "_parse_tables", "(", "parsed_content", ")", "char", "=", "Character", "(", ")", "if", "\"Could not fi...
Creates an instance of the class from the html content of the character's page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`Character` The character contained in the page, or None if the chara...
[ "Creates", "an", "instance", "of", "the", "class", "from", "the", "html", "content", "of", "the", "character", "s", "page", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L189-L220
Galarzaa90/tibia.py
tibiapy/character.py
Character.from_tibiadata
def from_tibiadata(cls, content): """Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` The JSON content of the response. Returns ------- :class:`Character` The character contained i...
python
def from_tibiadata(cls, content): """Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` The JSON content of the response. Returns ------- :class:`Character` The character contained i...
[ "def", "from_tibiadata", "(", "cls", ",", "content", ")", ":", "json_content", "=", "parse_json", "(", "content", ")", "char", "=", "cls", "(", ")", "try", ":", "character", "=", "json_content", "[", "\"characters\"", "]", "if", "\"error\"", "in", "charact...
Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` The JSON content of the response. Returns ------- :class:`Character` The character contained in the page, or None if the character doesn't ...
[ "Builds", "a", "character", "object", "from", "a", "TibiaData", "character", "response", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L223-L291
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_account_information
def _parse_account_information(self, rows): """ Parses the character's account information Parameters ---------- rows: :class:`list` of :class:`bs4.Tag`, optional A list of all rows contained in the table. """ acc_info = {} if not rows: ...
python
def _parse_account_information(self, rows): """ Parses the character's account information Parameters ---------- rows: :class:`list` of :class:`bs4.Tag`, optional A list of all rows contained in the table. """ acc_info = {} if not rows: ...
[ "def", "_parse_account_information", "(", "self", ",", "rows", ")", ":", "acc_info", "=", "{", "}", "if", "not", "rows", ":", "return", "for", "row", "in", "rows", ":", "cols_raw", "=", "row", ".", "find_all", "(", "'td'", ")", "cols", "=", "[", "ele...
Parses the character's account information Parameters ---------- rows: :class:`list` of :class:`bs4.Tag`, optional A list of all rows contained in the table.
[ "Parses", "the", "character", "s", "account", "information" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L295-L317
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_achievements
def _parse_achievements(self, rows): """ Parses the character's displayed achievements Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols = row.find_all('td') ...
python
def _parse_achievements(self, rows): """ Parses the character's displayed achievements Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols = row.find_all('td') ...
[ "def", "_parse_achievements", "(", "self", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "cols", "=", "row", ".", "find_all", "(", "'td'", ")", "if", "len", "(", "cols", ")", "!=", "2", ":", "continue", "field", ",", "value", "=", "cols",...
Parses the character's displayed achievements Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table.
[ "Parses", "the", "character", "s", "displayed", "achievements" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L319-L335
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_character_information
def _parse_character_information(self, rows): """ Parses the character's basic information and applies the found values. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ int_rows = ["level", ...
python
def _parse_character_information(self, rows): """ Parses the character's basic information and applies the found values. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ int_rows = ["level", ...
[ "def", "_parse_character_information", "(", "self", ",", "rows", ")", ":", "int_rows", "=", "[", "\"level\"", ",", "\"achievement_points\"", "]", "char", "=", "{", "}", "house", "=", "{", "}", "for", "row", "in", "rows", ":", "cols_raw", "=", "row", ".",...
Parses the character's basic information and applies the found values. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table.
[ "Parses", "the", "character", "s", "basic", "information", "and", "applies", "the", "found", "values", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L337-L399
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_deaths
def _parse_deaths(self, rows): """ Parses the character's recent deaths Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols = row.find_all('td') dea...
python
def _parse_deaths(self, rows): """ Parses the character's recent deaths Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols = row.find_all('td') dea...
[ "def", "_parse_deaths", "(", "self", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "cols", "=", "row", ".", "find_all", "(", "'td'", ")", "death_time_str", "=", "cols", "[", "0", "]", ".", "text", ".", "replace", "(", "\"\\xa0\"", ",", "\...
Parses the character's recent deaths Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table.
[ "Parses", "the", "character", "s", "recent", "deaths" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L401-L442
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_killer
def _parse_killer(cls, killer): """Parses a killer into a dictionary. Parameters ---------- killer: :class:`str` The killer's raw HTML string. Returns ------- :class:`dict`: A dictionary containing the killer's info. """ # If the kill...
python
def _parse_killer(cls, killer): """Parses a killer into a dictionary. Parameters ---------- killer: :class:`str` The killer's raw HTML string. Returns ------- :class:`dict`: A dictionary containing the killer's info. """ # If the kill...
[ "def", "_parse_killer", "(", "cls", ",", "killer", ")", ":", "# If the killer contains a link, it is a player.", "if", "\"href\"", "in", "killer", ":", "killer_dict", "=", "{", "\"name\"", ":", "link_content", ".", "search", "(", "killer", ")", ".", "group", "("...
Parses a killer into a dictionary. Parameters ---------- killer: :class:`str` The killer's raw HTML string. Returns ------- :class:`dict`: A dictionary containing the killer's info.
[ "Parses", "a", "killer", "into", "a", "dictionary", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L469-L490
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_other_characters
def _parse_other_characters(self, rows): """ Parses the character's other visible characters. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols_raw = row.find...
python
def _parse_other_characters(self, rows): """ Parses the character's other visible characters. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table. """ for row in rows: cols_raw = row.find...
[ "def", "_parse_other_characters", "(", "self", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "cols_raw", "=", "row", ".", "find_all", "(", "'td'", ")", "cols", "=", "[", "ele", ".", "text", ".", "strip", "(", ")", "for", "ele", "in", "col...
Parses the character's other visible characters. Parameters ---------- rows: :class:`list` of :class:`bs4.Tag` A list of all rows contained in the table.
[ "Parses", "the", "character", "s", "other", "visible", "characters", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L492-L508
Galarzaa90/tibia.py
tibiapy/character.py
Character._parse_tables
def _parse_tables(cls, parsed_content): """ Parses the information tables contained in a character's page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------- ...
python
def _parse_tables(cls, parsed_content): """ Parses the information tables contained in a character's page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------- ...
[ "def", "_parse_tables", "(", "cls", ",", "parsed_content", ")", ":", "tables", "=", "parsed_content", ".", "find_all", "(", "'table'", ",", "attrs", "=", "{", "\"width\"", ":", "\"100%\"", "}", ")", "output", "=", "OrderedDict", "(", ")", "for", "table", ...
Parses the information tables contained in a character's page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------- :class:`OrderedDict`[str, :class:`list`of :class:`bs4....
[ "Parses", "the", "information", "tables", "contained", "in", "a", "character", "s", "page", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L511-L530
Galarzaa90/tibia.py
tibiapy/character.py
Character._split_list
def _split_list(cls, items, separator=",", last_separator=" and "): """ Splits a string listing elements into an actual list. Parameters ---------- items: :class:`str` A string listing elements. separator: :class:`str` The separator between each i...
python
def _split_list(cls, items, separator=",", last_separator=" and "): """ Splits a string listing elements into an actual list. Parameters ---------- items: :class:`str` A string listing elements. separator: :class:`str` The separator between each i...
[ "def", "_split_list", "(", "cls", ",", "items", ",", "separator", "=", "\",\"", ",", "last_separator", "=", "\" and \"", ")", ":", "if", "items", "is", "None", ":", "return", "None", "items", "=", "items", ".", "split", "(", "separator", ")", "last_item"...
Splits a string listing elements into an actual list. Parameters ---------- items: :class:`str` A string listing elements. separator: :class:`str` The separator between each item. A comma by default. last_separator: :class:`str` The separator ...
[ "Splits", "a", "string", "listing", "elements", "into", "an", "actual", "list", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L534-L560
Galarzaa90/tibia.py
tibiapy/character.py
Death.by_player
def by_player(self): """:class:`bool`: Whether the kill involves other characters.""" return any([k.player and self.name != k.name for k in self.killers])
python
def by_player(self): """:class:`bool`: Whether the kill involves other characters.""" return any([k.player and self.name != k.name for k in self.killers])
[ "def", "by_player", "(", "self", ")", ":", "return", "any", "(", "[", "k", ".", "player", "and", "self", ".", "name", "!=", "k", ".", "name", "for", "k", "in", "self", ".", "killers", "]", ")" ]
:class:`bool`: Whether the kill involves other characters.
[ ":", "class", ":", "bool", ":", "Whether", "the", "kill", "involves", "other", "characters", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/character.py#L606-L608
ff0000/scarlet
scarlet/versioning/fields.py
create_many_to_many_intermediary_model
def create_many_to_many_intermediary_model(field, klass): """ Copied from django, but uses FKToVersion for the 'from' field. Fields are also always called 'from' and 'to' to avoid problems between version combined models. """ managed = True if (isinstance(field.remote_field.to, basestring) a...
python
def create_many_to_many_intermediary_model(field, klass): """ Copied from django, but uses FKToVersion for the 'from' field. Fields are also always called 'from' and 'to' to avoid problems between version combined models. """ managed = True if (isinstance(field.remote_field.to, basestring) a...
[ "def", "create_many_to_many_intermediary_model", "(", "field", ",", "klass", ")", ":", "managed", "=", "True", "if", "(", "isinstance", "(", "field", ".", "remote_field", ".", "to", ",", "basestring", ")", "and", "field", ".", "remote_field", ".", "to", "!="...
Copied from django, but uses FKToVersion for the 'from' field. Fields are also always called 'from' and 'to' to avoid problems between version combined models.
[ "Copied", "from", "django", "but", "uses", "FKToVersion", "for", "the", "from", "field", ".", "Fields", "are", "also", "always", "called", "from", "and", "to", "to", "avoid", "problems", "between", "version", "combined", "models", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/fields.py#L96-L157
ff0000/scarlet
scarlet/versioning/fields.py
FKToVersion.deconstruct
def deconstruct(self): """ FK to version always points to a version table """ name, path, args, kwargs = super(FKToVersion, self).deconstruct() if not kwargs['to'].endswith('_version'): kwargs['to'] = '{0}_version'.format(kwargs['to']) return name, path, args,...
python
def deconstruct(self): """ FK to version always points to a version table """ name, path, args, kwargs = super(FKToVersion, self).deconstruct() if not kwargs['to'].endswith('_version'): kwargs['to'] = '{0}_version'.format(kwargs['to']) return name, path, args,...
[ "def", "deconstruct", "(", "self", ")", ":", "name", ",", "path", ",", "args", ",", "kwargs", "=", "super", "(", "FKToVersion", ",", "self", ")", ".", "deconstruct", "(", ")", "if", "not", "kwargs", "[", "'to'", "]", ".", "endswith", "(", "'_version'...
FK to version always points to a version table
[ "FK", "to", "version", "always", "points", "to", "a", "version", "table" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/fields.py#L17-L24
ff0000/scarlet
scarlet/versioning/fields.py
M2MFromVersion.update_rel_to
def update_rel_to(self, klass): """ If we have a string for a model, see if we know about it yet, if so use it directly otherwise take the lazy approach. This check is needed because this is called before the main M2M field contribute to class is called. """ if i...
python
def update_rel_to(self, klass): """ If we have a string for a model, see if we know about it yet, if so use it directly otherwise take the lazy approach. This check is needed because this is called before the main M2M field contribute to class is called. """ if i...
[ "def", "update_rel_to", "(", "self", ",", "klass", ")", ":", "if", "isinstance", "(", "self", ".", "remote_field", ".", "to", ",", "basestring", ")", ":", "relation", "=", "self", ".", "remote_field", ".", "to", "try", ":", "app_label", ",", "model_name"...
If we have a string for a model, see if we know about it yet, if so use it directly otherwise take the lazy approach. This check is needed because this is called before the main M2M field contribute to class is called.
[ "If", "we", "have", "a", "string", "for", "a", "model", "see", "if", "we", "know", "about", "it", "yet", "if", "so", "use", "it", "directly", "otherwise", "take", "the", "lazy", "approach", ".", "This", "check", "is", "needed", "because", "this", "is",...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/fields.py#L42-L71
ff0000/scarlet
scarlet/versioning/fields.py
M2MFromVersion.contribute_to_class
def contribute_to_class(self, cls, name): """ Because django doesn't give us a nice way to provide a through table without losing functionality. We have to provide our own through table creation that uses the FKToVersion field to be used for the from field. """ s...
python
def contribute_to_class(self, cls, name): """ Because django doesn't give us a nice way to provide a through table without losing functionality. We have to provide our own through table creation that uses the FKToVersion field to be used for the from field. """ s...
[ "def", "contribute_to_class", "(", "self", ",", "cls", ",", "name", ")", ":", "self", ".", "update_rel_to", "(", "cls", ")", "# Called to get a name", "self", ".", "set_attributes_from_name", "(", "name", ")", "self", ".", "model", "=", "cls", "# Set the throu...
Because django doesn't give us a nice way to provide a through table without losing functionality. We have to provide our own through table creation that uses the FKToVersion field to be used for the from field.
[ "Because", "django", "doesn", "t", "give", "us", "a", "nice", "way", "to", "provide", "a", "through", "table", "without", "losing", "functionality", ".", "We", "have", "to", "provide", "our", "own", "through", "table", "creation", "that", "uses", "the", "F...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/versioning/fields.py#L73-L93
note35/sinon
sinon/lib/assertion.py
SinonAssertion.notCalled
def notCalled(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is not called Args: SinonSpy """ cls.__is_spy(spy) if not (not spy.called): raise cls.failException(cls.message)
python
def notCalled(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is not called Args: SinonSpy """ cls.__is_spy(spy) if not (not spy.called): raise cls.failException(cls.message)
[ "def", "notCalled", "(", "cls", ",", "spy", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "not", "spy", ".", "called", ")", ":", "raise", "cls", ".", "failException", "(", "cls", ".", "message", "...
Checking the inspector is not called Args: SinonSpy
[ "Checking", "the", "inspector", "is", "not", "called", "Args", ":", "SinonSpy" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L36-L43
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledOnce
def calledOnce(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called once Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledOnce): raise cls.failException(cls.message)
python
def calledOnce(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called once Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledOnce): raise cls.failException(cls.message)
[ "def", "calledOnce", "(", "cls", ",", "spy", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledOnce", ")", ":", "raise", "cls", ".", "failException", "(", "cls", ".", "message", ")" ]
Checking the inspector is called once Args: SinonSpy
[ "Checking", "the", "inspector", "is", "called", "once", "Args", ":", "SinonSpy" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L56-L63
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledTwice
def calledTwice(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called twice Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledTwice): raise cls.failException(cls.message)
python
def calledTwice(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called twice Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledTwice): raise cls.failException(cls.message)
[ "def", "calledTwice", "(", "cls", ",", "spy", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledTwice", ")", ":", "raise", "cls", ".", "failException", "(", "cls", ".", "message", ")"...
Checking the inspector is called twice Args: SinonSpy
[ "Checking", "the", "inspector", "is", "called", "twice", "Args", ":", "SinonSpy" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L66-L73
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledThrice
def calledThrice(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called thrice Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledThrice): raise cls.failException(cls.message)
python
def calledThrice(cls, spy): #pylint: disable=invalid-name """ Checking the inspector is called thrice Args: SinonSpy """ cls.__is_spy(spy) if not (spy.calledThrice): raise cls.failException(cls.message)
[ "def", "calledThrice", "(", "cls", ",", "spy", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledThrice", ")", ":", "raise", "cls", ".", "failException", "(", "cls", ".", "message", "...
Checking the inspector is called thrice Args: SinonSpy
[ "Checking", "the", "inspector", "is", "called", "thrice", "Args", ":", "SinonSpy" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L76-L83
note35/sinon
sinon/lib/assertion.py
SinonAssertion.callCount
def callCount(cls, spy, number): #pylint: disable=invalid-name """ Checking the inspector is called number times Args: SinonSpy, number """ cls.__is_spy(spy) if not (spy.callCount == number): raise cls.failException(cls.message)
python
def callCount(cls, spy, number): #pylint: disable=invalid-name """ Checking the inspector is called number times Args: SinonSpy, number """ cls.__is_spy(spy) if not (spy.callCount == number): raise cls.failException(cls.message)
[ "def", "callCount", "(", "cls", ",", "spy", ",", "number", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "callCount", "==", "number", ")", ":", "raise", "cls", ".", "failException", "(",...
Checking the inspector is called number times Args: SinonSpy, number
[ "Checking", "the", "inspector", "is", "called", "number", "times", "Args", ":", "SinonSpy", "number" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L86-L93
note35/sinon
sinon/lib/assertion.py
SinonAssertion.callOrder
def callOrder(cls, *args): #pylint: disable=invalid-name """ Checking the inspector is called with given priority Args: SinonSpy, list of inspectors eg. [spy1, spy2, spy3] => spy1 is called before spy2, spy2 is called before spy3 [spy1, spy2, spy1] => spy1 is call...
python
def callOrder(cls, *args): #pylint: disable=invalid-name """ Checking the inspector is called with given priority Args: SinonSpy, list of inspectors eg. [spy1, spy2, spy3] => spy1 is called before spy2, spy2 is called before spy3 [spy1, spy2, spy1] => spy1 is call...
[ "def", "callOrder", "(", "cls", ",", "*", "args", ")", ":", "#pylint: disable=invalid-name", "for", "spy", "in", "args", ":", "cls", ".", "__is_spy", "(", "spy", ")", "for", "idx", ",", "val", "in", "enumerate", "(", "args", ")", ":", "if", "val", "!...
Checking the inspector is called with given priority Args: SinonSpy, list of inspectors eg. [spy1, spy2, spy3] => spy1 is called before spy2, spy2 is called before spy3 [spy1, spy2, spy1] => spy1 is called before and after spy2
[ "Checking", "the", "inspector", "is", "called", "with", "given", "priority", "Args", ":", "SinonSpy", "list", "of", "inspectors", "eg", ".", "[", "spy1", "spy2", "spy3", "]", "=", ">", "spy1", "is", "called", "before", "spy2", "spy2", "is", "called", "be...
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L96-L112
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledWith
def calledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWith(*args, **kwargs)): raise cls.failException(cls.messa...
python
def calledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWith(*args, **kwargs)): raise cls.failException(cls.messa...
[ "def", "calledWith", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledWith", "(", "*", "args", ",", "*", "*", ...
Checking the inspector is called with partial args/kwargs Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "called", "with", "partial", "args", "/", "kwargs", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L115-L122
note35/sinon
sinon/lib/assertion.py
SinonAssertion.alwaysCalledWith
def alwaysCalledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWith(*args, **kwargs)): raise cls.fail...
python
def alwaysCalledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWith(*args, **kwargs)): raise cls.fail...
[ "def", "alwaysCalledWith", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "alwaysCalledWith", "(", "*", "args", ",", "...
Checking the inspector is always called with partial args/kwargs Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "always", "called", "with", "partial", "args", "/", "kwargs", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L125-L132
note35/sinon
sinon/lib/assertion.py
SinonAssertion.neverCalledWith
def neverCalledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is never called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.neverCalledWith(*args, **kwargs)): raise cls.failExc...
python
def neverCalledWith(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is never called with partial args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.neverCalledWith(*args, **kwargs)): raise cls.failExc...
[ "def", "neverCalledWith", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "neverCalledWith", "(", "*", "args", ",", "*"...
Checking the inspector is never called with partial args/kwargs Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "never", "called", "with", "partial", "args", "/", "kwargs", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L135-L142
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledWithExactly
def calledWithExactly(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with exactly args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWithExactly(*args, **kwargs)): raise cls.failExcep...
python
def calledWithExactly(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with exactly args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWithExactly(*args, **kwargs)): raise cls.failExcep...
[ "def", "calledWithExactly", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledWithExactly", "(", "*", "args", ",", ...
Checking the inspector is called with exactly args/kwargs Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "called", "with", "exactly", "args", "/", "kwargs", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L145-L152
note35/sinon
sinon/lib/assertion.py
SinonAssertion.alwaysCalledWithExactly
def alwaysCalledWithExactly(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with exactly args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWithExactly(*args, **kwargs)): ...
python
def alwaysCalledWithExactly(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with exactly args/kwargs Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWithExactly(*args, **kwargs)): ...
[ "def", "alwaysCalledWithExactly", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "alwaysCalledWithExactly", "(", "*", "arg...
Checking the inspector is always called with exactly args/kwargs Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "always", "called", "with", "exactly", "args", "/", "kwargs", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L155-L162
note35/sinon
sinon/lib/assertion.py
SinonAssertion.calledWithMatch
def calledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWithMatch(*args, **kwargs)): raise cls...
python
def calledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.calledWithMatch(*args, **kwargs)): raise cls...
[ "def", "calledWithMatch", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "calledWithMatch", "(", "*", "args", ",", "*"...
Checking the inspector is called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "called", "with", "partial", "SinonMatcher", "(", "args", "/", "kwargs", ")", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L165-L172
note35/sinon
sinon/lib/assertion.py
SinonAssertion.alwaysCalledWithMatch
def alwaysCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWithMatch(*args, **kwargs)): ...
python
def alwaysCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is always called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.alwaysCalledWithMatch(*args, **kwargs)): ...
[ "def", "alwaysCalledWithMatch", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "alwaysCalledWithMatch", "(", "*", "args", ...
Checking the inspector is always called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "always", "called", "with", "partial", "SinonMatcher", "(", "args", "/", "kwargs", ")", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L175-L182
note35/sinon
sinon/lib/assertion.py
SinonAssertion.neverCalledWithMatch
def neverCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is never called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.neverCalledWithMatch(*args, **kwargs)): ...
python
def neverCalledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name """ Checking the inspector is never called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs """ cls.__is_spy(spy) if not (spy.neverCalledWithMatch(*args, **kwargs)): ...
[ "def", "neverCalledWithMatch", "(", "cls", ",", "spy", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "neverCalledWithMatch", "(", "*", "args", ...
Checking the inspector is never called with partial SinonMatcher(args/kwargs) Args: SinonSpy, args/kwargs
[ "Checking", "the", "inspector", "is", "never", "called", "with", "partial", "SinonMatcher", "(", "args", "/", "kwargs", ")", "Args", ":", "SinonSpy", "args", "/", "kwargs" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L185-L192
note35/sinon
sinon/lib/assertion.py
SinonAssertion.threw
def threw(cls, spy, error_type=None): """ Checking the inspector is raised error_type Args: SinonSpy, Exception (defaut: None) """ cls.__is_spy(spy) if not (spy.threw(error_type)): raise cls.failException(cls.message)
python
def threw(cls, spy, error_type=None): """ Checking the inspector is raised error_type Args: SinonSpy, Exception (defaut: None) """ cls.__is_spy(spy) if not (spy.threw(error_type)): raise cls.failException(cls.message)
[ "def", "threw", "(", "cls", ",", "spy", ",", "error_type", "=", "None", ")", ":", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "threw", "(", "error_type", ")", ")", ":", "raise", "cls", ".", "failException", "(", "cls", ...
Checking the inspector is raised error_type Args: SinonSpy, Exception (defaut: None)
[ "Checking", "the", "inspector", "is", "raised", "error_type", "Args", ":", "SinonSpy", "Exception", "(", "defaut", ":", "None", ")" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L195-L202
note35/sinon
sinon/lib/assertion.py
SinonAssertion.alwaysThrew
def alwaysThrew(cls, spy, error_type=None): #pylint: disable=invalid-name """ Checking the inspector is always raised error_type Args: SinonSpy, Exception (defaut: None) """ cls.__is_spy(spy) if not (spy.alwaysThrew(error_type)): raise cls.failException(cls.me...
python
def alwaysThrew(cls, spy, error_type=None): #pylint: disable=invalid-name """ Checking the inspector is always raised error_type Args: SinonSpy, Exception (defaut: None) """ cls.__is_spy(spy) if not (spy.alwaysThrew(error_type)): raise cls.failException(cls.me...
[ "def", "alwaysThrew", "(", "cls", ",", "spy", ",", "error_type", "=", "None", ")", ":", "#pylint: disable=invalid-name", "cls", ".", "__is_spy", "(", "spy", ")", "if", "not", "(", "spy", ".", "alwaysThrew", "(", "error_type", ")", ")", ":", "raise", "cls...
Checking the inspector is always raised error_type Args: SinonSpy, Exception (defaut: None)
[ "Checking", "the", "inspector", "is", "always", "raised", "error_type", "Args", ":", "SinonSpy", "Exception", "(", "defaut", ":", "None", ")" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/assertion.py#L205-L212
klahnakoski/pyLibrary
pyLibrary/aws/s3.py
_scrub_key
def _scrub_key(key): """ RETURN JUST THE :. CHARACTERS """ if key == None: return None output = [] for c in key: if c in [":", "."]: output.append(c) return "".join(output)
python
def _scrub_key(key): """ RETURN JUST THE :. CHARACTERS """ if key == None: return None output = [] for c in key: if c in [":", "."]: output.append(c) return "".join(output)
[ "def", "_scrub_key", "(", "key", ")", ":", "if", "key", "==", "None", ":", "return", "None", "output", "=", "[", "]", "for", "c", "in", "key", ":", "if", "c", "in", "[", "\":\"", ",", "\".\"", "]", ":", "output", ".", "append", "(", "c", ")", ...
RETURN JUST THE :. CHARACTERS
[ "RETURN", "JUST", "THE", ":", ".", "CHARACTERS" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/s3.py#L477-L488
klahnakoski/pyLibrary
pyLibrary/aws/s3.py
Bucket.get_meta
def get_meta(self, key, conforming=True): """ RETURN METADATA ON FILE IN BUCKET :param key: KEY, OR PREFIX OF KEY :param conforming: TEST IF THE KEY CONFORMS TO REQUIRED PATTERN :return: METADATA, IF UNIQUE, ELSE ERROR """ try: metas = list(self.bucke...
python
def get_meta(self, key, conforming=True): """ RETURN METADATA ON FILE IN BUCKET :param key: KEY, OR PREFIX OF KEY :param conforming: TEST IF THE KEY CONFORMS TO REQUIRED PATTERN :return: METADATA, IF UNIQUE, ELSE ERROR """ try: metas = list(self.bucke...
[ "def", "get_meta", "(", "self", ",", "key", ",", "conforming", "=", "True", ")", ":", "try", ":", "metas", "=", "list", "(", "self", ".", "bucket", ".", "list", "(", "prefix", "=", "key", ")", ")", "metas", "=", "wrap", "(", "[", "m", "for", "m...
RETURN METADATA ON FILE IN BUCKET :param key: KEY, OR PREFIX OF KEY :param conforming: TEST IF THE KEY CONFORMS TO REQUIRED PATTERN :return: METADATA, IF UNIQUE, ELSE ERROR
[ "RETURN", "METADATA", "ON", "FILE", "IN", "BUCKET", ":", "param", "key", ":", "KEY", "OR", "PREFIX", "OF", "KEY", ":", "param", "conforming", ":", "TEST", "IF", "THE", "KEY", "CONFORMS", "TO", "REQUIRED", "PATTERN", ":", "return", ":", "METADATA", "IF", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/s3.py#L169-L210
klahnakoski/pyLibrary
pyLibrary/aws/s3.py
Bucket.keys
def keys(self, prefix=None, delimiter=None): """ :param prefix: NOT A STRING PREFIX, RATHER PATH ID PREFIX (MUST MATCH TO NEXT "." OR ":") :param delimiter: TO GET Prefix OBJECTS, RATHER THAN WHOLE KEYS :return: SET OF KEYS IN BUCKET, OR """ if delimiter: # ...
python
def keys(self, prefix=None, delimiter=None): """ :param prefix: NOT A STRING PREFIX, RATHER PATH ID PREFIX (MUST MATCH TO NEXT "." OR ":") :param delimiter: TO GET Prefix OBJECTS, RATHER THAN WHOLE KEYS :return: SET OF KEYS IN BUCKET, OR """ if delimiter: # ...
[ "def", "keys", "(", "self", ",", "prefix", "=", "None", ",", "delimiter", "=", "None", ")", ":", "if", "delimiter", ":", "# WE REALLY DO NOT GET KEYS, BUT RATHER Prefix OBJECTS", "# AT LEAST THEY ARE UNIQUE", "candidates", "=", "[", "k", ".", "name", ".", "rstrip"...
:param prefix: NOT A STRING PREFIX, RATHER PATH ID PREFIX (MUST MATCH TO NEXT "." OR ":") :param delimiter: TO GET Prefix OBJECTS, RATHER THAN WHOLE KEYS :return: SET OF KEYS IN BUCKET, OR
[ ":", "param", "prefix", ":", "NOT", "A", "STRING", "PREFIX", "RATHER", "PATH", "ID", "PREFIX", "(", "MUST", "MATCH", "TO", "NEXT", ".", "OR", ":", ")", ":", "param", "delimiter", ":", "TO", "GET", "Prefix", "OBJECTS", "RATHER", "THAN", "WHOLE", "KEYS",...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/s3.py#L212-L228
klahnakoski/pyLibrary
pyLibrary/aws/s3.py
Bucket.metas
def metas(self, prefix=None, limit=None, delimiter=None): """ RETURN THE METADATA DESCRIPTORS FOR EACH KEY """ limit = coalesce(limit, TOO_MANY_KEYS) keys = self.bucket.list(prefix=prefix, delimiter=delimiter) prefix_len = len(prefix) output = [] for i, k ...
python
def metas(self, prefix=None, limit=None, delimiter=None): """ RETURN THE METADATA DESCRIPTORS FOR EACH KEY """ limit = coalesce(limit, TOO_MANY_KEYS) keys = self.bucket.list(prefix=prefix, delimiter=delimiter) prefix_len = len(prefix) output = [] for i, k ...
[ "def", "metas", "(", "self", ",", "prefix", "=", "None", ",", "limit", "=", "None", ",", "delimiter", "=", "None", ")", ":", "limit", "=", "coalesce", "(", "limit", ",", "TOO_MANY_KEYS", ")", "keys", "=", "self", ".", "bucket", ".", "list", "(", "p...
RETURN THE METADATA DESCRIPTORS FOR EACH KEY
[ "RETURN", "THE", "METADATA", "DESCRIPTORS", "FOR", "EACH", "KEY" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/s3.py#L230-L247
ralphbean/raptorizemw
raptorizemw/middleware.py
make_middleware
def make_middleware(app=None, *args, **kw): """ Given an app, return that app wrapped in RaptorizeMiddleware """ app = RaptorizeMiddleware(app, *args, **kw) return app
python
def make_middleware(app=None, *args, **kw): """ Given an app, return that app wrapped in RaptorizeMiddleware """ app = RaptorizeMiddleware(app, *args, **kw) return app
[ "def", "make_middleware", "(", "app", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "app", "=", "RaptorizeMiddleware", "(", "app", ",", "*", "args", ",", "*", "*", "kw", ")", "return", "app" ]
Given an app, return that app wrapped in RaptorizeMiddleware
[ "Given", "an", "app", "return", "that", "app", "wrapped", "in", "RaptorizeMiddleware" ]
train
https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/raptorizemw/middleware.py#L148-L151
ralphbean/raptorizemw
raptorizemw/middleware.py
RaptorizeMiddleware.should_raptorize
def should_raptorize(self, req, resp): """ Determine if this request should be raptorized. Boolean. """ if resp.status != "200 OK": return False content_type = resp.headers.get('Content-Type', 'text/plain').lower() if not 'html' in content_type: return False ...
python
def should_raptorize(self, req, resp): """ Determine if this request should be raptorized. Boolean. """ if resp.status != "200 OK": return False content_type = resp.headers.get('Content-Type', 'text/plain').lower() if not 'html' in content_type: return False ...
[ "def", "should_raptorize", "(", "self", ",", "req", ",", "resp", ")", ":", "if", "resp", ".", "status", "!=", "\"200 OK\"", ":", "return", "False", "content_type", "=", "resp", ".", "headers", ".", "get", "(", "'Content-Type'", ",", "'text/plain'", ")", ...
Determine if this request should be raptorized. Boolean.
[ "Determine", "if", "this", "request", "should", "be", "raptorized", ".", "Boolean", "." ]
train
https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/raptorizemw/middleware.py#L75-L93
ralphbean/raptorizemw
raptorizemw/middleware.py
RaptorizeMiddleware.raptorize
def raptorize(self, resp): """ Raptorize this response! Insert javascript into the <head> tag. If jquery is already included, make sure not to stomp on it by re-including it. """ soup = BeautifulSoup.BeautifulSoup(resp.body) if not soup.html: retur...
python
def raptorize(self, resp): """ Raptorize this response! Insert javascript into the <head> tag. If jquery is already included, make sure not to stomp on it by re-including it. """ soup = BeautifulSoup.BeautifulSoup(resp.body) if not soup.html: retur...
[ "def", "raptorize", "(", "self", ",", "resp", ")", ":", "soup", "=", "BeautifulSoup", ".", "BeautifulSoup", "(", "resp", ".", "body", ")", "if", "not", "soup", ".", "html", ":", "return", "resp", "if", "not", "soup", ".", "html", ".", "head", ":", ...
Raptorize this response! Insert javascript into the <head> tag. If jquery is already included, make sure not to stomp on it by re-including it.
[ "Raptorize", "this", "response!" ]
train
https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/raptorizemw/middleware.py#L95-L145
tetframework/Tonnikala
tonnikala/runtime/python.py
bind
def bind(context, block=False): """ Given the context, returns a decorator wrapper; the binder replaces the wrapped func with the value from the context OR puts this function in the context with the name. """ if block: def decorate(func): name = func.__name__.replace('__...
python
def bind(context, block=False): """ Given the context, returns a decorator wrapper; the binder replaces the wrapped func with the value from the context OR puts this function in the context with the name. """ if block: def decorate(func): name = func.__name__.replace('__...
[ "def", "bind", "(", "context", ",", "block", "=", "False", ")", ":", "if", "block", ":", "def", "decorate", "(", "func", ")", ":", "name", "=", "func", ".", "__name__", ".", "replace", "(", "'__TK__block__'", ",", "''", ")", "if", "name", "not", "i...
Given the context, returns a decorator wrapper; the binder replaces the wrapped func with the value from the context OR puts this function in the context with the name.
[ "Given", "the", "context", "returns", "a", "decorator", "wrapper", ";", "the", "binder", "replaces", "the", "wrapped", "func", "with", "the", "value", "from", "the", "context", "OR", "puts", "this", "function", "in", "the", "context", "with", "the", "name", ...
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/runtime/python.py#L87-L110
klahnakoski/pyLibrary
mo_kwargs/__init__.py
override
def override(func): """ THIS DECORATOR WILL PUT ALL PARAMETERS INTO THE `kwargs` PARAMETER AND THEN PUT ALL `kwargs` PARAMETERS INTO THE FUNCTION PARAMETERS. THIS HAS THE BENEFIT OF HAVING ALL PARAMETERS IN ONE PLACE (kwargs), PLUS ALL PARAMETERS ARE EXPLICIT FOR CLARITY. OF COURSE, THIS MEANS ...
python
def override(func): """ THIS DECORATOR WILL PUT ALL PARAMETERS INTO THE `kwargs` PARAMETER AND THEN PUT ALL `kwargs` PARAMETERS INTO THE FUNCTION PARAMETERS. THIS HAS THE BENEFIT OF HAVING ALL PARAMETERS IN ONE PLACE (kwargs), PLUS ALL PARAMETERS ARE EXPLICIT FOR CLARITY. OF COURSE, THIS MEANS ...
[ "def", "override", "(", "func", ")", ":", "func_name", "=", "get_function_name", "(", "func", ")", "params", "=", "get_function_arguments", "(", "func", ")", "if", "not", "get_function_defaults", "(", "func", ")", ":", "defaults", "=", "{", "}", "else", ":...
THIS DECORATOR WILL PUT ALL PARAMETERS INTO THE `kwargs` PARAMETER AND THEN PUT ALL `kwargs` PARAMETERS INTO THE FUNCTION PARAMETERS. THIS HAS THE BENEFIT OF HAVING ALL PARAMETERS IN ONE PLACE (kwargs), PLUS ALL PARAMETERS ARE EXPLICIT FOR CLARITY. OF COURSE, THIS MEANS PARAMETER ASSIGNMENT MAY NOT BE ...
[ "THIS", "DECORATOR", "WILL", "PUT", "ALL", "PARAMETERS", "INTO", "THE", "kwargs", "PARAMETER", "AND", "THEN", "PUT", "ALL", "kwargs", "PARAMETERS", "INTO", "THE", "FUNCTION", "PARAMETERS", ".", "THIS", "HAS", "THE", "BENEFIT", "OF", "HAVING", "ALL", "PARAMETER...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_kwargs/__init__.py#L18-L119
openfisca/openfisca-france-indirect-taxation
openfisca_france_indirect_taxation/build_survey_data/step_2_homogeneisation_vehicules.py
build_homogeneisation_vehicules
def build_homogeneisation_vehicules(temporary_store = None, year = None): assert temporary_store is not None """Compute vehicule numbers by type""" assert year is not None # Load data bdf_survey_collection = SurveyCollection.load( collection = 'budget_des_familles', config_files_directory =...
python
def build_homogeneisation_vehicules(temporary_store = None, year = None): assert temporary_store is not None """Compute vehicule numbers by type""" assert year is not None # Load data bdf_survey_collection = SurveyCollection.load( collection = 'budget_des_familles', config_files_directory =...
[ "def", "build_homogeneisation_vehicules", "(", "temporary_store", "=", "None", ",", "year", "=", "None", ")", ":", "assert", "temporary_store", "is", "not", "None", "assert", "year", "is", "not", "None", "# Load data", "bdf_survey_collection", "=", "SurveyCollection...
Compute vehicule numbers by type
[ "Compute", "vehicule", "numbers", "by", "type" ]
train
https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/build_survey_data/step_2_homogeneisation_vehicules.py#L55-L109
klahnakoski/pyLibrary
pyLibrary/env/http.py
request
def request(method, url, headers=None, zip=None, retry=None, **kwargs): """ JUST LIKE requests.request() BUT WITH DEFAULT HEADERS AND FIXES DEMANDS data IS ONE OF: * A JSON-SERIALIZABLE STRUCTURE, OR * LIST OF JSON-SERIALIZABLE STRUCTURES, OR * None Parameters * zip - ZIP THE REQUEST B...
python
def request(method, url, headers=None, zip=None, retry=None, **kwargs): """ JUST LIKE requests.request() BUT WITH DEFAULT HEADERS AND FIXES DEMANDS data IS ONE OF: * A JSON-SERIALIZABLE STRUCTURE, OR * LIST OF JSON-SERIALIZABLE STRUCTURES, OR * None Parameters * zip - ZIP THE REQUEST B...
[ "def", "request", "(", "method", ",", "url", ",", "headers", "=", "None", ",", "zip", "=", "None", ",", "retry", "=", "None", ",", "*", "*", "kwargs", ")", ":", "global", "_warning_sent", "global", "request_count", "if", "not", "_warning_sent", "and", ...
JUST LIKE requests.request() BUT WITH DEFAULT HEADERS AND FIXES DEMANDS data IS ONE OF: * A JSON-SERIALIZABLE STRUCTURE, OR * LIST OF JSON-SERIALIZABLE STRUCTURES, OR * None Parameters * zip - ZIP THE REQUEST BODY, IF BIG ENOUGH * json - JSON-SERIALIZABLE STRUCTURE * retry - {"times"...
[ "JUST", "LIKE", "requests", ".", "request", "()", "BUT", "WITH", "DEFAULT", "HEADERS", "AND", "FIXES", "DEMANDS", "data", "IS", "ONE", "OF", ":", "*", "A", "JSON", "-", "SERIALIZABLE", "STRUCTURE", "OR", "*", "LIST", "OF", "JSON", "-", "SERIALIZABLE", "S...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/http.py#L63-L171
klahnakoski/pyLibrary
pyLibrary/env/http.py
get_json
def get_json(url, **kwargs): """ ASSUME RESPONSE IN IN JSON """ response = get(url, **kwargs) try: c = response.all_content return json2value(utf82unicode(c)) except Exception as e: if mo_math.round(response.status_code, decimal=-2) in [400, 500]: Log.error(u"...
python
def get_json(url, **kwargs): """ ASSUME RESPONSE IN IN JSON """ response = get(url, **kwargs) try: c = response.all_content return json2value(utf82unicode(c)) except Exception as e: if mo_math.round(response.status_code, decimal=-2) in [400, 500]: Log.error(u"...
[ "def", "get_json", "(", "url", ",", "*", "*", "kwargs", ")", ":", "response", "=", "get", "(", "url", ",", "*", "*", "kwargs", ")", "try", ":", "c", "=", "response", ".", "all_content", "return", "json2value", "(", "utf82unicode", "(", "c", ")", ")...
ASSUME RESPONSE IN IN JSON
[ "ASSUME", "RESPONSE", "IN", "IN", "JSON" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/http.py#L196-L208
klahnakoski/pyLibrary
pyLibrary/env/http.py
post_json
def post_json(url, **kwargs): """ ASSUME RESPONSE IN IN JSON """ if 'json' in kwargs: kwargs['data'] = unicode2utf8(value2json(kwargs['json'])) del kwargs['json'] elif 'data' in kwargs: kwargs['data'] = unicode2utf8(value2json(kwargs['data'])) else: Log.error(u"Ex...
python
def post_json(url, **kwargs): """ ASSUME RESPONSE IN IN JSON """ if 'json' in kwargs: kwargs['data'] = unicode2utf8(value2json(kwargs['json'])) del kwargs['json'] elif 'data' in kwargs: kwargs['data'] = unicode2utf8(value2json(kwargs['data'])) else: Log.error(u"Ex...
[ "def", "post_json", "(", "url", ",", "*", "*", "kwargs", ")", ":", "if", "'json'", "in", "kwargs", ":", "kwargs", "[", "'data'", "]", "=", "unicode2utf8", "(", "value2json", "(", "kwargs", "[", "'json'", "]", ")", ")", "del", "kwargs", "[", "'json'",...
ASSUME RESPONSE IN IN JSON
[ "ASSUME", "RESPONSE", "IN", "IN", "JSON" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/http.py#L223-L243
dotzero/tilda-api-python
tilda/client.py
Client.get_projects_list
def get_projects_list(self): """ Get projects list """ try: result = self._request('/getprojectslist/') return [TildaProject(**p) for p in result] except NetworkError: return []
python
def get_projects_list(self): """ Get projects list """ try: result = self._request('/getprojectslist/') return [TildaProject(**p) for p in result] except NetworkError: return []
[ "def", "get_projects_list", "(", "self", ")", ":", "try", ":", "result", "=", "self", ".", "_request", "(", "'/getprojectslist/'", ")", "return", "[", "TildaProject", "(", "*", "*", "p", ")", "for", "p", "in", "result", "]", "except", "NetworkError", ":"...
Get projects list
[ "Get", "projects", "list" ]
train
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L75-L81
dotzero/tilda-api-python
tilda/client.py
Client.get_project
def get_project(self, project_id): """ Get project info """ try: result = self._request('/getproject/', {'projectid': project_id}) return TildaProject(**result) except NetworkError: return []
python
def get_project(self, project_id): """ Get project info """ try: result = self._request('/getproject/', {'projectid': project_id}) return TildaProject(**result) except NetworkError: return []
[ "def", "get_project", "(", "self", ",", "project_id", ")", ":", "try", ":", "result", "=", "self", ".", "_request", "(", "'/getproject/'", ",", "{", "'projectid'", ":", "project_id", "}", ")", "return", "TildaProject", "(", "*", "*", "result", ")", "exce...
Get project info
[ "Get", "project", "info" ]
train
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L83-L90
dotzero/tilda-api-python
tilda/client.py
Client.get_project_export
def get_project_export(self, project_id): """ Get project info for export """ try: result = self._request('/getprojectexport/', {'projectid': project_id}) return TildaProject(**result) except NetworkError: return []
python
def get_project_export(self, project_id): """ Get project info for export """ try: result = self._request('/getprojectexport/', {'projectid': project_id}) return TildaProject(**result) except NetworkError: return []
[ "def", "get_project_export", "(", "self", ",", "project_id", ")", ":", "try", ":", "result", "=", "self", ".", "_request", "(", "'/getprojectexport/'", ",", "{", "'projectid'", ":", "project_id", "}", ")", "return", "TildaProject", "(", "*", "*", "result", ...
Get project info for export
[ "Get", "project", "info", "for", "export" ]
train
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L92-L99
dotzero/tilda-api-python
tilda/client.py
Client.get_pages_list
def get_pages_list(self, project_id): """ Get pages list """ try: result = self._request('/getpageslist/', {'projectid': project_id}) return [TildaPage(**p) for p in result] except NetworkError: return []
python
def get_pages_list(self, project_id): """ Get pages list """ try: result = self._request('/getpageslist/', {'projectid': project_id}) return [TildaPage(**p) for p in result] except NetworkError: return []
[ "def", "get_pages_list", "(", "self", ",", "project_id", ")", ":", "try", ":", "result", "=", "self", ".", "_request", "(", "'/getpageslist/'", ",", "{", "'projectid'", ":", "project_id", "}", ")", "return", "[", "TildaPage", "(", "*", "*", "p", ")", "...
Get pages list
[ "Get", "pages", "list" ]
train
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L101-L108