repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
thisfred/val
val/_val.py
_determine_keys
def _determine_keys(dictionary): """Determine the different kinds of keys.""" optional = {} defaults = {} mandatory = {} types = {} for key, value in dictionary.items(): if isinstance(key, Optional): optional[key.value] = parse_schema(value) if isinstance(value, B...
python
def _determine_keys(dictionary): """Determine the different kinds of keys.""" optional = {} defaults = {} mandatory = {} types = {} for key, value in dictionary.items(): if isinstance(key, Optional): optional[key.value] = parse_schema(value) if isinstance(value, B...
[ "def", "_determine_keys", "(", "dictionary", ")", ":", "optional", "=", "{", "}", "defaults", "=", "{", "}", "mandatory", "=", "{", "}", "types", "=", "{", "}", "for", "key", ",", "value", "in", "dictionary", ".", "items", "(", ")", ":", "if", "isi...
Determine the different kinds of keys.
[ "Determine", "the", "different", "kinds", "of", "keys", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L93-L112
thisfred/val
val/_val.py
_validate_mandatory_keys
def _validate_mandatory_keys(mandatory, validated, data, to_validate): """Validate the manditory keys.""" errors = [] for key, sub_schema in mandatory.items(): if key not in data: errors.append('missing key: %r' % (key,)) continue try: validated[key] = sub...
python
def _validate_mandatory_keys(mandatory, validated, data, to_validate): """Validate the manditory keys.""" errors = [] for key, sub_schema in mandatory.items(): if key not in data: errors.append('missing key: %r' % (key,)) continue try: validated[key] = sub...
[ "def", "_validate_mandatory_keys", "(", "mandatory", ",", "validated", ",", "data", ",", "to_validate", ")", ":", "errors", "=", "[", "]", "for", "key", ",", "sub_schema", "in", "mandatory", ".", "items", "(", ")", ":", "if", "key", "not", "in", "data", ...
Validate the manditory keys.
[ "Validate", "the", "manditory", "keys", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L115-L127
thisfred/val
val/_val.py
_validate_optional_key
def _validate_optional_key(key, missing, value, validated, optional): """Validate an optional key.""" try: validated[key] = optional[key](value) except NotValid as ex: return ['%r: %s' % (key, arg) for arg in ex.args] if key in missing: missing.remove(key) return []
python
def _validate_optional_key(key, missing, value, validated, optional): """Validate an optional key.""" try: validated[key] = optional[key](value) except NotValid as ex: return ['%r: %s' % (key, arg) for arg in ex.args] if key in missing: missing.remove(key) return []
[ "def", "_validate_optional_key", "(", "key", ",", "missing", ",", "value", ",", "validated", ",", "optional", ")", ":", "try", ":", "validated", "[", "key", "]", "=", "optional", "[", "key", "]", "(", "value", ")", "except", "NotValid", "as", "ex", ":"...
Validate an optional key.
[ "Validate", "an", "optional", "key", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L130-L138
thisfred/val
val/_val.py
_validate_type_key
def _validate_type_key(key, value, types, validated): """Validate a key's value by type.""" for key_schema, value_schema in types.items(): if not isinstance(key, key_schema): continue try: validated[key] = value_schema(value) except NotValid: continue ...
python
def _validate_type_key(key, value, types, validated): """Validate a key's value by type.""" for key_schema, value_schema in types.items(): if not isinstance(key, key_schema): continue try: validated[key] = value_schema(value) except NotValid: continue ...
[ "def", "_validate_type_key", "(", "key", ",", "value", ",", "types", ",", "validated", ")", ":", "for", "key_schema", ",", "value_schema", "in", "types", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "key", ",", "key_schema", ")", ":", "...
Validate a key's value by type.
[ "Validate", "a", "key", "s", "value", "by", "type", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L141-L153
thisfred/val
val/_val.py
_validate_other_keys
def _validate_other_keys(optional, types, missing, validated, data, to_validate): """Validate the rest of the keys present in the data.""" errors = [] for key in to_validate: value = data[key] if key in optional: errors.extend( _validate_o...
python
def _validate_other_keys(optional, types, missing, validated, data, to_validate): """Validate the rest of the keys present in the data.""" errors = [] for key in to_validate: value = data[key] if key in optional: errors.extend( _validate_o...
[ "def", "_validate_other_keys", "(", "optional", ",", "types", ",", "missing", ",", "validated", ",", "data", ",", "to_validate", ")", ":", "errors", "=", "[", "]", "for", "key", "in", "to_validate", ":", "value", "=", "data", "[", "key", "]", "if", "ke...
Validate the rest of the keys present in the data.
[ "Validate", "the", "rest", "of", "the", "keys", "present", "in", "the", "data", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L156-L168
thisfred/val
val/_val.py
_build_dict_validator
def _build_dict_validator(dictionary): """Build a validator from a dictionary.""" mandatory, optional, types, defaults = _determine_keys(dictionary) def dict_validator(data): """Validate dictionaries.""" missing = list(defaults.keys()) if not isinstance(data, dict): rais...
python
def _build_dict_validator(dictionary): """Build a validator from a dictionary.""" mandatory, optional, types, defaults = _determine_keys(dictionary) def dict_validator(data): """Validate dictionaries.""" missing = list(defaults.keys()) if not isinstance(data, dict): rais...
[ "def", "_build_dict_validator", "(", "dictionary", ")", ":", "mandatory", ",", "optional", ",", "types", ",", "defaults", "=", "_determine_keys", "(", "dictionary", ")", "def", "dict_validator", "(", "data", ")", ":", "\"\"\"Validate dictionaries.\"\"\"", "missing",...
Build a validator from a dictionary.
[ "Build", "a", "validator", "from", "a", "dictionary", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L171-L195
thisfred/val
val/_val.py
parse_schema
def parse_schema(schema): """Parse a val schema definition.""" if isinstance(schema, BaseSchema): return schema.validate if type(schema) is type: return _build_type_validator(schema) if isinstance(schema, dict): return _build_dict_validator(schema) if type(schema) in (lis...
python
def parse_schema(schema): """Parse a val schema definition.""" if isinstance(schema, BaseSchema): return schema.validate if type(schema) is type: return _build_type_validator(schema) if isinstance(schema, dict): return _build_dict_validator(schema) if type(schema) in (lis...
[ "def", "parse_schema", "(", "schema", ")", ":", "if", "isinstance", "(", "schema", ",", "BaseSchema", ")", ":", "return", "schema", ".", "validate", "if", "type", "(", "schema", ")", "is", "type", ":", "return", "_build_type_validator", "(", "schema", ")",...
Parse a val schema definition.
[ "Parse", "a", "val", "schema", "definition", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L198-L216
thisfred/val
val/_val.py
BaseSchema.validate
def validate(self, data): """Validate data. Raise NotValid error for invalid data.""" validated = self._validated(data) errors = [] for validator in self.additional_validators: if not validator(validated): errors.append( "%s invalidated by ...
python
def validate(self, data): """Validate data. Raise NotValid error for invalid data.""" validated = self._validated(data) errors = [] for validator in self.additional_validators: if not validator(validated): errors.append( "%s invalidated by ...
[ "def", "validate", "(", "self", ",", "data", ")", ":", "validated", "=", "self", ".", "_validated", "(", "data", ")", "errors", "=", "[", "]", "for", "validator", "in", "self", ".", "additional_validators", ":", "if", "not", "validator", "(", "validated"...
Validate data. Raise NotValid error for invalid data.
[ "Validate", "data", ".", "Raise", "NotValid", "error", "for", "invalid", "data", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L243-L265
thisfred/val
val/_val.py
Or._validated
def _validated(self, data): """Validate data if any subschema validates it.""" errors = [] for sub in self.schemas: try: return sub(data) except NotValid as ex: errors.extend(ex.args) raise NotValid(' and '.join(errors))
python
def _validated(self, data): """Validate data if any subschema validates it.""" errors = [] for sub in self.schemas: try: return sub(data) except NotValid as ex: errors.extend(ex.args) raise NotValid(' and '.join(errors))
[ "def", "_validated", "(", "self", ",", "data", ")", ":", "errors", "=", "[", "]", "for", "sub", "in", "self", ".", "schemas", ":", "try", ":", "return", "sub", "(", "data", ")", "except", "NotValid", "as", "ex", ":", "errors", ".", "extend", "(", ...
Validate data if any subschema validates it.
[ "Validate", "data", "if", "any", "subschema", "validates", "it", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L310-L319
thisfred/val
val/_val.py
And._validated
def _validated(self, data): """Validate data if all subschemas validate it.""" for sub in self.schemas: data = sub(data) return data
python
def _validated(self, data): """Validate data if all subschemas validate it.""" for sub in self.schemas: data = sub(data) return data
[ "def", "_validated", "(", "self", ",", "data", ")", ":", "for", "sub", "in", "self", ".", "schemas", ":", "data", "=", "sub", "(", "data", ")", "return", "data" ]
Validate data if all subschemas validate it.
[ "Validate", "data", "if", "all", "subschemas", "validate", "it", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L339-L343
thisfred/val
val/_val.py
Convert._validated
def _validated(self, data): """Convert data or die trying.""" try: return self.convert(data) except (TypeError, ValueError) as ex: raise NotValid(*ex.args)
python
def _validated(self, data): """Convert data or die trying.""" try: return self.convert(data) except (TypeError, ValueError) as ex: raise NotValid(*ex.args)
[ "def", "_validated", "(", "self", ",", "data", ")", ":", "try", ":", "return", "self", ".", "convert", "(", "data", ")", "except", "(", "TypeError", ",", "ValueError", ")", "as", "ex", ":", "raise", "NotValid", "(", "*", "ex", ".", "args", ")" ]
Convert data or die trying.
[ "Convert", "data", "or", "die", "trying", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L358-L363
thisfred/val
val/_val.py
Ordered._validated
def _validated(self, values): """Validate if the values are validated one by one in order.""" if self.length != len(values): raise NotValid( "%r does not have exactly %d values. (Got %d.)" % ( values, self.length, len(values))) return type(self.sch...
python
def _validated(self, values): """Validate if the values are validated one by one in order.""" if self.length != len(values): raise NotValid( "%r does not have exactly %d values. (Got %d.)" % ( values, self.length, len(values))) return type(self.sch...
[ "def", "_validated", "(", "self", ",", "values", ")", ":", "if", "self", ".", "length", "!=", "len", "(", "values", ")", ":", "raise", "NotValid", "(", "\"%r does not have exactly %d values. (Got %d.)\"", "%", "(", "values", ",", "self", ".", "length", ",", ...
Validate if the values are validated one by one in order.
[ "Validate", "if", "the", "values", "are", "validated", "one", "by", "one", "in", "order", "." ]
train
https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L380-L387
testingrequired/vom
vom/__init__.py
ViewDriver.find_element
def find_element(self, by, value, view_cls=None): # type: (By, Any, View) -> View """ Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching ...
python
def find_element(self, by, value, view_cls=None): # type: (By, Any, View) -> View """ Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching ...
[ "def", "find_element", "(", "self", ",", "by", ",", "value", ",", "view_cls", "=", "None", ")", ":", "# type: (By, Any, View) -> View", "if", "view_cls", "is", "None", ":", "view_cls", "=", "View", "return", "view_cls", "(", "lambda", ":", "self", ".", "dr...
Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching element wrapped in a view
[ "Find", "one", "element", "matching", "condition", ":", "param", "by", ":", "Type", "of", "condition", ":", "param", "value", ":", "Condition", "value", ":", "param", "view_cls", ":", "Optional", "custom", "class", "to", "wrap", "returned", "elements", ":", ...
train
https://github.com/testingrequired/vom/blob/9e4da7d90c6ae6a01af3c7ec5c40ee4b08327188/vom/__init__.py#L18-L30
testingrequired/vom
vom/__init__.py
View.find_element
def find_element(self, by, value, view_cls=None): # type: (By, Any, View) -> View """ Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching ...
python
def find_element(self, by, value, view_cls=None): # type: (By, Any, View) -> View """ Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching ...
[ "def", "find_element", "(", "self", ",", "by", ",", "value", ",", "view_cls", "=", "None", ")", ":", "# type: (By, Any, View) -> View", "if", "view_cls", "is", "None", ":", "view_cls", "=", "View", "return", "view_cls", "(", "lambda", ":", "self", ".", "ro...
Find one element matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: Matching element wrapped in a view
[ "Find", "one", "element", "matching", "condition", ":", "param", "by", ":", "Type", "of", "condition", ":", "param", "value", ":", "Condition", "value", ":", "param", "view_cls", ":", "Optional", "custom", "class", "to", "wrap", "returned", "elements", ":", ...
train
https://github.com/testingrequired/vom/blob/9e4da7d90c6ae6a01af3c7ec5c40ee4b08327188/vom/__init__.py#L255-L267
testingrequired/vom
vom/__init__.py
View.find_elements
def find_elements(self, by, value, view_cls=None): # type: (By, Any, Value) -> List[View] """ Find one or more elements matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :...
python
def find_elements(self, by, value, view_cls=None): # type: (By, Any, Value) -> List[View] """ Find one or more elements matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :...
[ "def", "find_elements", "(", "self", ",", "by", ",", "value", ",", "view_cls", "=", "None", ")", ":", "# type: (By, Any, Value) -> List[View]", "if", "view_cls", "is", "None", ":", "view_cls", "=", "View", "def", "get_elements", "(", ")", ":", "results", "="...
Find one or more elements matching condition :param by: Type of condition :param value: Condition value :param view_cls: Optional custom class to wrap returned elements :return: List of matching web elements wrapped in a view
[ "Find", "one", "or", "more", "elements", "matching", "condition", ":", "param", "by", ":", "Type", "of", "condition", ":", "param", "value", ":", "Condition", "value", ":", "param", "view_cls", ":", "Optional", "custom", "class", "to", "wrap", "returned", ...
train
https://github.com/testingrequired/vom/blob/9e4da7d90c6ae6a01af3c7ec5c40ee4b08327188/vom/__init__.py#L269-L294
esterhui/pypu
pypu/service_facebook.py
service_facebook._connectToFB
def _connectToFB(self): """Establish the actual TCP connection to FB""" if self.connected_to_fb: logger.debug("Already connected to fb") return True logger.debug("Connecting to fb") token = facebook_login.get_fb_token() try: self.fb = faceb...
python
def _connectToFB(self): """Establish the actual TCP connection to FB""" if self.connected_to_fb: logger.debug("Already connected to fb") return True logger.debug("Connecting to fb") token = facebook_login.get_fb_token() try: self.fb = faceb...
[ "def", "_connectToFB", "(", "self", ")", ":", "if", "self", ".", "connected_to_fb", ":", "logger", ".", "debug", "(", "\"Already connected to fb\"", ")", "return", "True", "logger", ".", "debug", "(", "\"Connecting to fb\"", ")", "token", "=", "facebook_login", ...
Establish the actual TCP connection to FB
[ "Establish", "the", "actual", "TCP", "connection", "to", "FB" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L45-L64
esterhui/pypu
pypu/service_facebook.py
service_facebook._isConfigFile
def _isConfigFile(self,filename): """If this is a config file or meta file return true""" ext=os.path.splitext(filename)[1].lower() if filename in self.FB_CONFIG_FILES: return True elif ext in self.FB_META_EXTENSIONS: return True return False
python
def _isConfigFile(self,filename): """If this is a config file or meta file return true""" ext=os.path.splitext(filename)[1].lower() if filename in self.FB_CONFIG_FILES: return True elif ext in self.FB_META_EXTENSIONS: return True return False
[ "def", "_isConfigFile", "(", "self", ",", "filename", ")", ":", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", ".", "lower", "(", ")", "if", "filename", "in", "self", ".", "FB_CONFIG_FILES", ":", "return", "True"...
If this is a config file or meta file return true
[ "If", "this", "is", "a", "config", "file", "or", "meta", "file", "return", "true" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L75-L83
esterhui/pypu
pypu/service_facebook.py
service_facebook.KnowsFile
def KnowsFile(self,filename): """Looks at extension and decides if it knows how to manage this file""" if self._isMediaFile(filename) or self._isConfigFile(filename): return True return False
python
def KnowsFile(self,filename): """Looks at extension and decides if it knows how to manage this file""" if self._isMediaFile(filename) or self._isConfigFile(filename): return True return False
[ "def", "KnowsFile", "(", "self", ",", "filename", ")", ":", "if", "self", ".", "_isMediaFile", "(", "filename", ")", "or", "self", ".", "_isConfigFile", "(", "filename", ")", ":", "return", "True", "return", "False" ]
Looks at extension and decides if it knows how to manage this file
[ "Looks", "at", "extension", "and", "decides", "if", "it", "knows", "how", "to", "manage", "this", "file" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L86-L91
esterhui/pypu
pypu/service_facebook.py
service_facebook.Upload
def Upload(self,directory,filename): """Uploads/Updates/Replaces files""" if self._isMediaFile(filename): return self._upload_media(directory,filename) elif self._isConfigFile(filename): return self._update_config(directory,filename) print "Not handled!" ...
python
def Upload(self,directory,filename): """Uploads/Updates/Replaces files""" if self._isMediaFile(filename): return self._upload_media(directory,filename) elif self._isConfigFile(filename): return self._update_config(directory,filename) print "Not handled!" ...
[ "def", "Upload", "(", "self", ",", "directory", ",", "filename", ")", ":", "if", "self", ".", "_isMediaFile", "(", "filename", ")", ":", "return", "self", ".", "_upload_media", "(", "directory", ",", "filename", ")", "elif", "self", ".", "_isConfigFile", ...
Uploads/Updates/Replaces files
[ "Uploads", "/", "Updates", "/", "Replaces", "files" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L93-L101
esterhui/pypu
pypu/service_facebook.py
service_facebook.Remove
def Remove(self,directory,filename): """Deletes files from fb""" if self._isMediaFile(filename): return self._remove_media(directory,filename) elif self._isConfigFile(filename): return True print "Not handled!" return False
python
def Remove(self,directory,filename): """Deletes files from fb""" if self._isMediaFile(filename): return self._remove_media(directory,filename) elif self._isConfigFile(filename): return True print "Not handled!" return False
[ "def", "Remove", "(", "self", ",", "directory", ",", "filename", ")", ":", "if", "self", ".", "_isMediaFile", "(", "filename", ")", ":", "return", "self", ".", "_remove_media", "(", "directory", ",", "filename", ")", "elif", "self", ".", "_isConfigFile", ...
Deletes files from fb
[ "Deletes", "files", "from", "fb" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L103-L111
esterhui/pypu
pypu/service_facebook.py
service_facebook._update_config
def _update_config(self,directory,filename): """Manages FB config files""" basefilename=os.path.splitext(filename)[0] ext=os.path.splitext(filename)[1].lower() #if filename==LOCATION_FILE: #return self._update_config_location(directory) #FIXME #elif filename==...
python
def _update_config(self,directory,filename): """Manages FB config files""" basefilename=os.path.splitext(filename)[0] ext=os.path.splitext(filename)[1].lower() #if filename==LOCATION_FILE: #return self._update_config_location(directory) #FIXME #elif filename==...
[ "def", "_update_config", "(", "self", ",", "directory", ",", "filename", ")", ":", "basefilename", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "["...
Manages FB config files
[ "Manages", "FB", "config", "files" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L113-L132
esterhui/pypu
pypu/service_facebook.py
service_facebook._get_title
def _get_title(self,directory,filename): """Loads image title if any""" # =========== LOAD TITLE ======== fullfile=os.path.join(directory,filename+'.title') try: logger.debug('trying to open [%s]'%(fullfile)) _title=(open(fullfile).readline().strip()) ...
python
def _get_title(self,directory,filename): """Loads image title if any""" # =========== LOAD TITLE ======== fullfile=os.path.join(directory,filename+'.title') try: logger.debug('trying to open [%s]'%(fullfile)) _title=(open(fullfile).readline().strip()) ...
[ "def", "_get_title", "(", "self", ",", "directory", ",", "filename", ")", ":", "# =========== LOAD TITLE ========", "fullfile", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "filename", "+", "'.title'", ")", "try", ":", "logger", ".", "debug", ...
Loads image title if any
[ "Loads", "image", "title", "if", "any" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L134-L145
esterhui/pypu
pypu/service_facebook.py
service_facebook._load_megapixels
def _load_megapixels(self,directory): """Opens megapixel file, if contains '3.5' for instance, will scale all uploaded photos in directory this this size, the original photo is untouched. Returns None if file not found """ #FIXME: should check if DB tracking file...
python
def _load_megapixels(self,directory): """Opens megapixel file, if contains '3.5' for instance, will scale all uploaded photos in directory this this size, the original photo is untouched. Returns None if file not found """ #FIXME: should check if DB tracking file...
[ "def", "_load_megapixels", "(", "self", ",", "directory", ")", ":", "#FIXME: should check if DB tracking file before using it", "fullfile", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "MEGAPIXEL_FILE", ")", "try", ":", "mp", "=", "float", "(", "o...
Opens megapixel file, if contains '3.5' for instance, will scale all uploaded photos in directory this this size, the original photo is untouched. Returns None if file not found
[ "Opens", "megapixel", "file", "if", "contains", "3", ".", "5", "for", "instance", "will", "scale", "all", "uploaded", "photos", "in", "directory", "this", "this", "size", "the", "original", "photo", "is", "untouched", ".", "Returns", "None", "if", "file", ...
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L147-L165
esterhui/pypu
pypu/service_facebook.py
service_facebook._load_sets
def _load_sets(self,directory): """Loads sets from set file and return as list of strings """ # --- Read sets out of file _sets=[] try: fullfile=os.path.join(directory,SET_FILE) lsets=open(fullfile).readline().split(',') for tag in lset...
python
def _load_sets(self,directory): """Loads sets from set file and return as list of strings """ # --- Read sets out of file _sets=[] try: fullfile=os.path.join(directory,SET_FILE) lsets=open(fullfile).readline().split(',') for tag in lset...
[ "def", "_load_sets", "(", "self", ",", "directory", ")", ":", "# --- Read sets out of file", "_sets", "=", "[", "]", "try", ":", "fullfile", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "SET_FILE", ")", "lsets", "=", "open", "(", "fullfile...
Loads sets from set file and return as list of strings
[ "Loads", "sets", "from", "set", "file", "and", "return", "as", "list", "of", "strings" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L167-L183
esterhui/pypu
pypu/service_facebook.py
service_facebook._createphotoset
def _createphotoset(self,myset): """Creates a photo set (album) on FB""" if not self._connectToFB(): print("%s - Couldn't connect to fb"%(directory)) return False logger.debug('fb: Creating photo set %s' %(myset)) resp=self.fb.put_object(USER_ID,"albums",...
python
def _createphotoset(self,myset): """Creates a photo set (album) on FB""" if not self._connectToFB(): print("%s - Couldn't connect to fb"%(directory)) return False logger.debug('fb: Creating photo set %s' %(myset)) resp=self.fb.put_object(USER_ID,"albums",...
[ "def", "_createphotoset", "(", "self", ",", "myset", ")", ":", "if", "not", "self", ".", "_connectToFB", "(", ")", ":", "print", "(", "\"%s - Couldn't connect to fb\"", "%", "(", "directory", ")", ")", "return", "False", "logger", ".", "debug", "(", "'fb: ...
Creates a photo set (album) on FB
[ "Creates", "a", "photo", "set", "(", "album", ")", "on", "FB" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L185-L199
esterhui/pypu
pypu/service_facebook.py
service_facebook._get_album
def _get_album(self,directory): """ Loads set name from SET_FILE, looks up album_id on fb, it it doesn't exists, creates album. Returns album id and album name """ if not self._connectToFB(): print("%s - Couldn't connect to fb"%(directory)) return None,No...
python
def _get_album(self,directory): """ Loads set name from SET_FILE, looks up album_id on fb, it it doesn't exists, creates album. Returns album id and album name """ if not self._connectToFB(): print("%s - Couldn't connect to fb"%(directory)) return None,No...
[ "def", "_get_album", "(", "self", ",", "directory", ")", ":", "if", "not", "self", ".", "_connectToFB", "(", ")", ":", "print", "(", "\"%s - Couldn't connect to fb\"", "%", "(", "directory", ")", ")", "return", "None", ",", "None", "# Load sets from SET_FILE",...
Loads set name from SET_FILE, looks up album_id on fb, it it doesn't exists, creates album. Returns album id and album name
[ "Loads", "set", "name", "from", "SET_FILE", "looks", "up", "album_id", "on", "fb", "it", "it", "doesn", "t", "exists", "creates", "album", ".", "Returns", "album", "id", "and", "album", "name" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L201-L230
esterhui/pypu
pypu/service_facebook.py
service_facebook._getphoto_originalsize
def _getphoto_originalsize(self,pid): """Asks fb for photo original size returns tuple with width,height """ logger.debug('%s - Getting original size from fb'%(pid)) i=self.fb.get_object(pid) width=i['images'][0]['width'] height=i['images'][0]['height'] re...
python
def _getphoto_originalsize(self,pid): """Asks fb for photo original size returns tuple with width,height """ logger.debug('%s - Getting original size from fb'%(pid)) i=self.fb.get_object(pid) width=i['images'][0]['width'] height=i['images'][0]['height'] re...
[ "def", "_getphoto_originalsize", "(", "self", ",", "pid", ")", ":", "logger", ".", "debug", "(", "'%s - Getting original size from fb'", "%", "(", "pid", ")", ")", "i", "=", "self", ".", "fb", ".", "get_object", "(", "pid", ")", "width", "=", "i", "[", ...
Asks fb for photo original size returns tuple with width,height
[ "Asks", "fb", "for", "photo", "original", "size", "returns", "tuple", "with", "width", "height" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L251-L259
esterhui/pypu
pypu/service_facebook.py
service_facebook._getphoto_location
def _getphoto_location(self,pid): """Asks fb for photo location information returns tuple with lat,lon,accuracy """ logger.debug('%s - Getting location from fb'%(pid)) lat=None lon=None accuracy=None resp=self.fb.photos_geo_getLocation(photo_id=pid) ...
python
def _getphoto_location(self,pid): """Asks fb for photo location information returns tuple with lat,lon,accuracy """ logger.debug('%s - Getting location from fb'%(pid)) lat=None lon=None accuracy=None resp=self.fb.photos_geo_getLocation(photo_id=pid) ...
[ "def", "_getphoto_location", "(", "self", ",", "pid", ")", ":", "logger", ".", "debug", "(", "'%s - Getting location from fb'", "%", "(", "pid", ")", ")", "lat", "=", "None", "lon", "=", "None", "accuracy", "=", "None", "resp", "=", "self", ".", "fb", ...
Asks fb for photo location information returns tuple with lat,lon,accuracy
[ "Asks", "fb", "for", "photo", "location", "information", "returns", "tuple", "with", "lat", "lon", "accuracy" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L262-L285
esterhui/pypu
pypu/service_facebook.py
service_facebook._remove_media
def _remove_media(self,directory,files=None): """Removes specified files from fb""" # Connect if we aren't already if not self._connectToFB(): logger.error("%s - Couldn't connect to fb") return False db=self._loadDB(directory) # If no files given, use fil...
python
def _remove_media(self,directory,files=None): """Removes specified files from fb""" # Connect if we aren't already if not self._connectToFB(): logger.error("%s - Couldn't connect to fb") return False db=self._loadDB(directory) # If no files given, use fil...
[ "def", "_remove_media", "(", "self", ",", "directory", ",", "files", "=", "None", ")", ":", "# Connect if we aren't already", "if", "not", "self", ".", "_connectToFB", "(", ")", ":", "logger", ".", "error", "(", "\"%s - Couldn't connect to fb\"", ")", "return", ...
Removes specified files from fb
[ "Removes", "specified", "files", "from", "fb" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L287-L322
esterhui/pypu
pypu/service_facebook.py
service_facebook._upload_media
def _upload_media(self,directory,files=None,resize_request=None, \ movealbum_request=None,changetitle_request=None): """Uploads media file to FB, returns True if uploaded successfully, Will replace if already uploaded, If megapixels > 0, will scale photos before upload ...
python
def _upload_media(self,directory,files=None,resize_request=None, \ movealbum_request=None,changetitle_request=None): """Uploads media file to FB, returns True if uploaded successfully, Will replace if already uploaded, If megapixels > 0, will scale photos before upload ...
[ "def", "_upload_media", "(", "self", ",", "directory", ",", "files", "=", "None", ",", "resize_request", "=", "None", ",", "movealbum_request", "=", "None", ",", "changetitle_request", "=", "None", ")", ":", "# Connect if we aren't already", "if", "not", "self",...
Uploads media file to FB, returns True if uploaded successfully, Will replace if already uploaded, If megapixels > 0, will scale photos before upload If no filename given, will go through all files in DB
[ "Uploads", "media", "file", "to", "FB", "returns", "True", "if", "uploaded", "successfully", "Will", "replace", "if", "already", "uploaded", "If", "megapixels", ">", "0", "will", "scale", "photos", "before", "upload", "If", "no", "filename", "given", "will", ...
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L324-L375
esterhui/pypu
pypu/service_facebook.py
service_facebook._upload_or_replace_fb
def _upload_or_replace_fb(self,directory,fn,_album_id,\ _megapixels=None,resize_request=None,movealbum_request=None,\ changetitle_request=None,_title=None): """Does the actual upload to fb. if resize_request, will resize picture only if it already exists and the geometry ...
python
def _upload_or_replace_fb(self,directory,fn,_album_id,\ _megapixels=None,resize_request=None,movealbum_request=None,\ changetitle_request=None,_title=None): """Does the actual upload to fb. if resize_request, will resize picture only if it already exists and the geometry ...
[ "def", "_upload_or_replace_fb", "(", "self", ",", "directory", ",", "fn", ",", "_album_id", ",", "_megapixels", "=", "None", ",", "resize_request", "=", "None", ",", "movealbum_request", "=", "None", ",", "changetitle_request", "=", "None", ",", "_title", "=",...
Does the actual upload to fb. if resize_request, will resize picture only if it already exists and the geometry on fb doesn't match what we want, returns (status)
[ "Does", "the", "actual", "upload", "to", "fb", ".", "if", "resize_request", "will", "resize", "picture", "only", "if", "it", "already", "exists", "and", "the", "geometry", "on", "fb", "doesn", "t", "match", "what", "we", "want", "returns", "(", "status", ...
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L377-L466
esterhui/pypu
pypu/service_facebook.py
service_facebook._title_uptodate
def _title_uptodate(self,fullfile,pid,_title): """Check fb photo title against provided title, returns true if they match""" i=self.fb.get_object(pid) if i.has_key('name'): if _title == i['name']: return True return False
python
def _title_uptodate(self,fullfile,pid,_title): """Check fb photo title against provided title, returns true if they match""" i=self.fb.get_object(pid) if i.has_key('name'): if _title == i['name']: return True return False
[ "def", "_title_uptodate", "(", "self", ",", "fullfile", ",", "pid", ",", "_title", ")", ":", "i", "=", "self", ".", "fb", ".", "get_object", "(", "pid", ")", "if", "i", ".", "has_key", "(", "'name'", ")", ":", "if", "_title", "==", "i", "[", "'na...
Check fb photo title against provided title, returns true if they match
[ "Check", "fb", "photo", "title", "against", "provided", "title", "returns", "true", "if", "they", "match" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L468-L476
esterhui/pypu
pypu/service_facebook.py
service_facebook._already_in_album
def _already_in_album(self,fullfile,pid,album_id): """Check to see if photo with given pid is already in the album_id, returns true if this is the case """ logger.debug("fb: Checking if pid %s in album %s",pid,album_id) pid_in_album=[] # Get all photos in album p...
python
def _already_in_album(self,fullfile,pid,album_id): """Check to see if photo with given pid is already in the album_id, returns true if this is the case """ logger.debug("fb: Checking if pid %s in album %s",pid,album_id) pid_in_album=[] # Get all photos in album p...
[ "def", "_already_in_album", "(", "self", ",", "fullfile", ",", "pid", ",", "album_id", ")", ":", "logger", ".", "debug", "(", "\"fb: Checking if pid %s in album %s\"", ",", "pid", ",", "album_id", ")", "pid_in_album", "=", "[", "]", "# Get all photos in album", ...
Check to see if photo with given pid is already in the album_id, returns true if this is the case
[ "Check", "to", "see", "if", "photo", "with", "given", "pid", "is", "already", "in", "the", "album_id", "returns", "true", "if", "this", "is", "the", "case" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L478-L498
esterhui/pypu
pypu/service_facebook.py
service_facebook._already_resized_on_fb
def _already_resized_on_fb(self,fn,pid,_megapixels): """Checks if image file (fn) with photo_id (pid) has already been resized on fb. If so, returns True""" logger.debug("%s - resize requested"%(fn)) # Get width/height from fb width_fb,height_fb=self._getphoto_originalsize(pid) ...
python
def _already_resized_on_fb(self,fn,pid,_megapixels): """Checks if image file (fn) with photo_id (pid) has already been resized on fb. If so, returns True""" logger.debug("%s - resize requested"%(fn)) # Get width/height from fb width_fb,height_fb=self._getphoto_originalsize(pid) ...
[ "def", "_already_resized_on_fb", "(", "self", ",", "fn", ",", "pid", ",", "_megapixels", ")", ":", "logger", ".", "debug", "(", "\"%s - resize requested\"", "%", "(", "fn", ")", ")", "# Get width/height from fb", "width_fb", ",", "height_fb", "=", "self", ".",...
Checks if image file (fn) with photo_id (pid) has already been resized on fb. If so, returns True
[ "Checks", "if", "image", "file", "(", "fn", ")", "with", "photo_id", "(", "pid", ")", "has", "already", "been", "resized", "on", "fb", ".", "If", "so", "returns", "True" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L500-L517
esterhui/pypu
pypu/service_facebook.py
service_facebook._getphotosets
def _getphotosets(self): """Returns dictionary of photosets retrieved from fb d['title']['number_photos'] : Number of photos d['title']['id'] : ID of photoset d['title']['photo_id'] : ID of primary photo d['title']['url'] : URL to photoset """ ...
python
def _getphotosets(self): """Returns dictionary of photosets retrieved from fb d['title']['number_photos'] : Number of photos d['title']['id'] : ID of photoset d['title']['photo_id'] : ID of primary photo d['title']['url'] : URL to photoset """ ...
[ "def", "_getphotosets", "(", "self", ")", ":", "sets", "=", "{", "}", "if", "not", "self", ".", "_connectToFB", "(", ")", ":", "print", "(", "\"Couldn't connect to fb\"", ")", "return", "sets", "# Gets facebook albums", "psets", "=", "self", ".", "fb", "."...
Returns dictionary of photosets retrieved from fb d['title']['number_photos'] : Number of photos d['title']['id'] : ID of photoset d['title']['photo_id'] : ID of primary photo d['title']['url'] : URL to photoset
[ "Returns", "dictionary", "of", "photosets", "retrieved", "from", "fb", "d", "[", "title", "]", "[", "number_photos", "]", ":", "Number", "of", "photos", "d", "[", "title", "]", "[", "id", "]", ":", "ID", "of", "photoset", "d", "[", "title", "]", "[",...
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L519-L548
esterhui/pypu
pypu/service_facebook.py
service_facebook.PrintSets
def PrintSets(self): """Prints set name and number of photos in set""" sets=self._getphotosets() for setname in sets: print("%s [%d]"%(setname,sets[setname]['number_photos']))
python
def PrintSets(self): """Prints set name and number of photos in set""" sets=self._getphotosets() for setname in sets: print("%s [%d]"%(setname,sets[setname]['number_photos']))
[ "def", "PrintSets", "(", "self", ")", ":", "sets", "=", "self", ".", "_getphotosets", "(", ")", "for", "setname", "in", "sets", ":", "print", "(", "\"%s [%d]\"", "%", "(", "setname", ",", "sets", "[", "setname", "]", "[", "'number_photos'", "]", ")", ...
Prints set name and number of photos in set
[ "Prints", "set", "name", "and", "number", "of", "photos", "in", "set" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L550-L554
JNRowe/jnrbase
jnrbase/context.py
chdir
def chdir(__path: str) -> ContextManager: """Context handler to temporarily switch directories. Args: __path: Directory to change to Yields: Execution context in ``path`` """ old = os.getcwd() try: os.chdir(__path) yield finally: os.chdir(old)
python
def chdir(__path: str) -> ContextManager: """Context handler to temporarily switch directories. Args: __path: Directory to change to Yields: Execution context in ``path`` """ old = os.getcwd() try: os.chdir(__path) yield finally: os.chdir(old)
[ "def", "chdir", "(", "__path", ":", "str", ")", "->", "ContextManager", ":", "old", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "__path", ")", "yield", "finally", ":", "os", ".", "chdir", "(", "old", ")" ]
Context handler to temporarily switch directories. Args: __path: Directory to change to Yields: Execution context in ``path``
[ "Context", "handler", "to", "temporarily", "switch", "directories", "." ]
train
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/context.py#L27-L41
JNRowe/jnrbase
jnrbase/context.py
env
def env(**kwargs: Union[Dict[str, str], None]) -> ContextManager: """Context handler to temporarily alter environment. If you supply a value of ``None``, then the associated key will be deleted from the environment. Args: kwargs: Environment variables to override Yields: Execution...
python
def env(**kwargs: Union[Dict[str, str], None]) -> ContextManager: """Context handler to temporarily alter environment. If you supply a value of ``None``, then the associated key will be deleted from the environment. Args: kwargs: Environment variables to override Yields: Execution...
[ "def", "env", "(", "*", "*", "kwargs", ":", "Union", "[", "Dict", "[", "str", ",", "str", "]", ",", "None", "]", ")", "->", "ContextManager", ":", "old", "=", "os", ".", "environ", ".", "copy", "(", ")", "try", ":", "os", ".", "environ", ".", ...
Context handler to temporarily alter environment. If you supply a value of ``None``, then the associated key will be deleted from the environment. Args: kwargs: Environment variables to override Yields: Execution context with modified environment
[ "Context", "handler", "to", "temporarily", "alter", "environment", "." ]
train
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/context.py#L45-L77
stevepeak/stuffed
stuffed/address.py
Address.distance_to
def distance_to(self, address, measure="Miles", httpclient=None): """Distance to another address """ if isinstance(address, Address) and self.latlng and address.latlng: lat1, lon1 = map(float, self.latlng) lat2, lon2 = map(float, address.latlng) elif self.latlng a...
python
def distance_to(self, address, measure="Miles", httpclient=None): """Distance to another address """ if isinstance(address, Address) and self.latlng and address.latlng: lat1, lon1 = map(float, self.latlng) lat2, lon2 = map(float, address.latlng) elif self.latlng a...
[ "def", "distance_to", "(", "self", ",", "address", ",", "measure", "=", "\"Miles\"", ",", "httpclient", "=", "None", ")", ":", "if", "isinstance", "(", "address", ",", "Address", ")", "and", "self", ".", "latlng", "and", "address", ".", "latlng", ":", ...
Distance to another address
[ "Distance", "to", "another", "address" ]
train
https://github.com/stevepeak/stuffed/blob/cc18d5d34b36225035d618d666275c913f5f66de/stuffed/address.py#L93-L120
limix/chiscore
chiscore/_optimal.py
optimal_davies_pvalue
def optimal_davies_pvalue(q, mu, var, kur, w, remain_var, df, trho, grid, pmin=None): r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : array_like Most significant of the independent test statistics, qₘᵢₙ(𝜌ᵥ) [1]. mu : float Mea...
python
def optimal_davies_pvalue(q, mu, var, kur, w, remain_var, df, trho, grid, pmin=None): r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : array_like Most significant of the independent test statistics, qₘᵢₙ(𝜌ᵥ) [1]. mu : float Mea...
[ "def", "optimal_davies_pvalue", "(", "q", ",", "mu", ",", "var", ",", "kur", ",", "w", ",", "remain_var", ",", "df", ",", "trho", ",", "grid", ",", "pmin", "=", "None", ")", ":", "q", "=", "asarray", "(", "q", ",", "float", ")", "mu", "=", "flo...
r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : array_like Most significant of the independent test statistics, qₘᵢₙ(𝜌ᵥ) [1]. mu : float Mean of the linear combination of the chi-squared distributions. var : float Vari...
[ "r", "Joint", "significance", "of", "statistics", "derived", "from", "chi2", "-", "squared", "distributions", "." ]
train
https://github.com/limix/chiscore/blob/c3e774648b8166a5161df86e6bcad34af3cec95c/chiscore/_optimal.py#L9-L77
Fuyukai/ConfigMaster
configmaster/JSONConfigFile.py
json_dump_hook
def json_dump_hook(cfg, text: bool=False): """ Dumps all the data into a JSON file. """ data = cfg.config.dump() if not text: json.dump(data, cfg.fd) else: return json.dumps(data)
python
def json_dump_hook(cfg, text: bool=False): """ Dumps all the data into a JSON file. """ data = cfg.config.dump() if not text: json.dump(data, cfg.fd) else: return json.dumps(data)
[ "def", "json_dump_hook", "(", "cfg", ",", "text", ":", "bool", "=", "False", ")", ":", "data", "=", "cfg", ".", "config", ".", "dump", "(", ")", "if", "not", "text", ":", "json", ".", "dump", "(", "data", ",", "cfg", ".", "fd", ")", "else", ":"...
Dumps all the data into a JSON file.
[ "Dumps", "all", "the", "data", "into", "a", "JSON", "file", "." ]
train
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/JSONConfigFile.py#L49-L58
skitazaki/python-clitool
clitool/config.py
ConfigLoader.load
def load(self, env=None): """ Load a section values of given environment. If nothing to specified, use environmental variable. If unknown environment was specified, warn it on logger. :param env: environment key to load in a coercive manner :type env: string :rtype: dict...
python
def load(self, env=None): """ Load a section values of given environment. If nothing to specified, use environmental variable. If unknown environment was specified, warn it on logger. :param env: environment key to load in a coercive manner :type env: string :rtype: dict...
[ "def", "load", "(", "self", ",", "env", "=", "None", ")", ":", "self", ".", "_load", "(", ")", "e", "=", "env", "or", "os", ".", "environ", ".", "get", "(", "RUNNING_MODE_ENVKEY", ",", "DEFAULT_RUNNING_MODE", ")", "if", "e", "in", "self", ".", "con...
Load a section values of given environment. If nothing to specified, use environmental variable. If unknown environment was specified, warn it on logger. :param env: environment key to load in a coercive manner :type env: string :rtype: dict
[ "Load", "a", "section", "values", "of", "given", "environment", ".", "If", "nothing", "to", "specified", "use", "environmental", "variable", ".", "If", "unknown", "environment", "was", "specified", "warn", "it", "on", "logger", "." ]
train
https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/config.py#L78-L92
skitazaki/python-clitool
clitool/config.py
ConfigLoader.flip
def flip(self): """ Provide flip view to compare how key/value pair is defined in each environment for administrative usage. :rtype: dict """ self._load() groups = self.config.keys() tabular = {} for g in groups: config = self.config[g] ...
python
def flip(self): """ Provide flip view to compare how key/value pair is defined in each environment for administrative usage. :rtype: dict """ self._load() groups = self.config.keys() tabular = {} for g in groups: config = self.config[g] ...
[ "def", "flip", "(", "self", ")", ":", "self", ".", "_load", "(", ")", "groups", "=", "self", ".", "config", ".", "keys", "(", ")", "tabular", "=", "{", "}", "for", "g", "in", "groups", ":", "config", "=", "self", ".", "config", "[", "g", "]", ...
Provide flip view to compare how key/value pair is defined in each environment for administrative usage. :rtype: dict
[ "Provide", "flip", "view", "to", "compare", "how", "key", "/", "value", "pair", "is", "defined", "in", "each", "environment", "for", "administrative", "usage", "." ]
train
https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/config.py#L94-L109
dusty-phillips/opterator
examples/ls.py
main
def main(show_details:['-l']=False, cols:['-w', '--width']='', *files): ''' List information about a particular file or set of files :param show_details: Whether to show detailed info about files :param cols: specify screen width ''' print(files) print(show_details) print(cols)
python
def main(show_details:['-l']=False, cols:['-w', '--width']='', *files): ''' List information about a particular file or set of files :param show_details: Whether to show detailed info about files :param cols: specify screen width ''' print(files) print(show_details) print(cols)
[ "def", "main", "(", "show_details", ":", "[", "'-l'", "]", "=", "False", ",", "cols", ":", "[", "'-w'", ",", "'--width'", "]", "=", "''", ",", "*", "files", ")", ":", "print", "(", "files", ")", "print", "(", "show_details", ")", "print", "(", "c...
List information about a particular file or set of files :param show_details: Whether to show detailed info about files :param cols: specify screen width
[ "List", "information", "about", "a", "particular", "file", "or", "set", "of", "files" ]
train
https://github.com/dusty-phillips/opterator/blob/84fe31f22c73dc0a3666ed82c179461b1799c257/examples/ls.py#L7-L16
edwards-lab/libGWAS
libgwas/locus.py
Locus.flip
def flip(self): """This will switch major/minor around, regardless of frequency truth. This is intended for forcing one of two populations to relate correctly to the same genotype definitions. When flipped, Ps and Qs will be backward, and the maf will no longer relate to the "minor" all...
python
def flip(self): """This will switch major/minor around, regardless of frequency truth. This is intended for forcing one of two populations to relate correctly to the same genotype definitions. When flipped, Ps and Qs will be backward, and the maf will no longer relate to the "minor" all...
[ "def", "flip", "(", "self", ")", ":", "maj_count", "=", "self", ".", "maj_allele_count", "self", ".", "maj_allele_count", "=", "self", ".", "min_allele_count", "self", ".", "min_allele_count", "=", "maj_count", "alleles", "=", "self", ".", "alleles", "self", ...
This will switch major/minor around, regardless of frequency truth. This is intended for forcing one of two populations to relate correctly to the same genotype definitions. When flipped, Ps and Qs will be backward, and the maf will no longer relate to the "minor" allele frequency. Howe...
[ "This", "will", "switch", "major", "/", "minor", "around", "regardless", "of", "frequency", "truth", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/locus.py#L57-L72
jpablo128/simplystatic
simplystatic/util.py
random_date
def random_date(): '''Return a valid random date.''' d = datetime.datetime.now().date() d = d - datetime.timedelta(random.randint(20,2001)) return d
python
def random_date(): '''Return a valid random date.''' d = datetime.datetime.now().date() d = d - datetime.timedelta(random.randint(20,2001)) return d
[ "def", "random_date", "(", ")", ":", "d", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "date", "(", ")", "d", "=", "d", "-", "datetime", ".", "timedelta", "(", "random", ".", "randint", "(", "20", ",", "2001", ")", ")", "return", ...
Return a valid random date.
[ "Return", "a", "valid", "random", "date", "." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/util.py#L65-L69
jpablo128/simplystatic
simplystatic/util.py
random_md_page
def random_md_page(): '''Generate random markdown page content.. If the parameters are zero, instead of a fixed number of elements it uses a random number. ''' # headers #, ## # blockquote > # lists * # codeblock (indent 4 spaces) # hrule, 3 or more - in a line # emphasis: wor...
python
def random_md_page(): '''Generate random markdown page content.. If the parameters are zero, instead of a fixed number of elements it uses a random number. ''' # headers #, ## # blockquote > # lists * # codeblock (indent 4 spaces) # hrule, 3 or more - in a line # emphasis: wor...
[ "def", "random_md_page", "(", ")", ":", "# headers #, ##", "# blockquote >", "# lists *", "# codeblock (indent 4 spaces)", "# hrule, 3 or more - in a line", "# emphasis: word surrounded by one * or _", "lines", "=", "[", "]", "lines", ".", "append", "(", "\"\\n# \"", "+", "...
Generate random markdown page content.. If the parameters are zero, instead of a fixed number of elements it uses a random number.
[ "Generate", "random", "markdown", "page", "content", ".." ]
train
https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/util.py#L83-L106
thomasbiddle/Kippt-for-Python
kippt/lists.py
Lists.all
def all(self, **args): """ Return all Lists. """ limit = args['limit'] if 'limit' in args else 20 offset = args['offset'] if 'offset' in args else 0 r = requests.get( "https://kippt.com/api/lists?limit=%s&offset=%s" % (limit, offset), headers=self.kippt....
python
def all(self, **args): """ Return all Lists. """ limit = args['limit'] if 'limit' in args else 20 offset = args['offset'] if 'offset' in args else 0 r = requests.get( "https://kippt.com/api/lists?limit=%s&offset=%s" % (limit, offset), headers=self.kippt....
[ "def", "all", "(", "self", ",", "*", "*", "args", ")", ":", "limit", "=", "args", "[", "'limit'", "]", "if", "'limit'", "in", "args", "else", "20", "offset", "=", "args", "[", "'offset'", "]", "if", "'offset'", "in", "args", "else", "0", "r", "="...
Return all Lists.
[ "Return", "all", "Lists", "." ]
train
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/lists.py#L19-L30
thomasbiddle/Kippt-for-Python
kippt/lists.py
Lists.create
def create(self, title, **args): """ Create a new Kippt List. Parameters: - title (Required) - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/list.md """ # Merge our t...
python
def create(self, title, **args): """ Create a new Kippt List. Parameters: - title (Required) - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/list.md """ # Merge our t...
[ "def", "create", "(", "self", ",", "title", ",", "*", "*", "args", ")", ":", "# Merge our title as a parameter and JSONify it.", "data", "=", "json", ".", "dumps", "(", "dict", "(", "{", "'title'", ":", "title", "}", ",", "*", "*", "args", ")", ")", "r...
Create a new Kippt List. Parameters: - title (Required) - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/list.md
[ "Create", "a", "new", "Kippt", "List", "." ]
train
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/lists.py#L48-L65
inveniosoftware-contrib/record-recommender
record_recommender/cli.py
cli
def cli(config_path, verbose): """Record-Recommender command line version.""" global config, store if not config_path: config_path = '/etc/record_recommender.yml' config = get_config(config_path) setup_logging(config) store = FileStore(config)
python
def cli(config_path, verbose): """Record-Recommender command line version.""" global config, store if not config_path: config_path = '/etc/record_recommender.yml' config = get_config(config_path) setup_logging(config) store = FileStore(config)
[ "def", "cli", "(", "config_path", ",", "verbose", ")", ":", "global", "config", ",", "store", "if", "not", "config_path", ":", "config_path", "=", "'/etc/record_recommender.yml'", "config", "=", "get_config", "(", "config_path", ")", "setup_logging", "(", "confi...
Record-Recommender command line version.
[ "Record", "-", "Recommender", "command", "line", "version", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L49-L56
inveniosoftware-contrib/record-recommender
record_recommender/cli.py
fetch
def fetch(weeks, force): """Fetch newest PageViews and Downloads.""" weeks = get_last_weeks(weeks) print(weeks) recommender = RecordRecommender(config) recommender.fetch_weeks(weeks, overwrite=force)
python
def fetch(weeks, force): """Fetch newest PageViews and Downloads.""" weeks = get_last_weeks(weeks) print(weeks) recommender = RecordRecommender(config) recommender.fetch_weeks(weeks, overwrite=force)
[ "def", "fetch", "(", "weeks", ",", "force", ")", ":", "weeks", "=", "get_last_weeks", "(", "weeks", ")", "print", "(", "weeks", ")", "recommender", "=", "RecordRecommender", "(", "config", ")", "recommender", ".", "fetch_weeks", "(", "weeks", ",", "overwri...
Fetch newest PageViews and Downloads.
[ "Fetch", "newest", "PageViews", "and", "Downloads", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L75-L80
inveniosoftware-contrib/record-recommender
record_recommender/cli.py
update_recommender
def update_recommender(ctx, weeks, processes): """ Download and build the recommendations. - Fetch new statistics from the current week. - Generate recommendations. - Update the recommendations. """ weeks = get_last_weeks(weeks) recommender = RecordRecommender(config) # Redownload i...
python
def update_recommender(ctx, weeks, processes): """ Download and build the recommendations. - Fetch new statistics from the current week. - Generate recommendations. - Update the recommendations. """ weeks = get_last_weeks(weeks) recommender = RecordRecommender(config) # Redownload i...
[ "def", "update_recommender", "(", "ctx", ",", "weeks", ",", "processes", ")", ":", "weeks", "=", "get_last_weeks", "(", "weeks", ")", "recommender", "=", "RecordRecommender", "(", "config", ")", "# Redownload incomplete weeks", "first_weeks", "=", "weeks", "[", ...
Download and build the recommendations. - Fetch new statistics from the current week. - Generate recommendations. - Update the recommendations.
[ "Download", "and", "build", "the", "recommendations", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L87-L107
inveniosoftware-contrib/record-recommender
record_recommender/cli.py
profiles
def profiles(weeks): """ Number of weeks to build. Starting with the current week. """ profiles = Profiles(store) weeks = get_last_weeks(weeks) if isinstance(weeks, int) else weeks print(weeks) profiles.create(weeks)
python
def profiles(weeks): """ Number of weeks to build. Starting with the current week. """ profiles = Profiles(store) weeks = get_last_weeks(weeks) if isinstance(weeks, int) else weeks print(weeks) profiles.create(weeks)
[ "def", "profiles", "(", "weeks", ")", ":", "profiles", "=", "Profiles", "(", "store", ")", "weeks", "=", "get_last_weeks", "(", "weeks", ")", "if", "isinstance", "(", "weeks", ",", "int", ")", "else", "weeks", "print", "(", "weeks", ")", "profiles", "....
Number of weeks to build. Starting with the current week.
[ "Number", "of", "weeks", "to", "build", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L112-L121
inveniosoftware-contrib/record-recommender
record_recommender/cli.py
build
def build(processes): """ Calculate all recommendations using the number of specified processes. The recommendations are calculated from the generated Profiles file. """ recommender = RecordRecommender(config) recommender.create_all_recommendations(processes, ip_views=True)
python
def build(processes): """ Calculate all recommendations using the number of specified processes. The recommendations are calculated from the generated Profiles file. """ recommender = RecordRecommender(config) recommender.create_all_recommendations(processes, ip_views=True)
[ "def", "build", "(", "processes", ")", ":", "recommender", "=", "RecordRecommender", "(", "config", ")", "recommender", ".", "create_all_recommendations", "(", "processes", ",", "ip_views", "=", "True", ")" ]
Calculate all recommendations using the number of specified processes. The recommendations are calculated from the generated Profiles file.
[ "Calculate", "all", "recommendations", "using", "the", "number", "of", "specified", "processes", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L126-L133
klmitch/appathy
appathy/response.py
ResponseObject._bind
def _bind(self, _descriptor): """ Bind a ResponseObject to a given action descriptor. This updates the default HTTP response code and selects the appropriate content type and serializer for the response. """ # If the method has a default code, use it self._defco...
python
def _bind(self, _descriptor): """ Bind a ResponseObject to a given action descriptor. This updates the default HTTP response code and selects the appropriate content type and serializer for the response. """ # If the method has a default code, use it self._defco...
[ "def", "_bind", "(", "self", ",", "_descriptor", ")", ":", "# If the method has a default code, use it", "self", ".", "_defcode", "=", "getattr", "(", "_descriptor", ".", "method", ",", "'_wsgi_code'", ",", "200", ")", "# Set up content type and serializer", "self", ...
Bind a ResponseObject to a given action descriptor. This updates the default HTTP response code and selects the appropriate content type and serializer for the response.
[ "Bind", "a", "ResponseObject", "to", "a", "given", "action", "descriptor", ".", "This", "updates", "the", "default", "HTTP", "response", "code", "and", "selects", "the", "appropriate", "content", "type", "and", "serializer", "for", "the", "response", "." ]
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L122-L133
klmitch/appathy
appathy/response.py
ResponseObject._serialize
def _serialize(self): """ Serialize the ResponseObject. Returns a webob `Response` object. """ # Do something appropriate if the response object is unbound if self._defcode is None: raise exceptions.UnboundResponse() # Build the response res...
python
def _serialize(self): """ Serialize the ResponseObject. Returns a webob `Response` object. """ # Do something appropriate if the response object is unbound if self._defcode is None: raise exceptions.UnboundResponse() # Build the response res...
[ "def", "_serialize", "(", "self", ")", ":", "# Do something appropriate if the response object is unbound", "if", "self", ".", "_defcode", "is", "None", ":", "raise", "exceptions", ".", "UnboundResponse", "(", ")", "# Build the response", "resp", "=", "self", ".", "...
Serialize the ResponseObject. Returns a webob `Response` object.
[ "Serialize", "the", "ResponseObject", ".", "Returns", "a", "webob", "Response", "object", "." ]
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L135-L155
klmitch/appathy
appathy/response.py
ResponseObject.code
def code(self): """ The HTTP response code associated with this ResponseObject. If instantiated directly without overriding the code, returns 200 even if the default for the method is some other value. Can be set or deleted; in the latter case, the default will be restore...
python
def code(self): """ The HTTP response code associated with this ResponseObject. If instantiated directly without overriding the code, returns 200 even if the default for the method is some other value. Can be set or deleted; in the latter case, the default will be restore...
[ "def", "code", "(", "self", ")", ":", "if", "self", ".", "_code", "is", "not", "None", ":", "return", "self", ".", "_code", "elif", "self", ".", "_defcode", "is", "not", "None", ":", "return", "self", ".", "_defcode", "return", "200" ]
The HTTP response code associated with this ResponseObject. If instantiated directly without overriding the code, returns 200 even if the default for the method is some other value. Can be set or deleted; in the latter case, the default will be restored.
[ "The", "HTTP", "response", "code", "associated", "with", "this", "ResponseObject", ".", "If", "instantiated", "directly", "without", "overriding", "the", "code", "returns", "200", "even", "if", "the", "default", "for", "the", "method", "is", "some", "other", "...
train
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L158-L171
deviantony/valigator
valigator/notify.py
report_message
def report_message(report): """Report message.""" body = 'Error: return code != 0\n\n' body += 'Archive: {}\n\n'.format(report['archive']) body += 'Docker image: {}\n\n'.format(report['image']) body += 'Docker container: {}\n\n'.format(report['container_id']) return body
python
def report_message(report): """Report message.""" body = 'Error: return code != 0\n\n' body += 'Archive: {}\n\n'.format(report['archive']) body += 'Docker image: {}\n\n'.format(report['image']) body += 'Docker container: {}\n\n'.format(report['container_id']) return body
[ "def", "report_message", "(", "report", ")", ":", "body", "=", "'Error: return code != 0\\n\\n'", "body", "+=", "'Archive: {}\\n\\n'", ".", "format", "(", "report", "[", "'archive'", "]", ")", "body", "+=", "'Docker image: {}\\n\\n'", ".", "format", "(", "report",...
Report message.
[ "Report", "message", "." ]
train
https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L53-L59
deviantony/valigator
valigator/notify.py
task_failure_message
def task_failure_message(task_report): """Task failure message.""" trace_list = traceback.format_tb(task_report['traceback']) body = 'Error: task failure\n\n' body += 'Task ID: {}\n\n'.format(task_report['task_id']) body += 'Archive: {}\n\n'.format(task_report['archive']) body += 'Docker image: ...
python
def task_failure_message(task_report): """Task failure message.""" trace_list = traceback.format_tb(task_report['traceback']) body = 'Error: task failure\n\n' body += 'Task ID: {}\n\n'.format(task_report['task_id']) body += 'Archive: {}\n\n'.format(task_report['archive']) body += 'Docker image: ...
[ "def", "task_failure_message", "(", "task_report", ")", ":", "trace_list", "=", "traceback", ".", "format_tb", "(", "task_report", "[", "'traceback'", "]", ")", "body", "=", "'Error: task failure\\n\\n'", "body", "+=", "'Task ID: {}\\n\\n'", ".", "format", "(", "t...
Task failure message.
[ "Task", "failure", "message", "." ]
train
https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L62-L72
deviantony/valigator
valigator/notify.py
MailNotifier.send_email
def send_email(self, message): """Initiate a SMTP session and send an email.""" msg = MIMEMultipart() msg['From'] = self.from_address msg['To'] = self.to_address msg['Subject'] = self.title msg.attach(MIMEText('<pre>' + cgi.escape(message) + '</pre>', 'html')) smt...
python
def send_email(self, message): """Initiate a SMTP session and send an email.""" msg = MIMEMultipart() msg['From'] = self.from_address msg['To'] = self.to_address msg['Subject'] = self.title msg.attach(MIMEText('<pre>' + cgi.escape(message) + '</pre>', 'html')) smt...
[ "def", "send_email", "(", "self", ",", "message", ")", ":", "msg", "=", "MIMEMultipart", "(", ")", "msg", "[", "'From'", "]", "=", "self", ".", "from_address", "msg", "[", "'To'", "]", "=", "self", ".", "to_address", "msg", "[", "'Subject'", "]", "="...
Initiate a SMTP session and send an email.
[ "Initiate", "a", "SMTP", "session", "and", "send", "an", "email", "." ]
train
https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L27-L40
honzamach/pynspect
pynspect/jpath.py
jpath_parse
def jpath_parse(jpath): """ Parse given JPath into chunks. Returns list of dictionaries describing all of the JPath chunks. :param str jpath: JPath to be parsed into chunks :return: JPath chunks as list of dicts :rtype: :py:class:`list` :raises JPathException: in case of invalid JPath synt...
python
def jpath_parse(jpath): """ Parse given JPath into chunks. Returns list of dictionaries describing all of the JPath chunks. :param str jpath: JPath to be parsed into chunks :return: JPath chunks as list of dicts :rtype: :py:class:`list` :raises JPathException: in case of invalid JPath synt...
[ "def", "jpath_parse", "(", "jpath", ")", ":", "result", "=", "[", "]", "breadcrumbs", "=", "[", "]", "# Split JPath into chunks based on '.' character.", "chunks", "=", "jpath", ".", "split", "(", "'.'", ")", "for", "chnk", "in", "chunks", ":", "match", "=",...
Parse given JPath into chunks. Returns list of dictionaries describing all of the JPath chunks. :param str jpath: JPath to be parsed into chunks :return: JPath chunks as list of dicts :rtype: :py:class:`list` :raises JPathException: in case of invalid JPath syntax
[ "Parse", "given", "JPath", "into", "chunks", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L191-L235
honzamach/pynspect
pynspect/jpath.py
jpath_parse_c
def jpath_parse_c(jpath): """ Caching variant of :py:func:`jpath_parse` function. Same arguments and return value. For performance reasons thee is no copying and all returned values are references to internal cache. Treat the returned values as read only, or suffer the consequences. """ ...
python
def jpath_parse_c(jpath): """ Caching variant of :py:func:`jpath_parse` function. Same arguments and return value. For performance reasons thee is no copying and all returned values are references to internal cache. Treat the returned values as read only, or suffer the consequences. """ ...
[ "def", "jpath_parse_c", "(", "jpath", ")", ":", "if", "not", "jpath", "in", "_JPATH_CACHE", ":", "_JPATH_CACHE", "[", "jpath", "]", "=", "jpath_parse", "(", "jpath", ")", "return", "_JPATH_CACHE", "[", "jpath", "]" ]
Caching variant of :py:func:`jpath_parse` function. Same arguments and return value. For performance reasons thee is no copying and all returned values are references to internal cache. Treat the returned values as read only, or suffer the consequences.
[ "Caching", "variant", "of", ":", "py", ":", "func", ":", "jpath_parse", "function", ".", "Same", "arguments", "and", "return", "value", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L238-L249
honzamach/pynspect
pynspect/jpath.py
jpath_values
def jpath_values(structure, jpath): """ Return all values at given JPath within given data structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: found va...
python
def jpath_values(structure, jpath): """ Return all values at given JPath within given data structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: found va...
[ "def", "jpath_values", "(", "structure", ",", "jpath", ")", ":", "# Current working node set.", "nodes_a", "=", "[", "structure", "]", "# Next iteration working node set.", "nodes_b", "=", "[", "]", "# Process sequentially all JPath chunks.", "chunks", "=", "jpath_parse_c...
Return all values at given JPath within given data structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: found values as a list :rtype: :py:class:`list`
[ "Return", "all", "values", "at", "given", "JPath", "within", "given", "data", "structure", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L252-L313
honzamach/pynspect
pynspect/jpath.py
jpath_exists
def jpath_exists(structure, jpath): """ Check if node at given JPath within given data structure does exist. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: True or False :rtype: bool """ result = jpath_value(structure, jpath) if ...
python
def jpath_exists(structure, jpath): """ Check if node at given JPath within given data structure does exist. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: True or False :rtype: bool """ result = jpath_value(structure, jpath) if ...
[ "def", "jpath_exists", "(", "structure", ",", "jpath", ")", ":", "result", "=", "jpath_value", "(", "structure", ",", "jpath", ")", "if", "not", "result", "is", "None", ":", "return", "True", "return", "False" ]
Check if node at given JPath within given data structure does exist. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :return: True or False :rtype: bool
[ "Check", "if", "node", "at", "given", "JPath", "within", "given", "data", "structure", "does", "exist", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L333-L345
honzamach/pynspect
pynspect/jpath.py
jpath_set
def jpath_set(structure, jpath, value, overwrite = True, unique = False): """ Set given JPath to given value within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be ...
python
def jpath_set(structure, jpath, value, overwrite = True, unique = False): """ Set given JPath to given value within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be ...
[ "def", "jpath_set", "(", "structure", ",", "jpath", ",", "value", ",", "overwrite", "=", "True", ",", "unique", "=", "False", ")", ":", "chunks", "=", "jpath_parse_c", "(", "jpath", ")", "size", "=", "len", "(", "chunks", ")", "-", "1", "current", "=...
Set given JPath to given value within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be searched :param str jpath: JPath to be evaluated :param any value: value of any type to be set at given path :param b...
[ "Set", "given", "JPath", "to", "given", "value", "within", "given", "structure", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L348-L440
honzamach/pynspect
pynspect/jpath.py
jpath_unset
def jpath_unset(structure, jpath): """ Unset (delete) value at given JPath within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be trimmed :param str jpath: JPath to be evaluated """ chunks = jpat...
python
def jpath_unset(structure, jpath): """ Unset (delete) value at given JPath within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be trimmed :param str jpath: JPath to be evaluated """ chunks = jpat...
[ "def", "jpath_unset", "(", "structure", ",", "jpath", ")", ":", "chunks", "=", "jpath_parse_c", "(", "jpath", ")", "size", "=", "len", "(", "chunks", ")", "-", "1", "# Current working node set.", "nodes_a", "=", "[", "structure", "]", "# Next iteration working...
Unset (delete) value at given JPath within given structure. For performance reasons this method is intentionally not written as recursive. :param str structure: data structure to be trimmed :param str jpath: JPath to be evaluated
[ "Unset", "(", "delete", ")", "value", "at", "given", "JPath", "within", "given", "structure", "." ]
train
https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L442-L530
shreyaspotnis/rampage
rampage/queuer.py
queue_ramp_dicts
def queue_ramp_dicts(ramp_dict_list, server_ip_and_port): """Simple utility function to queue up a list of dictionaries.""" client = server.ClientForServer(server.BECServer, server_ip_and_port) for dct in ramp_dict_list: client.queue_ramp(dct) client.start({})
python
def queue_ramp_dicts(ramp_dict_list, server_ip_and_port): """Simple utility function to queue up a list of dictionaries.""" client = server.ClientForServer(server.BECServer, server_ip_and_port) for dct in ramp_dict_list: client.queue_ramp(dct) client.start({})
[ "def", "queue_ramp_dicts", "(", "ramp_dict_list", ",", "server_ip_and_port", ")", ":", "client", "=", "server", ".", "ClientForServer", "(", "server", ".", "BECServer", ",", "server_ip_and_port", ")", "for", "dct", "in", "ramp_dict_list", ":", "client", ".", "qu...
Simple utility function to queue up a list of dictionaries.
[ "Simple", "utility", "function", "to", "queue", "up", "a", "list", "of", "dictionaries", "." ]
train
https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L48-L53
shreyaspotnis/rampage
rampage/queuer.py
flatten_dict
def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]): """Returns a list of string identifiers for each element in dct. Recursively scans through dct and finds every element whose type is in allowed_types and adds a string indentifier for it. eg: dct = { 'a': 'a stri...
python
def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]): """Returns a list of string identifiers for each element in dct. Recursively scans through dct and finds every element whose type is in allowed_types and adds a string indentifier for it. eg: dct = { 'a': 'a stri...
[ "def", "flatten_dict", "(", "dct", ",", "separator", "=", "'-->'", ",", "allowed_types", "=", "[", "int", ",", "float", ",", "bool", "]", ")", ":", "flat_list", "=", "[", "]", "for", "key", "in", "sorted", "(", "dct", ")", ":", "if", "key", "[", ...
Returns a list of string identifiers for each element in dct. Recursively scans through dct and finds every element whose type is in allowed_types and adds a string indentifier for it. eg: dct = { 'a': 'a string', 'b': { 'c': 1.0, 'd': True ...
[ "Returns", "a", "list", "of", "string", "identifiers", "for", "each", "element", "in", "dct", "." ]
train
https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L57-L86
shreyaspotnis/rampage
rampage/queuer.py
set_dict_item
def set_dict_item(dct, name_string, set_to): """Sets dictionary item identified by name_string to set_to. name_string is the indentifier generated using flatten_dict. Maintains the type of the orginal object in dct and tries to convert set_to to that type. """ key_strings = str(name_string).sp...
python
def set_dict_item(dct, name_string, set_to): """Sets dictionary item identified by name_string to set_to. name_string is the indentifier generated using flatten_dict. Maintains the type of the orginal object in dct and tries to convert set_to to that type. """ key_strings = str(name_string).sp...
[ "def", "set_dict_item", "(", "dct", ",", "name_string", ",", "set_to", ")", ":", "key_strings", "=", "str", "(", "name_string", ")", ".", "split", "(", "'-->'", ")", "d", "=", "dct", "for", "ks", "in", "key_strings", "[", ":", "-", "1", "]", ":", "...
Sets dictionary item identified by name_string to set_to. name_string is the indentifier generated using flatten_dict. Maintains the type of the orginal object in dct and tries to convert set_to to that type.
[ "Sets", "dictionary", "item", "identified", "by", "name_string", "to", "set_to", "." ]
train
https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L89-L102
bitlabstudio/django-localized-names
localized_names/templatetags/localized_names_tags.py
get_name
def get_name(obj, setting_name='LONG_NAME_FORMAT'): """ Returns the correct order of the name according to the current language. """ nickname = obj.get_nickname() romanized_first_name = obj.get_romanized_first_name() romanized_last_name = obj.get_romanized_last_name() non_romanized_first_na...
python
def get_name(obj, setting_name='LONG_NAME_FORMAT'): """ Returns the correct order of the name according to the current language. """ nickname = obj.get_nickname() romanized_first_name = obj.get_romanized_first_name() romanized_last_name = obj.get_romanized_last_name() non_romanized_first_na...
[ "def", "get_name", "(", "obj", ",", "setting_name", "=", "'LONG_NAME_FORMAT'", ")", ":", "nickname", "=", "obj", ".", "get_nickname", "(", ")", "romanized_first_name", "=", "obj", ".", "get_romanized_first_name", "(", ")", "romanized_last_name", "=", "obj", ".",...
Returns the correct order of the name according to the current language.
[ "Returns", "the", "correct", "order", "of", "the", "name", "according", "to", "the", "current", "language", "." ]
train
https://github.com/bitlabstudio/django-localized-names/blob/d2a67fd256f6bf61f0e17b5d77aac1ec7ccfa0cb/localized_names/templatetags/localized_names_tags.py#L11-L65
jaraco/jaraco.ui
jaraco/ui/progress.py
countdown
def countdown(template, duration=datetime.timedelta(seconds=5)): """ Do a countdown for duration, printing the template (which may accept one positional argument). Template should be something like ``countdown complete in {} seconds.`` """ now = datetime.datetime.now() deadline = now + duration remaining = dead...
python
def countdown(template, duration=datetime.timedelta(seconds=5)): """ Do a countdown for duration, printing the template (which may accept one positional argument). Template should be something like ``countdown complete in {} seconds.`` """ now = datetime.datetime.now() deadline = now + duration remaining = dead...
[ "def", "countdown", "(", "template", ",", "duration", "=", "datetime", ".", "timedelta", "(", "seconds", "=", "5", ")", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "deadline", "=", "now", "+", "duration", "remaining", "=", ...
Do a countdown for duration, printing the template (which may accept one positional argument). Template should be something like ``countdown complete in {} seconds.``
[ "Do", "a", "countdown", "for", "duration", "printing", "the", "template", "(", "which", "may", "accept", "one", "positional", "argument", ")", ".", "Template", "should", "be", "something", "like", "countdown", "complete", "in", "{}", "seconds", "." ]
train
https://github.com/jaraco/jaraco.ui/blob/10e844c03f3afb3d37bd5d727ba9334af2547fcf/jaraco/ui/progress.py#L135-L153
Vito2015/pyextend
pyextend/core/wrappers/timethis.py
timethis
def timethis(func): """A wrapper use for timeit.""" func_module, func_name = func.__module__, func.__name__ @functools.wraps(func) def wrapper(*args, **kwargs): start = _time_perf_counter() r = func(*args, **kwargs) end = _time_perf_counter() print('timethis : <{}.{}> : ...
python
def timethis(func): """A wrapper use for timeit.""" func_module, func_name = func.__module__, func.__name__ @functools.wraps(func) def wrapper(*args, **kwargs): start = _time_perf_counter() r = func(*args, **kwargs) end = _time_perf_counter() print('timethis : <{}.{}> : ...
[ "def", "timethis", "(", "func", ")", ":", "func_module", ",", "func_name", "=", "func", ".", "__module__", ",", "func", ".", "__name__", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")...
A wrapper use for timeit.
[ "A", "wrapper", "use", "for", "timeit", "." ]
train
https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/wrappers/timethis.py#L23-L34
biocore/mustached-octo-ironman
moi/group.py
create_info
def create_info(name, info_type, url=None, parent=None, id=None, context=ctx_default, store=False): """Return a group object""" id = str(uuid4()) if id is None else id pubsub = _pubsub_key(id) info = {'id': id, 'type': info_type, 'pubsub': pubsub, 'ur...
python
def create_info(name, info_type, url=None, parent=None, id=None, context=ctx_default, store=False): """Return a group object""" id = str(uuid4()) if id is None else id pubsub = _pubsub_key(id) info = {'id': id, 'type': info_type, 'pubsub': pubsub, 'ur...
[ "def", "create_info", "(", "name", ",", "info_type", ",", "url", "=", "None", ",", "parent", "=", "None", ",", "id", "=", "None", ",", "context", "=", "ctx_default", ",", "store", "=", "False", ")", ":", "id", "=", "str", "(", "uuid4", "(", ")", ...
Return a group object
[ "Return", "a", "group", "object" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L351-L376
biocore/mustached-octo-ironman
moi/group.py
get_id_from_user
def get_id_from_user(user): """Get an ID from a user, creates if necessary""" id = r_client.hget('user-id-map', user) if id is None: id = str(uuid4()) r_client.hset('user-id-map', user, id) r_client.hset('user-id-map', id, user) return id
python
def get_id_from_user(user): """Get an ID from a user, creates if necessary""" id = r_client.hget('user-id-map', user) if id is None: id = str(uuid4()) r_client.hset('user-id-map', user, id) r_client.hset('user-id-map', id, user) return id
[ "def", "get_id_from_user", "(", "user", ")", ":", "id", "=", "r_client", ".", "hget", "(", "'user-id-map'", ",", "user", ")", "if", "id", "is", "None", ":", "id", "=", "str", "(", "uuid4", "(", ")", ")", "r_client", ".", "hset", "(", "'user-id-map'",...
Get an ID from a user, creates if necessary
[ "Get", "an", "ID", "from", "a", "user", "creates", "if", "necessary" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L384-L391
biocore/mustached-octo-ironman
moi/group.py
Group.traverse
def traverse(self, id_=None): """Traverse groups and yield info dicts for jobs""" if id_ is None: id_ = self.group nodes = r_client.smembers(_children_key(id_)) while nodes: current_id = nodes.pop() details = r_client.get(current_id) if d...
python
def traverse(self, id_=None): """Traverse groups and yield info dicts for jobs""" if id_ is None: id_ = self.group nodes = r_client.smembers(_children_key(id_)) while nodes: current_id = nodes.pop() details = r_client.get(current_id) if d...
[ "def", "traverse", "(", "self", ",", "id_", "=", "None", ")", ":", "if", "id_", "is", "None", ":", "id_", "=", "self", ".", "group", "nodes", "=", "r_client", ".", "smembers", "(", "_children_key", "(", "id_", ")", ")", "while", "nodes", ":", "curr...
Traverse groups and yield info dicts for jobs
[ "Traverse", "groups", "and", "yield", "info", "dicts", "for", "jobs" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L83-L104
biocore/mustached-octo-ironman
moi/group.py
Group.close
def close(self): """Unsubscribe the group and all jobs being listened too""" for channel in self._listening_to: self.toredis.unsubscribe(channel) self.toredis.unsubscribe(self.group_pubsub)
python
def close(self): """Unsubscribe the group and all jobs being listened too""" for channel in self._listening_to: self.toredis.unsubscribe(channel) self.toredis.unsubscribe(self.group_pubsub)
[ "def", "close", "(", "self", ")", ":", "for", "channel", "in", "self", ".", "_listening_to", ":", "self", ".", "toredis", ".", "unsubscribe", "(", "channel", ")", "self", ".", "toredis", ".", "unsubscribe", "(", "self", ".", "group_pubsub", ")" ]
Unsubscribe the group and all jobs being listened too
[ "Unsubscribe", "the", "group", "and", "all", "jobs", "being", "listened", "too" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L109-L113
biocore/mustached-octo-ironman
moi/group.py
Group.listen_for_updates
def listen_for_updates(self): """Attach a callback on the group pubsub""" self.toredis.subscribe(self.group_pubsub, callback=self.callback)
python
def listen_for_updates(self): """Attach a callback on the group pubsub""" self.toredis.subscribe(self.group_pubsub, callback=self.callback)
[ "def", "listen_for_updates", "(", "self", ")", ":", "self", ".", "toredis", ".", "subscribe", "(", "self", ".", "group_pubsub", ",", "callback", "=", "self", ".", "callback", ")" ]
Attach a callback on the group pubsub
[ "Attach", "a", "callback", "on", "the", "group", "pubsub" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L126-L128
biocore/mustached-octo-ironman
moi/group.py
Group.listen_to_node
def listen_to_node(self, id_): """Attach a callback on the job pubsub if it exists""" if r_client.get(id_) is None: return else: self.toredis.subscribe(_pubsub_key(id_), callback=self.callback) self._listening_to[_pubsub_key(id_)] = id_ return id_
python
def listen_to_node(self, id_): """Attach a callback on the job pubsub if it exists""" if r_client.get(id_) is None: return else: self.toredis.subscribe(_pubsub_key(id_), callback=self.callback) self._listening_to[_pubsub_key(id_)] = id_ return id_
[ "def", "listen_to_node", "(", "self", ",", "id_", ")", ":", "if", "r_client", ".", "get", "(", "id_", ")", "is", "None", ":", "return", "else", ":", "self", ".", "toredis", ".", "subscribe", "(", "_pubsub_key", "(", "id_", ")", ",", "callback", "=", ...
Attach a callback on the job pubsub if it exists
[ "Attach", "a", "callback", "on", "the", "job", "pubsub", "if", "it", "exists" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L130-L137
biocore/mustached-octo-ironman
moi/group.py
Group.unlisten_to_node
def unlisten_to_node(self, id_): """Stop listening to a job Parameters ---------- id_ : str An ID to remove Returns -------- str or None The ID removed or None if the ID was not removed """ id_pubsub = _pubsub_key(id_) ...
python
def unlisten_to_node(self, id_): """Stop listening to a job Parameters ---------- id_ : str An ID to remove Returns -------- str or None The ID removed or None if the ID was not removed """ id_pubsub = _pubsub_key(id_) ...
[ "def", "unlisten_to_node", "(", "self", ",", "id_", ")", ":", "id_pubsub", "=", "_pubsub_key", "(", "id_", ")", "if", "id_pubsub", "in", "self", ".", "_listening_to", ":", "del", "self", ".", "_listening_to", "[", "id_pubsub", "]", "self", ".", "toredis", ...
Stop listening to a job Parameters ---------- id_ : str An ID to remove Returns -------- str or None The ID removed or None if the ID was not removed
[ "Stop", "listening", "to", "a", "job" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L139-L163
biocore/mustached-octo-ironman
moi/group.py
Group.callback
def callback(self, msg): """Accept a message that was published, process and forward Parameters ---------- msg : tuple, (str, str, str) The message sent over the line. The `tuple` is of the form: (message_type, channel, payload). Notes ----- ...
python
def callback(self, msg): """Accept a message that was published, process and forward Parameters ---------- msg : tuple, (str, str, str) The message sent over the line. The `tuple` is of the form: (message_type, channel, payload). Notes ----- ...
[ "def", "callback", "(", "self", ",", "msg", ")", ":", "message_type", ",", "channel", ",", "payload", "=", "msg", "if", "message_type", "!=", "'message'", ":", "return", "try", ":", "payload", "=", "self", ".", "_decode", "(", "payload", ")", "except", ...
Accept a message that was published, process and forward Parameters ---------- msg : tuple, (str, str, str) The message sent over the line. The `tuple` is of the form: (message_type, channel, payload). Notes ----- This method only handles message...
[ "Accept", "a", "message", "that", "was", "published", "process", "and", "forward" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L165-L202
biocore/mustached-octo-ironman
moi/group.py
Group.action
def action(self, verb, args): """Process the described action Parameters ---------- verb : str, {'add', 'remove', 'get'} The specific action to perform args : {list, set, tuple} Any relevant arguments for the action. Raises ------ ...
python
def action(self, verb, args): """Process the described action Parameters ---------- verb : str, {'add', 'remove', 'get'} The specific action to perform args : {list, set, tuple} Any relevant arguments for the action. Raises ------ ...
[ "def", "action", "(", "self", ",", "verb", ",", "args", ")", ":", "if", "not", "isinstance", "(", "args", ",", "(", "list", ",", "set", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "\"args is unknown type: %s\"", "%", "type", "(", "args", ...
Process the described action Parameters ---------- verb : str, {'add', 'remove', 'get'} The specific action to perform args : {list, set, tuple} Any relevant arguments for the action. Raises ------ TypeError If args is an unre...
[ "Process", "the", "described", "action" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L204-L238
biocore/mustached-octo-ironman
moi/group.py
Group._action_add
def _action_add(self, ids): """Add IDs to the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to add Returns ------- list of dict The details of the added jobs """ return self._action_get((se...
python
def _action_add(self, ids): """Add IDs to the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to add Returns ------- list of dict The details of the added jobs """ return self._action_get((se...
[ "def", "_action_add", "(", "self", ",", "ids", ")", ":", "return", "self", ".", "_action_get", "(", "(", "self", ".", "listen_to_node", "(", "id_", ")", "for", "id_", "in", "ids", ")", ")" ]
Add IDs to the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to add Returns ------- list of dict The details of the added jobs
[ "Add", "IDs", "to", "the", "group" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L272-L285
biocore/mustached-octo-ironman
moi/group.py
Group._action_remove
def _action_remove(self, ids): """Remove IDs from the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to remove Returns ------- list of dict The details of the removed jobs """ return self._a...
python
def _action_remove(self, ids): """Remove IDs from the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to remove Returns ------- list of dict The details of the removed jobs """ return self._a...
[ "def", "_action_remove", "(", "self", ",", "ids", ")", ":", "return", "self", ".", "_action_get", "(", "(", "self", ".", "unlisten_to_node", "(", "id_", ")", "for", "id_", "in", "ids", ")", ")" ]
Remove IDs from the group Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to remove Returns ------- list of dict The details of the removed jobs
[ "Remove", "IDs", "from", "the", "group" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L287-L300
biocore/mustached-octo-ironman
moi/group.py
Group._action_get
def _action_get(self, ids): """Get the details for ids Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to get Notes ----- If ids is empty, then all IDs are returned. Returns ------- list of dict ...
python
def _action_get(self, ids): """Get the details for ids Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to get Notes ----- If ids is empty, then all IDs are returned. Returns ------- list of dict ...
[ "def", "_action_get", "(", "self", ",", "ids", ")", ":", "if", "not", "ids", ":", "ids", "=", "self", ".", "jobs", "result", "=", "[", "]", "ids", "=", "set", "(", "ids", ")", "while", "ids", ":", "id_", "=", "ids", ".", "pop", "(", ")", "if"...
Get the details for ids Parameters ---------- ids : {list, set, tuple, generator} of str The IDs to get Notes ----- If ids is empty, then all IDs are returned. Returns ------- list of dict The details of the jobs
[ "Get", "the", "details", "for", "ids" ]
train
https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L302-L348
jordanncg/Bison
bison/libs/process.py
main
def main(): """Main method that runs the build""" data = Common.open_file(F_INFO) config = Common.open_file(F_CONFIG) file_full_path = "" env = load_jinja2_env(config['p_template']) for index, page in data.iteritems(): logging.info('Creating ' + index + ' page:') template = en...
python
def main(): """Main method that runs the build""" data = Common.open_file(F_INFO) config = Common.open_file(F_CONFIG) file_full_path = "" env = load_jinja2_env(config['p_template']) for index, page in data.iteritems(): logging.info('Creating ' + index + ' page:') template = en...
[ "def", "main", "(", ")", ":", "data", "=", "Common", ".", "open_file", "(", "F_INFO", ")", "config", "=", "Common", ".", "open_file", "(", "F_CONFIG", ")", "file_full_path", "=", "\"\"", "env", "=", "load_jinja2_env", "(", "config", "[", "'p_template'", ...
Main method that runs the build
[ "Main", "method", "that", "runs", "the", "build" ]
train
https://github.com/jordanncg/Bison/blob/c7f04fd67d141fe26cd29db3c3fb3fc0fd0c45df/bison/libs/process.py#L33-L65
PRIArobotics/HedgehogUtils
hedgehog/utils/zmq/__init__.py
_ConfigureSocketMixin.configure
def configure(self, *, hwm: int=None, rcvtimeo: int=None, sndtimeo: int=None, linger: int=None) -> 'Socket': """ Allows to configure some common socket options and configurations, while allowing method chaining """ if hwm is not None: self.set_hwm(hwm) if rcvtimeo is ...
python
def configure(self, *, hwm: int=None, rcvtimeo: int=None, sndtimeo: int=None, linger: int=None) -> 'Socket': """ Allows to configure some common socket options and configurations, while allowing method chaining """ if hwm is not None: self.set_hwm(hwm) if rcvtimeo is ...
[ "def", "configure", "(", "self", ",", "*", ",", "hwm", ":", "int", "=", "None", ",", "rcvtimeo", ":", "int", "=", "None", ",", "sndtimeo", ":", "int", "=", "None", ",", "linger", ":", "int", "=", "None", ")", "->", "'Socket'", ":", "if", "hwm", ...
Allows to configure some common socket options and configurations, while allowing method chaining
[ "Allows", "to", "configure", "some", "common", "socket", "options", "and", "configurations", "while", "allowing", "method", "chaining" ]
train
https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/zmq/__init__.py#L11-L23
PRIArobotics/HedgehogUtils
hedgehog/utils/zmq/__init__.py
_AsyncSocketExtensionsMixin.recv_multipart_expect
async def recv_multipart_expect(self, data: Tuple[bytes, ...]=(b'',)) -> None: """ Waits for the next multipart message and asserts that it contains the given data. """ expect_all(await self.recv_multipart(), data)
python
async def recv_multipart_expect(self, data: Tuple[bytes, ...]=(b'',)) -> None: """ Waits for the next multipart message and asserts that it contains the given data. """ expect_all(await self.recv_multipart(), data)
[ "async", "def", "recv_multipart_expect", "(", "self", ",", "data", ":", "Tuple", "[", "bytes", ",", "...", "]", "=", "(", "b''", ",", ")", ")", "->", "None", ":", "expect_all", "(", "await", "self", ".", "recv_multipart", "(", ")", ",", "data", ")" ]
Waits for the next multipart message and asserts that it contains the given data.
[ "Waits", "for", "the", "next", "multipart", "message", "and", "asserts", "that", "it", "contains", "the", "given", "data", "." ]
train
https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/zmq/__init__.py#L71-L75
renzon/gaepagseguro
gaepagseguro/pagseguro_facade.py
generate_payment
def generate_payment(redirect_url, client_name, client_email, payment_owner, validate_address_cmd, *validate_item_cmds): """ Function used to generate a payment on pagseguro See facade_tests to undestand the steps before generating a payment @param redirect_url: the url where payment status change mus...
python
def generate_payment(redirect_url, client_name, client_email, payment_owner, validate_address_cmd, *validate_item_cmds): """ Function used to generate a payment on pagseguro See facade_tests to undestand the steps before generating a payment @param redirect_url: the url where payment status change mus...
[ "def", "generate_payment", "(", "redirect_url", ",", "client_name", ",", "client_email", ",", "payment_owner", ",", "validate_address_cmd", ",", "*", "validate_item_cmds", ")", ":", "return", "GeneratePayment", "(", "redirect_url", ",", "client_name", ",", "client_ema...
Function used to generate a payment on pagseguro See facade_tests to undestand the steps before generating a payment @param redirect_url: the url where payment status change must be sent @param client_name: client's name @param client_email: client's email @param payment_owner: owner of payment. H...
[ "Function", "used", "to", "generate", "a", "payment", "on", "pagseguro", "See", "facade_tests", "to", "undestand", "the", "steps", "before", "generating", "a", "payment" ]
train
https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/pagseguro_facade.py#L57-L72
renzon/gaepagseguro
gaepagseguro/pagseguro_facade.py
validate_address_cmd
def validate_address_cmd(street, number, quarter, postalcode, town, state, complement="Sem Complemento"): """ Build an address form to be used with payment function """ return ValidateAddressCmd(street=street, number=number, quarter=quarter, postalcode=postalcode, town=town, ...
python
def validate_address_cmd(street, number, quarter, postalcode, town, state, complement="Sem Complemento"): """ Build an address form to be used with payment function """ return ValidateAddressCmd(street=street, number=number, quarter=quarter, postalcode=postalcode, town=town, ...
[ "def", "validate_address_cmd", "(", "street", ",", "number", ",", "quarter", ",", "postalcode", ",", "town", ",", "state", ",", "complement", "=", "\"Sem Complemento\"", ")", ":", "return", "ValidateAddressCmd", "(", "street", "=", "street", ",", "number", "="...
Build an address form to be used with payment function
[ "Build", "an", "address", "form", "to", "be", "used", "with", "payment", "function" ]
train
https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/pagseguro_facade.py#L87-L92
renzon/gaepagseguro
gaepagseguro/pagseguro_facade.py
validate_item_cmd
def validate_item_cmd(description, price, quantity, reference=None): """ Create a commando to save items from the order. A list of items or commands must be created to save a order @param description: Item's description @param price: Item's price @param quantity: Item's quantity @param refer...
python
def validate_item_cmd(description, price, quantity, reference=None): """ Create a commando to save items from the order. A list of items or commands must be created to save a order @param description: Item's description @param price: Item's price @param quantity: Item's quantity @param refer...
[ "def", "validate_item_cmd", "(", "description", ",", "price", ",", "quantity", ",", "reference", "=", "None", ")", ":", "return", "ValidateItemCmd", "(", "description", "=", "description", ",", "price", "=", "price", ",", "quantity", "=", "quantity", ",", "r...
Create a commando to save items from the order. A list of items or commands must be created to save a order @param description: Item's description @param price: Item's price @param quantity: Item's quantity @param reference: a product reference for the item. Must be a Node @return: A Command tha...
[ "Create", "a", "commando", "to", "save", "items", "from", "the", "order", ".", "A", "list", "of", "items", "or", "commands", "must", "be", "created", "to", "save", "a", "order" ]
train
https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/pagseguro_facade.py#L95-L105
renzon/gaepagseguro
gaepagseguro/pagseguro_facade.py
search_all_payments
def search_all_payments(payment_status=None, page_size=20, start_cursor=None, offset=0, use_cache=True, cache_begin=True, relations=None): """ Returns a command to search all payments ordered by creation desc @param payment_status: The payment status. If None is going to return resul...
python
def search_all_payments(payment_status=None, page_size=20, start_cursor=None, offset=0, use_cache=True, cache_begin=True, relations=None): """ Returns a command to search all payments ordered by creation desc @param payment_status: The payment status. If None is going to return resul...
[ "def", "search_all_payments", "(", "payment_status", "=", "None", ",", "page_size", "=", "20", ",", "start_cursor", "=", "None", ",", "offset", "=", "0", ",", "use_cache", "=", "True", ",", "cache_begin", "=", "True", ",", "relations", "=", "None", ")", ...
Returns a command to search all payments ordered by creation desc @param payment_status: The payment status. If None is going to return results independent from status @param page_size: number of payments per page @param start_cursor: cursor to continue the search @param offset: offset number of payment...
[ "Returns", "a", "command", "to", "search", "all", "payments", "ordered", "by", "creation", "desc" ]
train
https://github.com/renzon/gaepagseguro/blob/c88f00580c380ff5b35d873311d6c786fa1f29d2/gaepagseguro/pagseguro_facade.py#L127-L143
TAPPGuild/tapp-config
tapp_config.py
get_config
def get_config(name=__name__): """ Get a configuration parser for a given TAPP name. Reads config.ini files only, not in-database configuration records. :param name: The tapp name to get a configuration for. :rtype: ConfigParser :return: A config parser matching the given name """ cfg =...
python
def get_config(name=__name__): """ Get a configuration parser for a given TAPP name. Reads config.ini files only, not in-database configuration records. :param name: The tapp name to get a configuration for. :rtype: ConfigParser :return: A config parser matching the given name """ cfg =...
[ "def", "get_config", "(", "name", "=", "__name__", ")", ":", "cfg", "=", "ConfigParser", "(", ")", "path", "=", "os", ".", "environ", ".", "get", "(", "'%s_CONFIG_FILE'", "%", "name", ".", "upper", "(", ")", ")", "if", "path", "is", "None", "or", "...
Get a configuration parser for a given TAPP name. Reads config.ini files only, not in-database configuration records. :param name: The tapp name to get a configuration for. :rtype: ConfigParser :return: A config parser matching the given name
[ "Get", "a", "configuration", "parser", "for", "a", "given", "TAPP", "name", ".", "Reads", "config", ".", "ini", "files", "only", "not", "in", "-", "database", "configuration", "records", "." ]
train
https://github.com/TAPPGuild/tapp-config/blob/20fdbe00e4763f38a90845ad2cfb63c94e13ca81/tapp_config.py#L20-L41
TAPPGuild/tapp-config
tapp_config.py
setup_logging
def setup_logging(name, prefix="trademanager", cfg=None): """ Create a logger, based on the given configuration. Accepts LOGFILE and LOGLEVEL settings. :param name: the name of the tapp to log :param cfg: The configuration object with logging info. :return: The session and the engine as a list ...
python
def setup_logging(name, prefix="trademanager", cfg=None): """ Create a logger, based on the given configuration. Accepts LOGFILE and LOGLEVEL settings. :param name: the name of the tapp to log :param cfg: The configuration object with logging info. :return: The session and the engine as a list ...
[ "def", "setup_logging", "(", "name", ",", "prefix", "=", "\"trademanager\"", ",", "cfg", "=", "None", ")", ":", "logname", "=", "\"/var/log/%s/%s_tapp.log\"", "%", "(", "prefix", ",", "name", ")", "logfile", "=", "cfg", ".", "get", "(", "'log'", ",", "'L...
Create a logger, based on the given configuration. Accepts LOGFILE and LOGLEVEL settings. :param name: the name of the tapp to log :param cfg: The configuration object with logging info. :return: The session and the engine as a list (in that order)
[ "Create", "a", "logger", "based", "on", "the", "given", "configuration", ".", "Accepts", "LOGFILE", "and", "LOGLEVEL", "settings", "." ]
train
https://github.com/TAPPGuild/tapp-config/blob/20fdbe00e4763f38a90845ad2cfb63c94e13ca81/tapp_config.py#L44-L59
edwards-lab/libGWAS
libgwas/pheno_covar.py
PhenoCovar.destandardize_variables
def destandardize_variables(self, tv, blin, bvar, errBeta, nonmissing): """Destandardize betas and other components.""" return self.test_variables.destandardize(tv, blin, bvar, errBeta, nonmissing)
python
def destandardize_variables(self, tv, blin, bvar, errBeta, nonmissing): """Destandardize betas and other components.""" return self.test_variables.destandardize(tv, blin, bvar, errBeta, nonmissing)
[ "def", "destandardize_variables", "(", "self", ",", "tv", ",", "blin", ",", "bvar", ",", "errBeta", ",", "nonmissing", ")", ":", "return", "self", ".", "test_variables", ".", "destandardize", "(", "tv", ",", "blin", ",", "bvar", ",", "errBeta", ",", "non...
Destandardize betas and other components.
[ "Destandardize", "betas", "and", "other", "components", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/pheno_covar.py#L89-L91
edwards-lab/libGWAS
libgwas/pheno_covar.py
PhenoCovar.freeze_subjects
def freeze_subjects(self): """Converts variable data into numpy arrays. This is required after all subjects have been added via the add_subject function, since we don't know ahead of time who is participating in the analysis due to various filtering possibilities. """ se...
python
def freeze_subjects(self): """Converts variable data into numpy arrays. This is required after all subjects have been added via the add_subject function, since we don't know ahead of time who is participating in the analysis due to various filtering possibilities. """ se...
[ "def", "freeze_subjects", "(", "self", ")", ":", "self", ".", "phenotype_data", "=", "numpy", ".", "array", "(", "self", ".", "phenotype_data", ")", "self", ".", "covariate_data", "=", "numpy", ".", "array", "(", "self", ".", "covariate_data", ")" ]
Converts variable data into numpy arrays. This is required after all subjects have been added via the add_subject function, since we don't know ahead of time who is participating in the analysis due to various filtering possibilities.
[ "Converts", "variable", "data", "into", "numpy", "arrays", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/pheno_covar.py#L94-L102
edwards-lab/libGWAS
libgwas/pheno_covar.py
PhenoCovar.add_subject
def add_subject(self, ind_id, sex=None, phenotype=None): """Add new subject to study, with optional sex and phenotype Throws MalformedInputFile if sex is can't be converted to int """ self.pedigree_data[ind_id] = len(self.phenotype_data[0]) if phenotype != None: if ...
python
def add_subject(self, ind_id, sex=None, phenotype=None): """Add new subject to study, with optional sex and phenotype Throws MalformedInputFile if sex is can't be converted to int """ self.pedigree_data[ind_id] = len(self.phenotype_data[0]) if phenotype != None: if ...
[ "def", "add_subject", "(", "self", ",", "ind_id", ",", "sex", "=", "None", ",", "phenotype", "=", "None", ")", ":", "self", ".", "pedigree_data", "[", "ind_id", "]", "=", "len", "(", "self", ".", "phenotype_data", "[", "0", "]", ")", "if", "phenotype...
Add new subject to study, with optional sex and phenotype Throws MalformedInputFile if sex is can't be converted to int
[ "Add", "new", "subject", "to", "study", "with", "optional", "sex", "and", "phenotype" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/pheno_covar.py#L106-L124
edwards-lab/libGWAS
libgwas/pheno_covar.py
PhenoCovar.load_phenofile
def load_phenofile(self, file, indices=[], names=[], sample_file=False): """Load phenotype data from phenotype file Whitespace delimited, FAMID, INDID, VAR1, [VAR2], etc Users can specify phenotypes of interest via indices and names. Indices are 1 based and start with the first variabl...
python
def load_phenofile(self, file, indices=[], names=[], sample_file=False): """Load phenotype data from phenotype file Whitespace delimited, FAMID, INDID, VAR1, [VAR2], etc Users can specify phenotypes of interest via indices and names. Indices are 1 based and start with the first variabl...
[ "def", "load_phenofile", "(", "self", ",", "file", ",", "indices", "=", "[", "]", ",", "names", "=", "[", "]", ",", "sample_file", "=", "False", ")", ":", "file", ".", "seek", "(", "0", ")", "self", ".", "phenotype_names", "=", "[", "]", "if", "f...
Load phenotype data from phenotype file Whitespace delimited, FAMID, INDID, VAR1, [VAR2], etc Users can specify phenotypes of interest via indices and names. Indices are 1 based and start with the first variable. names must match name specified in the header (case is ignored).
[ "Load", "phenotype", "data", "from", "phenotype", "file" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/pheno_covar.py#L126-L228
edwards-lab/libGWAS
libgwas/pheno_covar.py
PhenoCovar.load_covarfile
def load_covarfile(self, file, indices=[], names=[], sample_file=False): """Load covariate data from file. Unlike phenofiles, if we already have data, we keep it (that would be the sex covariate)""" # Clean up input in case we are given some empty values var_indices = [] for x ...
python
def load_covarfile(self, file, indices=[], names=[], sample_file=False): """Load covariate data from file. Unlike phenofiles, if we already have data, we keep it (that would be the sex covariate)""" # Clean up input in case we are given some empty values var_indices = [] for x ...
[ "def", "load_covarfile", "(", "self", ",", "file", ",", "indices", "=", "[", "]", ",", "names", "=", "[", "]", ",", "sample_file", "=", "False", ")", ":", "# Clean up input in case we are given some empty values", "var_indices", "=", "[", "]", "for", "x", "i...
Load covariate data from file. Unlike phenofiles, if we already have data, we keep it (that would be the sex covariate)
[ "Load", "covariate", "data", "from", "file", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/pheno_covar.py#L230-L321
tBaxter/tango-shared-core
build/lib/tango_shared/templatetags/tango_time_tags.py
format_time
def format_time(date_obj, time_obj=None, datebox=False, dt_type=None, classes=None): """ Returns formatted HTML5 elements based on given datetime object. By default returns a time element, but will return a .datebox if requested. dt_type allows passing dt_start or dt_end for hcal formatting. link a...
python
def format_time(date_obj, time_obj=None, datebox=False, dt_type=None, classes=None): """ Returns formatted HTML5 elements based on given datetime object. By default returns a time element, but will return a .datebox if requested. dt_type allows passing dt_start or dt_end for hcal formatting. link a...
[ "def", "format_time", "(", "date_obj", ",", "time_obj", "=", "None", ",", "datebox", "=", "False", ",", "dt_type", "=", "None", ",", "classes", "=", "None", ")", ":", "if", "not", "time_obj", ":", "time_obj", "=", "getattr", "(", "date_obj", ",", "'tim...
Returns formatted HTML5 elements based on given datetime object. By default returns a time element, but will return a .datebox if requested. dt_type allows passing dt_start or dt_end for hcal formatting. link allows passing a url to the datebox. classes allows sending arbitrary classnames. Useful for ...
[ "Returns", "formatted", "HTML5", "elements", "based", "on", "given", "datetime", "object", ".", "By", "default", "returns", "a", "time", "element", "but", "will", "return", "a", ".", "datebox", "if", "requested", "." ]
train
https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/templatetags/tango_time_tags.py#L10-L40
tBaxter/tango-shared-core
build/lib/tango_shared/templatetags/tango_time_tags.py
short_timesince
def short_timesince(date): """ A shorter version of Django's built-in timesince filter. Selects only the first part of the returned string, splitting on the comma. Falls back on default Django timesince if it fails. Example: 3 days, 20 hours becomes "3 days". """ try: t = time...
python
def short_timesince(date): """ A shorter version of Django's built-in timesince filter. Selects only the first part of the returned string, splitting on the comma. Falls back on default Django timesince if it fails. Example: 3 days, 20 hours becomes "3 days". """ try: t = time...
[ "def", "short_timesince", "(", "date", ")", ":", "try", ":", "t", "=", "timesince", "(", "date", ")", ".", "split", "(", "\", \"", ")", "[", "0", "]", "except", "IndexError", ":", "t", "=", "timesince", "(", "date", ")", "return", "t" ]
A shorter version of Django's built-in timesince filter. Selects only the first part of the returned string, splitting on the comma. Falls back on default Django timesince if it fails. Example: 3 days, 20 hours becomes "3 days".
[ "A", "shorter", "version", "of", "Django", "s", "built", "-", "in", "timesince", "filter", ".", "Selects", "only", "the", "first", "part", "of", "the", "returned", "string", "splitting", "on", "the", "comma", "." ]
train
https://github.com/tBaxter/tango-shared-core/blob/35fc10aef1ceedcdb4d6d866d44a22efff718812/build/lib/tango_shared/templatetags/tango_time_tags.py#L44-L59