repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
MSchnei/pyprf_feature
pyprf_feature/analysis/old/pRF_mdlCrt.py
crtPrfNrlTc
def crtPrfNrlTc(aryBoxCar, varNumMtDrctn, varNumVol, tplPngSize, varNumX, varExtXmin, varExtXmax, varNumY, varExtYmin, varExtYmax, varNumPrfSizes, varPrfStdMin, varPrfStdMax, varPar): """Create neural model time courses from pixel-wise boxcar functions. Parameters ---------...
python
def crtPrfNrlTc(aryBoxCar, varNumMtDrctn, varNumVol, tplPngSize, varNumX, varExtXmin, varExtXmax, varNumY, varExtYmin, varExtYmax, varNumPrfSizes, varPrfStdMin, varPrfStdMax, varPar): """Create neural model time courses from pixel-wise boxcar functions. Parameters ---------...
[ "def", "crtPrfNrlTc", "(", "aryBoxCar", ",", "varNumMtDrctn", ",", "varNumVol", ",", "tplPngSize", ",", "varNumX", ",", "varExtXmin", ",", "varExtXmax", ",", "varNumY", ",", "varExtYmin", ",", "varExtYmax", ",", "varNumPrfSizes", ",", "varPrfStdMin", ",", "varPr...
Create neural model time courses from pixel-wise boxcar functions. Parameters ---------- aryBoxCar : 4d numpy array, shape [n_x_pix, n_y_pix, n_mtn_dir, n_vol] Description of input 1. varNumMtDrctn : float, positive Description of input 2. varNumVol : float, positive Descrip...
[ "Create", "neural", "model", "time", "courses", "from", "pixel", "-", "wise", "boxcar", "functions", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L253-L445
MSchnei/pyprf_feature
pyprf_feature/analysis/old/pRF_mdlCrt.py
cnvlPwBoxCarFn
def cnvlPwBoxCarFn(aryNrlTc, varNumVol, varTr, tplPngSize, varNumMtDrctn, switchHrfSet, lgcOldSchoolHrf, varPar,): """Create 2D Gaussian kernel. Parameters ---------- aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol] Description of input 1. varNu...
python
def cnvlPwBoxCarFn(aryNrlTc, varNumVol, varTr, tplPngSize, varNumMtDrctn, switchHrfSet, lgcOldSchoolHrf, varPar,): """Create 2D Gaussian kernel. Parameters ---------- aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol] Description of input 1. varNu...
[ "def", "cnvlPwBoxCarFn", "(", "aryNrlTc", ",", "varNumVol", ",", "varTr", ",", "tplPngSize", ",", "varNumMtDrctn", ",", "switchHrfSet", ",", "lgcOldSchoolHrf", ",", "varPar", ",", ")", ":", "print", "(", "'------Convolve every pixel box car function with hrf function(s)...
Create 2D Gaussian kernel. Parameters ---------- aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol] Description of input 1. varNumVol : float, positive Description of input 2. varTr : float, positive Description of input 1. tplPngSize : tuple ...
[ "Create", "2D", "Gaussian", "kernel", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L448-L562
MSchnei/pyprf_feature
pyprf_feature/analysis/old/pRF_mdlCrt.py
rsmplInHighRes
def rsmplInHighRes(aryBoxCarConv, tplPngSize, tplVslSpcHighSze, varNumMtDrctn, varNumVol): """Resample pixel-time courses in high-res visual space. Parameters ---------- input1 : 2d numpy array, shape [n_samples, n_measurements...
python
def rsmplInHighRes(aryBoxCarConv, tplPngSize, tplVslSpcHighSze, varNumMtDrctn, varNumVol): """Resample pixel-time courses in high-res visual space. Parameters ---------- input1 : 2d numpy array, shape [n_samples, n_measurements...
[ "def", "rsmplInHighRes", "(", "aryBoxCarConv", ",", "tplPngSize", ",", "tplVslSpcHighSze", ",", "varNumMtDrctn", ",", "varNumVol", ")", ":", "# Array for super-sampled pixel-time courses:", "aryBoxCarConvHigh", "=", "np", ".", "zeros", "(", "(", "tplVslSpcHighSze", "[",...
Resample pixel-time courses in high-res visual space. Parameters ---------- input1 : 2d numpy array, shape [n_samples, n_measurements] Description of input 1. input2 : float, positive Description of input 2. Returns ------- data : 2d numpy array, shape [n_samples, n_measuremen...
[ "Resample", "pixel", "-", "time", "courses", "in", "high", "-", "res", "visual", "space", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L565-L633
MSchnei/pyprf_feature
pyprf_feature/analysis/pyprf_sim_ep.py
get_arg_parse
def get_arg_parse(): """Parses the Command Line Arguments using argparse.""" # Create parser object: objParser = argparse.ArgumentParser() # Add argument to namespace -strCsvPrf results file path: objParser.add_argument('-strCsvPrf', required=True, metavar='/path/to/my_pr...
python
def get_arg_parse(): """Parses the Command Line Arguments using argparse.""" # Create parser object: objParser = argparse.ArgumentParser() # Add argument to namespace -strCsvPrf results file path: objParser.add_argument('-strCsvPrf', required=True, metavar='/path/to/my_pr...
[ "def", "get_arg_parse", "(", ")", ":", "# Create parser object:", "objParser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# Add argument to namespace -strCsvPrf results file path:", "objParser", ".", "add_argument", "(", "'-strCsvPrf'", ",", "required", "=", "True...
Parses the Command Line Arguments using argparse.
[ "Parses", "the", "Command", "Line", "Arguments", "using", "argparse", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim_ep.py#L14-L54
MSchnei/pyprf_feature
pyprf_feature/analysis/pyprf_sim_ep.py
main
def main(): """pyprf_sim entry point.""" # Get list of input arguments (without first one, which is the path to the # function that is called): --NOTE: This is another way of accessing # input arguments, but since we use 'argparse' it is redundant. # lstArgs = sys.argv[1:] strWelcome = 'pyprf_s...
python
def main(): """pyprf_sim entry point.""" # Get list of input arguments (without first one, which is the path to the # function that is called): --NOTE: This is another way of accessing # input arguments, but since we use 'argparse' it is redundant. # lstArgs = sys.argv[1:] strWelcome = 'pyprf_s...
[ "def", "main", "(", ")", ":", "# Get list of input arguments (without first one, which is the path to the", "# function that is called): --NOTE: This is another way of accessing", "# input arguments, but since we use 'argparse' it is redundant.", "# lstArgs = sys.argv[1:]", "strWelcome", "=", ...
pyprf_sim entry point.
[ "pyprf_sim", "entry", "point", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim_ep.py#L57-L83
lvieirajr/mongorest
mongorest/decorators.py
login_required
def login_required(wrapped): """ Requires that the user is logged in and authorized to execute requests Except if the method is in authorized_methods of the auth_collection Then he can execute the requests even not being authorized """ @wraps(wrapped) def wrapper(*args, **kwargs): re...
python
def login_required(wrapped): """ Requires that the user is logged in and authorized to execute requests Except if the method is in authorized_methods of the auth_collection Then he can execute the requests even not being authorized """ @wraps(wrapped) def wrapper(*args, **kwargs): re...
[ "def", "login_required", "(", "wrapped", ")", ":", "@", "wraps", "(", "wrapped", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "request", "=", "args", "[", "1", "]", "auth_collection", "=", "settings", ".", "AUTH_COLLECTIO...
Requires that the user is logged in and authorized to execute requests Except if the method is in authorized_methods of the auth_collection Then he can execute the requests even not being authorized
[ "Requires", "that", "the", "user", "is", "logged", "in", "and", "authorized", "to", "execute", "requests", "Except", "if", "the", "method", "is", "in", "authorized_methods", "of", "the", "auth_collection", "Then", "he", "can", "execute", "the", "requests", "ev...
train
https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/decorators.py#L17-L44
lvieirajr/mongorest
mongorest/decorators.py
serializable
def serializable(wrapped): """ If a keyword argument 'serialize' with a True value is passed to the Wrapped function, the return of the wrapped function will be serialized. Nothing happens if the argument is not passed or the value is not True """ @wraps(wrapped) def wrapper(*args, **kwargs...
python
def serializable(wrapped): """ If a keyword argument 'serialize' with a True value is passed to the Wrapped function, the return of the wrapped function will be serialized. Nothing happens if the argument is not passed or the value is not True """ @wraps(wrapped) def wrapper(*args, **kwargs...
[ "def", "serializable", "(", "wrapped", ")", ":", "@", "wraps", "(", "wrapped", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "should_serialize", "=", "kwargs", ".", "pop", "(", "'serialize'", ",", "False", ")", "result", ...
If a keyword argument 'serialize' with a True value is passed to the Wrapped function, the return of the wrapped function will be serialized. Nothing happens if the argument is not passed or the value is not True
[ "If", "a", "keyword", "argument", "serialize", "with", "a", "True", "value", "is", "passed", "to", "the", "Wrapped", "function", "the", "return", "of", "the", "wrapped", "function", "will", "be", "serialized", ".", "Nothing", "happens", "if", "the", "argumen...
train
https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/decorators.py#L47-L67
lvieirajr/mongorest
mongorest/utils.py
deserialize
def deserialize(to_deserialize, *args, **kwargs): """ Deserializes a string into a PyMongo BSON """ if isinstance(to_deserialize, string_types): if re.match('^[0-9a-f]{24}$', to_deserialize): return ObjectId(to_deserialize) try: return bson_loads(to_deserialize, *...
python
def deserialize(to_deserialize, *args, **kwargs): """ Deserializes a string into a PyMongo BSON """ if isinstance(to_deserialize, string_types): if re.match('^[0-9a-f]{24}$', to_deserialize): return ObjectId(to_deserialize) try: return bson_loads(to_deserialize, *...
[ "def", "deserialize", "(", "to_deserialize", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "to_deserialize", ",", "string_types", ")", ":", "if", "re", ".", "match", "(", "'^[0-9a-f]{24}$'", ",", "to_deserialize", ")", ":", ...
Deserializes a string into a PyMongo BSON
[ "Deserializes", "a", "string", "into", "a", "PyMongo", "BSON" ]
train
https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/utils.py#L16-L28
musically-ut/seqfile
seqfile/seqfile.py
_doAtomicFileCreation
def _doAtomicFileCreation(filePath): """Tries to atomically create the requested file.""" try: _os.close(_os.open(filePath, _os.O_CREAT | _os.O_EXCL)) return True except OSError as e: if e.errno == _errno.EEXIST: return False else: raise e
python
def _doAtomicFileCreation(filePath): """Tries to atomically create the requested file.""" try: _os.close(_os.open(filePath, _os.O_CREAT | _os.O_EXCL)) return True except OSError as e: if e.errno == _errno.EEXIST: return False else: raise e
[ "def", "_doAtomicFileCreation", "(", "filePath", ")", ":", "try", ":", "_os", ".", "close", "(", "_os", ".", "open", "(", "filePath", ",", "_os", ".", "O_CREAT", "|", "_os", ".", "O_EXCL", ")", ")", "return", "True", "except", "OSError", "as", "e", "...
Tries to atomically create the requested file.
[ "Tries", "to", "atomically", "create", "the", "requested", "file", "." ]
train
https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L11-L20
musically-ut/seqfile
seqfile/seqfile.py
findNextFile
def findNextFile(folder='.', prefix=None, suffix=None, fnameGen=None, base=0, maxattempts=10): """Finds the next available file-name in a sequence. This function will create a file of zero size and will return the path to ...
python
def findNextFile(folder='.', prefix=None, suffix=None, fnameGen=None, base=0, maxattempts=10): """Finds the next available file-name in a sequence. This function will create a file of zero size and will return the path to ...
[ "def", "findNextFile", "(", "folder", "=", "'.'", ",", "prefix", "=", "None", ",", "suffix", "=", "None", ",", "fnameGen", "=", "None", ",", "base", "=", "0", ",", "maxattempts", "=", "10", ")", ":", "expFolder", "=", "_os", ".", "path", ".", "expa...
Finds the next available file-name in a sequence. This function will create a file of zero size and will return the path to it to the caller. No files which exist will be altered in this operation and concurrent executions of this function will return separate files. In case of conflict, the function w...
[ "Finds", "the", "next", "available", "file", "-", "name", "in", "a", "sequence", "." ]
train
https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L97-L145
musically-ut/seqfile
seqfile/seqfile.py
_run
def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None): """Executes the script, gets prefix/suffix from the command prompt and produces output on STDOUT. For help with command line options, invoke script with '--help'. """ description = """Finds the next available file-name in a sequence....
python
def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None): """Executes the script, gets prefix/suffix from the command prompt and produces output on STDOUT. For help with command line options, invoke script with '--help'. """ description = """Finds the next available file-name in a sequence....
[ "def", "_run", "(", "passedArgs", "=", "None", ",", "stderr", "=", "None", ",", "stdout", "=", "None", ",", "exitFn", "=", "None", ")", ":", "description", "=", "\"\"\"Finds the next available file-name in a sequence.\n\n This program will create a file of zero size an...
Executes the script, gets prefix/suffix from the command prompt and produces output on STDOUT. For help with command line options, invoke script with '--help'.
[ "Executes", "the", "script", "gets", "prefix", "/", "suffix", "from", "the", "command", "prompt", "and", "produces", "output", "on", "STDOUT", ".", "For", "help", "with", "command", "line", "options", "invoke", "script", "with", "--", "help", "." ]
train
https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L148-L215
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_errstr
def _errstr(value): """Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If it's truncated, the returned value will have '...' on the end. """ value = str(value) # We won't make the caller convert value to a string each time. if len(value) > MAX_ERROR_STR_LEN: return value[:...
python
def _errstr(value): """Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If it's truncated, the returned value will have '...' on the end. """ value = str(value) # We won't make the caller convert value to a string each time. if len(value) > MAX_ERROR_STR_LEN: return value[:...
[ "def", "_errstr", "(", "value", ")", ":", "value", "=", "str", "(", "value", ")", "# We won't make the caller convert value to a string each time.", "if", "len", "(", "value", ")", ">", "MAX_ERROR_STR_LEN", ":", "return", "value", "[", ":", "MAX_ERROR_STR_LEN", "]...
Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If it's truncated, the returned value will have '...' on the end.
[ "Returns", "the", "value", "str", "truncated", "to", "MAX_ERROR_STR_LEN", "characters", ".", "If", "it", "s", "truncated", "the", "returned", "value", "will", "have", "...", "on", "the", "end", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L75-L84
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_getStrippedValue
def _getStrippedValue(value, strip): """Like the strip() string method, except the strip argument describes different behavior: If strip is None, whitespace is stripped. If strip is a string, the characters in the string are stripped. If strip is False, nothing is stripped.""" if strip is Non...
python
def _getStrippedValue(value, strip): """Like the strip() string method, except the strip argument describes different behavior: If strip is None, whitespace is stripped. If strip is a string, the characters in the string are stripped. If strip is False, nothing is stripped.""" if strip is Non...
[ "def", "_getStrippedValue", "(", "value", ",", "strip", ")", ":", "if", "strip", "is", "None", ":", "value", "=", "value", ".", "strip", "(", ")", "# Call strip() with no arguments to strip whitespace.", "elif", "isinstance", "(", "strip", ",", "str", ")", ":"...
Like the strip() string method, except the strip argument describes different behavior: If strip is None, whitespace is stripped. If strip is a string, the characters in the string are stripped. If strip is False, nothing is stripped.
[ "Like", "the", "strip", "()", "string", "method", "except", "the", "strip", "argument", "describes", "different", "behavior", ":" ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L87-L102
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_raiseValidationException
def _raiseValidationException(standardExcMsg, customExcMsg=None): """Raise ValidationException with standardExcMsg, unless customExcMsg is specified.""" if customExcMsg is None: raise ValidationException(str(standardExcMsg)) else: raise ValidationException(str(customExcMsg))
python
def _raiseValidationException(standardExcMsg, customExcMsg=None): """Raise ValidationException with standardExcMsg, unless customExcMsg is specified.""" if customExcMsg is None: raise ValidationException(str(standardExcMsg)) else: raise ValidationException(str(customExcMsg))
[ "def", "_raiseValidationException", "(", "standardExcMsg", ",", "customExcMsg", "=", "None", ")", ":", "if", "customExcMsg", "is", "None", ":", "raise", "ValidationException", "(", "str", "(", "standardExcMsg", ")", ")", "else", ":", "raise", "ValidationException"...
Raise ValidationException with standardExcMsg, unless customExcMsg is specified.
[ "Raise", "ValidationException", "with", "standardExcMsg", "unless", "customExcMsg", "is", "specified", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L105-L110
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_prevalidationCheck
def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None): """Returns a tuple of two values: the first is a bool that tells the caller if they should immediately return True, the second is a new, possibly stripped value to replace the value passed for value parameter. ...
python
def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None): """Returns a tuple of two values: the first is a bool that tells the caller if they should immediately return True, the second is a new, possibly stripped value to replace the value passed for value parameter. ...
[ "def", "_prevalidationCheck", "(", "value", ",", "blank", ",", "strip", ",", "allowlistRegexes", ",", "blocklistRegexes", ",", "excMsg", "=", "None", ")", ":", "# TODO - add a allowlistFirst and blocklistFirst to determine which is checked first. (Right now it's allowlist)", "v...
Returns a tuple of two values: the first is a bool that tells the caller if they should immediately return True, the second is a new, possibly stripped value to replace the value passed for value parameter. We'd want the caller immediately return value in some cases where further validation isn't neede...
[ "Returns", "a", "tuple", "of", "two", "values", ":", "the", "first", "is", "a", "bool", "that", "tells", "the", "caller", "if", "they", "should", "immediately", "return", "True", "the", "second", "is", "a", "new", "possibly", "stripped", "value", "to", "...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L113-L164
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_validateGenericParameters
def _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes): """Returns None if the blank, strip, and blocklistRegexes parameters are valid of PySimpleValidate's validation functions have. Raises a PySimpleValidateException if any of the arguments are invalid.""" # Check blank para...
python
def _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes): """Returns None if the blank, strip, and blocklistRegexes parameters are valid of PySimpleValidate's validation functions have. Raises a PySimpleValidateException if any of the arguments are invalid.""" # Check blank para...
[ "def", "_validateGenericParameters", "(", "blank", ",", "strip", ",", "allowlistRegexes", ",", "blocklistRegexes", ")", ":", "# Check blank parameter.", "if", "not", "isinstance", "(", "blank", ",", "bool", ")", ":", "raise", "PySimpleValidateException", "(", "'blan...
Returns None if the blank, strip, and blocklistRegexes parameters are valid of PySimpleValidate's validation functions have. Raises a PySimpleValidateException if any of the arguments are invalid.
[ "Returns", "None", "if", "the", "blank", "strip", "and", "blocklistRegexes", "parameters", "are", "valid", "of", "PySimpleValidate", "s", "validation", "functions", "have", ".", "Raises", "a", "PySimpleValidateException", "if", "any", "of", "the", "arguments", "ar...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L167-L209
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_validateParamsFor_validateNum
def _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None): """Raises an exception if the arguments are invalid. This is called by the validateNum(), validateInt(), and validateFloat() functions to check its arguments. This code was refactored out to a separate function so t...
python
def _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None): """Raises an exception if the arguments are invalid. This is called by the validateNum(), validateInt(), and validateFloat() functions to check its arguments. This code was refactored out to a separate function so t...
[ "def", "_validateParamsFor_validateNum", "(", "min", "=", "None", ",", "max", "=", "None", ",", "lessThan", "=", "None", ",", "greaterThan", "=", "None", ")", ":", "if", "(", "min", "is", "not", "None", ")", "and", "(", "greaterThan", "is", "not", "Non...
Raises an exception if the arguments are invalid. This is called by the validateNum(), validateInt(), and validateFloat() functions to check its arguments. This code was refactored out to a separate function so that the PyInputPlus module (or other modules) could check their parameters' arguments for in...
[ "Raises", "an", "exception", "if", "the", "arguments", "are", "invalid", ".", "This", "is", "called", "by", "the", "validateNum", "()", "validateInt", "()", "and", "validateFloat", "()", "functions", "to", "check", "its", "arguments", ".", "This", "code", "w...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L212-L235
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateStr
def validateStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a string. This function is identical to the built-in input() function, but also offers the PySimpleValidate features of not allowing blank values by defau...
python
def validateStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a string. This function is identical to the built-in input() function, but also offers the PySimpleValidate features of not allowing blank values by defau...
[ "def", "validateStr", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# Validate parameters.", "_validateGenericParameters", ...
Raises ValidationException if value is not a string. This function is identical to the built-in input() function, but also offers the PySimpleValidate features of not allowing blank values by default, automatically stripping whitespace, and having allowlist/blocklist regular expressions. Returns va...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "string", ".", "This", "function", "is", "identical", "to", "the", "built", "-", "in", "input", "()", "function", "but", "also", "offers", "the", "PySimpleValidate", "features", "of", "not", "...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L238-L283
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateNum
def validateNum(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, _numType='num', min=None, max=None, lessThan=None, greaterThan=None, excMsg=None): """Raises ValidationException if value is not a float or int. Returns value, so it can be used inline in an expression...
python
def validateNum(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, _numType='num', min=None, max=None, lessThan=None, greaterThan=None, excMsg=None): """Raises ValidationException if value is not a float or int. Returns value, so it can be used inline in an expression...
[ "def", "validateNum", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "_numType", "=", "'num'", ",", "min", "=", "None", ",", "max", "=", "None", ",",...
Raises ValidationException if value is not a float or int. Returns value, so it can be used inline in an expression: print(2 + validateNum(your_number)) Note that since int() and float() ignore leading or trailing whitespace when converting a string to a number, so does this validateNum(). *...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "float", "or", "int", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L286-L393
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateInt
def validateInt(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, min=None, max=None, lessThan=None, greaterThan=None, excMsg=None): """Raises ValidationException if value is not a int. Returns value, so it can be used inline in an expression: print(2 + vali...
python
def validateInt(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, min=None, max=None, lessThan=None, greaterThan=None, excMsg=None): """Raises ValidationException if value is not a int. Returns value, so it can be used inline in an expression: print(2 + vali...
[ "def", "validateInt", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "min", "=", "None", ",", "max", "=", "None", ",", "lessThan", "=", "None", ",", ...
Raises ValidationException if value is not a int. Returns value, so it can be used inline in an expression: print(2 + validateInt(your_number)) Note that since int() and ignore leading or trailing whitespace when converting a string to a number, so does this validateNum(). * value (str): The...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "int", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L396-L432
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_validateParamsFor_validateChoice
def _validateParamsFor_validateChoice(choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, numbered=False, lettered=False, caseSensitive=False, excMsg=None): """Raises PySimpleValidateException if the arguments are invalid. This is called by the validateChoice() fun...
python
def _validateParamsFor_validateChoice(choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, numbered=False, lettered=False, caseSensitive=False, excMsg=None): """Raises PySimpleValidateException if the arguments are invalid. This is called by the validateChoice() fun...
[ "def", "_validateParamsFor_validateChoice", "(", "choices", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "numbered", "=", "False", ",", "lettered", "=", "False", ",", ...
Raises PySimpleValidateException if the arguments are invalid. This is called by the validateChoice() function to check its arguments. This code was refactored out to a separate function so that the PyInputPlus module (or other modules) could check their parameters' arguments for inputChoice().
[ "Raises", "PySimpleValidateException", "if", "the", "arguments", "are", "invalid", ".", "This", "is", "called", "by", "the", "validateChoice", "()", "function", "to", "check", "its", "arguments", ".", "This", "code", "was", "refactored", "out", "to", "a", "sep...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L488-L523
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateChoice
def validateChoice(value, choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, numbered=False, lettered=False, caseSensitive=False, excMsg=None): """Raises ValidationException if value is not one of the values in choices. Returns the selected choice. Returns th...
python
def validateChoice(value, choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, numbered=False, lettered=False, caseSensitive=False, excMsg=None): """Raises ValidationException if value is not one of the values in choices. Returns the selected choice. Returns th...
[ "def", "validateChoice", "(", "value", ",", "choices", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "numbered", "=", "False", ",", "lettered", "=", "False", ",", "...
Raises ValidationException if value is not one of the values in choices. Returns the selected choice. Returns the value in choices that was selected, so it can be used inline in an expression: print('You chose ' + validateChoice(your_choice, ['cat', 'dog'])) Note that value itself is not retu...
[ "Raises", "ValidationException", "if", "value", "is", "not", "one", "of", "the", "values", "in", "choices", ".", "Returns", "the", "selected", "choice", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L526-L608
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
_validateParamsFor__validateToDateTimeFormat
def _validateParamsFor__validateToDateTimeFormat(formats, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises PySimpleValidateException if the arguments are invalid. This is called by the validateTime() function to check its arguments. This code was refactored out ...
python
def _validateParamsFor__validateToDateTimeFormat(formats, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises PySimpleValidateException if the arguments are invalid. This is called by the validateTime() function to check its arguments. This code was refactored out ...
[ "def", "_validateParamsFor__validateToDateTimeFormat", "(", "formats", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "_validateGenericParamet...
Raises PySimpleValidateException if the arguments are invalid. This is called by the validateTime() function to check its arguments. This code was refactored out to a separate function so that the PyInputPlus module (or other modules) could check their parameters' arguments for inputTime().
[ "Raises", "PySimpleValidateException", "if", "the", "arguments", "are", "invalid", ".", "This", "is", "called", "by", "the", "validateTime", "()", "function", "to", "check", "its", "arguments", ".", "This", "code", "was", "refactored", "out", "to", "a", "separ...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L611-L633
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateTime
def validateTime(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%H:%M:%S', '%H:%M', '%X'), excMsg=None): """Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.time object of value. * value (...
python
def validateTime(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%H:%M:%S', '%H:%M', '%X'), excMsg=None): """Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.time object of value. * value (...
[ "def", "validateTime", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "formats", "=", "(", "'%H:%M:%S'", ",", "'%H:%M'", ",", "'%X'", ")", ",", "excMsg...
Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.time object of value. * value (str): The value being validated as a time. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If None, whites...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "time", "formatted", "in", "one", "of", "the", "formats", "formats", ".", "Returns", "a", "datetime", ".", "time", "object", "of", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L658-L691
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateDate
def validateDate(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%Y/%m/%d', '%y/%m/%d', '%m/%d/%Y', '%m/%d/%y', '%x'), excMsg=None): """Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.date obje...
python
def validateDate(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%Y/%m/%d', '%y/%m/%d', '%m/%d/%Y', '%m/%d/%y', '%x'), excMsg=None): """Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.date obje...
[ "def", "validateDate", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "formats", "=", "(", "'%Y/%m/%d'", ",", "'%y/%m/%d'", ",", "'%m/%d/%Y'", ",", "'%m/...
Raises ValidationException if value is not a time formatted in one of the formats formats. Returns a datetime.date object of value. * value (str): The value being validated as a time. * blank (bool): If True, a blank string for value will be accepted. * strip (bool, str, None): If None, whitespace is s...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "time", "formatted", "in", "one", "of", "the", "formats", "formats", ".", "Returns", "a", "datetime", ".", "date", "object", "of", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L694-L722
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateDatetime
def validateDatetime(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%Y/%m/%d %H:%M:%S', '%y/%m/%d %H:%M:%S', '%m/%d/%Y %H:%M:%S', '%m/%d/%y %H:%M:%S', '%x %H:%M:%S', '%Y/%m/%d %H:%M', '%y/%m/%d %H:%M', '%m/%d/%Y %H:%M', '%m/%d/%...
python
def validateDatetime(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, formats=('%Y/%m/%d %H:%M:%S', '%y/%m/%d %H:%M:%S', '%m/%d/%Y %H:%M:%S', '%m/%d/%y %H:%M:%S', '%x %H:%M:%S', '%Y/%m/%d %H:%M', '%y/%m/%d %H:%M', '%m/%d/%Y %H:%M', '%m/%d/%...
[ "def", "validateDatetime", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "formats", "=", "(", "'%Y/%m/%d %H:%M:%S'", ",", "'%y/%m/%d %H:%M:%S'", ",", "'%m/%...
Raises ValidationException if value is not a datetime formatted in one of the formats formats. Returns a datetime.datetime object of value. * value (str): The value being validated as a datetime. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If ...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "datetime", "formatted", "in", "one", "of", "the", "formats", "formats", ".", "Returns", "a", "datetime", ".", "datetime", "object", "of", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L725-L755
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateFilename
def validateFilename(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | or end with a space. Returns the value argument. Note that this validates filenames...
python
def validateFilename(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | or end with a space. Returns the value argument. Note that this validates filenames...
[ "def", "validateFilename", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "returnNow", ",", "value", "=", "_prevalidatio...
Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | or end with a space. Returns the value argument. Note that this validates filenames, not filepaths. The / and \\ characters are invalid for filenames. * value (str): The value being validated as...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "valid", "filename", ".", "Filenames", "can", "t", "contain", "\\\\", "/", ":", "*", "?", "<", ">", "|", "or", "end", "with", "a", "space", ".", "Returns", "the", "value", "argument", "....
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L758-L792
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateFilepath
def validateFilepath(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None, mustExist=False): r"""Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | Returns the value argument. * value (str): The value being valida...
python
def validateFilepath(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None, mustExist=False): r"""Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | Returns the value argument. * value (str): The value being valida...
[ "def", "validateFilepath", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ",", "mustExist", "=", "False", ")", ":", "returnNow", ...
r"""Raises ValidationException if value is not a valid filename. Filenames can't contain \\ / : * ? " < > | Returns the value argument. * value (str): The value being validated as an IP address. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): ...
[ "r", "Raises", "ValidationException", "if", "value", "is", "not", "a", "valid", "filename", ".", "Filenames", "can", "t", "contain", "\\\\", "/", ":", "*", "?", "<", ">", "|", "Returns", "the", "value", "argument", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L795-L830
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateIP
def validateIP(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not an IPv4 or IPv6 address. Returns the value argument. * value (str): The value being validated as an IP address. * blank (bool): If True, a blank strin...
python
def validateIP(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not an IPv4 or IPv6 address. Returns the value argument. * value (str): The value being validated as an IP address. * blank (bool): If True, a blank strin...
[ "def", "validateIP", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# Validate parameters.", "_validateGenericParameters", ...
Raises ValidationException if value is not an IPv4 or IPv6 address. Returns the value argument. * value (str): The value being validated as an IP address. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If None, whitespace is stripped from value. ...
[ "Raises", "ValidationException", "if", "value", "is", "not", "an", "IPv4", "or", "IPv6", "address", ".", "Returns", "the", "value", "argument", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L833-L881
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateRegex
def validateRegex(value, regex, flags=0, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value does not match the regular expression in regex. Returns the value argument. This is similar to calling inputStr() and using the allowlistRegex...
python
def validateRegex(value, regex, flags=0, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value does not match the regular expression in regex. Returns the value argument. This is similar to calling inputStr() and using the allowlistRegex...
[ "def", "validateRegex", "(", "value", ",", "regex", ",", "flags", "=", "0", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# Vali...
Raises ValidationException if value does not match the regular expression in regex. Returns the value argument. This is similar to calling inputStr() and using the allowlistRegexes keyword argument, however, validateRegex() allows you to pass regex flags such as re.IGNORECASE or re.VERBOSE. You can als...
[ "Raises", "ValidationException", "if", "value", "does", "not", "match", "the", "regular", "expression", "in", "regex", ".", "Returns", "the", "value", "argument", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L959-L1005
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateRegexStr
def validateRegexStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value can't be used as a regular expression string. Returns the value argument as a regex object. If you want to check if a string matches a regular expression, ...
python
def validateRegexStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value can't be used as a regular expression string. Returns the value argument as a regex object. If you want to check if a string matches a regular expression, ...
[ "def", "validateRegexStr", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# TODO - I'd be nice to check regexes in other langua...
Raises ValidationException if value can't be used as a regular expression string. Returns the value argument as a regex object. If you want to check if a string matches a regular expression, call validateRegex(). * value (str): The value being validated as a regular expression string. * regex (str...
[ "Raises", "ValidationException", "if", "value", "can", "t", "be", "used", "as", "a", "regular", "expression", "string", ".", "Returns", "the", "value", "argument", "as", "a", "regex", "object", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1008-L1045
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateURL
def validateURL(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a URL. Returns the value argument. The "http" or "https" protocol part of the URL is optional. * value (str): The value being validated as a URL. ...
python
def validateURL(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a URL. Returns the value argument. The "http" or "https" protocol part of the URL is optional. * value (str): The value being validated as a URL. ...
[ "def", "validateURL", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# Reuse the logic in validateRegex()", "try", ":", "...
Raises ValidationException if value is not a URL. Returns the value argument. The "http" or "https" protocol part of the URL is optional. * value (str): The value being validated as a URL. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If N...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "URL", ".", "Returns", "the", "value", "argument", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1048-L1090
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateEmail
def validateEmail(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not an email address. Returns the value argument. * value (str): The value being validated as an email address. * blank (bool): If True, a blank strin...
python
def validateEmail(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not an email address. Returns the value argument. * value (str): The value being validated as an email address. * blank (bool): If True, a blank strin...
[ "def", "validateEmail", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "# Reuse the logic in validateRegex()", "try", ":", ...
Raises ValidationException if value is not an email address. Returns the value argument. * value (str): The value being validated as an email address. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If None, whitespace is stripped from value. If ...
[ "Raises", "ValidationException", "if", "value", "is", "not", "an", "email", "address", ".", "Returns", "the", "value", "argument", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1093-L1119
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateYesNo
def validateYesNo(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, yesVal='yes', noVal='no', caseSensitive=False, excMsg=None): """Raises ValidationException if value is not a yes or no response. Returns the yesVal or noVal argument, not value. Note that value can be any case (...
python
def validateYesNo(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, yesVal='yes', noVal='no', caseSensitive=False, excMsg=None): """Raises ValidationException if value is not a yes or no response. Returns the yesVal or noVal argument, not value. Note that value can be any case (...
[ "def", "validateYesNo", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "yesVal", "=", "'yes'", ",", "noVal", "=", "'no'", ",", "caseSensitive", "=", "F...
Raises ValidationException if value is not a yes or no response. Returns the yesVal or noVal argument, not value. Note that value can be any case (by default) and can also just match the * value (str): The value being validated as an email address. * blank (bool): If True, a blank string will be acce...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "yes", "or", "no", "response", ".", "Returns", "the", "yesVal", "or", "noVal", "argument", "not", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1122-L1180
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateBool
def validateBool(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, trueVal='True', falseVal='False', caseSensitive=False, excMsg=None): """Raises ValidationException if value is not an email address. Returns the yesVal or noVal argument, not value. * value (str): The value being...
python
def validateBool(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, trueVal='True', falseVal='False', caseSensitive=False, excMsg=None): """Raises ValidationException if value is not an email address. Returns the yesVal or noVal argument, not value. * value (str): The value being...
[ "def", "validateBool", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "trueVal", "=", "'True'", ",", "falseVal", "=", "'False'", ",", "caseSensitive", "=...
Raises ValidationException if value is not an email address. Returns the yesVal or noVal argument, not value. * value (str): The value being validated as an email address. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If None, whitespace is str...
[ "Raises", "ValidationException", "if", "value", "is", "not", "an", "email", "address", ".", "Returns", "the", "yesVal", "or", "noVal", "argument", "not", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1183-L1232
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateState
def validateState(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None, returnStateName=False): """Raises ValidationException if value is not a USA state. Returns the capitalized state abbreviation, unless returnStateName is True in which case it returns the titlecased s...
python
def validateState(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None, returnStateName=False): """Raises ValidationException if value is not a USA state. Returns the capitalized state abbreviation, unless returnStateName is True in which case it returns the titlecased s...
[ "def", "validateState", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ",", "returnStateName", "=", "False", ")", ":", "# TODO - n...
Raises ValidationException if value is not a USA state. Returns the capitalized state abbreviation, unless returnStateName is True in which case it returns the titlecased state name. * value (str): The value being validated as an email address. * blank (bool): If True, a blank string will be accepted....
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "USA", "state", ".", "Returns", "the", "capitalized", "state", "abbreviation", "unless", "returnStateName", "is", "True", "in", "which", "case", "it", "returns", "the", "titlecased", "state", "nam...
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1235-L1279
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateMonth
def validateMonth(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, monthNames=ENGLISH_MONTHS, excMsg=None): """Raises ValidationException if value is not a month, like 'Jan' or 'March'. Returns the titlecased month. * value (str): The value being validated as an email address. ...
python
def validateMonth(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, monthNames=ENGLISH_MONTHS, excMsg=None): """Raises ValidationException if value is not a month, like 'Jan' or 'March'. Returns the titlecased month. * value (str): The value being validated as an email address. ...
[ "def", "validateMonth", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "monthNames", "=", "ENGLISH_MONTHS", ",", "excMsg", "=", "None", ")", ":", "# retu...
Raises ValidationException if value is not a month, like 'Jan' or 'March'. Returns the titlecased month. * value (str): The value being validated as an email address. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If None, whitespace is stripped...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "month", "like", "Jan", "or", "March", ".", "Returns", "the", "titlecased", "month", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1294-L1338
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateDayOfWeek
def validateDayOfWeek(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, dayNames=ENGLISH_DAYS_OF_WEEK, excMsg=None): """Raises ValidationException if value is not a day of the week, such as 'Mon' or 'Friday'. Returns the titlecased day of the week. * value (str): The value being...
python
def validateDayOfWeek(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, dayNames=ENGLISH_DAYS_OF_WEEK, excMsg=None): """Raises ValidationException if value is not a day of the week, such as 'Mon' or 'Friday'. Returns the titlecased day of the week. * value (str): The value being...
[ "def", "validateDayOfWeek", "(", "value", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "dayNames", "=", "ENGLISH_DAYS_OF_WEEK", ",", "excMsg", "=", "None", ")", ":", ...
Raises ValidationException if value is not a day of the week, such as 'Mon' or 'Friday'. Returns the titlecased day of the week. * value (str): The value being validated as a day of the week. * blank (bool): If True, a blank string will be accepted. Defaults to False. * strip (bool, str, None): If Non...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "day", "of", "the", "week", "such", "as", "Mon", "or", "Friday", ".", "Returns", "the", "titlecased", "day", "of", "the", "week", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1341-L1369
asweigart/pysimplevalidate
src/pysimplevalidate/__init__.py
validateDayOfMonth
def validateDayOfMonth(value, year, month, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a day of the month, from 1 to 28, 29, 30, or 31 depending on the month and year. Returns value. * value (str): The value being va...
python
def validateDayOfMonth(value, year, month, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None): """Raises ValidationException if value is not a day of the month, from 1 to 28, 29, 30, or 31 depending on the month and year. Returns value. * value (str): The value being va...
[ "def", "validateDayOfMonth", "(", "value", ",", "year", ",", "month", ",", "blank", "=", "False", ",", "strip", "=", "None", ",", "allowlistRegexes", "=", "None", ",", "blocklistRegexes", "=", "None", ",", "excMsg", "=", "None", ")", ":", "try", ":", "...
Raises ValidationException if value is not a day of the month, from 1 to 28, 29, 30, or 31 depending on the month and year. Returns value. * value (str): The value being validated as existing as a numbered day in the given year and month. * year (int): The given year. * month (int): The given month...
[ "Raises", "ValidationException", "if", "value", "is", "not", "a", "day", "of", "the", "month", "from", "1", "to", "28", "29", "30", "or", "31", "depending", "on", "the", "month", "and", "year", ".", "Returns", "value", "." ]
train
https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1373-L1411
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/logs.py
get_level
def get_level(level_string): """ Returns an appropriate logging level integer from a string name """ levels = {'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL} try: level = levels[level...
python
def get_level(level_string): """ Returns an appropriate logging level integer from a string name """ levels = {'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL} try: level = levels[level...
[ "def", "get_level", "(", "level_string", ")", ":", "levels", "=", "{", "'debug'", ":", "logging", ".", "DEBUG", ",", "'info'", ":", "logging", ".", "INFO", ",", "'warning'", ":", "logging", ".", "WARNING", ",", "'error'", ":", "logging", ".", "ERROR", ...
Returns an appropriate logging level integer from a string name
[ "Returns", "an", "appropriate", "logging", "level", "integer", "from", "a", "string", "name" ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/logs.py#L15-L27
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/logs.py
config_logging
def config_logging(no_log_file, log_to, log_level, silent, verbosity): """ Configures and generates a Logger object, 'openaccess_epub' based on common parameters used for console interface script execution in OpenAccess_EPUB. These parameters are: no_log_file Boolean. Disables logging t...
python
def config_logging(no_log_file, log_to, log_level, silent, verbosity): """ Configures and generates a Logger object, 'openaccess_epub' based on common parameters used for console interface script execution in OpenAccess_EPUB. These parameters are: no_log_file Boolean. Disables logging t...
[ "def", "config_logging", "(", "no_log_file", ",", "log_to", ",", "log_level", ",", "silent", ",", "verbosity", ")", ":", "log_level", "=", "get_level", "(", "log_level", ")", "console_level", "=", "get_level", "(", "verbosity", ")", "#We want to configure our open...
Configures and generates a Logger object, 'openaccess_epub' based on common parameters used for console interface script execution in OpenAccess_EPUB. These parameters are: no_log_file Boolean. Disables logging to file. If set to True, log_to and log_level become irrelevant. log...
[ "Configures", "and", "generates", "a", "Logger", "object", "openaccess_epub", "based", "on", "common", "parameters", "used", "for", "console", "interface", "script", "execution", "in", "OpenAccess_EPUB", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/logs.py#L38-L82
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/logs.py
replace_filehandler
def replace_filehandler(logname, new_file, level=None, frmt=None): """ This utility function will remove a previous Logger FileHandler, if one exists, and add a new filehandler. Parameters: logname The name of the log to reconfigure, 'openaccess_epub' for example new_file ...
python
def replace_filehandler(logname, new_file, level=None, frmt=None): """ This utility function will remove a previous Logger FileHandler, if one exists, and add a new filehandler. Parameters: logname The name of the log to reconfigure, 'openaccess_epub' for example new_file ...
[ "def", "replace_filehandler", "(", "logname", ",", "new_file", ",", "level", "=", "None", ",", "frmt", "=", "None", ")", ":", "#Call up the Logger to get reconfigured", "log", "=", "logging", ".", "getLogger", "(", "logname", ")", "#Set up defaults and whether expli...
This utility function will remove a previous Logger FileHandler, if one exists, and add a new filehandler. Parameters: logname The name of the log to reconfigure, 'openaccess_epub' for example new_file The file location for the new FileHandler level Optional. Lev...
[ "This", "utility", "function", "will", "remove", "a", "previous", "Logger", "FileHandler", "if", "one", "exists", "and", "add", "a", "new", "filehandler", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/logs.py#L85-L152
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
rmp_pixel_deg_xys
def rmp_pixel_deg_xys(vecX, vecY, vecPrfSd, tplPngSize, varExtXmin, varExtXmax, varExtYmin, varExtYmax): """Remap x, y, sigma parameters from pixel to degree. Parameters ---------- vecX : 1D numpy array Array with possible x parametrs in pixels vecY : 1D numpy array ...
python
def rmp_pixel_deg_xys(vecX, vecY, vecPrfSd, tplPngSize, varExtXmin, varExtXmax, varExtYmin, varExtYmax): """Remap x, y, sigma parameters from pixel to degree. Parameters ---------- vecX : 1D numpy array Array with possible x parametrs in pixels vecY : 1D numpy array ...
[ "def", "rmp_pixel_deg_xys", "(", "vecX", ",", "vecY", ",", "vecPrfSd", ",", "tplPngSize", ",", "varExtXmin", ",", "varExtXmax", ",", "varExtYmin", ",", "varExtYmax", ")", ":", "# Remap modelled x-positions of the pRFs:", "vecXdgr", "=", "rmp_rng", "(", "vecX", ","...
Remap x, y, sigma parameters from pixel to degree. Parameters ---------- vecX : 1D numpy array Array with possible x parametrs in pixels vecY : 1D numpy array Array with possible y parametrs in pixels vecPrfSd : 1D numpy array Array with possible sd parametrs in pixels t...
[ "Remap", "x", "y", "sigma", "parameters", "from", "pixel", "to", "degree", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L88-L144
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
crt_mdl_prms
def crt_mdl_prms(tplPngSize, varNum1, varExtXmin, varExtXmax, varNum2, varExtYmin, varExtYmax, varNumPrfSizes, varPrfStdMin, varPrfStdMax, kwUnt='pix', kwCrd='crt'): """Create an array with all possible model parameter combinations Parameters ---------- tplPngSize : t...
python
def crt_mdl_prms(tplPngSize, varNum1, varExtXmin, varExtXmax, varNum2, varExtYmin, varExtYmax, varNumPrfSizes, varPrfStdMin, varPrfStdMax, kwUnt='pix', kwCrd='crt'): """Create an array with all possible model parameter combinations Parameters ---------- tplPngSize : t...
[ "def", "crt_mdl_prms", "(", "tplPngSize", ",", "varNum1", ",", "varExtXmin", ",", "varExtXmax", ",", "varNum2", ",", "varExtYmin", ",", "varExtYmax", ",", "varNumPrfSizes", ",", "varPrfStdMin", ",", "varPrfStdMax", ",", "kwUnt", "=", "'pix'", ",", "kwCrd", "="...
Create an array with all possible model parameter combinations Parameters ---------- tplPngSize : tuple, 2 Pixel dimensions of the visual space (width, height). varNum1 : int, positive Number of x-positions to model varExtXmin : float Extent of visual space from centre in ne...
[ "Create", "an", "array", "with", "all", "possible", "model", "parameter", "combinations" ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L147-L305
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
crt_mdl_rsp
def crt_mdl_rsp(arySptExpInf, tplPngSize, aryMdlParams, varPar, strCrd='crt', lgcPrint=True): """Create responses of 2D Gauss models to spatial conditions. Parameters ---------- arySptExpInf : 3d numpy array, shape [n_x_pix, n_y_pix, n_conditions] All spatial conditions stacked ...
python
def crt_mdl_rsp(arySptExpInf, tplPngSize, aryMdlParams, varPar, strCrd='crt', lgcPrint=True): """Create responses of 2D Gauss models to spatial conditions. Parameters ---------- arySptExpInf : 3d numpy array, shape [n_x_pix, n_y_pix, n_conditions] All spatial conditions stacked ...
[ "def", "crt_mdl_rsp", "(", "arySptExpInf", ",", "tplPngSize", ",", "aryMdlParams", ",", "varPar", ",", "strCrd", "=", "'crt'", ",", "lgcPrint", "=", "True", ")", ":", "if", "varPar", "==", "1", ":", "# if the number of cores requested by the user is equal to 1,", ...
Create responses of 2D Gauss models to spatial conditions. Parameters ---------- arySptExpInf : 3d numpy array, shape [n_x_pix, n_y_pix, n_conditions] All spatial conditions stacked along second axis. tplPngSize : tuple, 2 Pixel dimensions of the visual space (width, height). aryMdl...
[ "Create", "responses", "of", "2D", "Gauss", "models", "to", "spatial", "conditions", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L308-L396
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
crt_nrl_tc
def crt_nrl_tc(aryMdlRsp, aryCnd, aryOns, aryDrt, varTr, varNumVol, varTmpOvsmpl, lgcPrint=True): """Create temporally upsampled neural time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos * n_sd, n_cond] Responses of 2D Gauss models to spatial...
python
def crt_nrl_tc(aryMdlRsp, aryCnd, aryOns, aryDrt, varTr, varNumVol, varTmpOvsmpl, lgcPrint=True): """Create temporally upsampled neural time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos * n_sd, n_cond] Responses of 2D Gauss models to spatial...
[ "def", "crt_nrl_tc", "(", "aryMdlRsp", ",", "aryCnd", ",", "aryOns", ",", "aryDrt", ",", "varTr", ",", "varNumVol", ",", "varTmpOvsmpl", ",", "lgcPrint", "=", "True", ")", ":", "# adjust the input, if necessary, such that input is 2D", "tplInpShp", "=", "aryMdlRsp",...
Create temporally upsampled neural time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos * n_sd, n_cond] Responses of 2D Gauss models to spatial conditions. aryCnd : np.array 1D array with condition identifiers (every condition has its own int) ary...
[ "Create", "temporally", "upsampled", "neural", "time", "courses", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L399-L476
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
crt_prf_tc
def crt_prf_tc(aryNrlTc, varNumVol, varTr, varTmpOvsmpl, switchHrfSet, tplPngSize, varPar, dctPrm=None, lgcPrint=True): """Convolve every neural time course with HRF function. Parameters ---------- aryNrlTc : 4d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_vol] Temporally upsamp...
python
def crt_prf_tc(aryNrlTc, varNumVol, varTr, varTmpOvsmpl, switchHrfSet, tplPngSize, varPar, dctPrm=None, lgcPrint=True): """Convolve every neural time course with HRF function. Parameters ---------- aryNrlTc : 4d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_vol] Temporally upsamp...
[ "def", "crt_prf_tc", "(", "aryNrlTc", ",", "varNumVol", ",", "varTr", ",", "varTmpOvsmpl", ",", "switchHrfSet", ",", "tplPngSize", ",", "varPar", ",", "dctPrm", "=", "None", ",", "lgcPrint", "=", "True", ")", ":", "# Create hrf time course function:", "if", "s...
Convolve every neural time course with HRF function. Parameters ---------- aryNrlTc : 4d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_vol] Temporally upsampled neural time course models. varNumVol : float, positive Number of volumes of the (fMRI) data. varTr : float, positive ...
[ "Convolve", "every", "neural", "time", "course", "with", "HRF", "function", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L479-L591
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
crt_prf_ftr_tc
def crt_prf_ftr_tc(aryMdlRsp, aryTmpExpInf, varNumVol, varTr, varTmpOvsmpl, switchHrfSet, tplPngSize, varPar, dctPrm=None, lgcPrint=True): """Create all spatial x feature prf time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos *...
python
def crt_prf_ftr_tc(aryMdlRsp, aryTmpExpInf, varNumVol, varTr, varTmpOvsmpl, switchHrfSet, tplPngSize, varPar, dctPrm=None, lgcPrint=True): """Create all spatial x feature prf time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos *...
[ "def", "crt_prf_ftr_tc", "(", "aryMdlRsp", ",", "aryTmpExpInf", ",", "varNumVol", ",", "varTr", ",", "varTmpOvsmpl", ",", "switchHrfSet", ",", "tplPngSize", ",", "varPar", ",", "dctPrm", "=", "None", ",", "lgcPrint", "=", "True", ")", ":", "# Identify number o...
Create all spatial x feature prf time courses. Parameters ---------- aryMdlRsp : 2d numpy array, shape [n_x_pos * n_y_pos * n_sd, n_cond] Responses of 2D Gauss models to spatial conditions aryTmpExpInf: 2d numpy array, shape [unknown, 4] Temporal information about conditions varNumV...
[ "Create", "all", "spatial", "x", "feature", "prf", "time", "courses", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L594-L662
MSchnei/pyprf_feature
pyprf_feature/analysis/model_creation_utils.py
fnd_unq_rws
def fnd_unq_rws(A, return_index=False, return_inverse=False): """Find unique rows in 2D array. Parameters ---------- A : 2d numpy array Array for which unique rows should be identified. return_index : bool Bool to decide whether I is returned. return_inverse : bool Bool ...
python
def fnd_unq_rws(A, return_index=False, return_inverse=False): """Find unique rows in 2D array. Parameters ---------- A : 2d numpy array Array for which unique rows should be identified. return_index : bool Bool to decide whether I is returned. return_inverse : bool Bool ...
[ "def", "fnd_unq_rws", "(", "A", ",", "return_index", "=", "False", ",", "return_inverse", "=", "False", ")", ":", "A", "=", "np", ".", "require", "(", "A", ",", "requirements", "=", "'C'", ")", "assert", "A", ".", "ndim", "==", "2", ",", "\"array mus...
Find unique rows in 2D array. Parameters ---------- A : 2d numpy array Array for which unique rows should be identified. return_index : bool Bool to decide whether I is returned. return_inverse : bool Bool to decide whether J is returned. Returns ------- B : 1d ...
[ "Find", "unique", "rows", "in", "2D", "array", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/model_creation_utils.py#L665-L699
bachya/pyflunearyou
pyflunearyou/client.py
Client._request
async def _request( self, method: str, endpoint: str, *, headers: dict = None) -> dict: """Make a request against air-matters.com.""" url = '{0}/{1}'.format(API_URL_SCAFFOLD, endpoint) if not headers: headers = {} headers.update({ 'Host': DEFAULT_HOST...
python
async def _request( self, method: str, endpoint: str, *, headers: dict = None) -> dict: """Make a request against air-matters.com.""" url = '{0}/{1}'.format(API_URL_SCAFFOLD, endpoint) if not headers: headers = {} headers.update({ 'Host': DEFAULT_HOST...
[ "async", "def", "_request", "(", "self", ",", "method", ":", "str", ",", "endpoint", ":", "str", ",", "*", ",", "headers", ":", "dict", "=", "None", ")", "->", "dict", ":", "url", "=", "'{0}/{1}'", ".", "format", "(", "API_URL_SCAFFOLD", ",", "endpoi...
Make a request against air-matters.com.
[ "Make", "a", "request", "against", "air", "-", "matters", ".", "com", "." ]
train
https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/client.py#L34-L59
olivier-m/rafter
rafter/filters.py
filter_transform_response
def filter_transform_response(get_response, params): """ This filter process the returned response. It does 3 things: - If the response is a ``sanic.response.HTTPResponse`` and not a :class:`rafter.http.Response`, return it immediately. - If the response is not a :class:`rafter.http.Response` ins...
python
def filter_transform_response(get_response, params): """ This filter process the returned response. It does 3 things: - If the response is a ``sanic.response.HTTPResponse`` and not a :class:`rafter.http.Response`, return it immediately. - If the response is not a :class:`rafter.http.Response` ins...
[ "def", "filter_transform_response", "(", "get_response", ",", "params", ")", ":", "async", "def", "decorated_filter", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "await", "get_response", "(", "request", ",", "*", "...
This filter process the returned response. It does 3 things: - If the response is a ``sanic.response.HTTPResponse`` and not a :class:`rafter.http.Response`, return it immediately. - If the response is not a :class:`rafter.http.Response` instance, turn it to a :class:`rafter.http.Response` instance ...
[ "This", "filter", "process", "the", "returned", "response", ".", "It", "does", "3", "things", ":" ]
train
https://github.com/olivier-m/rafter/blob/aafcf8fd019f24abcf519307c4484cc6b4697c04/rafter/filters.py#L11-L38
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/article/__init__.py
Article.get_publisher
def get_publisher(self): """ This method defines how the Article tries to determine the publisher of the article. This method relies on the success of the get_DOI method to fetch the appropriate full DOI for the article. It then takes the DOI prefix which corresponds to ...
python
def get_publisher(self): """ This method defines how the Article tries to determine the publisher of the article. This method relies on the success of the get_DOI method to fetch the appropriate full DOI for the article. It then takes the DOI prefix which corresponds to ...
[ "def", "get_publisher", "(", "self", ")", ":", "#For a detailed explanation of the DOI system, visit:", "#http://www.doi.org/hb.html", "#The basic syntax of a DOI is this <prefix>/<suffix>", "#The <prefix> specifies a unique DOI registrant, in our case, this", "#should correspond to the publishe...
This method defines how the Article tries to determine the publisher of the article. This method relies on the success of the get_DOI method to fetch the appropriate full DOI for the article. It then takes the DOI prefix which corresponds to the publisher and then uses that to attempt t...
[ "This", "method", "defines", "how", "the", "Article", "tries", "to", "determine", "the", "publisher", "of", "the", "article", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/article/__init__.py#L135-L170
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/article/__init__.py
Article.get_DOI
def get_DOI(self): """ This method defines how the Article tries to detect the DOI. It attempts to determine the article DOI string by DTD-appropriate inspection of the article metadata. This method should be made as flexible as necessary to properly collect the DOI for any XML ...
python
def get_DOI(self): """ This method defines how the Article tries to detect the DOI. It attempts to determine the article DOI string by DTD-appropriate inspection of the article metadata. This method should be made as flexible as necessary to properly collect the DOI for any XML ...
[ "def", "get_DOI", "(", "self", ")", ":", "if", "self", ".", "dtd_name", "==", "'JPTS'", ":", "doi", "=", "self", ".", "root", ".", "xpath", "(", "\"./front/article-meta/article-id[@pub-id-type='doi']\"", ")", "if", "doi", ":", "return", "doi", "[", "0", "]...
This method defines how the Article tries to detect the DOI. It attempts to determine the article DOI string by DTD-appropriate inspection of the article metadata. This method should be made as flexible as necessary to properly collect the DOI for any XML publishing specification. ...
[ "This", "method", "defines", "how", "the", "Article", "tries", "to", "detect", "the", "DOI", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/article/__init__.py#L172-L195
MSchnei/pyprf_feature
pyprf_feature/analysis/find_prf_utils_np.py
np_lst_sq
def np_lst_sq(vecMdl, aryFuncChnk): """Least squares fitting in numpy without cross-validation. Notes ----- This is just a wrapper function for np.linalg.lstsq to keep piping consistent. """ aryTmpBts, vecTmpRes = np.linalg.lstsq(vecMdl, aryFuncCh...
python
def np_lst_sq(vecMdl, aryFuncChnk): """Least squares fitting in numpy without cross-validation. Notes ----- This is just a wrapper function for np.linalg.lstsq to keep piping consistent. """ aryTmpBts, vecTmpRes = np.linalg.lstsq(vecMdl, aryFuncCh...
[ "def", "np_lst_sq", "(", "vecMdl", ",", "aryFuncChnk", ")", ":", "aryTmpBts", ",", "vecTmpRes", "=", "np", ".", "linalg", ".", "lstsq", "(", "vecMdl", ",", "aryFuncChnk", ",", "rcond", "=", "-", "1", ")", "[", ":", "2", "]", "return", "aryTmpBts", ",...
Least squares fitting in numpy without cross-validation. Notes ----- This is just a wrapper function for np.linalg.lstsq to keep piping consistent.
[ "Least", "squares", "fitting", "in", "numpy", "without", "cross", "-", "validation", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/find_prf_utils_np.py#L8-L21
MSchnei/pyprf_feature
pyprf_feature/analysis/find_prf_utils_np.py
np_lst_sq_xval
def np_lst_sq_xval(vecMdl, aryFuncChnk, aryIdxTrn, aryIdxTst): """Least squares fitting in numpy with cross-validation. """ varNumXval = aryIdxTrn.shape[-1] varNumVoxChnk = aryFuncChnk.shape[-1] # pre-allocate ary to collect cross-validation # error for every xval fold aryResXval = np.emp...
python
def np_lst_sq_xval(vecMdl, aryFuncChnk, aryIdxTrn, aryIdxTst): """Least squares fitting in numpy with cross-validation. """ varNumXval = aryIdxTrn.shape[-1] varNumVoxChnk = aryFuncChnk.shape[-1] # pre-allocate ary to collect cross-validation # error for every xval fold aryResXval = np.emp...
[ "def", "np_lst_sq_xval", "(", "vecMdl", ",", "aryFuncChnk", ",", "aryIdxTrn", ",", "aryIdxTst", ")", ":", "varNumXval", "=", "aryIdxTrn", ".", "shape", "[", "-", "1", "]", "varNumVoxChnk", "=", "aryFuncChnk", ".", "shape", "[", "-", "1", "]", "# pre-alloca...
Least squares fitting in numpy with cross-validation.
[ "Least", "squares", "fitting", "in", "numpy", "with", "cross", "-", "validation", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/find_prf_utils_np.py#L24-L64
bachya/pyflunearyou
pyflunearyou/report.py
Report._raw_user_report_data
async def _raw_user_report_data(self) -> list: """Return user report data (if accompanied by latitude/longitude).""" data = await self._request('get', 'map/markers') return [ location for location in data if location['latitude'] and location['longitude'] ]
python
async def _raw_user_report_data(self) -> list: """Return user report data (if accompanied by latitude/longitude).""" data = await self._request('get', 'map/markers') return [ location for location in data if location['latitude'] and location['longitude'] ]
[ "async", "def", "_raw_user_report_data", "(", "self", ")", "->", "list", ":", "data", "=", "await", "self", ".", "_request", "(", "'get'", ",", "'map/markers'", ")", "return", "[", "location", "for", "location", "in", "data", "if", "location", "[", "'latit...
Return user report data (if accompanied by latitude/longitude).
[ "Return", "user", "report", "data", "(", "if", "accompanied", "by", "latitude", "/", "longitude", ")", "." ]
train
https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/report.py#L29-L35
bachya/pyflunearyou
pyflunearyou/report.py
Report._raw_state_data
async def _raw_state_data(self) -> list: """Return a list of states.""" data = await self._request('get', 'states') return [ location for location in data if location['name'] != 'United States' ]
python
async def _raw_state_data(self) -> list: """Return a list of states.""" data = await self._request('get', 'states') return [ location for location in data if location['name'] != 'United States' ]
[ "async", "def", "_raw_state_data", "(", "self", ")", "->", "list", ":", "data", "=", "await", "self", ".", "_request", "(", "'get'", ",", "'states'", ")", "return", "[", "location", "for", "location", "in", "data", "if", "location", "[", "'name'", "]", ...
Return a list of states.
[ "Return", "a", "list", "of", "states", "." ]
train
https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/report.py#L37-L43
bachya/pyflunearyou
pyflunearyou/report.py
Report.nearest_by_coordinates
async def nearest_by_coordinates( self, latitude: float, longitude: float) -> dict: """Get the nearest report (with local and state info) to a lat/lon.""" # Since user data is more granular than state or CDC data, find the # user report whose coordinates are closest to the provided ...
python
async def nearest_by_coordinates( self, latitude: float, longitude: float) -> dict: """Get the nearest report (with local and state info) to a lat/lon.""" # Since user data is more granular than state or CDC data, find the # user report whose coordinates are closest to the provided ...
[ "async", "def", "nearest_by_coordinates", "(", "self", ",", "latitude", ":", "float", ",", "longitude", ":", "float", ")", "->", "dict", ":", "# Since user data is more granular than state or CDC data, find the", "# user report whose coordinates are closest to the provided", "#...
Get the nearest report (with local and state info) to a lat/lon.
[ "Get", "the", "nearest", "report", "(", "with", "local", "and", "state", "info", ")", "to", "a", "lat", "/", "lon", "." ]
train
https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/report.py#L45-L70
mediawiki-utilities/python-mwreverts
mwreverts/historical_dict.py
HistoricalDict.initialize
def initialize(self, maxsize, history=None): '''size specifies the maximum amount of history to keep''' super().__init__() self.maxsize = int(maxsize) self.history = deque(maxlen=self.maxsize) # Preserves order history # If `items` are specified, then initialize with them ...
python
def initialize(self, maxsize, history=None): '''size specifies the maximum amount of history to keep''' super().__init__() self.maxsize = int(maxsize) self.history = deque(maxlen=self.maxsize) # Preserves order history # If `items` are specified, then initialize with them ...
[ "def", "initialize", "(", "self", ",", "maxsize", ",", "history", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "maxsize", "=", "int", "(", "maxsize", ")", "self", ".", "history", "=", "deque", "(", "maxlen", "="...
size specifies the maximum amount of history to keep
[ "size", "specifies", "the", "maximum", "amount", "of", "history", "to", "keep" ]
train
https://github.com/mediawiki-utilities/python-mwreverts/blob/d379ac941e14e235ad82a48bd445a3dfa6cc022e/mwreverts/historical_dict.py#L13-L23
mediawiki-utilities/python-mwreverts
mwreverts/historical_dict.py
HistoricalDict.insert
def insert(self, key, value): '''Adds a new key-value pair. Returns any discarded values.''' # Add to history and catch expectorate if len(self.history) == self.maxsize: expectorate = self.history[0] else: expectorate = None self.history.append((key, val...
python
def insert(self, key, value): '''Adds a new key-value pair. Returns any discarded values.''' # Add to history and catch expectorate if len(self.history) == self.maxsize: expectorate = self.history[0] else: expectorate = None self.history.append((key, val...
[ "def", "insert", "(", "self", ",", "key", ",", "value", ")", ":", "# Add to history and catch expectorate", "if", "len", "(", "self", ".", "history", ")", "==", "self", ".", "maxsize", ":", "expectorate", "=", "self", ".", "history", "[", "0", "]", "else...
Adds a new key-value pair. Returns any discarded values.
[ "Adds", "a", "new", "key", "-", "value", "pair", ".", "Returns", "any", "discarded", "values", "." ]
train
https://github.com/mediawiki-utilities/python-mwreverts/blob/d379ac941e14e235ad82a48bd445a3dfa6cc022e/mwreverts/historical_dict.py#L28-L52
mediawiki-utilities/python-mwreverts
mwreverts/historical_dict.py
HistoricalDict.up_to
def up_to(self, key): '''Gets the recently inserted values up to a key''' for okey, ovalue in reversed(self.history): if okey == key: break else: yield ovalue
python
def up_to(self, key): '''Gets the recently inserted values up to a key''' for okey, ovalue in reversed(self.history): if okey == key: break else: yield ovalue
[ "def", "up_to", "(", "self", ",", "key", ")", ":", "for", "okey", ",", "ovalue", "in", "reversed", "(", "self", ".", "history", ")", ":", "if", "okey", "==", "key", ":", "break", "else", ":", "yield", "ovalue" ]
Gets the recently inserted values up to a key
[ "Gets", "the", "recently", "inserted", "values", "up", "to", "a", "key" ]
train
https://github.com/mediawiki-utilities/python-mwreverts/blob/d379ac941e14e235ad82a48bd445a3dfa6cc022e/mwreverts/historical_dict.py#L60-L66
olivier-m/rafter
rafter/app.py
Rafter.resource
def resource(self, uri, methods=frozenset({'GET'}), **kwargs): """ Decorates a function to be registered as a resource route. :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param strict_slashes: :param stream: :...
python
def resource(self, uri, methods=frozenset({'GET'}), **kwargs): """ Decorates a function to be registered as a resource route. :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param strict_slashes: :param stream: :...
[ "def", "resource", "(", "self", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "'GET'", "}", ")", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "kwargs", ".", "get", "(", "'stream'", ")", ":", "f", "....
Decorates a function to be registered as a resource route. :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param strict_slashes: :param stream: :param version: :param name: user defined route name for url_for :pa...
[ "Decorates", "a", "function", "to", "be", "registered", "as", "a", "resource", "route", "." ]
train
https://github.com/olivier-m/rafter/blob/aafcf8fd019f24abcf519307c4484cc6b4697c04/rafter/app.py#L66-L88
olivier-m/rafter
rafter/app.py
Rafter.add_resource
def add_resource(self, handler, uri, methods=frozenset({'GET'}), **kwargs): """ Register a resource route. :param handler: function or class instance :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :p...
python
def add_resource(self, handler, uri, methods=frozenset({'GET'}), **kwargs): """ Register a resource route. :param handler: function or class instance :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :p...
[ "def", "add_resource", "(", "self", ",", "handler", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "'GET'", "}", ")", ",", "*", "*", "kwargs", ")", ":", "sanic_args", "=", "(", "'host'", ",", "'strict_slashes'", ",", "'version'", ",", "'name'"...
Register a resource route. :param handler: function or class instance :param uri: path of the URL :param methods: list or tuple of methods allowed :param host: :param strict_slashes: :param version: :param name: user defined route name for url_for :param ...
[ "Register", "a", "resource", "route", "." ]
train
https://github.com/olivier-m/rafter/blob/aafcf8fd019f24abcf519307c4484cc6b4697c04/rafter/app.py#L90-L127
mediawiki-utilities/python-mwreverts
mwreverts/api.py
check
def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None): """ Checks the revert status of a revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by another edit and/or was 'reverted_to' by another ed...
python
def check(session, rev_id, page_id=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None): """ Checks the revert status of a revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by another edit and/or was 'reverted_to' by another ed...
[ "def", "check", "(", "session", ",", "rev_id", ",", "page_id", "=", "None", ",", "radius", "=", "defaults", ".", "RADIUS", ",", "before", "=", "None", ",", "window", "=", "None", ",", "rvprop", "=", "None", ")", ":", "rev_id", "=", "int", "(", "rev...
Checks the revert status of a revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by another edit and/or was 'reverted_to' by another edit. :Parameters: session : :class:`mwapi.Session` An API session to make use of rev_id : int ...
[ "Checks", "the", "revert", "status", "of", "a", "revision", ".", "With", "this", "method", "you", "can", "determine", "whether", "an", "edit", "is", "a", "reverting", "edit", "was", "reverted", "by", "another", "edit", "and", "/", "or", "was", "reverted_to...
train
https://github.com/mediawiki-utilities/python-mwreverts/blob/d379ac941e14e235ad82a48bd445a3dfa6cc022e/mwreverts/api.py#L58-L163
mediawiki-utilities/python-mwreverts
mwreverts/api.py
check_deleted
def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None): """ Checks the revert status of a deleted revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by...
python
def check_deleted(session, rev_id, title=None, timestamp=None, radius=defaults.RADIUS, before=None, window=None, rvprop=None): """ Checks the revert status of a deleted revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by...
[ "def", "check_deleted", "(", "session", ",", "rev_id", ",", "title", "=", "None", ",", "timestamp", "=", "None", ",", "radius", "=", "defaults", ".", "RADIUS", ",", "before", "=", "None", ",", "window", "=", "None", ",", "rvprop", "=", "None", ")", "...
Checks the revert status of a deleted revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by another edit and/or was 'reverted_to' by another edit. :Parameters: session : :class:`mwapi.Session` An API session to make use of rev_id...
[ "Checks", "the", "revert", "status", "of", "a", "deleted", "revision", ".", "With", "this", "method", "you", "can", "determine", "whether", "an", "edit", "is", "a", "reverting", "edit", "was", "reverted", "by", "another", "edit", "and", "/", "or", "was", ...
train
https://github.com/mediawiki-utilities/python-mwreverts/blob/d379ac941e14e235ad82a48bd445a3dfa6cc022e/mwreverts/api.py#L210-L286
rcbops/osa_differ
osa_differ/osa_differ.py
get_commits
def get_commits(repo_dir, old_commit, new_commit, hide_merges=True): """Find all commits between two commit SHAs.""" repo = Repo(repo_dir) commits = repo.iter_commits(rev="{0}..{1}".format(old_commit, new_commit)) if hide_merges: return [x for x in commits if not x.summary.startswith("Merge ")] ...
python
def get_commits(repo_dir, old_commit, new_commit, hide_merges=True): """Find all commits between two commit SHAs.""" repo = Repo(repo_dir) commits = repo.iter_commits(rev="{0}..{1}".format(old_commit, new_commit)) if hide_merges: return [x for x in commits if not x.summary.startswith("Merge ")] ...
[ "def", "get_commits", "(", "repo_dir", ",", "old_commit", ",", "new_commit", ",", "hide_merges", "=", "True", ")", ":", "repo", "=", "Repo", "(", "repo_dir", ")", "commits", "=", "repo", ".", "iter_commits", "(", "rev", "=", "\"{0}..{1}\"", ".", "format", ...
Find all commits between two commit SHAs.
[ "Find", "all", "commits", "between", "two", "commit", "SHAs", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L181-L188
rcbops/osa_differ
osa_differ/osa_differ.py
get_commit_url
def get_commit_url(repo_url): """Determine URL to view commits for repo.""" if "github.com" in repo_url: return repo_url[:-4] if repo_url.endswith(".git") else repo_url if "git.openstack.org" in repo_url: uri = '/'.join(repo_url.split('/')[-2:]) return "https://github.com/{0}".format...
python
def get_commit_url(repo_url): """Determine URL to view commits for repo.""" if "github.com" in repo_url: return repo_url[:-4] if repo_url.endswith(".git") else repo_url if "git.openstack.org" in repo_url: uri = '/'.join(repo_url.split('/')[-2:]) return "https://github.com/{0}".format...
[ "def", "get_commit_url", "(", "repo_url", ")", ":", "if", "\"github.com\"", "in", "repo_url", ":", "return", "repo_url", "[", ":", "-", "4", "]", "if", "repo_url", ".", "endswith", "(", "\".git\"", ")", "else", "repo_url", "if", "\"git.openstack.org\"", "in"...
Determine URL to view commits for repo.
[ "Determine", "URL", "to", "view", "commits", "for", "repo", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L191-L200
rcbops/osa_differ
osa_differ/osa_differ.py
get_projects
def get_projects(osa_repo_dir, commit): """Get all projects from multiple YAML files.""" # Check out the correct commit SHA from the repository repo = Repo(osa_repo_dir) checkout(repo, commit) yaml_files = glob.glob( '{0}/playbooks/defaults/repo_packages/*.yml'.format(osa_repo_dir) ) ...
python
def get_projects(osa_repo_dir, commit): """Get all projects from multiple YAML files.""" # Check out the correct commit SHA from the repository repo = Repo(osa_repo_dir) checkout(repo, commit) yaml_files = glob.glob( '{0}/playbooks/defaults/repo_packages/*.yml'.format(osa_repo_dir) ) ...
[ "def", "get_projects", "(", "osa_repo_dir", ",", "commit", ")", ":", "# Check out the correct commit SHA from the repository", "repo", "=", "Repo", "(", "osa_repo_dir", ")", "checkout", "(", "repo", ",", "commit", ")", "yaml_files", "=", "glob", ".", "glob", "(", ...
Get all projects from multiple YAML files.
[ "Get", "all", "projects", "from", "multiple", "YAML", "files", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L203-L219
rcbops/osa_differ
osa_differ/osa_differ.py
checkout
def checkout(repo, ref): """Checkout a repoself.""" # Delete local branch if it exists, remote branch will be tracked # automatically. This prevents stale local branches from causing problems. # It also avoids problems with appending origin/ to refs as that doesn't # work with tags, SHAs, and upstre...
python
def checkout(repo, ref): """Checkout a repoself.""" # Delete local branch if it exists, remote branch will be tracked # automatically. This prevents stale local branches from causing problems. # It also avoids problems with appending origin/ to refs as that doesn't # work with tags, SHAs, and upstre...
[ "def", "checkout", "(", "repo", ",", "ref", ")", ":", "# Delete local branch if it exists, remote branch will be tracked", "# automatically. This prevents stale local branches from causing problems.", "# It also avoids problems with appending origin/ to refs as that doesn't", "# work with tags...
Checkout a repoself.
[ "Checkout", "a", "repoself", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L222-L245
rcbops/osa_differ
osa_differ/osa_differ.py
get_roles
def get_roles(osa_repo_dir, commit, role_requirements): """Read OSA role information at a particular commit.""" repo = Repo(osa_repo_dir) checkout(repo, commit) log.info("Looking for file {f} in repo {r}".format(r=osa_repo_dir, f=role_requirements...
python
def get_roles(osa_repo_dir, commit, role_requirements): """Read OSA role information at a particular commit.""" repo = Repo(osa_repo_dir) checkout(repo, commit) log.info("Looking for file {f} in repo {r}".format(r=osa_repo_dir, f=role_requirements...
[ "def", "get_roles", "(", "osa_repo_dir", ",", "commit", ",", "role_requirements", ")", ":", "repo", "=", "Repo", "(", "osa_repo_dir", ")", "checkout", "(", "repo", ",", "commit", ")", "log", ".", "info", "(", "\"Looking for file {f} in repo {r}\"", ".", "forma...
Read OSA role information at a particular commit.
[ "Read", "OSA", "role", "information", "at", "a", "particular", "commit", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L248-L260
rcbops/osa_differ
osa_differ/osa_differ.py
make_osa_report
def make_osa_report(repo_dir, old_commit, new_commit, args): """Create initial RST report header for OpenStack-Ansible.""" update_repo(repo_dir, args.osa_repo_url, args.update) # Are these commits valid? validate_commits(repo_dir, [old_commit, new_commit]) # Do we have a valid ...
python
def make_osa_report(repo_dir, old_commit, new_commit, args): """Create initial RST report header for OpenStack-Ansible.""" update_repo(repo_dir, args.osa_repo_url, args.update) # Are these commits valid? validate_commits(repo_dir, [old_commit, new_commit]) # Do we have a valid ...
[ "def", "make_osa_report", "(", "repo_dir", ",", "old_commit", ",", "new_commit", ",", "args", ")", ":", "update_repo", "(", "repo_dir", ",", "args", ".", "osa_repo_url", ",", "args", ".", "update", ")", "# Are these commits valid?", "validate_commits", "(", "rep...
Create initial RST report header for OpenStack-Ansible.
[ "Create", "initial", "RST", "report", "header", "for", "OpenStack", "-", "Ansible", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L263-L286
rcbops/osa_differ
osa_differ/osa_differ.py
make_report
def make_report(storage_directory, old_pins, new_pins, do_update=False, version_mappings=None): """Create RST report from a list of projects/roles.""" report = "" version_mappings = version_mappings or {} for new_pin in new_pins: repo_name, repo_url, commit_sha = new_pin ...
python
def make_report(storage_directory, old_pins, new_pins, do_update=False, version_mappings=None): """Create RST report from a list of projects/roles.""" report = "" version_mappings = version_mappings or {} for new_pin in new_pins: repo_name, repo_url, commit_sha = new_pin ...
[ "def", "make_report", "(", "storage_directory", ",", "old_pins", ",", "new_pins", ",", "do_update", "=", "False", ",", "version_mappings", "=", "None", ")", ":", "report", "=", "\"\"", "version_mappings", "=", "version_mappings", "or", "{", "}", "for", "new_pi...
Create RST report from a list of projects/roles.
[ "Create", "RST", "report", "from", "a", "list", "of", "projects", "/", "roles", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L289-L329
rcbops/osa_differ
osa_differ/osa_differ.py
normalize_yaml
def normalize_yaml(yaml): """Normalize the YAML from project and role lookups. These are returned as a list of tuples. """ if isinstance(yaml, list): # Normalize the roles YAML data normalized_yaml = [(x['name'], x['src'], x.get('version', 'HEAD')) for x in ya...
python
def normalize_yaml(yaml): """Normalize the YAML from project and role lookups. These are returned as a list of tuples. """ if isinstance(yaml, list): # Normalize the roles YAML data normalized_yaml = [(x['name'], x['src'], x.get('version', 'HEAD')) for x in ya...
[ "def", "normalize_yaml", "(", "yaml", ")", ":", "if", "isinstance", "(", "yaml", ",", "list", ")", ":", "# Normalize the roles YAML data", "normalized_yaml", "=", "[", "(", "x", "[", "'name'", "]", ",", "x", "[", "'src'", "]", ",", "x", ".", "get", "("...
Normalize the YAML from project and role lookups. These are returned as a list of tuples.
[ "Normalize", "the", "YAML", "from", "project", "and", "role", "lookups", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L332-L351
rcbops/osa_differ
osa_differ/osa_differ.py
post_gist
def post_gist(report_data, old_sha, new_sha): """Post the report to a GitHub Gist and return the URL of the gist.""" payload = { "description": ("Changes in OpenStack-Ansible between " "{0} and {1}".format(old_sha, new_sha)), "public": True, "files": { ...
python
def post_gist(report_data, old_sha, new_sha): """Post the report to a GitHub Gist and return the URL of the gist.""" payload = { "description": ("Changes in OpenStack-Ansible between " "{0} and {1}".format(old_sha, new_sha)), "public": True, "files": { ...
[ "def", "post_gist", "(", "report_data", ",", "old_sha", ",", "new_sha", ")", ":", "payload", "=", "{", "\"description\"", ":", "(", "\"Changes in OpenStack-Ansible between \"", "\"{0} and {1}\"", ".", "format", "(", "old_sha", ",", "new_sha", ")", ")", ",", "\"p...
Post the report to a GitHub Gist and return the URL of the gist.
[ "Post", "the", "report", "to", "a", "GitHub", "Gist", "and", "return", "the", "URL", "of", "the", "gist", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L361-L376
rcbops/osa_differ
osa_differ/osa_differ.py
prepare_storage_dir
def prepare_storage_dir(storage_directory): """Prepare the storage directory.""" storage_directory = os.path.expanduser(storage_directory) if not os.path.exists(storage_directory): os.mkdir(storage_directory) return storage_directory
python
def prepare_storage_dir(storage_directory): """Prepare the storage directory.""" storage_directory = os.path.expanduser(storage_directory) if not os.path.exists(storage_directory): os.mkdir(storage_directory) return storage_directory
[ "def", "prepare_storage_dir", "(", "storage_directory", ")", ":", "storage_directory", "=", "os", ".", "path", ".", "expanduser", "(", "storage_directory", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "storage_directory", ")", ":", "os", ".", "mk...
Prepare the storage directory.
[ "Prepare", "the", "storage", "directory", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L399-L405
rcbops/osa_differ
osa_differ/osa_differ.py
render_template
def render_template(template_file, template_vars): """Render a jinja template.""" # Load our Jinja templates template_dir = "{0}/templates".format( os.path.dirname(os.path.abspath(__file__)) ) jinja_env = jinja2.Environment( loader=jinja2.FileSystemLoader(template_dir), trim_...
python
def render_template(template_file, template_vars): """Render a jinja template.""" # Load our Jinja templates template_dir = "{0}/templates".format( os.path.dirname(os.path.abspath(__file__)) ) jinja_env = jinja2.Environment( loader=jinja2.FileSystemLoader(template_dir), trim_...
[ "def", "render_template", "(", "template_file", ",", "template_vars", ")", ":", "# Load our Jinja templates", "template_dir", "=", "\"{0}/templates\"", ".", "format", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__"...
Render a jinja template.
[ "Render", "a", "jinja", "template", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L408-L420
rcbops/osa_differ
osa_differ/osa_differ.py
repo_pull
def repo_pull(repo_dir, repo_url, fetch=False): """Reset repository and optionally update it.""" # Make sure the repository is reset to the master branch. repo = Repo(repo_dir) repo.git.clean("-df") repo.git.reset("--hard") repo.git.checkout("master") repo.head.reset(index=True, working_tree...
python
def repo_pull(repo_dir, repo_url, fetch=False): """Reset repository and optionally update it.""" # Make sure the repository is reset to the master branch. repo = Repo(repo_dir) repo.git.clean("-df") repo.git.reset("--hard") repo.git.checkout("master") repo.head.reset(index=True, working_tree...
[ "def", "repo_pull", "(", "repo_dir", ",", "repo_url", ",", "fetch", "=", "False", ")", ":", "# Make sure the repository is reset to the master branch.", "repo", "=", "Repo", "(", "repo_dir", ")", "repo", ".", "git", ".", "clean", "(", "\"-df\"", ")", "repo", "...
Reset repository and optionally update it.
[ "Reset", "repository", "and", "optionally", "update", "it", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L429-L456
rcbops/osa_differ
osa_differ/osa_differ.py
update_repo
def update_repo(repo_dir, repo_url, fetch=False): """Clone the repo if it doesn't exist already, otherwise update it.""" repo_exists = os.path.exists(repo_dir) if not repo_exists: log.info("Cloning repo {}".format(repo_url)) repo = repo_clone(repo_dir, repo_url) # Make sure the repo is ...
python
def update_repo(repo_dir, repo_url, fetch=False): """Clone the repo if it doesn't exist already, otherwise update it.""" repo_exists = os.path.exists(repo_dir) if not repo_exists: log.info("Cloning repo {}".format(repo_url)) repo = repo_clone(repo_dir, repo_url) # Make sure the repo is ...
[ "def", "update_repo", "(", "repo_dir", ",", "repo_url", ",", "fetch", "=", "False", ")", ":", "repo_exists", "=", "os", ".", "path", ".", "exists", "(", "repo_dir", ")", "if", "not", "repo_exists", ":", "log", ".", "info", "(", "\"Cloning repo {}\"", "."...
Clone the repo if it doesn't exist already, otherwise update it.
[ "Clone", "the", "repo", "if", "it", "doesn", "t", "exist", "already", "otherwise", "update", "it", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L459-L471
rcbops/osa_differ
osa_differ/osa_differ.py
validate_commits
def validate_commits(repo_dir, commits): """Test if a commit is valid for the repository.""" log.debug("Validating {c} exist in {r}".format(c=commits, r=repo_dir)) repo = Repo(repo_dir) for commit in commits: try: commit = repo.commit(commit) except Exception: msg...
python
def validate_commits(repo_dir, commits): """Test if a commit is valid for the repository.""" log.debug("Validating {c} exist in {r}".format(c=commits, r=repo_dir)) repo = Repo(repo_dir) for commit in commits: try: commit = repo.commit(commit) except Exception: msg...
[ "def", "validate_commits", "(", "repo_dir", ",", "commits", ")", ":", "log", ".", "debug", "(", "\"Validating {c} exist in {r}\"", ".", "format", "(", "c", "=", "commits", ",", "r", "=", "repo_dir", ")", ")", "repo", "=", "Repo", "(", "repo_dir", ")", "f...
Test if a commit is valid for the repository.
[ "Test", "if", "a", "commit", "is", "valid", "for", "the", "repository", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L474-L488
rcbops/osa_differ
osa_differ/osa_differ.py
validate_commit_range
def validate_commit_range(repo_dir, old_commit, new_commit): """Check if commit range is valid. Flip it if needed.""" # Are there any commits between the two commits that were provided? try: commits = get_commits(repo_dir, old_commit, new_commit) except Exception: commits = [] if len...
python
def validate_commit_range(repo_dir, old_commit, new_commit): """Check if commit range is valid. Flip it if needed.""" # Are there any commits between the two commits that were provided? try: commits = get_commits(repo_dir, old_commit, new_commit) except Exception: commits = [] if len...
[ "def", "validate_commit_range", "(", "repo_dir", ",", "old_commit", ",", "new_commit", ")", ":", "# Are there any commits between the two commits that were provided?", "try", ":", "commits", "=", "get_commits", "(", "repo_dir", ",", "old_commit", ",", "new_commit", ")", ...
Check if commit range is valid. Flip it if needed.
[ "Check", "if", "commit", "range", "is", "valid", ".", "Flip", "it", "if", "needed", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L491-L516
rcbops/osa_differ
osa_differ/osa_differ.py
get_release_notes
def get_release_notes(osa_repo_dir, osa_old_commit, osa_new_commit): """Get release notes between the two revisions.""" repo = Repo(osa_repo_dir) # Get a list of tags, sorted tags = repo.git.tag().split('\n') tags = sorted(tags, key=LooseVersion) # Currently major tags are being printed after r...
python
def get_release_notes(osa_repo_dir, osa_old_commit, osa_new_commit): """Get release notes between the two revisions.""" repo = Repo(osa_repo_dir) # Get a list of tags, sorted tags = repo.git.tag().split('\n') tags = sorted(tags, key=LooseVersion) # Currently major tags are being printed after r...
[ "def", "get_release_notes", "(", "osa_repo_dir", ",", "osa_old_commit", ",", "osa_new_commit", ")", ":", "repo", "=", "Repo", "(", "osa_repo_dir", ")", "# Get a list of tags, sorted", "tags", "=", "repo", ".", "git", ".", "tag", "(", ")", ".", "split", "(", ...
Get release notes between the two revisions.
[ "Get", "release", "notes", "between", "the", "two", "revisions", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L519-L614
rcbops/osa_differ
osa_differ/osa_differ.py
run_osa_differ
def run_osa_differ(): """Start here.""" # Get our arguments from the command line args = parse_arguments() # Set up DEBUG logging if needed if args.debug: log.setLevel(logging.DEBUG) elif args.verbose: log.setLevel(logging.INFO) # Create the storage directory if it doesn't ...
python
def run_osa_differ(): """Start here.""" # Get our arguments from the command line args = parse_arguments() # Set up DEBUG logging if needed if args.debug: log.setLevel(logging.DEBUG) elif args.verbose: log.setLevel(logging.INFO) # Create the storage directory if it doesn't ...
[ "def", "run_osa_differ", "(", ")", ":", "# Get our arguments from the command line", "args", "=", "parse_arguments", "(", ")", "# Set up DEBUG logging if needed", "if", "args", ".", "debug", ":", "log", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "elif", "...
Start here.
[ "Start", "here", "." ]
train
https://github.com/rcbops/osa_differ/blob/b3452436655ba3db8cc6602390fd7fdf4ef30f01/osa_differ/osa_differ.py#L646-L720
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
append_new_text
def append_new_text(destination, text, join_str=None): """ This method provides the functionality of adding text appropriately underneath the destination node. This will be either to the destination's text attribute or to the tail attribute of the last child. """ if join_str is None: joi...
python
def append_new_text(destination, text, join_str=None): """ This method provides the functionality of adding text appropriately underneath the destination node. This will be either to the destination's text attribute or to the tail attribute of the last child. """ if join_str is None: joi...
[ "def", "append_new_text", "(", "destination", ",", "text", ",", "join_str", "=", "None", ")", ":", "if", "join_str", "is", "None", ":", "join_str", "=", "' '", "if", "len", "(", "destination", ")", ">", "0", ":", "# Destination has children", "last", "=", ...
This method provides the functionality of adding text appropriately underneath the destination node. This will be either to the destination's text attribute or to the tail attribute of the last child.
[ "This", "method", "provides", "the", "functionality", "of", "adding", "text", "appropriately", "underneath", "the", "destination", "node", ".", "This", "will", "be", "either", "to", "the", "destination", "s", "text", "attribute", "or", "to", "the", "tail", "at...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L24-L42
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
append_all_below
def append_all_below(destination, source, join_str=None): """ Compared to xml.dom.minidom, lxml's treatment of text as .text and .tail attributes of elements is an oddity. It can even be a little frustrating when one is attempting to copy everything underneath some element to another element; one ha...
python
def append_all_below(destination, source, join_str=None): """ Compared to xml.dom.minidom, lxml's treatment of text as .text and .tail attributes of elements is an oddity. It can even be a little frustrating when one is attempting to copy everything underneath some element to another element; one ha...
[ "def", "append_all_below", "(", "destination", ",", "source", ",", "join_str", "=", "None", ")", ":", "if", "join_str", "is", "None", ":", "join_str", "=", "' '", "if", "source", ".", "text", "is", "not", "None", ":", "# If source has text", "if", "len", ...
Compared to xml.dom.minidom, lxml's treatment of text as .text and .tail attributes of elements is an oddity. It can even be a little frustrating when one is attempting to copy everything underneath some element to another element; one has to write in extra code to handle the text. This method provides ...
[ "Compared", "to", "xml", ".", "dom", ".", "minidom", "lxml", "s", "treatment", "of", "text", "as", ".", "text", "and", ".", "tail", "attributes", "of", "elements", "is", "an", "oddity", ".", "It", "can", "even", "be", "a", "little", "frustrating", "whe...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L45-L70
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
all_text
def all_text(element): """ A method for extending lxml's functionality, this will find and concatenate all text data that exists one level immediately underneath the given element. Unlike etree.tostring(element, method='text'), this will not recursively walk the entire underlying tree. It merely com...
python
def all_text(element): """ A method for extending lxml's functionality, this will find and concatenate all text data that exists one level immediately underneath the given element. Unlike etree.tostring(element, method='text'), this will not recursively walk the entire underlying tree. It merely com...
[ "def", "all_text", "(", "element", ")", ":", "if", "element", ".", "text", "is", "None", ":", "text", "=", "[", "]", "else", ":", "text", "=", "[", "element", ".", "text", "]", "tails", "=", "[", "child", ".", "tail", "for", "child", "in", "eleme...
A method for extending lxml's functionality, this will find and concatenate all text data that exists one level immediately underneath the given element. Unlike etree.tostring(element, method='text'), this will not recursively walk the entire underlying tree. It merely combines the element text attribut...
[ "A", "method", "for", "extending", "lxml", "s", "functionality", "this", "will", "find", "and", "concatenate", "all", "text", "data", "that", "exists", "one", "level", "immediately", "underneath", "the", "given", "element", ".", "Unlike", "etree", ".", "tostri...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L73-L87
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
remove_all_attributes
def remove_all_attributes(element, exclude=None): """ This method will remove all attributes of any provided element. A list of strings may be passed to the keyward-argument "exclude", which will serve as a list of attributes which will not be removed. """ if exclude is None: exclude = ...
python
def remove_all_attributes(element, exclude=None): """ This method will remove all attributes of any provided element. A list of strings may be passed to the keyward-argument "exclude", which will serve as a list of attributes which will not be removed. """ if exclude is None: exclude = ...
[ "def", "remove_all_attributes", "(", "element", ",", "exclude", "=", "None", ")", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "[", "]", "for", "k", "in", "element", ".", "attrib", ".", "keys", "(", ")", ":", "if", "k", "not", "in", "ex...
This method will remove all attributes of any provided element. A list of strings may be passed to the keyward-argument "exclude", which will serve as a list of attributes which will not be removed.
[ "This", "method", "will", "remove", "all", "attributes", "of", "any", "provided", "element", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L90-L101
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
ns_format
def ns_format(element, namespaced_string): """ Provides a convenient method for adapting a tag or attribute name to use lxml's format. Use this for tags like ops:switch or attributes like xlink:href. """ if ':' not in namespaced_string: print('This name contains no namespace, returning i...
python
def ns_format(element, namespaced_string): """ Provides a convenient method for adapting a tag or attribute name to use lxml's format. Use this for tags like ops:switch or attributes like xlink:href. """ if ':' not in namespaced_string: print('This name contains no namespace, returning i...
[ "def", "ns_format", "(", "element", ",", "namespaced_string", ")", ":", "if", "':'", "not", "in", "namespaced_string", ":", "print", "(", "'This name contains no namespace, returning it unmodified: '", "+", "namespaced_string", ")", "return", "namespaced_string", "namespa...
Provides a convenient method for adapting a tag or attribute name to use lxml's format. Use this for tags like ops:switch or attributes like xlink:href.
[ "Provides", "a", "convenient", "method", "for", "adapting", "a", "tag", "or", "attribute", "name", "to", "use", "lxml", "s", "format", ".", "Use", "this", "for", "tags", "like", "ops", ":", "switch", "or", "attributes", "like", "xlink", ":", "href", "." ...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L136-L146
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
rename_attributes
def rename_attributes(element, attrs): """ Renames the attributes of the element. Accepts the element and a dictionary of string values. The keys are the original names, and their values will be the altered names. This method treats all attributes as optional and will not fail on missing attributes....
python
def rename_attributes(element, attrs): """ Renames the attributes of the element. Accepts the element and a dictionary of string values. The keys are the original names, and their values will be the altered names. This method treats all attributes as optional and will not fail on missing attributes....
[ "def", "rename_attributes", "(", "element", ",", "attrs", ")", ":", "for", "name", "in", "attrs", ".", "keys", "(", ")", ":", "if", "name", "not", "in", "element", ".", "attrib", ":", "continue", "else", ":", "element", ".", "attrib", "[", "attrs", "...
Renames the attributes of the element. Accepts the element and a dictionary of string values. The keys are the original names, and their values will be the altered names. This method treats all attributes as optional and will not fail on missing attributes.
[ "Renames", "the", "attributes", "of", "the", "element", ".", "Accepts", "the", "element", "and", "a", "dictionary", "of", "string", "values", ".", "The", "keys", "are", "the", "original", "names", "and", "their", "values", "will", "be", "the", "altered", "...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L149-L160
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
elevate_element
def elevate_element(node, adopt_name=None, adopt_attrs=None): """ This method serves a specialized function. It comes up most often when working with block level elements that may not be contained within paragraph elements, which are presented in the source document as inline ele...
python
def elevate_element(node, adopt_name=None, adopt_attrs=None): """ This method serves a specialized function. It comes up most often when working with block level elements that may not be contained within paragraph elements, which are presented in the source document as inline ele...
[ "def", "elevate_element", "(", "node", ",", "adopt_name", "=", "None", ",", "adopt_attrs", "=", "None", ")", ":", "#These must be collected before modifying the xml", "parent", "=", "node", ".", "getparent", "(", ")", "grandparent", "=", "parent", ".", "getparent"...
This method serves a specialized function. It comes up most often when working with block level elements that may not be contained within paragraph elements, which are presented in the source document as inline elements (inside a paragraph element). It would be inappropriate to merely i...
[ "This", "method", "serves", "a", "specialized", "function", ".", "It", "comes", "up", "most", "often", "when", "working", "with", "block", "level", "elements", "that", "may", "not", "be", "contained", "within", "paragraph", "elements", "which", "are", "present...
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L163-L212
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
replace
def replace(old, new): """ A simple way to replace one element node with another. """ parent = old.getparent() parent.replace(old, new)
python
def replace(old, new): """ A simple way to replace one element node with another. """ parent = old.getparent() parent.replace(old, new)
[ "def", "replace", "(", "old", ",", "new", ")", ":", "parent", "=", "old", ".", "getparent", "(", ")", "parent", ".", "replace", "(", "old", ",", "new", ")" ]
A simple way to replace one element node with another.
[ "A", "simple", "way", "to", "replace", "one", "element", "node", "with", "another", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L223-L228
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
insert_before
def insert_before(old, new): """ A simple way to insert a new element node before the old element node among its siblings. """ parent = old.getparent() parent.insert(parent.index(old), new)
python
def insert_before(old, new): """ A simple way to insert a new element node before the old element node among its siblings. """ parent = old.getparent() parent.insert(parent.index(old), new)
[ "def", "insert_before", "(", "old", ",", "new", ")", ":", "parent", "=", "old", ".", "getparent", "(", ")", "parent", ".", "insert", "(", "parent", ".", "index", "(", "old", ")", ",", "new", ")" ]
A simple way to insert a new element node before the old element node among its siblings.
[ "A", "simple", "way", "to", "insert", "a", "new", "element", "node", "before", "the", "old", "element", "node", "among", "its", "siblings", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L231-L237
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
comment
def comment(node): """ Converts the node received to a comment, in place, and will also return the comment element. """ parent = node.parentNode comment = node.ownerDocument.createComment(node.toxml()) parent.replaceChild(comment, node) return comment
python
def comment(node): """ Converts the node received to a comment, in place, and will also return the comment element. """ parent = node.parentNode comment = node.ownerDocument.createComment(node.toxml()) parent.replaceChild(comment, node) return comment
[ "def", "comment", "(", "node", ")", ":", "parent", "=", "node", ".", "parentNode", "comment", "=", "node", ".", "ownerDocument", ".", "createComment", "(", "node", ".", "toxml", "(", ")", ")", "parent", ".", "replaceChild", "(", "comment", ",", "node", ...
Converts the node received to a comment, in place, and will also return the comment element.
[ "Converts", "the", "node", "received", "to", "a", "comment", "in", "place", "and", "will", "also", "return", "the", "comment", "element", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L240-L248
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
uncomment
def uncomment(comment): """ Converts the comment node received to a non-commented element, in place, and will return the new node. This may fail, primarily due to special characters within the comment that the xml parser is unable to handle. If it fails, this method will log an error and return...
python
def uncomment(comment): """ Converts the comment node received to a non-commented element, in place, and will return the new node. This may fail, primarily due to special characters within the comment that the xml parser is unable to handle. If it fails, this method will log an error and return...
[ "def", "uncomment", "(", "comment", ")", ":", "parent", "=", "comment", ".", "parentNode", "h", "=", "html", ".", "parser", ".", "HTMLParser", "(", ")", "data", "=", "h", ".", "unescape", "(", "comment", ".", "data", ")", "try", ":", "node", "=", "...
Converts the comment node received to a non-commented element, in place, and will return the new node. This may fail, primarily due to special characters within the comment that the xml parser is unable to handle. If it fails, this method will log an error and return None
[ "Converts", "the", "comment", "node", "received", "to", "a", "non", "-", "commented", "element", "in", "place", "and", "will", "return", "the", "new", "node", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L251-L270
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/element_methods.py
serialize
def serialize(element, strip=False): """ A handy way to serialize an element to text. """ text = etree.tostring(element, method='text', encoding='utf-8') if strip: text = text.strip() return str(text, encoding='utf-8')
python
def serialize(element, strip=False): """ A handy way to serialize an element to text. """ text = etree.tostring(element, method='text', encoding='utf-8') if strip: text = text.strip() return str(text, encoding='utf-8')
[ "def", "serialize", "(", "element", ",", "strip", "=", "False", ")", ":", "text", "=", "etree", ".", "tostring", "(", "element", ",", "method", "=", "'text'", ",", "encoding", "=", "'utf-8'", ")", "if", "strip", ":", "text", "=", "text", ".", "strip"...
A handy way to serialize an element to text.
[ "A", "handy", "way", "to", "serialize", "an", "element", "to", "text", "." ]
train
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/element_methods.py#L273-L280
MSchnei/pyprf_feature
pyprf_feature/analysis/pyprf_opt_ep.py
get_arg_parse
def get_arg_parse(): """Parses the Command Line Arguments using argparse.""" # Create parser object: objParser = argparse.ArgumentParser() # Add argument to namespace -config file path: objParser.add_argument('-config', required=True, metavar='/path/to/config.csv', ...
python
def get_arg_parse(): """Parses the Command Line Arguments using argparse.""" # Create parser object: objParser = argparse.ArgumentParser() # Add argument to namespace -config file path: objParser.add_argument('-config', required=True, metavar='/path/to/config.csv', ...
[ "def", "get_arg_parse", "(", ")", ":", "# Create parser object:", "objParser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# Add argument to namespace -config file path:", "objParser", ".", "add_argument", "(", "'-config'", ",", "required", "=", "True", ",", "m...
Parses the Command Line Arguments using argparse.
[ "Parses", "the", "Command", "Line", "Arguments", "using", "argparse", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_opt_ep.py#L16-L71
MSchnei/pyprf_feature
pyprf_feature/analysis/pyprf_opt_ep.py
main
def main(): """pyprf_opt_brute entry point.""" # Get list of input arguments (without first one, which is the path to the # function that is called): --NOTE: This is another way of accessing # input arguments, but since we use 'argparse' it is redundant. # lstArgs = sys.argv[1:] strWelcome = 'p...
python
def main(): """pyprf_opt_brute entry point.""" # Get list of input arguments (without first one, which is the path to the # function that is called): --NOTE: This is another way of accessing # input arguments, but since we use 'argparse' it is redundant. # lstArgs = sys.argv[1:] strWelcome = 'p...
[ "def", "main", "(", ")", ":", "# Get list of input arguments (without first one, which is the path to the", "# function that is called): --NOTE: This is another way of accessing", "# input arguments, but since we use 'argparse' it is redundant.", "# lstArgs = sys.argv[1:]", "strWelcome", "=", ...
pyprf_opt_brute entry point.
[ "pyprf_opt_brute", "entry", "point", "." ]
train
https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_opt_ep.py#L74-L171
pmacosta/pcsv
pcsv/csv_file.py
_homogenize_data_filter
def _homogenize_data_filter(dfilter): """ Make data filter definition consistent. Create a tuple where first element is the row filter and the second element is the column filter """ if isinstance(dfilter, tuple) and (len(dfilter) == 1): dfilter = (dfilter[0], None) if (dfilter is N...
python
def _homogenize_data_filter(dfilter): """ Make data filter definition consistent. Create a tuple where first element is the row filter and the second element is the column filter """ if isinstance(dfilter, tuple) and (len(dfilter) == 1): dfilter = (dfilter[0], None) if (dfilter is N...
[ "def", "_homogenize_data_filter", "(", "dfilter", ")", ":", "if", "isinstance", "(", "dfilter", ",", "tuple", ")", "and", "(", "len", "(", "dfilter", ")", "==", "1", ")", ":", "dfilter", "=", "(", "dfilter", "[", "0", "]", ",", "None", ")", "if", "...
Make data filter definition consistent. Create a tuple where first element is the row filter and the second element is the column filter
[ "Make", "data", "filter", "definition", "consistent", "." ]
train
https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/csv_file.py#L38-L61
pmacosta/pcsv
pcsv/csv_file.py
_tofloat
def _tofloat(obj): """Convert to float if object is a float string.""" if "inf" in obj.lower().strip(): return obj try: return int(obj) except ValueError: try: return float(obj) except ValueError: return obj
python
def _tofloat(obj): """Convert to float if object is a float string.""" if "inf" in obj.lower().strip(): return obj try: return int(obj) except ValueError: try: return float(obj) except ValueError: return obj
[ "def", "_tofloat", "(", "obj", ")", ":", "if", "\"inf\"", "in", "obj", ".", "lower", "(", ")", ".", "strip", "(", ")", ":", "return", "obj", "try", ":", "return", "int", "(", "obj", ")", "except", "ValueError", ":", "try", ":", "return", "float", ...
Convert to float if object is a float string.
[ "Convert", "to", "float", "if", "object", "is", "a", "float", "string", "." ]
train
https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/csv_file.py#L64-L74
pmacosta/pcsv
pcsv/csv_file.py
CsvFile._in_header
def _in_header(self, col): """Validate column identifier(s).""" # pylint: disable=R1704 if not self._has_header: # Conditionally register exceptions so that they do not appear # in situations where has_header is always True. In this way # they are not auto-doc...
python
def _in_header(self, col): """Validate column identifier(s).""" # pylint: disable=R1704 if not self._has_header: # Conditionally register exceptions so that they do not appear # in situations where has_header is always True. In this way # they are not auto-doc...
[ "def", "_in_header", "(", "self", ",", "col", ")", ":", "# pylint: disable=R1704", "if", "not", "self", ".", "_has_header", ":", "# Conditionally register exceptions so that they do not appear", "# in situations where has_header is always True. In this way", "# they are not auto-do...
Validate column identifier(s).
[ "Validate", "column", "identifier", "(", "s", ")", "." ]
train
https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/csv_file.py#L367-L393
pmacosta/pcsv
pcsv/csv_file.py
CsvFile._validate_frow
def _validate_frow(self, frow): """Validate frow argument.""" is_int = isinstance(frow, int) and (not isinstance(frow, bool)) pexdoc.exh.addai("frow", not (is_int and (frow >= 0))) return frow
python
def _validate_frow(self, frow): """Validate frow argument.""" is_int = isinstance(frow, int) and (not isinstance(frow, bool)) pexdoc.exh.addai("frow", not (is_int and (frow >= 0))) return frow
[ "def", "_validate_frow", "(", "self", ",", "frow", ")", ":", "is_int", "=", "isinstance", "(", "frow", ",", "int", ")", "and", "(", "not", "isinstance", "(", "frow", ",", "bool", ")", ")", "pexdoc", ".", "exh", ".", "addai", "(", "\"frow\"", ",", "...
Validate frow argument.
[ "Validate", "frow", "argument", "." ]
train
https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/csv_file.py#L489-L493