repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
getObjectFromTaskArg
def getObjectFromTaskArg(theTask, strict, setAllToDefaults): """ Take the arg (usually called theTask), which can be either a subclass of ConfigObjPars, or a string package name, or a .cfg filename - no matter what it is - take it and return a ConfigObjPars object. strict - bool - warning severity, pass...
python
def getObjectFromTaskArg(theTask, strict, setAllToDefaults): """ Take the arg (usually called theTask), which can be either a subclass of ConfigObjPars, or a string package name, or a .cfg filename - no matter what it is - take it and return a ConfigObjPars object. strict - bool - warning severity, pass...
[ "def", "getObjectFromTaskArg", "(", "theTask", ",", "strict", ",", "setAllToDefaults", ")", ":", "# Already in the form we need (instance of us or of subclass)", "if", "isinstance", "(", "theTask", ",", "ConfigObjPars", ")", ":", "if", "setAllToDefaults", ":", "raise", ...
Take the arg (usually called theTask), which can be either a subclass of ConfigObjPars, or a string package name, or a .cfg filename - no matter what it is - take it and return a ConfigObjPars object. strict - bool - warning severity, passed to the ConfigObjPars() ctor setAllToDefaults - bool - if theTa...
[ "Take", "the", "arg", "(", "usually", "called", "theTask", ")", "which", "can", "be", "either", "a", "subclass", "of", "ConfigObjPars", "or", "a", "string", "package", "name", "or", "a", ".", "cfg", "filename", "-", "no", "matter", "what", "it", "is", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L45-L84
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
getEmbeddedKeyVal
def getEmbeddedKeyVal(cfgFileName, kwdName, dflt=None): """ Read a config file and pull out the value of a given keyword. """ # Assume this is a ConfigObj file. Use that s/w to quickly read it and # put it in dict format. Assume kwd is at top level (not in a section). # The input may also be a .cfgspc...
python
def getEmbeddedKeyVal(cfgFileName, kwdName, dflt=None): """ Read a config file and pull out the value of a given keyword. """ # Assume this is a ConfigObj file. Use that s/w to quickly read it and # put it in dict format. Assume kwd is at top level (not in a section). # The input may also be a .cfgspc...
[ "def", "getEmbeddedKeyVal", "(", "cfgFileName", ",", "kwdName", ",", "dflt", "=", "None", ")", ":", "# Assume this is a ConfigObj file. Use that s/w to quickly read it and", "# put it in dict format. Assume kwd is at top level (not in a section).", "# The input may also be a .cfgspc fi...
Read a config file and pull out the value of a given keyword.
[ "Read", "a", "config", "file", "and", "pull", "out", "the", "value", "of", "a", "given", "keyword", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L87-L120
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
findCfgFileForPkg
def findCfgFileForPkg(pkgName, theExt, pkgObj=None, taskName=None): """ Locate the configuration files for/from/within a given python package. pkgName is a string python package name. This is used unless pkgObj is given, in which case pkgName is taken from pkgObj.__name__. theExt is either '.cfg' or '....
python
def findCfgFileForPkg(pkgName, theExt, pkgObj=None, taskName=None): """ Locate the configuration files for/from/within a given python package. pkgName is a string python package name. This is used unless pkgObj is given, in which case pkgName is taken from pkgObj.__name__. theExt is either '.cfg' or '....
[ "def", "findCfgFileForPkg", "(", "pkgName", ",", "theExt", ",", "pkgObj", "=", "None", ",", "taskName", "=", "None", ")", ":", "# arg check", "ext", "=", "theExt", "if", "ext", "[", "0", "]", "!=", "'.'", ":", "ext", "=", "'.'", "+", "theExt", "# Do ...
Locate the configuration files for/from/within a given python package. pkgName is a string python package name. This is used unless pkgObj is given, in which case pkgName is taken from pkgObj.__name__. theExt is either '.cfg' or '.cfgspc'. If the task name is known, it is given as taskName, otherwise o...
[ "Locate", "the", "configuration", "files", "for", "/", "from", "/", "within", "a", "given", "python", "package", ".", "pkgName", "is", "a", "string", "python", "package", "name", ".", "This", "is", "used", "unless", "pkgObj", "is", "given", "in", "which", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L123-L193
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
findAllCfgTasksUnderDir
def findAllCfgTasksUnderDir(aDir): """ Finds all installed tasks by examining any .cfg files found on disk at and under the given directory, as an installation might be. This returns a dict of { file name : task name } """ retval = {} for f in irafutils.rglob(aDir, '*.cfg'): retv...
python
def findAllCfgTasksUnderDir(aDir): """ Finds all installed tasks by examining any .cfg files found on disk at and under the given directory, as an installation might be. This returns a dict of { file name : task name } """ retval = {} for f in irafutils.rglob(aDir, '*.cfg'): retv...
[ "def", "findAllCfgTasksUnderDir", "(", "aDir", ")", ":", "retval", "=", "{", "}", "for", "f", "in", "irafutils", ".", "rglob", "(", "aDir", ",", "'*.cfg'", ")", ":", "retval", "[", "f", "]", "=", "getEmbeddedKeyVal", "(", "f", ",", "TASK_NAME_KEY", ","...
Finds all installed tasks by examining any .cfg files found on disk at and under the given directory, as an installation might be. This returns a dict of { file name : task name }
[ "Finds", "all", "installed", "tasks", "by", "examining", "any", ".", "cfg", "files", "found", "on", "disk", "at", "and", "under", "the", "given", "directory", "as", "an", "installation", "might", "be", ".", "This", "returns", "a", "dict", "of", "{", "fil...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L196-L204
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
getCfgFilesInDirForTask
def getCfgFilesInDirForTask(aDir, aTask, recurse=False): """ This is a specialized function which is meant only to keep the same code from needlessly being much repeated throughout this application. This must be kept as fast and as light as possible. This checks a given directory for .cfg f...
python
def getCfgFilesInDirForTask(aDir, aTask, recurse=False): """ This is a specialized function which is meant only to keep the same code from needlessly being much repeated throughout this application. This must be kept as fast and as light as possible. This checks a given directory for .cfg f...
[ "def", "getCfgFilesInDirForTask", "(", "aDir", ",", "aTask", ",", "recurse", "=", "False", ")", ":", "if", "recurse", ":", "flist", "=", "irafutils", ".", "rglob", "(", "aDir", ",", "'*.cfg'", ")", "else", ":", "flist", "=", "glob", ".", "glob", "(", ...
This is a specialized function which is meant only to keep the same code from needlessly being much repeated throughout this application. This must be kept as fast and as light as possible. This checks a given directory for .cfg files matching a given task. If recurse is True, it will ...
[ "This", "is", "a", "specialized", "function", "which", "is", "meant", "only", "to", "keep", "the", "same", "code", "from", "needlessly", "being", "much", "repeated", "throughout", "this", "application", ".", "This", "must", "be", "kept", "as", "fast", "and",...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L207-L229
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
getParsObjForPyPkg
def getParsObjForPyPkg(pkgName, strict): """ Locate the appropriate ConfigObjPars (or subclass) within the given package. NOTE this begins the same way as getUsrCfgFilesForPyPkg(). Look for .cfg file matches in these places, in this order: 1 - any named .cfg file in current directory match...
python
def getParsObjForPyPkg(pkgName, strict): """ Locate the appropriate ConfigObjPars (or subclass) within the given package. NOTE this begins the same way as getUsrCfgFilesForPyPkg(). Look for .cfg file matches in these places, in this order: 1 - any named .cfg file in current directory match...
[ "def", "getParsObjForPyPkg", "(", "pkgName", ",", "strict", ")", ":", "# Get the python package and it's .cfg file - need this no matter what", "installedPkg", ",", "installedFile", "=", "findCfgFileForPkg", "(", "pkgName", ",", "'.cfg'", ")", "theFile", "=", "None", "tna...
Locate the appropriate ConfigObjPars (or subclass) within the given package. NOTE this begins the same way as getUsrCfgFilesForPyPkg(). Look for .cfg file matches in these places, in this order: 1 - any named .cfg file in current directory matching given task 2 - if there exists a ~/...
[ "Locate", "the", "appropriate", "ConfigObjPars", "(", "or", "subclass", ")", "within", "the", "given", "package", ".", "NOTE", "this", "begins", "the", "same", "way", "as", "getUsrCfgFilesForPyPkg", "()", ".", "Look", "for", ".", "cfg", "file", "matches", "i...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L232-L279
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
getUsrCfgFilesForPyPkg
def getUsrCfgFilesForPyPkg(pkgName): """ See if the user has one of their own local .cfg files for this task, such as might be created automatically during the save of a read-only package, and return their names. """ # Get the python package and it's .cfg file thePkg, theFile = findCfgFileFo...
python
def getUsrCfgFilesForPyPkg(pkgName): """ See if the user has one of their own local .cfg files for this task, such as might be created automatically during the save of a read-only package, and return their names. """ # Get the python package and it's .cfg file thePkg, theFile = findCfgFileFo...
[ "def", "getUsrCfgFilesForPyPkg", "(", "pkgName", ")", ":", "# Get the python package and it's .cfg file", "thePkg", ",", "theFile", "=", "findCfgFileForPkg", "(", "pkgName", ",", "'.cfg'", ")", "# See if the user has any of their own local .cfg files for this task", "tname", "=...
See if the user has one of their own local .cfg files for this task, such as might be created automatically during the save of a read-only package, and return their names.
[ "See", "if", "the", "user", "has", "one", "of", "their", "own", "local", ".", "cfg", "files", "for", "this", "task", "such", "as", "might", "be", "created", "automatically", "during", "the", "save", "of", "a", "read", "-", "only", "package", "and", "re...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L282-L291
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
checkSetReadOnly
def checkSetReadOnly(fname, raiseOnErr = False): """ See if we have write-privileges to this file. If we do, and we are not supposed to, then fix that case. """ if os.access(fname, os.W_OK): # We can write to this but it is supposed to be read-only. Fix it. # Take away usr-write, leave grou...
python
def checkSetReadOnly(fname, raiseOnErr = False): """ See if we have write-privileges to this file. If we do, and we are not supposed to, then fix that case. """ if os.access(fname, os.W_OK): # We can write to this but it is supposed to be read-only. Fix it. # Take away usr-write, leave grou...
[ "def", "checkSetReadOnly", "(", "fname", ",", "raiseOnErr", "=", "False", ")", ":", "if", "os", ".", "access", "(", "fname", ",", "os", ".", "W_OK", ")", ":", "# We can write to this but it is supposed to be read-only. Fix it.", "# Take away usr-write, leave group and o...
See if we have write-privileges to this file. If we do, and we are not supposed to, then fix that case.
[ "See", "if", "we", "have", "write", "-", "privileges", "to", "this", "file", ".", "If", "we", "do", "and", "we", "are", "not", "supposed", "to", "then", "fix", "that", "case", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L294-L301
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
flattenDictTree
def flattenDictTree(aDict): """ Takes a dict of vals and dicts (so, a tree) as input, and returns a flat dict (only one level) as output. All key-vals are moved to the top level. Sub-section dict names (keys) are ignored/dropped. If there are name collisions, an error is raised. """ retval = {} ...
python
def flattenDictTree(aDict): """ Takes a dict of vals and dicts (so, a tree) as input, and returns a flat dict (only one level) as output. All key-vals are moved to the top level. Sub-section dict names (keys) are ignored/dropped. If there are name collisions, an error is raised. """ retval = {} ...
[ "def", "flattenDictTree", "(", "aDict", ")", ":", "retval", "=", "{", "}", "for", "k", "in", "aDict", ":", "val", "=", "aDict", "[", "k", "]", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "# This val is a dict, get its data (recursively) into a fla...
Takes a dict of vals and dicts (so, a tree) as input, and returns a flat dict (only one level) as output. All key-vals are moved to the top level. Sub-section dict names (keys) are ignored/dropped. If there are name collisions, an error is raised.
[ "Takes", "a", "dict", "of", "vals", "and", "dicts", "(", "so", "a", "tree", ")", "as", "input", "and", "returns", "a", "flat", "dict", "(", "only", "one", "level", ")", "as", "output", ".", "All", "key", "-", "vals", "are", "moved", "to", "the", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L304-L331
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
countKey
def countKey(theDict, name): """ Return the number of times the given par exists in this dict-tree, since the same key name may be used in different sections/sub-sections. """ retval = 0 for key in theDict: val = theDict[key] if isinstance(val, dict): retval += countKey(val,...
python
def countKey(theDict, name): """ Return the number of times the given par exists in this dict-tree, since the same key name may be used in different sections/sub-sections. """ retval = 0 for key in theDict: val = theDict[key] if isinstance(val, dict): retval += countKey(val,...
[ "def", "countKey", "(", "theDict", ",", "name", ")", ":", "retval", "=", "0", "for", "key", "in", "theDict", ":", "val", "=", "theDict", "[", "key", "]", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "retval", "+=", "countKey", "(", "val",...
Return the number of times the given par exists in this dict-tree, since the same key name may be used in different sections/sub-sections.
[ "Return", "the", "number", "of", "times", "the", "given", "par", "exists", "in", "this", "dict", "-", "tree", "since", "the", "same", "key", "name", "may", "be", "used", "in", "different", "sections", "/", "sub", "-", "sections", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L334-L349
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
findFirstPar
def findFirstPar(theDict, name, _depth=0): """ Find the given par. Return tuple: (its own (sub-)dict, its value). Returns the first match found, without checking whether the given key name is unique or whether it is used in multiple sections. """ for key in theDict: val = theDict[key] # ...
python
def findFirstPar(theDict, name, _depth=0): """ Find the given par. Return tuple: (its own (sub-)dict, its value). Returns the first match found, without checking whether the given key name is unique or whether it is used in multiple sections. """ for key in theDict: val = theDict[key] # ...
[ "def", "findFirstPar", "(", "theDict", ",", "name", ",", "_depth", "=", "0", ")", ":", "for", "key", "in", "theDict", ":", "val", "=", "theDict", "[", "key", "]", "# print _depth*' ', key, str(val)[:40]", "if", "isinstance", "(", "val", ",", "dict", ...
Find the given par. Return tuple: (its own (sub-)dict, its value). Returns the first match found, without checking whether the given key name is unique or whether it is used in multiple sections.
[ "Find", "the", "given", "par", ".", "Return", "tuple", ":", "(", "its", "own", "(", "sub", "-", ")", "dict", "its", "value", ")", ".", "Returns", "the", "first", "match", "found", "without", "checking", "whether", "the", "given", "key", "name", "is", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L352-L374
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
findScopedPar
def findScopedPar(theDict, scope, name): """ Find the given par. Return tuple: (its own (sub-)dict, its value). """ # Do not search (like findFirstPar), but go right to the correct # sub-section, and pick it up. Assume it is there as stated. if len(scope): theDict = theDict[scope] # ! only goe...
python
def findScopedPar(theDict, scope, name): """ Find the given par. Return tuple: (its own (sub-)dict, its value). """ # Do not search (like findFirstPar), but go right to the correct # sub-section, and pick it up. Assume it is there as stated. if len(scope): theDict = theDict[scope] # ! only goe...
[ "def", "findScopedPar", "(", "theDict", ",", "scope", ",", "name", ")", ":", "# Do not search (like findFirstPar), but go right to the correct", "# sub-section, and pick it up. Assume it is there as stated.", "if", "len", "(", "scope", ")", ":", "theDict", "=", "theDict", ...
Find the given par. Return tuple: (its own (sub-)dict, its value).
[ "Find", "the", "given", "par", ".", "Return", "tuple", ":", "(", "its", "own", "(", "sub", "-", ")", "dict", "its", "value", ")", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L377-L383
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
setPar
def setPar(theDict, name, value): """ Sets a par's value without having to give its scope/section. """ section, previousVal = findFirstPar(theDict, name) # "section" is the actual object, not a copy section[name] = value
python
def setPar(theDict, name, value): """ Sets a par's value without having to give its scope/section. """ section, previousVal = findFirstPar(theDict, name) # "section" is the actual object, not a copy section[name] = value
[ "def", "setPar", "(", "theDict", ",", "name", ",", "value", ")", ":", "section", ",", "previousVal", "=", "findFirstPar", "(", "theDict", ",", "name", ")", "# \"section\" is the actual object, not a copy", "section", "[", "name", "]", "=", "value" ]
Sets a par's value without having to give its scope/section.
[ "Sets", "a", "par", "s", "value", "without", "having", "to", "give", "its", "scope", "/", "section", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L386-L390
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
mergeConfigObj
def mergeConfigObj(configObj, inputDict): """ Merge the inputDict values into an existing given configObj instance. The inputDict is a "flat" dict - it has no sections/sub-sections. The configObj may have sub-sections nested to any depth. This will raise a DuplicateKeyError if one of the inputDict key...
python
def mergeConfigObj(configObj, inputDict): """ Merge the inputDict values into an existing given configObj instance. The inputDict is a "flat" dict - it has no sections/sub-sections. The configObj may have sub-sections nested to any depth. This will raise a DuplicateKeyError if one of the inputDict key...
[ "def", "mergeConfigObj", "(", "configObj", ",", "inputDict", ")", ":", "# Expanded upon Warren's version in astrodrizzle", "# Verify that all inputDict keys in configObj are unique within configObj", "for", "key", "in", "inputDict", ":", "if", "countKey", "(", "configObj", ",",...
Merge the inputDict values into an existing given configObj instance. The inputDict is a "flat" dict - it has no sections/sub-sections. The configObj may have sub-sections nested to any depth. This will raise a DuplicateKeyError if one of the inputDict keys is used more than once in configObj (e.g. wi...
[ "Merge", "the", "inputDict", "values", "into", "an", "existing", "given", "configObj", "instance", ".", "The", "inputDict", "is", "a", "flat", "dict", "-", "it", "has", "no", "sections", "/", "sub", "-", "sections", ".", "The", "configObj", "may", "have", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L393-L407
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
findTheLost
def findTheLost(config_file, configspec_file, skipHidden=True): """ Find any lost/missing parameters in this cfg file, compared to what the .cfgspc says should be there. This method is recommended by the ConfigObj docs. Return a stringified list of item errors. """ # do some sanity checking, but don't (...
python
def findTheLost(config_file, configspec_file, skipHidden=True): """ Find any lost/missing parameters in this cfg file, compared to what the .cfgspc says should be there. This method is recommended by the ConfigObj docs. Return a stringified list of item errors. """ # do some sanity checking, but don't (...
[ "def", "findTheLost", "(", "config_file", ",", "configspec_file", ",", "skipHidden", "=", "True", ")", ":", "# do some sanity checking, but don't (yet) make this a serious error", "if", "not", "os", ".", "path", ".", "exists", "(", "config_file", ")", ":", "print", ...
Find any lost/missing parameters in this cfg file, compared to what the .cfgspc says should be there. This method is recommended by the ConfigObj docs. Return a stringified list of item errors.
[ "Find", "any", "lost", "/", "missing", "parameters", "in", "this", "cfg", "file", "compared", "to", "what", "the", ".", "cfgspc", "says", "should", "be", "there", ".", "This", "method", "is", "recommended", "by", "the", "ConfigObj", "docs", ".", "Return", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1244-L1281
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
isHiddenName
def isHiddenName(astr): """ Return True if this string name denotes a hidden par or section """ if astr is not None and len(astr) > 2 and astr.startswith('_') and \ astr.endswith('_'): return True else: return False
python
def isHiddenName(astr): """ Return True if this string name denotes a hidden par or section """ if astr is not None and len(astr) > 2 and astr.startswith('_') and \ astr.endswith('_'): return True else: return False
[ "def", "isHiddenName", "(", "astr", ")", ":", "if", "astr", "is", "not", "None", "and", "len", "(", "astr", ")", ">", "2", "and", "astr", ".", "startswith", "(", "'_'", ")", "and", "astr", ".", "endswith", "(", "'_'", ")", ":", "return", "True", ...
Return True if this string name denotes a hidden par or section
[ "Return", "True", "if", "this", "string", "name", "denotes", "a", "hidden", "par", "or", "section" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1284-L1290
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
flattened2str
def flattened2str(flattened, missing=False, extra=False): """ Return a pretty-printed multi-line string version of the output of flatten_errors. Know that flattened comes in the form of a list of keys that failed. Each member of the list is a tuple:: ([list of sections...], key, result) so we ...
python
def flattened2str(flattened, missing=False, extra=False): """ Return a pretty-printed multi-line string version of the output of flatten_errors. Know that flattened comes in the form of a list of keys that failed. Each member of the list is a tuple:: ([list of sections...], key, result) so we ...
[ "def", "flattened2str", "(", "flattened", ",", "missing", "=", "False", ",", "extra", "=", "False", ")", ":", "if", "flattened", "is", "None", "or", "len", "(", "flattened", ")", "<", "1", ":", "return", "''", "retval", "=", "''", "for", "sections", ...
Return a pretty-printed multi-line string version of the output of flatten_errors. Know that flattened comes in the form of a list of keys that failed. Each member of the list is a tuple:: ([list of sections...], key, result) so we turn that into a string. Set missing to True if all the input ...
[ "Return", "a", "pretty", "-", "printed", "multi", "-", "line", "string", "version", "of", "the", "output", "of", "flatten_errors", ".", "Know", "that", "flattened", "comes", "in", "the", "form", "of", "a", "list", "of", "keys", "that", "failed", ".", "Ea...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1293-L1341
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getDefaultSaveFilename
def getDefaultSaveFilename(self, stub=False): """ Return name of file where we are expected to be saved if no files for this task have ever been saved, and the user wishes to save. If stub is True, the result will be <dir>/<taskname>_stub.cfg instead of <dir>/<taskname>.cfg. """ ...
python
def getDefaultSaveFilename(self, stub=False): """ Return name of file where we are expected to be saved if no files for this task have ever been saved, and the user wishes to save. If stub is True, the result will be <dir>/<taskname>_stub.cfg instead of <dir>/<taskname>.cfg. """ ...
[ "def", "getDefaultSaveFilename", "(", "self", ",", "stub", "=", "False", ")", ":", "if", "stub", ":", "return", "self", ".", "_rcDir", "+", "os", ".", "sep", "+", "self", ".", "__taskName", "+", "'_stub.cfg'", "else", ":", "return", "self", ".", "_rcDi...
Return name of file where we are expected to be saved if no files for this task have ever been saved, and the user wishes to save. If stub is True, the result will be <dir>/<taskname>_stub.cfg instead of <dir>/<taskname>.cfg.
[ "Return", "name", "of", "file", "where", "we", "are", "expected", "to", "be", "saved", "if", "no", "files", "for", "this", "task", "have", "ever", "been", "saved", "and", "the", "user", "wishes", "to", "save", ".", "If", "stub", "is", "True", "the", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L628-L636
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.syncParamList
def syncParamList(self, firstTime, preserve_order=True): """ Set or reset the internal param list from the dict's contents. """ # See the note in setParam about this design. # Get latest par values from dict. Make sure we do not # change the id of the __paramList pointer here. ...
python
def syncParamList(self, firstTime, preserve_order=True): """ Set or reset the internal param list from the dict's contents. """ # See the note in setParam about this design. # Get latest par values from dict. Make sure we do not # change the id of the __paramList pointer here. ...
[ "def", "syncParamList", "(", "self", ",", "firstTime", ",", "preserve_order", "=", "True", ")", ":", "# See the note in setParam about this design.", "# Get latest par values from dict. Make sure we do not", "# change the id of the __paramList pointer here.", "new_list", "=", "sel...
Set or reset the internal param list from the dict's contents.
[ "Set", "or", "reset", "the", "internal", "param", "list", "from", "the", "dict", "s", "contents", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L638-L669
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getDefaultParList
def getDefaultParList(self): """ Return a par list just like ours, but with all default values. """ # The code below (create a new set-to-dflts obj) is correct, but it # adds a tenth of a second to startup. Clicking "Defaults" in the # GUI does not call this. But this can be used to se...
python
def getDefaultParList(self): """ Return a par list just like ours, but with all default values. """ # The code below (create a new set-to-dflts obj) is correct, but it # adds a tenth of a second to startup. Clicking "Defaults" in the # GUI does not call this. But this can be used to se...
[ "def", "getDefaultParList", "(", "self", ")", ":", "# The code below (create a new set-to-dflts obj) is correct, but it", "# adds a tenth of a second to startup. Clicking \"Defaults\" in the", "# GUI does not call this. But this can be used to set the order seen.", "# But first check for rare ca...
Return a par list just like ours, but with all default values.
[ "Return", "a", "par", "list", "just", "like", "ours", "but", "with", "all", "default", "values", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L680-L694
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.setParam
def setParam(self, name, val, scope='', check=1, idxHint=None): """ Find the ConfigObj entry. Update the __paramList. """ theDict, oldVal = findScopedPar(self, scope, name) # Set the value, even if invalid. It needs to be set before # the validation step (next). theDict[name] ...
python
def setParam(self, name, val, scope='', check=1, idxHint=None): """ Find the ConfigObj entry. Update the __paramList. """ theDict, oldVal = findScopedPar(self, scope, name) # Set the value, even if invalid. It needs to be set before # the validation step (next). theDict[name] ...
[ "def", "setParam", "(", "self", ",", "name", ",", "val", ",", "scope", "=", "''", ",", "check", "=", "1", ",", "idxHint", "=", "None", ")", ":", "theDict", ",", "oldVal", "=", "findScopedPar", "(", "self", ",", "scope", ",", "name", ")", "# Set the...
Find the ConfigObj entry. Update the __paramList.
[ "Find", "the", "ConfigObj", "entry", ".", "Update", "the", "__paramList", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L723-L750
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.saveParList
def saveParList(self, *args, **kw): """Write parameter data to filename (string or filehandle)""" if 'filename' in kw: filename = kw['filename'] if not filename: filename = self.getFilename() if not filename: raise ValueError("No filename specified to ...
python
def saveParList(self, *args, **kw): """Write parameter data to filename (string or filehandle)""" if 'filename' in kw: filename = kw['filename'] if not filename: filename = self.getFilename() if not filename: raise ValueError("No filename specified to ...
[ "def", "saveParList", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "'filename'", "in", "kw", ":", "filename", "=", "kw", "[", "'filename'", "]", "if", "not", "filename", ":", "filename", "=", "self", ".", "getFilename", "(", ...
Write parameter data to filename (string or filehandle)
[ "Write", "parameter", "data", "to", "filename", "(", "string", "or", "filehandle", ")" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L752-L790
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.run
def run(self, *args, **kw): """ This may be overridden by a subclass. """ if self._runFunc is not None: # remove the two args sent by EditParDialog which we do not use if 'mode' in kw: kw.pop('mode') if '_save' in kw: kw.pop('_save') return self._runFunc(s...
python
def run(self, *args, **kw): """ This may be overridden by a subclass. """ if self._runFunc is not None: # remove the two args sent by EditParDialog which we do not use if 'mode' in kw: kw.pop('mode') if '_save' in kw: kw.pop('_save') return self._runFunc(s...
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "self", ".", "_runFunc", "is", "not", "None", ":", "# remove the two args sent by EditParDialog which we do not use", "if", "'mode'", "in", "kw", ":", "kw", ".", "pop", "(", ...
This may be overridden by a subclass.
[ "This", "may", "be", "overridden", "by", "a", "subclass", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L792-L803
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.triggerLogicToStr
def triggerLogicToStr(self): """ Print all the trigger logic to a string and return it. """ try: import json except ImportError: return "Cannot dump triggers/dependencies/executes (need json)" retval = "TRIGGERS:\n"+json.dumps(self._allTriggers, indent=3) ...
python
def triggerLogicToStr(self): """ Print all the trigger logic to a string and return it. """ try: import json except ImportError: return "Cannot dump triggers/dependencies/executes (need json)" retval = "TRIGGERS:\n"+json.dumps(self._allTriggers, indent=3) ...
[ "def", "triggerLogicToStr", "(", "self", ")", ":", "try", ":", "import", "json", "except", "ImportError", ":", "return", "\"Cannot dump triggers/dependencies/executes (need json)\"", "retval", "=", "\"TRIGGERS:\\n\"", "+", "json", ".", "dumps", "(", "self", ".", "_a...
Print all the trigger logic to a string and return it.
[ "Print", "all", "the", "trigger", "logic", "to", "a", "string", "and", "return", "it", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L805-L815
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars._findAssociatedConfigSpecFile
def _findAssociatedConfigSpecFile(self, cfgFileName): """ Given a config file, find its associated config-spec file, and return the full pathname of the file. """ # Handle simplest 2 cases first: co-located or local .cfgspc file retval = "."+os.sep+self.__taskName+".cfgspc" if o...
python
def _findAssociatedConfigSpecFile(self, cfgFileName): """ Given a config file, find its associated config-spec file, and return the full pathname of the file. """ # Handle simplest 2 cases first: co-located or local .cfgspc file retval = "."+os.sep+self.__taskName+".cfgspc" if o...
[ "def", "_findAssociatedConfigSpecFile", "(", "self", ",", "cfgFileName", ")", ":", "# Handle simplest 2 cases first: co-located or local .cfgspc file", "retval", "=", "\".\"", "+", "os", ".", "sep", "+", "self", ".", "__taskName", "+", "\".cfgspc\"", "if", "os", ".", ...
Given a config file, find its associated config-spec file, and return the full pathname of the file.
[ "Given", "a", "config", "file", "find", "its", "associated", "config", "-", "spec", "file", "and", "return", "the", "full", "pathname", "of", "the", "file", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L828-L860
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars._getParamsFromConfigDict
def _getParamsFromConfigDict(self, cfgObj, scopePrefix='', initialPass=False, dumpCfgspcTo=None): """ Walk the given ConfigObj dict pulling out IRAF-like parameters into a list. Since this operates on a dict this can be called recursively. This is also our chance...
python
def _getParamsFromConfigDict(self, cfgObj, scopePrefix='', initialPass=False, dumpCfgspcTo=None): """ Walk the given ConfigObj dict pulling out IRAF-like parameters into a list. Since this operates on a dict this can be called recursively. This is also our chance...
[ "def", "_getParamsFromConfigDict", "(", "self", ",", "cfgObj", ",", "scopePrefix", "=", "''", ",", "initialPass", "=", "False", ",", "dumpCfgspcTo", "=", "None", ")", ":", "# init", "retval", "=", "[", "]", "if", "initialPass", "and", "len", "(", "scopePre...
Walk the given ConfigObj dict pulling out IRAF-like parameters into a list. Since this operates on a dict this can be called recursively. This is also our chance to find and pull out triggers and such dependencies.
[ "Walk", "the", "given", "ConfigObj", "dict", "pulling", "out", "IRAF", "-", "like", "parameters", "into", "a", "list", ".", "Since", "this", "operates", "on", "a", "dict", "this", "can", "be", "called", "recursively", ".", "This", "is", "also", "our", "c...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L863-L1084
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getTriggerStrings
def getTriggerStrings(self, parScope, parName): """ For a given item (scope + name), return all strings (in a tuple) that it is meant to trigger, if any exist. Returns None is none. """ # The data structure of _allTriggers was chosen for how easily/quickly # this particular access can b...
python
def getTriggerStrings(self, parScope, parName): """ For a given item (scope + name), return all strings (in a tuple) that it is meant to trigger, if any exist. Returns None is none. """ # The data structure of _allTriggers was chosen for how easily/quickly # this particular access can b...
[ "def", "getTriggerStrings", "(", "self", ",", "parScope", ",", "parName", ")", ":", "# The data structure of _allTriggers was chosen for how easily/quickly", "# this particular access can be made here.", "fullName", "=", "parScope", "+", "'.'", "+", "parName", "return", "self...
For a given item (scope + name), return all strings (in a tuple) that it is meant to trigger, if any exist. Returns None is none.
[ "For", "a", "given", "item", "(", "scope", "+", "name", ")", "return", "all", "strings", "(", "in", "a", "tuple", ")", "that", "it", "is", "meant", "to", "trigger", "if", "any", "exist", ".", "Returns", "None", "is", "none", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1087-L1093
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getExecuteStrings
def getExecuteStrings(self, parScope, parName): """ For a given item (scope + name), return all strings (in a tuple) that it is meant to execute, if any exist. Returns None is none. """ # The data structure of _allExecutes was chosen for how easily/quickly # this particular access can b...
python
def getExecuteStrings(self, parScope, parName): """ For a given item (scope + name), return all strings (in a tuple) that it is meant to execute, if any exist. Returns None is none. """ # The data structure of _allExecutes was chosen for how easily/quickly # this particular access can b...
[ "def", "getExecuteStrings", "(", "self", ",", "parScope", ",", "parName", ")", ":", "# The data structure of _allExecutes was chosen for how easily/quickly", "# this particular access can be made here.", "fullName", "=", "parScope", "+", "'.'", "+", "parName", "return", "self...
For a given item (scope + name), return all strings (in a tuple) that it is meant to execute, if any exist. Returns None is none.
[ "For", "a", "given", "item", "(", "scope", "+", "name", ")", "return", "all", "strings", "(", "in", "a", "tuple", ")", "that", "it", "is", "meant", "to", "execute", "if", "any", "exist", ".", "Returns", "None", "is", "none", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1104-L1110
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getPosArgs
def getPosArgs(self): """ Return a list, in order, of any parameters marked with "pos=N" in the .cfgspc file. """ if len(self._posArgs) < 1: return [] # The first item in the tuple is the index, so we now sort by it self._posArgs.sort() # Build a return list r...
python
def getPosArgs(self): """ Return a list, in order, of any parameters marked with "pos=N" in the .cfgspc file. """ if len(self._posArgs) < 1: return [] # The first item in the tuple is the index, so we now sort by it self._posArgs.sort() # Build a return list r...
[ "def", "getPosArgs", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_posArgs", ")", "<", "1", ":", "return", "[", "]", "# The first item in the tuple is the index, so we now sort by it", "self", ".", "_posArgs", ".", "sort", "(", ")", "# Build a return l...
Return a list, in order, of any parameters marked with "pos=N" in the .cfgspc file.
[ "Return", "a", "list", "in", "order", "of", "any", "parameters", "marked", "with", "pos", "=", "N", "in", "the", ".", "cfgspc", "file", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1113-L1124
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.getKwdArgs
def getKwdArgs(self, flatten = False): """ Return a dict of all normal dict parameters - that is, all parameters NOT marked with "pos=N" in the .cfgspc file. This will also exclude all hidden parameters (metadata, rules, etc). """ # Start with a full deep-copy. What complicate...
python
def getKwdArgs(self, flatten = False): """ Return a dict of all normal dict parameters - that is, all parameters NOT marked with "pos=N" in the .cfgspc file. This will also exclude all hidden parameters (metadata, rules, etc). """ # Start with a full deep-copy. What complicate...
[ "def", "getKwdArgs", "(", "self", ",", "flatten", "=", "False", ")", ":", "# Start with a full deep-copy. What complicates this method is the", "# idea of sub-sections. This dict can have dicts as values, and so on.", "dcopy", "=", "self", ".", "dict", "(", ")", "# ConfigObj ...
Return a dict of all normal dict parameters - that is, all parameters NOT marked with "pos=N" in the .cfgspc file. This will also exclude all hidden parameters (metadata, rules, etc).
[ "Return", "a", "dict", "of", "all", "normal", "dict", "parameters", "-", "that", "is", "all", "parameters", "NOT", "marked", "with", "pos", "=", "N", "in", "the", ".", "cfgspc", "file", ".", "This", "will", "also", "exclude", "all", "hidden", "parameters...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1127-L1155
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.tryValue
def tryValue(self, name, val, scope=''): """ For the given item name (and scope), we are being asked to try the given value to see if it would pass validation. We are not to set it, but just try it. We return a tuple: If it fails, we return: (False, the last known valid va...
python
def tryValue(self, name, val, scope=''): """ For the given item name (and scope), we are being asked to try the given value to see if it would pass validation. We are not to set it, but just try it. We return a tuple: If it fails, we return: (False, the last known valid va...
[ "def", "tryValue", "(", "self", ",", "name", ",", "val", ",", "scope", "=", "''", ")", ":", "# SIMILARITY BETWEEN THIS AND setParam() SHOULD BE CONSOLIDATED!", "# Set the value, even if invalid. It needs to be set before", "# the validation step (next).", "theDict", ",", "oldV...
For the given item name (and scope), we are being asked to try the given value to see if it would pass validation. We are not to set it, but just try it. We return a tuple: If it fails, we return: (False, the last known valid value). On success, we return: (True, None)...
[ "For", "the", "given", "item", "name", "(", "and", "scope", ")", "we", "are", "being", "asked", "to", "try", "the", "given", "value", "to", "see", "if", "it", "would", "pass", "validation", ".", "We", "are", "not", "to", "set", "it", "but", "just", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1169-L1203
spacetelescope/stsci.tools
lib/stsci/tools/cfgpars.py
ConfigObjPars.listTheExtras
def listTheExtras(self, deleteAlso): """ Use ConfigObj's get_extra_values() call to find any extra/unknown parameters we may have loaded. Return a string similar to findTheLost. If deleteAlso is True, this will also delete any extra/unknown items. """ # get list of extras ...
python
def listTheExtras(self, deleteAlso): """ Use ConfigObj's get_extra_values() call to find any extra/unknown parameters we may have loaded. Return a string similar to findTheLost. If deleteAlso is True, this will also delete any extra/unknown items. """ # get list of extras ...
[ "def", "listTheExtras", "(", "self", ",", "deleteAlso", ")", ":", "# get list of extras", "extras", "=", "configobj", ".", "get_extra_values", "(", "self", ")", "# extras is in format: [(sections, key), (sections, key), ]", "# but we need: [(sections, key, result), ...] - set all...
Use ConfigObj's get_extra_values() call to find any extra/unknown parameters we may have loaded. Return a string similar to findTheLost. If deleteAlso is True, this will also delete any extra/unknown items.
[ "Use", "ConfigObj", "s", "get_extra_values", "()", "call", "to", "find", "any", "extra", "/", "unknown", "parameters", "we", "may", "have", "loaded", ".", "Return", "a", "string", "similar", "to", "findTheLost", ".", "If", "deleteAlso", "is", "True", "this",...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1206-L1238
3ll3d00d/vibe
backend/src/analyser/resources/measurements.py
ReloadMeasurement.get
def get(self): """ Reloads the measurements from the backing store. :return: 200 if success. """ try: self._measurementController.reloadCompletedMeasurements() return None, 200 except: logger.exception("Failed to reload measurements") ...
python
def get(self): """ Reloads the measurements from the backing store. :return: 200 if success. """ try: self._measurementController.reloadCompletedMeasurements() return None, 200 except: logger.exception("Failed to reload measurements") ...
[ "def", "get", "(", "self", ")", ":", "try", ":", "self", ".", "_measurementController", ".", "reloadCompletedMeasurements", "(", ")", "return", "None", ",", "200", "except", ":", "logger", ".", "exception", "(", "\"Failed to reload measurements\"", ")", "return"...
Reloads the measurements from the backing store. :return: 200 if success.
[ "Reloads", "the", "measurements", "from", "the", "backing", "store", ".", ":", "return", ":", "200", "if", "success", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurements.py#L29-L39
3ll3d00d/vibe
backend/src/core/handler.py
CSVLogger.handle
def handle(self, data): """ Writes each sample to a csv file. :param data: the samples. :return: """ self.logger.debug("Handling " + str(len(data)) + " data items") for datum in data: if isinstance(datum, dict): # these have to wrapped ...
python
def handle(self, data): """ Writes each sample to a csv file. :param data: the samples. :return: """ self.logger.debug("Handling " + str(len(data)) + " data items") for datum in data: if isinstance(datum, dict): # these have to wrapped ...
[ "def", "handle", "(", "self", ",", "data", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Handling \"", "+", "str", "(", "len", "(", "data", ")", ")", "+", "\" data items\"", ")", "for", "datum", "in", "data", ":", "if", "isinstance", "(", ...
Writes each sample to a csv file. :param data: the samples. :return:
[ "Writes", "each", "sample", "to", "a", "csv", "file", ".", ":", "param", "data", ":", "the", "samples", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L93-L111
3ll3d00d/vibe
backend/src/core/handler.py
HttpPoster.start
def start(self, measurementId): """ Posts to the target to tell it a named measurement is starting. :param measurementId: """ self.sendURL = self.rootURL + measurementId + '/' + self.deviceName self.startResponseCode = self._doPut(self.sendURL)
python
def start(self, measurementId): """ Posts to the target to tell it a named measurement is starting. :param measurementId: """ self.sendURL = self.rootURL + measurementId + '/' + self.deviceName self.startResponseCode = self._doPut(self.sendURL)
[ "def", "start", "(", "self", ",", "measurementId", ")", ":", "self", ".", "sendURL", "=", "self", ".", "rootURL", "+", "measurementId", "+", "'/'", "+", "self", ".", "deviceName", "self", ".", "startResponseCode", "=", "self", ".", "_doPut", "(", "self",...
Posts to the target to tell it a named measurement is starting. :param measurementId:
[ "Posts", "to", "the", "target", "to", "tell", "it", "a", "named", "measurement", "is", "starting", ".", ":", "param", "measurementId", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L188-L194
3ll3d00d/vibe
backend/src/core/handler.py
HttpPoster.handle
def handle(self, data): """ puts the data in the target. :param data: the data to post. :return: """ self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data))
python
def handle(self, data): """ puts the data in the target. :param data: the data to post. :return: """ self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data))
[ "def", "handle", "(", "self", ",", "data", ")", ":", "self", ".", "dataResponseCode", ".", "append", "(", "self", ".", "_doPut", "(", "self", ".", "sendURL", "+", "'/data'", ",", "data", "=", "data", ")", ")" ]
puts the data in the target. :param data: the data to post. :return:
[ "puts", "the", "data", "in", "the", "target", ".", ":", "param", "data", ":", "the", "data", "to", "post", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L204-L210
3ll3d00d/vibe
backend/src/core/handler.py
HttpPoster.stop
def stop(self, measurementId, failureReason=None): """ informs the target the named measurement has completed :param measurementId: the measurement that has completed. :return: """ if failureReason is None: self.endResponseCode = self._doPut(self.sendURL + "/c...
python
def stop(self, measurementId, failureReason=None): """ informs the target the named measurement has completed :param measurementId: the measurement that has completed. :return: """ if failureReason is None: self.endResponseCode = self._doPut(self.sendURL + "/c...
[ "def", "stop", "(", "self", ",", "measurementId", ",", "failureReason", "=", "None", ")", ":", "if", "failureReason", "is", "None", ":", "self", ".", "endResponseCode", "=", "self", ".", "_doPut", "(", "self", ".", "sendURL", "+", "\"/complete\"", ")", "...
informs the target the named measurement has completed :param measurementId: the measurement that has completed. :return:
[ "informs", "the", "target", "the", "named", "measurement", "has", "completed", ":", "param", "measurementId", ":", "the", "measurement", "that", "has", "completed", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L212-L222
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
dottedQuadToNum
def dottedQuadToNum(ip): """ Convert decimal dotted quad string to long integer >>> int(dottedQuadToNum('1 ')) 1 >>> int(dottedQuadToNum(' 1.2')) 16777218 >>> int(dottedQuadToNum(' 1.2.3 ')) 16908291 >>> int(dottedQuadToNum('1.2.3.4')) 16909060 >>> dottedQuadToNum('255.255.2...
python
def dottedQuadToNum(ip): """ Convert decimal dotted quad string to long integer >>> int(dottedQuadToNum('1 ')) 1 >>> int(dottedQuadToNum(' 1.2')) 16777218 >>> int(dottedQuadToNum(' 1.2.3 ')) 16908291 >>> int(dottedQuadToNum('1.2.3.4')) 16909060 >>> dottedQuadToNum('255.255.2...
[ "def", "dottedQuadToNum", "(", "ip", ")", ":", "# import here to avoid it when ip_addr values are not used", "import", "socket", ",", "struct", "try", ":", "return", "struct", ".", "unpack", "(", "'!L'", ",", "socket", ".", "inet_aton", "(", "ip", ".", "strip", ...
Convert decimal dotted quad string to long integer >>> int(dottedQuadToNum('1 ')) 1 >>> int(dottedQuadToNum(' 1.2')) 16777218 >>> int(dottedQuadToNum(' 1.2.3 ')) 16908291 >>> int(dottedQuadToNum('1.2.3.4')) 16909060 >>> dottedQuadToNum('255.255.255.255') 4294967295 >>> dotte...
[ "Convert", "decimal", "dotted", "quad", "string", "to", "long", "integer" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L274-L301
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
numToDottedQuad
def numToDottedQuad(num): """ Convert long int to dotted quad string >>> numToDottedQuad(long(-1)) Traceback (most recent call last): ValueError: Not a good numeric IP: -1 >>> numToDottedQuad(long(1)) '0.0.0.1' >>> numToDottedQuad(long(16777218)) '1.0.0.2' >>> numToDottedQuad(lo...
python
def numToDottedQuad(num): """ Convert long int to dotted quad string >>> numToDottedQuad(long(-1)) Traceback (most recent call last): ValueError: Not a good numeric IP: -1 >>> numToDottedQuad(long(1)) '0.0.0.1' >>> numToDottedQuad(long(16777218)) '1.0.0.2' >>> numToDottedQuad(lo...
[ "def", "numToDottedQuad", "(", "num", ")", ":", "# import here to avoid it when ip_addr values are not used", "import", "socket", ",", "struct", "# no need to intercept here, 4294967295 is fine", "if", "num", ">", "4294967295", "or", "num", "<", "0", ":", "raise", "ValueE...
Convert long int to dotted quad string >>> numToDottedQuad(long(-1)) Traceback (most recent call last): ValueError: Not a good numeric IP: -1 >>> numToDottedQuad(long(1)) '0.0.0.1' >>> numToDottedQuad(long(16777218)) '1.0.0.2' >>> numToDottedQuad(long(16908291)) '1.2.0.3' >>> nu...
[ "Convert", "long", "int", "to", "dotted", "quad", "string" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L304-L336
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
_is_num_param
def _is_num_param(names, values, to_float=False): """ Return numbers from inputs or raise VdtParamError. Lets ``None`` pass through. Pass in keyword argument ``to_float=True`` to use float for the conversion rather than int. >>> _is_num_param(('', ''), (0, 1.0)) [0, 1] >>> _is_num_para...
python
def _is_num_param(names, values, to_float=False): """ Return numbers from inputs or raise VdtParamError. Lets ``None`` pass through. Pass in keyword argument ``to_float=True`` to use float for the conversion rather than int. >>> _is_num_param(('', ''), (0, 1.0)) [0, 1] >>> _is_num_para...
[ "def", "_is_num_param", "(", "names", ",", "values", ",", "to_float", "=", "False", ")", ":", "fun", "=", "to_float", "and", "float", "or", "int", "out_params", "=", "[", "]", "for", "(", "name", ",", "val", ")", "in", "zip", "(", "names", ",", "va...
Return numbers from inputs or raise VdtParamError. Lets ``None`` pass through. Pass in keyword argument ``to_float=True`` to use float for the conversion rather than int. >>> _is_num_param(('', ''), (0, 1.0)) [0, 1] >>> _is_num_param(('', ''), (0, 1.0), to_float=True) [0.0, 1.0] >>> _i...
[ "Return", "numbers", "from", "inputs", "or", "raise", "VdtParamError", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L740-L768
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_integer
def is_integer(value, min=None, max=None): """ A check that tests that a given value is an integer (int, or long) and optionally, between bounds. A negative value is accepted, while a float will fail. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is r...
python
def is_integer(value, min=None, max=None): """ A check that tests that a given value is an integer (int, or long) and optionally, between bounds. A negative value is accepted, while a float will fail. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is r...
[ "def", "is_integer", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_val", ",", "max_val", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ")", "if", "not", ...
A check that tests that a given value is an integer (int, or long) and optionally, between bounds. A negative value is accepted, while a float will fail. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised. >>> vtor = Validator() >>> vtor.check('...
[ "A", "check", "that", "tests", "that", "a", "given", "value", "is", "an", "integer", "(", "int", "or", "long", ")", "and", "optionally", "between", "bounds", ".", "A", "negative", "value", "is", "accepted", "while", "a", "float", "will", "fail", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L777-L831
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_float
def is_float(value, min=None, max=None): """ A check that tests that a given value is a float (an integer will be accepted), and optionally - that it is between bounds. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised. This can accept negative...
python
def is_float(value, min=None, max=None): """ A check that tests that a given value is a float (an integer will be accepted), and optionally - that it is between bounds. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised. This can accept negative...
[ "def", "is_float", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_val", ",", "max_val", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ",", "to_float", "=", ...
A check that tests that a given value is a float (an integer will be accepted), and optionally - that it is between bounds. If the value is a string, then the conversion is done - if possible. Otherwise a VdtError is raised. This can accept negative values. >>> vtor = Validator() >>> vtor.che...
[ "A", "check", "that", "tests", "that", "a", "given", "value", "is", "a", "float", "(", "an", "integer", "will", "be", "accepted", ")", "and", "optionally", "-", "that", "it", "is", "between", "bounds", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L834-L884
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_boolean
def is_boolean(value): """ Check if the value represents a boolean. >>> vtor = Validator() >>> vtor.check('boolean', 0) 0 >>> vtor.check('boolean', False) 0 >>> vtor.check('boolean', '0') 0 >>> vtor.check('boolean', 'off') 0 >>> vtor.check('boolean', 'false') 0 >...
python
def is_boolean(value): """ Check if the value represents a boolean. >>> vtor = Validator() >>> vtor.check('boolean', 0) 0 >>> vtor.check('boolean', False) 0 >>> vtor.check('boolean', '0') 0 >>> vtor.check('boolean', 'off') 0 >>> vtor.check('boolean', 'false') 0 >...
[ "def", "is_boolean", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "try", ":", "return", "bool_dict", "[", "value", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "raise", "VdtTypeError", "(", "value", ...
Check if the value represents a boolean. >>> vtor = Validator() >>> vtor.check('boolean', 0) 0 >>> vtor.check('boolean', False) 0 >>> vtor.check('boolean', '0') 0 >>> vtor.check('boolean', 'off') 0 >>> vtor.check('boolean', 'false') 0 >>> vtor.check('boolean', 'no') ...
[ "Check", "if", "the", "value", "represents", "a", "boolean", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L893-L951
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_ip_addr
def is_ip_addr(value): """ Check that the supplied value is an Internet Protocol address, v.4, represented by a dotted-quad string, i.e. '1.2.3.4'. >>> vtor = Validator() >>> vtor.check('ip_addr', '1 ') '1' >>> vtor.check('ip_addr', ' 1.2') '1.2' >>> vtor.check('ip_addr', ' 1.2.3 ')...
python
def is_ip_addr(value): """ Check that the supplied value is an Internet Protocol address, v.4, represented by a dotted-quad string, i.e. '1.2.3.4'. >>> vtor = Validator() >>> vtor.check('ip_addr', '1 ') '1' >>> vtor.check('ip_addr', ' 1.2') '1.2' >>> vtor.check('ip_addr', ' 1.2.3 ')...
[ "def", "is_ip_addr", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "string_types", ")", ":", "raise", "VdtTypeError", "(", "value", ")", "value", "=", "value", ".", "strip", "(", ")", "try", ":", "dottedQuadToNum", "(", "value", ...
Check that the supplied value is an Internet Protocol address, v.4, represented by a dotted-quad string, i.e. '1.2.3.4'. >>> vtor = Validator() >>> vtor.check('ip_addr', '1 ') '1' >>> vtor.check('ip_addr', ' 1.2') '1.2' >>> vtor.check('ip_addr', ' 1.2.3 ') '1.2.3' >>> vtor.check('ip...
[ "Check", "that", "the", "supplied", "value", "is", "an", "Internet", "Protocol", "address", "v", ".", "4", "represented", "by", "a", "dotted", "-", "quad", "string", "i", ".", "e", ".", "1", ".", "2", ".", "3", ".", "4", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L954-L989
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_list
def is_list(value, min=None, max=None): """ Check that the value is a list of values. You can optionally specify the minimum and maximum number of members. It does no check on list members. >>> vtor = Validator() >>> vtor.check('list', ()) [] >>> vtor.check('list', []) [] >>> ...
python
def is_list(value, min=None, max=None): """ Check that the value is a list of values. You can optionally specify the minimum and maximum number of members. It does no check on list members. >>> vtor = Validator() >>> vtor.check('list', ()) [] >>> vtor.check('list', []) [] >>> ...
[ "def", "is_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_len", ",", "max_len", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ")", "if", "isinstance"...
Check that the value is a list of values. You can optionally specify the minimum and maximum number of members. It does no check on list members. >>> vtor = Validator() >>> vtor.check('list', ()) [] >>> vtor.check('list', []) [] >>> vtor.check('list', (1, 2)) [1, 2] >>> vtor.c...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "values", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L992-L1035
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_int_list
def is_int_list(value, min=None, max=None): """ Check that the value is a list of integers. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an integer. >>> vtor = Validator() >>> vtor.check('int_list', ()) [] >>> vtor.check(...
python
def is_int_list(value, min=None, max=None): """ Check that the value is a list of integers. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an integer. >>> vtor = Validator() >>> vtor.check('int_list', ()) [] >>> vtor.check(...
[ "def", "is_int_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "return", "[", "is_integer", "(", "mem", ")", "for", "mem", "in", "is_list", "(", "value", ",", "min", ",", "max", ")", "]" ]
Check that the value is a list of integers. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an integer. >>> vtor = Validator() >>> vtor.check('int_list', ()) [] >>> vtor.check('int_list', []) [] >>> vtor.check('int_list', (1...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "integers", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1110-L1131
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_bool_list
def is_bool_list(value, min=None, max=None): """ Check that the value is a list of booleans. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a boolean. >>> vtor = Validator() >>> vtor.check('bool_list', ()) [] >>> vtor.check...
python
def is_bool_list(value, min=None, max=None): """ Check that the value is a list of booleans. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a boolean. >>> vtor = Validator() >>> vtor.check('bool_list', ()) [] >>> vtor.check...
[ "def", "is_bool_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "return", "[", "is_boolean", "(", "mem", ")", "for", "mem", "in", "is_list", "(", "value", ",", "min", ",", "max", ")", "]" ]
Check that the value is a list of booleans. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a boolean. >>> vtor = Validator() >>> vtor.check('bool_list', ()) [] >>> vtor.check('bool_list', []) [] >>> check_res = vtor.check('...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "booleans", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1134-L1157
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_float_list
def is_float_list(value, min=None, max=None): """ Check that the value is a list of floats. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a float. >>> vtor = Validator() >>> vtor.check('float_list', ()) [] >>> vtor.check('...
python
def is_float_list(value, min=None, max=None): """ Check that the value is a list of floats. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a float. >>> vtor = Validator() >>> vtor.check('float_list', ()) [] >>> vtor.check('...
[ "def", "is_float_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "return", "[", "is_float", "(", "mem", ")", "for", "mem", "in", "is_list", "(", "value", ",", "min", ",", "max", ")", "]" ]
Check that the value is a list of floats. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a float. >>> vtor = Validator() >>> vtor.check('float_list', ()) [] >>> vtor.check('float_list', []) [] >>> vtor.check('float_list', (...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "floats", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1160-L1181
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_string_list
def is_string_list(value, min=None, max=None): """ Check that the value is a list of strings. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a string. >>> vtor = Validator() >>> vtor.check('string_list', ()) [] >>> vtor.che...
python
def is_string_list(value, min=None, max=None): """ Check that the value is a list of strings. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a string. >>> vtor = Validator() >>> vtor.check('string_list', ()) [] >>> vtor.che...
[ "def", "is_string_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "raise", "VdtTypeError", "(", "value", ")", "return", "[", "is_string", "(", "mem", ")",...
Check that the value is a list of strings. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is a string. >>> vtor = Validator() >>> vtor.check('string_list', ()) [] >>> vtor.check('string_list', []) [] >>> vtor.check('string_lis...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "strings", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1184-L1208
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_ip_addr_list
def is_ip_addr_list(value, min=None, max=None): """ Check that the value is a list of IP addresses. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an IP address. >>> vtor = Validator() >>> vtor.check('ip_addr_list', ()) [] ...
python
def is_ip_addr_list(value, min=None, max=None): """ Check that the value is a list of IP addresses. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an IP address. >>> vtor = Validator() >>> vtor.check('ip_addr_list', ()) [] ...
[ "def", "is_ip_addr_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "return", "[", "is_ip_addr", "(", "mem", ")", "for", "mem", "in", "is_list", "(", "value", ",", "min", ",", "max", ")", "]" ]
Check that the value is a list of IP addresses. You can optionally specify the minimum and maximum number of members. Each list member is checked that it is an IP address. >>> vtor = Validator() >>> vtor.check('ip_addr_list', ()) [] >>> vtor.check('ip_addr_list', []) [] >>> vtor.check...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "IP", "addresses", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1211-L1230
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
force_list
def force_list(value, min=None, max=None): """ Check that a value is a list, coercing strings into a list with one member. Useful where users forget the trailing comma that turns a single value into a list. You can optionally specify the minimum and maximum number of members. A minumum of great...
python
def force_list(value, min=None, max=None): """ Check that a value is a list, coercing strings into a list with one member. Useful where users forget the trailing comma that turns a single value into a list. You can optionally specify the minimum and maximum number of members. A minumum of great...
[ "def", "force_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ")", ")", ":", "value", "=", "[", "value", "]", "return", "is_list", "(", "val...
Check that a value is a list, coercing strings into a list with one member. Useful where users forget the trailing comma that turns a single value into a list. You can optionally specify the minimum and maximum number of members. A minumum of greater than one will fail if the user only supplies a s...
[ "Check", "that", "a", "value", "is", "a", "list", "coercing", "strings", "into", "a", "list", "with", "one", "member", ".", "Useful", "where", "users", "forget", "the", "trailing", "comma", "that", "turns", "a", "single", "value", "into", "a", "list", "....
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1233-L1253
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_mixed_list
def is_mixed_list(value, *args): """ Check that the value is a list. Allow specifying the type of each member. Work on lists of specific lengths. You specify each member as a positional argument specifying type Each type should be one of the following strings : 'integer', 'float', 'ip_ad...
python
def is_mixed_list(value, *args): """ Check that the value is a list. Allow specifying the type of each member. Work on lists of specific lengths. You specify each member as a positional argument specifying type Each type should be one of the following strings : 'integer', 'float', 'ip_ad...
[ "def", "is_mixed_list", "(", "value", ",", "*", "args", ")", ":", "try", ":", "length", "=", "len", "(", "value", ")", "except", "TypeError", ":", "raise", "VdtTypeError", "(", "value", ")", "if", "length", "<", "len", "(", "args", ")", ":", "raise",...
Check that the value is a list. Allow specifying the type of each member. Work on lists of specific lengths. You specify each member as a positional argument specifying type Each type should be one of the following strings : 'integer', 'float', 'ip_addr', 'string', 'boolean' So you can spec...
[ "Check", "that", "the", "value", "is", "a", "list", ".", "Allow", "specifying", "the", "type", "of", "each", "member", ".", "Work", "on", "lists", "of", "specific", "lengths", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1265-L1331
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
is_option
def is_option(value, *options): """ This check matches the value to any of a set of options. >>> vtor = Validator() >>> vtor.check('option("yoda", "jedi")', 'yoda') 'yoda' >>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP Traceback (most recent call last): VdtValueError:...
python
def is_option(value, *options): """ This check matches the value to any of a set of options. >>> vtor = Validator() >>> vtor.check('option("yoda", "jedi")', 'yoda') 'yoda' >>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP Traceback (most recent call last): VdtValueError:...
[ "def", "is_option", "(", "value", ",", "*", "options", ")", ":", "if", "not", "isinstance", "(", "value", ",", "string_types", ")", ":", "raise", "VdtTypeError", "(", "value", ")", "if", "not", "value", "in", "options", ":", "raise", "VdtValueError", "("...
This check matches the value to any of a set of options. >>> vtor = Validator() >>> vtor.check('option("yoda", "jedi")', 'yoda') 'yoda' >>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP Traceback (most recent call last): VdtValueError: the value "jed" is unacceptable. >>> vt...
[ "This", "check", "matches", "the", "value", "to", "any", "of", "a", "set", "of", "options", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1334-L1352
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
Validator.check
def check(self, check, value, missing=False): """ Usage: check(check, value) Arguments: check: string representing check to apply (including arguments) value: object to be checked Returns value, converted to correct type if necessary If the check fails, ...
python
def check(self, check, value, missing=False): """ Usage: check(check, value) Arguments: check: string representing check to apply (including arguments) value: object to be checked Returns value, converted to correct type if necessary If the check fails, ...
[ "def", "check", "(", "self", ",", "check", ",", "value", ",", "missing", "=", "False", ")", ":", "fun_name", ",", "fun_args", ",", "fun_kwargs", ",", "default", "=", "self", ".", "_parse_with_caching", "(", "check", ")", "if", "missing", ":", "if", "de...
Usage: check(check, value) Arguments: check: string representing check to apply (including arguments) value: object to be checked Returns value, converted to correct type if necessary If the check fails, raises a ``ValidateError`` subclass. >>> vtor = Validator...
[ "Usage", ":", "check", "(", "check", "value", ")" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L575-L608
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
Validator._unquote
def _unquote(self, val): """Unquote a value if necessary.""" if (len(val) >= 2) and (val[0] in ("'", '"')) and (val[0] == val[-1]): val = val[1:-1] return val
python
def _unquote(self, val): """Unquote a value if necessary.""" if (len(val) >= 2) and (val[0] in ("'", '"')) and (val[0] == val[-1]): val = val[1:-1] return val
[ "def", "_unquote", "(", "self", ",", "val", ")", ":", "if", "(", "len", "(", "val", ")", ">=", "2", ")", "and", "(", "val", "[", "0", "]", "in", "(", "\"'\"", ",", "'\"'", ")", ")", "and", "(", "val", "[", "0", "]", "==", "val", "[", "-",...
Unquote a value if necessary.
[ "Unquote", "a", "value", "if", "necessary", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L693-L697
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
Validator._list_handle
def _list_handle(self, listmatch): """Take apart a ``keyword=list('val, 'val')`` type string.""" out = [] name = listmatch.group(1) args = listmatch.group(2) for arg in self._list_members.findall(args): out.append(self._unquote(arg)) return name, out
python
def _list_handle(self, listmatch): """Take apart a ``keyword=list('val, 'val')`` type string.""" out = [] name = listmatch.group(1) args = listmatch.group(2) for arg in self._list_members.findall(args): out.append(self._unquote(arg)) return name, out
[ "def", "_list_handle", "(", "self", ",", "listmatch", ")", ":", "out", "=", "[", "]", "name", "=", "listmatch", ".", "group", "(", "1", ")", "args", "=", "listmatch", ".", "group", "(", "2", ")", "for", "arg", "in", "self", ".", "_list_members", "....
Take apart a ``keyword=list('val, 'val')`` type string.
[ "Take", "apart", "a", "keyword", "=", "list", "(", "val", "val", ")", "type", "string", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L700-L707
spacetelescope/stsci.tools
lib/stsci/tools/validate.py
Validator.get_default_value
def get_default_value(self, check): """ Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised. """ fun_name, fun_args, fun_kwargs, default = self._parse...
python
def get_default_value(self, check): """ Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised. """ fun_name, fun_args, fun_kwargs, default = self._parse...
[ "def", "get_default_value", "(", "self", ",", "check", ")", ":", "fun_name", ",", "fun_args", ",", "fun_kwargs", ",", "default", "=", "self", ".", "_parse_with_caching", "(", "check", ")", "if", "default", "is", "None", ":", "raise", "KeyError", "(", "'Che...
Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised.
[ "Given", "a", "check", "return", "the", "default", "value", "for", "the", "check", "(", "converted", "to", "the", "right", "type", ")", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L723-L737
spacetelescope/stsci.tools
lib/stsci/tools/stpyfits.py
_ConstantValueImageBaseHDU.match_header
def match_header(cls, header): """A constant value HDU will only be recognized as such if the header contains a valid PIXVALUE and NAXIS == 0. """ pixvalue = header.get('PIXVALUE') naxis = header.get('NAXIS', 0) return (super(_ConstantValueImageBaseHDU, cls).match_heade...
python
def match_header(cls, header): """A constant value HDU will only be recognized as such if the header contains a valid PIXVALUE and NAXIS == 0. """ pixvalue = header.get('PIXVALUE') naxis = header.get('NAXIS', 0) return (super(_ConstantValueImageBaseHDU, cls).match_heade...
[ "def", "match_header", "(", "cls", ",", "header", ")", ":", "pixvalue", "=", "header", ".", "get", "(", "'PIXVALUE'", ")", "naxis", "=", "header", ".", "get", "(", "'NAXIS'", ",", "0", ")", "return", "(", "super", "(", "_ConstantValueImageBaseHDU", ",", ...
A constant value HDU will only be recognized as such if the header contains a valid PIXVALUE and NAXIS == 0.
[ "A", "constant", "value", "HDU", "will", "only", "be", "recognized", "as", "such", "if", "the", "header", "contains", "a", "valid", "PIXVALUE", "and", "NAXIS", "==", "0", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/stpyfits.py#L230-L240
spacetelescope/stsci.tools
lib/stsci/tools/stpyfits.py
_ConstantValueImageBaseHDU._check_constant_value_data
def _check_constant_value_data(self, data): """Verify that the HDU's data is a constant value array.""" arrayval = data.flat[0] if np.all(data == arrayval): return arrayval return None
python
def _check_constant_value_data(self, data): """Verify that the HDU's data is a constant value array.""" arrayval = data.flat[0] if np.all(data == arrayval): return arrayval return None
[ "def", "_check_constant_value_data", "(", "self", ",", "data", ")", ":", "arrayval", "=", "data", ".", "flat", "[", "0", "]", "if", "np", ".", "all", "(", "data", "==", "arrayval", ")", ":", "return", "arrayval", "return", "None" ]
Verify that the HDU's data is a constant value array.
[ "Verify", "that", "the", "HDU", "s", "data", "is", "a", "constant", "value", "array", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/stpyfits.py#L307-L313
spacetelescope/stsci.tools
lib/stsci/tools/listdlg.py
ListSingleSelectDialog.get_current_index
def get_current_index(self): """ Return currently selected index (or -1) """ # Need to convert to int; currently API returns a tuple of string curSel = self.__lb.curselection() if curSel and len(curSel) > 0: return int(curSel[0]) else: return -1
python
def get_current_index(self): """ Return currently selected index (or -1) """ # Need to convert to int; currently API returns a tuple of string curSel = self.__lb.curselection() if curSel and len(curSel) > 0: return int(curSel[0]) else: return -1
[ "def", "get_current_index", "(", "self", ")", ":", "# Need to convert to int; currently API returns a tuple of string", "curSel", "=", "self", ".", "__lb", ".", "curselection", "(", ")", "if", "curSel", "and", "len", "(", "curSel", ")", ">", "0", ":", "return", ...
Return currently selected index (or -1)
[ "Return", "currently", "selected", "index", "(", "or", "-", "1", ")" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/listdlg.py#L40-L48
spacetelescope/stsci.tools
lib/stsci/tools/convertgeis.py
convert
def convert(input): """Input GEIS files "input" will be read and a HDUList object will be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF. The user can use the writeto method to write the HDUList object to a FITS file. """ global dat cardLen = fits.C...
python
def convert(input): """Input GEIS files "input" will be read and a HDUList object will be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF. The user can use the writeto method to write the HDUList object to a FITS file. """ global dat cardLen = fits.C...
[ "def", "convert", "(", "input", ")", ":", "global", "dat", "cardLen", "=", "fits", ".", "Card", ".", "length", "# input file(s) must be of the form *.??h and *.??d", "if", "input", "[", "-", "1", "]", "!=", "'h'", "or", "input", "[", "-", "4", "]", "!=", ...
Input GEIS files "input" will be read and a HDUList object will be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF. The user can use the writeto method to write the HDUList object to a FITS file.
[ "Input", "GEIS", "files", "input", "will", "be", "read", "and", "a", "HDUList", "object", "will", "be", "returned", "that", "matches", "the", "waiver", "-", "FITS", "format", "written", "out", "by", "stwfits", "in", "IRAF", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertgeis.py#L102-L361
3ll3d00d/vibe
backend/src/core/BaseConfig.py
BaseConfig._loadConfig
def _loadConfig(self): """ loads configuration from some predictable locations. :return: the config. """ configPath = path.join(self._getConfigPath(), self._name + ".yml") if os.path.exists(configPath): self.logger.warning("Loading config from " + configPath) ...
python
def _loadConfig(self): """ loads configuration from some predictable locations. :return: the config. """ configPath = path.join(self._getConfigPath(), self._name + ".yml") if os.path.exists(configPath): self.logger.warning("Loading config from " + configPath) ...
[ "def", "_loadConfig", "(", "self", ")", ":", "configPath", "=", "path", ".", "join", "(", "self", ".", "_getConfigPath", "(", ")", ",", "self", ".", "_name", "+", "\".yml\"", ")", "if", "os", ".", "path", ".", "exists", "(", "configPath", ")", ":", ...
loads configuration from some predictable locations. :return: the config.
[ "loads", "configuration", "from", "some", "predictable", "locations", ".", ":", "return", ":", "the", "config", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L54-L66
3ll3d00d/vibe
backend/src/core/BaseConfig.py
BaseConfig._storeConfig
def _storeConfig(self, config, configPath): """ Writes the config to the configPath. :param config a dict of config. :param configPath the path to the file to write to, intermediate dirs will be created as necessary. """ self.logger.info("Writing to " + str(configPath)) ...
python
def _storeConfig(self, config, configPath): """ Writes the config to the configPath. :param config a dict of config. :param configPath the path to the file to write to, intermediate dirs will be created as necessary. """ self.logger.info("Writing to " + str(configPath)) ...
[ "def", "_storeConfig", "(", "self", ",", "config", ",", "configPath", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Writing to \"", "+", "str", "(", "configPath", ")", ")", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "...
Writes the config to the configPath. :param config a dict of config. :param configPath the path to the file to write to, intermediate dirs will be created as necessary.
[ "Writes", "the", "config", "to", "the", "configPath", ".", ":", "param", "config", "a", "dict", "of", "config", ".", ":", "param", "configPath", "the", "path", "to", "the", "file", "to", "write", "to", "intermediate", "dirs", "will", "be", "created", "as...
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L68-L77
3ll3d00d/vibe
backend/src/core/BaseConfig.py
BaseConfig._getConfigPath
def _getConfigPath(self): """ Gets the currently configured config path. :return: the path, raises ValueError if it doesn't exist. """ confHome = environ.get('VIBE_CONFIG_HOME') return confHome if confHome is not None else path.join(path.expanduser("~"), '.vibe')
python
def _getConfigPath(self): """ Gets the currently configured config path. :return: the path, raises ValueError if it doesn't exist. """ confHome = environ.get('VIBE_CONFIG_HOME') return confHome if confHome is not None else path.join(path.expanduser("~"), '.vibe')
[ "def", "_getConfigPath", "(", "self", ")", ":", "confHome", "=", "environ", ".", "get", "(", "'VIBE_CONFIG_HOME'", ")", "return", "confHome", "if", "confHome", "is", "not", "None", "else", "path", ".", "join", "(", "path", ".", "expanduser", "(", "\"~\"", ...
Gets the currently configured config path. :return: the path, raises ValueError if it doesn't exist.
[ "Gets", "the", "currently", "configured", "config", "path", ".", ":", "return", ":", "the", "path", "raises", "ValueError", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L87-L93
3ll3d00d/vibe
backend/src/core/BaseConfig.py
BaseConfig.configureLogger
def configureLogger(self): """ Configures the python logging system to log to a debug file and to stdout for warn and above. :return: the base logger. """ baseLogLevel = logging.DEBUG if self.isDebugLogging() else logging.INFO # create recorder app root logger log...
python
def configureLogger(self): """ Configures the python logging system to log to a debug file and to stdout for warn and above. :return: the base logger. """ baseLogLevel = logging.DEBUG if self.isDebugLogging() else logging.INFO # create recorder app root logger log...
[ "def", "configureLogger", "(", "self", ")", ":", "baseLogLevel", "=", "logging", ".", "DEBUG", "if", "self", ".", "isDebugLogging", "(", ")", "else", "logging", ".", "INFO", "# create recorder app root logger", "logger", "=", "logging", ".", "getLogger", "(", ...
Configures the python logging system to log to a debug file and to stdout for warn and above. :return: the base logger.
[ "Configures", "the", "python", "logging", "system", "to", "log", "to", "a", "debug", "file", "and", "to", "stdout", "for", "warn", "and", "above", ".", ":", "return", ":", "the", "base", "logger", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L95-L118
selik/xport
xport/v56.py
ibm_to_ieee
def ibm_to_ieee(ibm): ''' Translate IBM-format floating point numbers (as bytes) to IEEE 754 64-bit floating point format (as Python float). ''' # IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64) # Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023) # Pad-out to 8 bytes ...
python
def ibm_to_ieee(ibm): ''' Translate IBM-format floating point numbers (as bytes) to IEEE 754 64-bit floating point format (as Python float). ''' # IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64) # Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023) # Pad-out to 8 bytes ...
[ "def", "ibm_to_ieee", "(", "ibm", ")", ":", "# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)", "# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)", "# Pad-out to 8 bytes if necessary. We expect 2 to 8 bytes, but", "# there's no need to check; bizarre sizes will cause a s...
Translate IBM-format floating point numbers (as bytes) to IEEE 754 64-bit floating point format (as Python float).
[ "Translate", "IBM", "-", "format", "floating", "point", "numbers", "(", "as", "bytes", ")", "to", "IEEE", "754", "64", "-", "bit", "floating", "point", "format", "(", "as", "Python", "float", ")", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L36-L96
selik/xport
xport/v56.py
ieee_to_ibm
def ieee_to_ibm(ieee): ''' Translate Python floating point numbers to IBM-format (as bytes). ''' # Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023) # IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64) if ieee == 0.0: return b'\x00' * 8 if ieee is None or math.is...
python
def ieee_to_ibm(ieee): ''' Translate Python floating point numbers to IBM-format (as bytes). ''' # Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023) # IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64) if ieee == 0.0: return b'\x00' * 8 if ieee is None or math.is...
[ "def", "ieee_to_ibm", "(", "ieee", ")", ":", "# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)", "# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)", "if", "ieee", "==", "0.0", ":", "return", "b'\\x00'", "*", "8", "if", "ieee", "is", "None", "or", ...
Translate Python floating point numbers to IBM-format (as bytes).
[ "Translate", "Python", "floating", "point", "numbers", "to", "IBM", "-", "format", "(", "as", "bytes", ")", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L600-L657
selik/xport
xport/v56.py
dumps
def dumps(columns): ''' Serialize ``columns`` to a JSON formatted ``bytes`` object. ''' fp = BytesIO() dump(columns, fp) fp.seek(0) return fp.read()
python
def dumps(columns): ''' Serialize ``columns`` to a JSON formatted ``bytes`` object. ''' fp = BytesIO() dump(columns, fp) fp.seek(0) return fp.read()
[ "def", "dumps", "(", "columns", ")", ":", "fp", "=", "BytesIO", "(", ")", "dump", "(", "columns", ",", "fp", ")", "fp", ".", "seek", "(", "0", ")", "return", "fp", ".", "read", "(", ")" ]
Serialize ``columns`` to a JSON formatted ``bytes`` object.
[ "Serialize", "columns", "to", "a", "JSON", "formatted", "bytes", "object", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L669-L676
selik/xport
xport/v56.py
Library.match
def match(header): ''' Parse the 3-line (240-byte) header of a SAS XPORT file. ''' mo = Library.header_re.match(header) if mo is None: raise ValueError(f'Not a SAS Version 5 or 6 XPORT file') return { 'created': strptime(mo['created']), ...
python
def match(header): ''' Parse the 3-line (240-byte) header of a SAS XPORT file. ''' mo = Library.header_re.match(header) if mo is None: raise ValueError(f'Not a SAS Version 5 or 6 XPORT file') return { 'created': strptime(mo['created']), ...
[ "def", "match", "(", "header", ")", ":", "mo", "=", "Library", ".", "header_re", ".", "match", "(", "header", ")", "if", "mo", "is", "None", ":", "raise", "ValueError", "(", "f'Not a SAS Version 5 or 6 XPORT file'", ")", "return", "{", "'created'", ":", "s...
Parse the 3-line (240-byte) header of a SAS XPORT file.
[ "Parse", "the", "3", "-", "line", "(", "240", "-", "byte", ")", "header", "of", "a", "SAS", "XPORT", "file", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L146-L158
selik/xport
xport/v56.py
Member.header_match
def header_match(cls, header): ''' Parse the 4-line (320-byte) library member header. ''' mo = cls.header_re.match(header) if mo is None: msg = f'Expected {cls.header_re.pattern!r}, got {header!r}' raise ValueError(msg) return { 'name':...
python
def header_match(cls, header): ''' Parse the 4-line (320-byte) library member header. ''' mo = cls.header_re.match(header) if mo is None: msg = f'Expected {cls.header_re.pattern!r}, got {header!r}' raise ValueError(msg) return { 'name':...
[ "def", "header_match", "(", "cls", ",", "header", ")", ":", "mo", "=", "cls", ".", "header_re", ".", "match", "(", "header", ")", "if", "mo", "is", "None", ":", "msg", "=", "f'Expected {cls.header_re.pattern!r}, got {header!r}'", "raise", "ValueError", "(", ...
Parse the 4-line (320-byte) library member header.
[ "Parse", "the", "4", "-", "line", "(", "320", "-", "byte", ")", "library", "member", "header", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L292-L309
selik/xport
xport/v56.py
Variable.header_match
def header_match(cls, data): ''' Parse a member namestrs header (1 line, 80 bytes). ''' mo = cls.header_re.match(data) return int(mo['n_variables'])
python
def header_match(cls, data): ''' Parse a member namestrs header (1 line, 80 bytes). ''' mo = cls.header_re.match(data) return int(mo['n_variables'])
[ "def", "header_match", "(", "cls", ",", "data", ")", ":", "mo", "=", "cls", ".", "header_re", ".", "match", "(", "data", ")", "return", "int", "(", "mo", "[", "'n_variables'", "]", ")" ]
Parse a member namestrs header (1 line, 80 bytes).
[ "Parse", "a", "member", "namestrs", "header", "(", "1", "line", "80", "bytes", ")", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L421-L426
selik/xport
xport/v56.py
Variable.readall
def readall(cls, member, size): ''' Parse variable metadata for a XPORT file member. ''' fp = member.library.fp LINE = member.library.LINE n = cls.header_match(fp.read(LINE)) namestrs = [fp.read(size) for i in range(n)] # Each namestr field is 140 bytes ...
python
def readall(cls, member, size): ''' Parse variable metadata for a XPORT file member. ''' fp = member.library.fp LINE = member.library.LINE n = cls.header_match(fp.read(LINE)) namestrs = [fp.read(size) for i in range(n)] # Each namestr field is 140 bytes ...
[ "def", "readall", "(", "cls", ",", "member", ",", "size", ")", ":", "fp", "=", "member", ".", "library", ".", "fp", "LINE", "=", "member", ".", "library", ".", "LINE", "n", "=", "cls", ".", "header_match", "(", "fp", ".", "read", "(", "LINE", ")"...
Parse variable metadata for a XPORT file member.
[ "Parse", "variable", "metadata", "for", "a", "XPORT", "file", "member", "." ]
train
https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L464-L489
fitnr/convertdate
convertdate/islamic.py
to_jd
def to_jd(year, month, day): '''Determine Julian day count from Islamic date''' return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1
python
def to_jd(year, month, day): '''Determine Julian day count from Islamic date''' return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "return", "(", "day", "+", "ceil", "(", "29.5", "*", "(", "month", "-", "1", ")", ")", "+", "(", "year", "-", "1", ")", "*", "354", "+", "trunc", "(", "(", "3", "+", "(", "1...
Determine Julian day count from Islamic date
[ "Determine", "Julian", "day", "count", "from", "Islamic", "date" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/islamic.py#L28-L30
fitnr/convertdate
convertdate/islamic.py
from_jd
def from_jd(jd): '''Calculate Islamic date from Julian day''' jd = trunc(jd) + 0.5 year = trunc(((30 * (jd - EPOCH)) + 10646) / 10631) month = min(12, ceil((jd - (29 + to_jd(year, 1, 1))) / 29.5) + 1) day = int(jd - to_jd(year, month, 1)) + 1 return (year, month, day)
python
def from_jd(jd): '''Calculate Islamic date from Julian day''' jd = trunc(jd) + 0.5 year = trunc(((30 * (jd - EPOCH)) + 10646) / 10631) month = min(12, ceil((jd - (29 + to_jd(year, 1, 1))) / 29.5) + 1) day = int(jd - to_jd(year, month, 1)) + 1 return (year, month, day)
[ "def", "from_jd", "(", "jd", ")", ":", "jd", "=", "trunc", "(", "jd", ")", "+", "0.5", "year", "=", "trunc", "(", "(", "(", "30", "*", "(", "jd", "-", "EPOCH", ")", ")", "+", "10646", ")", "/", "10631", ")", "month", "=", "min", "(", "12", ...
Calculate Islamic date from Julian day
[ "Calculate", "Islamic", "date", "from", "Julian", "day" ]
train
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/islamic.py#L33-L40
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.checkAllTriggers
def checkAllTriggers(self, action): """ Go over all widgets and let them know they have been edited recently and they need to check for any trigger actions. This would be used right after all the widgets have their values set or forced (e.g. via setAllEntriesFromParList). ""...
python
def checkAllTriggers(self, action): """ Go over all widgets and let them know they have been edited recently and they need to check for any trigger actions. This would be used right after all the widgets have their values set or forced (e.g. via setAllEntriesFromParList). ""...
[ "def", "checkAllTriggers", "(", "self", ",", "action", ")", ":", "for", "entry", "in", "self", ".", "entryNo", ":", "entry", ".", "widgetEdited", "(", "action", "=", "action", ",", "skipDups", "=", "False", ")" ]
Go over all widgets and let them know they have been edited recently and they need to check for any trigger actions. This would be used right after all the widgets have their values set or forced (e.g. via setAllEntriesFromParList).
[ "Go", "over", "all", "widgets", "and", "let", "them", "know", "they", "have", "been", "edited", "recently", "and", "they", "need", "to", "check", "for", "any", "trigger", "actions", ".", "This", "would", "be", "used", "right", "after", "all", "the", "wid...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L417-L423
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.freshenFocus
def freshenFocus(self): """ Did something which requires a new look. Move scrollbar up. This often needs to be delayed a bit however, to let other events in the queue through first. """ self.top.update_idletasks() self.top.after(10, self.setViewAtTop)
python
def freshenFocus(self): """ Did something which requires a new look. Move scrollbar up. This often needs to be delayed a bit however, to let other events in the queue through first. """ self.top.update_idletasks() self.top.after(10, self.setViewAtTop)
[ "def", "freshenFocus", "(", "self", ")", ":", "self", ".", "top", ".", "update_idletasks", "(", ")", "self", ".", "top", ".", "after", "(", "10", ",", "self", ".", "setViewAtTop", ")" ]
Did something which requires a new look. Move scrollbar up. This often needs to be delayed a bit however, to let other events in the queue through first.
[ "Did", "something", "which", "requires", "a", "new", "look", ".", "Move", "scrollbar", "up", ".", "This", "often", "needs", "to", "be", "delayed", "a", "bit", "however", "to", "let", "other", "events", "in", "the", "queue", "through", "first", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L426-L431
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.mwl
def mwl(self, event): """Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this """ if event.num == 4: # up on Linux self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units') elif event.num == 5: # down on Linux self.top.f.canvas.yview_scroll(1*self._tmwm, 'units') ...
python
def mwl(self, event): """Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this """ if event.num == 4: # up on Linux self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units') elif event.num == 5: # down on Linux self.top.f.canvas.yview_scroll(1*self._tmwm, 'units') ...
[ "def", "mwl", "(", "self", ",", "event", ")", ":", "if", "event", ".", "num", "==", "4", ":", "# up on Linux", "self", ".", "top", ".", "f", ".", "canvas", ".", "yview_scroll", "(", "-", "1", "*", "self", ".", "_tmwm", ",", "'units'", ")", "elif"...
Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this
[ "Mouse", "Wheel", "-", "under", "tkinter", "we", "seem", "to", "need", "Tk", "v8", ".", "5", "+", "for", "this" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L444-L451
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.focusNext
def focusNext(self, event): """Set focus to next item in sequence""" try: event.widget.tk_focusNext().focus_set() except TypeError: # see tkinter equivalent code for tk_focusNext to see # commented original version name = event.widget.tk.call('tk_f...
python
def focusNext(self, event): """Set focus to next item in sequence""" try: event.widget.tk_focusNext().focus_set() except TypeError: # see tkinter equivalent code for tk_focusNext to see # commented original version name = event.widget.tk.call('tk_f...
[ "def", "focusNext", "(", "self", ",", "event", ")", ":", "try", ":", "event", ".", "widget", ".", "tk_focusNext", "(", ")", ".", "focus_set", "(", ")", "except", "TypeError", ":", "# see tkinter equivalent code for tk_focusNext to see", "# commented original version...
Set focus to next item in sequence
[ "Set", "focus", "to", "next", "item", "in", "sequence" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L458-L466
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.focusPrev
def focusPrev(self, event): """Set focus to previous item in sequence""" try: event.widget.tk_focusPrev().focus_set() except TypeError: # see tkinter equivalent code for tk_focusPrev to see # commented original version name = event.widget.tk.call('...
python
def focusPrev(self, event): """Set focus to previous item in sequence""" try: event.widget.tk_focusPrev().focus_set() except TypeError: # see tkinter equivalent code for tk_focusPrev to see # commented original version name = event.widget.tk.call('...
[ "def", "focusPrev", "(", "self", ",", "event", ")", ":", "try", ":", "event", ".", "widget", ".", "tk_focusPrev", "(", ")", ".", "focus_set", "(", ")", "except", "TypeError", ":", "# see tkinter equivalent code for tk_focusPrev to see", "# commented original version...
Set focus to previous item in sequence
[ "Set", "focus", "to", "previous", "item", "in", "sequence" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L468-L476
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.doScroll
def doScroll(self, event): """Scroll the panel down to ensure widget with focus to be visible Tracks the last widget that doScroll was called for and ignores repeated calls. That handles the case where the focus moves not between parameter entries but to someplace outside the hierarchy...
python
def doScroll(self, event): """Scroll the panel down to ensure widget with focus to be visible Tracks the last widget that doScroll was called for and ignores repeated calls. That handles the case where the focus moves not between parameter entries but to someplace outside the hierarchy...
[ "def", "doScroll", "(", "self", ",", "event", ")", ":", "canvas", "=", "self", ".", "top", ".", "f", ".", "canvas", "widgetWithFocus", "=", "event", ".", "widget", "if", "widgetWithFocus", "is", "self", ".", "lastFocusWidget", ":", "return", "FALSE", "se...
Scroll the panel down to ensure widget with focus to be visible Tracks the last widget that doScroll was called for and ignores repeated calls. That handles the case where the focus moves not between parameter entries but to someplace outside the hierarchy. In that case the scrolling i...
[ "Scroll", "the", "panel", "down", "to", "ensure", "widget", "with", "focus", "to", "be", "visible" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L478-L508
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog._handleParListMismatch
def _handleParListMismatch(self, probStr, extra=False): """ Handle the situation where two par lists do not match. This is meant to allow subclasses to override. Note that this only handles "missing" pars and "extra" pars, not wrong-type pars. """ errmsg = 'ERROR: mismatch between defau...
python
def _handleParListMismatch(self, probStr, extra=False): """ Handle the situation where two par lists do not match. This is meant to allow subclasses to override. Note that this only handles "missing" pars and "extra" pars, not wrong-type pars. """ errmsg = 'ERROR: mismatch between defau...
[ "def", "_handleParListMismatch", "(", "self", ",", "probStr", ",", "extra", "=", "False", ")", ":", "errmsg", "=", "'ERROR: mismatch between default and current par lists '", "+", "'for task \"'", "+", "self", ".", "taskName", "+", "'\"'", "if", "probStr", ":", "e...
Handle the situation where two par lists do not match. This is meant to allow subclasses to override. Note that this only handles "missing" pars and "extra" pars, not wrong-type pars.
[ "Handle", "the", "situation", "where", "two", "par", "lists", "do", "not", "match", ".", "This", "is", "meant", "to", "allow", "subclasses", "to", "override", ".", "Note", "that", "this", "only", "handles", "missing", "pars", "and", "extra", "pars", "not",...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L511-L522
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog._setupDefaultParamList
def _setupDefaultParamList(self): """ This creates self.defaultParamList. It also does some checks on the paramList, sets its order if needed, and deletes any extra or unknown pars if found. We assume the order of self.defaultParamList is the correct order. """ # Obtain the def...
python
def _setupDefaultParamList(self): """ This creates self.defaultParamList. It also does some checks on the paramList, sets its order if needed, and deletes any extra or unknown pars if found. We assume the order of self.defaultParamList is the correct order. """ # Obtain the def...
[ "def", "_setupDefaultParamList", "(", "self", ")", ":", "# Obtain the default parameter list", "self", ".", "defaultParamList", "=", "self", ".", "_taskParsObj", ".", "getDefaultParList", "(", ")", "theParamList", "=", "self", ".", "_taskParsObj", ".", "getParList", ...
This creates self.defaultParamList. It also does some checks on the paramList, sets its order if needed, and deletes any extra or unknown pars if found. We assume the order of self.defaultParamList is the correct order.
[ "This", "creates", "self", ".", "defaultParamList", ".", "It", "also", "does", "some", "checks", "on", "the", "paramList", "sets", "its", "order", "if", "needed", "and", "deletes", "any", "extra", "or", "unknown", "pars", "if", "found", ".", "We", "assume"...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L525-L579
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog._toggleSectionActiveState
def _toggleSectionActiveState(self, sectionName, state, skipList): """ Make an entire section (minus skipList items) either active or inactive. sectionName is the same as the param's scope. """ # Get model data, the list of pars theParamList = self._taskParsObj.getParList() ...
python
def _toggleSectionActiveState(self, sectionName, state, skipList): """ Make an entire section (minus skipList items) either active or inactive. sectionName is the same as the param's scope. """ # Get model data, the list of pars theParamList = self._taskParsObj.getParList() ...
[ "def", "_toggleSectionActiveState", "(", "self", ",", "sectionName", ",", "state", ",", "skipList", ")", ":", "# Get model data, the list of pars", "theParamList", "=", "self", ".", "_taskParsObj", ".", "getParList", "(", ")", "# Loop over their assoc. entries", "for", ...
Make an entire section (minus skipList items) either active or inactive. sectionName is the same as the param's scope.
[ "Make", "an", "entire", "section", "(", "minus", "skipList", "items", ")", "either", "active", "or", "inactive", ".", "sectionName", "is", "the", "same", "as", "the", "param", "s", "scope", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L645-L659
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.saveAs
def saveAs(self, event=None): """ Save the parameter settings to a user-specified file. Any changes here must be coordinated with the corresponding tpar save_as function. """ self.debug('Clicked Save as...') # On Linux Pers..Dlg causes the cwd to change, so get a copy of curren...
python
def saveAs(self, event=None): """ Save the parameter settings to a user-specified file. Any changes here must be coordinated with the corresponding tpar save_as function. """ self.debug('Clicked Save as...') # On Linux Pers..Dlg causes the cwd to change, so get a copy of curren...
[ "def", "saveAs", "(", "self", ",", "event", "=", "None", ")", ":", "self", ".", "debug", "(", "'Clicked Save as...'", ")", "# On Linux Pers..Dlg causes the cwd to change, so get a copy of current", "curdir", "=", "os", ".", "getcwd", "(", ")", "# The user wishes to sa...
Save the parameter settings to a user-specified file. Any changes here must be coordinated with the corresponding tpar save_as function.
[ "Save", "the", "parameter", "settings", "to", "a", "user", "-", "specified", "file", ".", "Any", "changes", "here", "must", "be", "coordinated", "with", "the", "corresponding", "tpar", "save_as", "function", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1122-L1190
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.htmlHelp
def htmlHelp(self, helpString=None, title=None, istask=False, tag=None): """ Pop up the help in a browser window. By default, this tries to show the help for the current task. With the option arguments, it can be used to show any help string. """ # Check the help string. If it turns o...
python
def htmlHelp(self, helpString=None, title=None, istask=False, tag=None): """ Pop up the help in a browser window. By default, this tries to show the help for the current task. With the option arguments, it can be used to show any help string. """ # Check the help string. If it turns o...
[ "def", "htmlHelp", "(", "self", ",", "helpString", "=", "None", ",", "title", "=", "None", ",", "istask", "=", "False", ",", "tag", "=", "None", ")", ":", "# Check the help string. If it turns out to be a URL, launch that,", "# if not, dump it to a quick and dirty tmp ...
Pop up the help in a browser window. By default, this tries to show the help for the current task. With the option arguments, it can be used to show any help string.
[ "Pop", "up", "the", "help", "in", "a", "browser", "window", ".", "By", "default", "this", "tries", "to", "show", "the", "help", "for", "the", "current", "task", ".", "With", "the", "option", "arguments", "it", "can", "be", "used", "to", "show", "any", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1298-L1329
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog._showAnyHelp
def _showAnyHelp(self, kind, tag=None): """ Invoke task/epar/etc. help and put the page in a window. This same logic is used for GUI help, task help, log msgs, etc. """ # sanity check assert kind in ('epar', 'task', 'log'), 'Unknown help kind: '+str(kind) #---------------------...
python
def _showAnyHelp(self, kind, tag=None): """ Invoke task/epar/etc. help and put the page in a window. This same logic is used for GUI help, task help, log msgs, etc. """ # sanity check assert kind in ('epar', 'task', 'log'), 'Unknown help kind: '+str(kind) #---------------------...
[ "def", "_showAnyHelp", "(", "self", ",", "kind", ",", "tag", "=", "None", ")", ":", "# sanity check", "assert", "kind", "in", "(", "'epar'", ",", "'task'", ",", "'log'", ")", ",", "'Unknown help kind: '", "+", "str", "(", "kind", ")", "#-------------------...
Invoke task/epar/etc. help and put the page in a window. This same logic is used for GUI help, task help, log msgs, etc.
[ "Invoke", "task", "/", "epar", "/", "etc", ".", "help", "and", "put", "the", "page", "in", "a", "window", ".", "This", "same", "logic", "is", "used", "for", "GUI", "help", "task", "help", "log", "msgs", "etc", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1332-L1383
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.setAllEntriesFromParList
def setAllEntriesFromParList(self, aParList, updateModel=False): """ Set all the parameter entry values in the GUI to the values in the given par list. If 'updateModel' is True, the internal param list will be updated to the new values as well as the GUI entries (slower and n...
python
def setAllEntriesFromParList(self, aParList, updateModel=False): """ Set all the parameter entry values in the GUI to the values in the given par list. If 'updateModel' is True, the internal param list will be updated to the new values as well as the GUI entries (slower and n...
[ "def", "setAllEntriesFromParList", "(", "self", ",", "aParList", ",", "updateModel", "=", "False", ")", ":", "# Get model data, the list of pars", "theParamList", "=", "self", ".", "_taskParsObj", ".", "getParList", "(", ")", "# we may modify members", "if", "len", ...
Set all the parameter entry values in the GUI to the values in the given par list. If 'updateModel' is True, the internal param list will be updated to the new values as well as the GUI entries (slower and not always necessary). Note the corresponding TparDisplay method.
[ "Set", "all", "the", "parameter", "entry", "values", "in", "the", "GUI", "to", "the", "values", "in", "the", "given", "par", "list", ".", "If", "updateModel", "is", "True", "the", "internal", "param", "list", "will", "be", "updated", "to", "the", "new", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1473-L1530
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.getValue
def getValue(self, name, scope=None, native=False): """ Return current par value from the GUI. This does not do any validation, and it it not necessarily the same value saved in the model, which is always behind the GUI setting, in time. This is NOT to be used to get all the values - it ...
python
def getValue(self, name, scope=None, native=False): """ Return current par value from the GUI. This does not do any validation, and it it not necessarily the same value saved in the model, which is always behind the GUI setting, in time. This is NOT to be used to get all the values - it ...
[ "def", "getValue", "(", "self", ",", "name", ",", "scope", "=", "None", ",", "native", "=", "False", ")", ":", "# Get model data, the list of pars", "theParamList", "=", "self", ".", "_taskParsObj", ".", "getParList", "(", ")", "# NOTE: If par scope is given, it w...
Return current par value from the GUI. This does not do any validation, and it it not necessarily the same value saved in the model, which is always behind the GUI setting, in time. This is NOT to be used to get all the values - it would not be efficient.
[ "Return", "current", "par", "value", "from", "the", "GUI", ".", "This", "does", "not", "do", "any", "validation", "and", "it", "it", "not", "necessarily", "the", "same", "value", "saved", "in", "the", "model", "which", "is", "always", "behind", "the", "G...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1540-L1564
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.checkSetSaveChildren
def checkSetSaveChildren(self, doSave=True): """Check, then set, then save the parameter settings for all child (pset) windows. Prompts if any problems are found. Returns None on success, list of bad entries on failure. """ if self.isChild: return #...
python
def checkSetSaveChildren(self, doSave=True): """Check, then set, then save the parameter settings for all child (pset) windows. Prompts if any problems are found. Returns None on success, list of bad entries on failure. """ if self.isChild: return #...
[ "def", "checkSetSaveChildren", "(", "self", ",", "doSave", "=", "True", ")", ":", "if", "self", ".", "isChild", ":", "return", "# Need to get all the entries and verify them.", "# Save the children in backwards order to coincide with the", "# display of the dialogs (LIFO)", "fo...
Check, then set, then save the parameter settings for all child (pset) windows. Prompts if any problems are found. Returns None on success, list of bad entries on failure.
[ "Check", "then", "set", "then", "save", "the", "parameter", "settings", "for", "all", "child", "(", "pset", ")", "windows", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1658-L1685
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog._pushMessages
def _pushMessages(self): """ Internal callback used to make sure the msg list keeps moving. """ # This continues to get itself called until no msgs are left in list. self.showStatus('') if len(self._statusMsgsToShow) > 0: self.top.after(200, self._pushMessages)
python
def _pushMessages(self): """ Internal callback used to make sure the msg list keeps moving. """ # This continues to get itself called until no msgs are left in list. self.showStatus('') if len(self._statusMsgsToShow) > 0: self.top.after(200, self._pushMessages)
[ "def", "_pushMessages", "(", "self", ")", ":", "# This continues to get itself called until no msgs are left in list.", "self", ".", "showStatus", "(", "''", ")", "if", "len", "(", "self", ".", "_statusMsgsToShow", ")", ">", "0", ":", "self", ".", "top", ".", "a...
Internal callback used to make sure the msg list keeps moving.
[ "Internal", "callback", "used", "to", "make", "sure", "the", "msg", "list", "keeps", "moving", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1688-L1693
spacetelescope/stsci.tools
lib/stsci/tools/editpar.py
EditParDialog.showStatus
def showStatus(self, msg, keep=0, cat=None): """ Show the given status string, but not until any given delay from the previous message has expired. keep is a time (secs) to force the message to remain without being overwritten or cleared. cat is a string category used only in...
python
def showStatus(self, msg, keep=0, cat=None): """ Show the given status string, but not until any given delay from the previous message has expired. keep is a time (secs) to force the message to remain without being overwritten or cleared. cat is a string category used only in...
[ "def", "showStatus", "(", "self", ",", "msg", ",", "keep", "=", "0", ",", "cat", "=", "None", ")", ":", "# prep it, space-wise", "msg", "=", "msg", ".", "strip", "(", ")", "if", "len", "(", "msg", ")", ">", "0", ":", "# right here is the ideal place to...
Show the given status string, but not until any given delay from the previous message has expired. keep is a time (secs) to force the message to remain without being overwritten or cleared. cat is a string category used only in the historical log.
[ "Show", "the", "given", "status", "string", "but", "not", "until", "any", "given", "delay", "from", "the", "previous", "message", "has", "expired", ".", "keep", "is", "a", "time", "(", "secs", ")", "to", "force", "the", "message", "to", "remain", "withou...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1701-L1749
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
teal
def teal(theTask, parent=None, loadOnly=False, returnAs="dict", canExecute=True, strict=False, errorsToTerm=False, autoClose=True, defaults=False): # overrides=None): """ Start the GUI session, or simply load a task's ConfigObj. """ if loadOnly: # this forces returnAs="dict" obj...
python
def teal(theTask, parent=None, loadOnly=False, returnAs="dict", canExecute=True, strict=False, errorsToTerm=False, autoClose=True, defaults=False): # overrides=None): """ Start the GUI session, or simply load a task's ConfigObj. """ if loadOnly: # this forces returnAs="dict" obj...
[ "def", "teal", "(", "theTask", ",", "parent", "=", "None", ",", "loadOnly", "=", "False", ",", "returnAs", "=", "\"dict\"", ",", "canExecute", "=", "True", ",", "strict", "=", "False", ",", "errorsToTerm", "=", "False", ",", "autoClose", "=", "True", "...
Start the GUI session, or simply load a task's ConfigObj.
[ "Start", "the", "GUI", "session", "or", "simply", "load", "a", "task", "s", "ConfigObj", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L167-L227
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
load
def load(theTask, canExecute=True, strict=True, defaults=False): """ Shortcut to load TEAL .cfg files for non-GUI access where loadOnly=True. """ return teal(theTask, parent=None, loadOnly=True, returnAs="dict", canExecute=canExecute, strict=strict, errorsToTerm=True, default...
python
def load(theTask, canExecute=True, strict=True, defaults=False): """ Shortcut to load TEAL .cfg files for non-GUI access where loadOnly=True. """ return teal(theTask, parent=None, loadOnly=True, returnAs="dict", canExecute=canExecute, strict=strict, errorsToTerm=True, default...
[ "def", "load", "(", "theTask", ",", "canExecute", "=", "True", ",", "strict", "=", "True", ",", "defaults", "=", "False", ")", ":", "return", "teal", "(", "theTask", ",", "parent", "=", "None", ",", "loadOnly", "=", "True", ",", "returnAs", "=", "\"d...
Shortcut to load TEAL .cfg files for non-GUI access where loadOnly=True.
[ "Shortcut", "to", "load", "TEAL", ".", "cfg", "files", "for", "non", "-", "GUI", "access", "where", "loadOnly", "=", "True", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L232-L237
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
unlearn
def unlearn(taskPkgName, deleteAll=False): """ Find the task named taskPkgName, and delete any/all user-owned .cfg files in the user's resource directory which apply to that task. Like a unix utility, this returns 0 on success (no files found or only 1 found but deleted). For multiple files found, this...
python
def unlearn(taskPkgName, deleteAll=False): """ Find the task named taskPkgName, and delete any/all user-owned .cfg files in the user's resource directory which apply to that task. Like a unix utility, this returns 0 on success (no files found or only 1 found but deleted). For multiple files found, this...
[ "def", "unlearn", "(", "taskPkgName", ",", "deleteAll", "=", "False", ")", ":", "# this WILL throw an exception if the taskPkgName isn't found", "flist", "=", "cfgpars", ".", "getUsrCfgFilesForPyPkg", "(", "taskPkgName", ")", "# can raise", "if", "flist", "is", "None", ...
Find the task named taskPkgName, and delete any/all user-owned .cfg files in the user's resource directory which apply to that task. Like a unix utility, this returns 0 on success (no files found or only 1 found but deleted). For multiple files found, this uses deleteAll, returning the file-name-list i...
[ "Find", "the", "task", "named", "taskPkgName", "and", "delete", "any", "/", "all", "user", "-", "owned", ".", "cfg", "files", "in", "the", "user", "s", "resource", "directory", "which", "apply", "to", "that", "task", ".", "Like", "a", "unix", "utility", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L248-L270
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
diffFromDefaults
def diffFromDefaults(theTask, report=False): """ Load the given file (or existing object), and return a dict of its values which are different from the default values. If report is set, print to stdout the differences. """ # get the 2 dicts (trees: dicts of dicts) defaultTree = load(theTask, canExe...
python
def diffFromDefaults(theTask, report=False): """ Load the given file (or existing object), and return a dict of its values which are different from the default values. If report is set, print to stdout the differences. """ # get the 2 dicts (trees: dicts of dicts) defaultTree = load(theTask, canExe...
[ "def", "diffFromDefaults", "(", "theTask", ",", "report", "=", "False", ")", ":", "# get the 2 dicts (trees: dicts of dicts)", "defaultTree", "=", "load", "(", "theTask", ",", "canExecute", "=", "False", ",", "strict", "=", "True", ",", "defaults", "=", "True", ...
Load the given file (or existing object), and return a dict of its values which are different from the default values. If report is set, print to stdout the differences.
[ "Load", "the", "given", "file", "(", "or", "existing", "object", ")", "and", "return", "a", "dict", "of", "its", "values", "which", "are", "different", "from", "the", "default", "values", ".", "If", "report", "is", "set", "print", "to", "stdout", "the", ...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L273-L297
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
_isInstalled
def _isInstalled(fullFname): """ Return True if the given file name is located in an installed area (versus a user-owned file) """ if not fullFname: return False if not os.path.exists(fullFname): return False instAreas = [] try: import site instAreas = site.getsitepackages() ...
python
def _isInstalled(fullFname): """ Return True if the given file name is located in an installed area (versus a user-owned file) """ if not fullFname: return False if not os.path.exists(fullFname): return False instAreas = [] try: import site instAreas = site.getsitepackages() ...
[ "def", "_isInstalled", "(", "fullFname", ")", ":", "if", "not", "fullFname", ":", "return", "False", "if", "not", "os", ".", "path", ".", "exists", "(", "fullFname", ")", ":", "return", "False", "instAreas", "=", "[", "]", "try", ":", "import", "site",...
Return True if the given file name is located in an installed area (versus a user-owned file)
[ "Return", "True", "if", "the", "given", "file", "name", "is", "located", "in", "an", "installed", "area", "(", "versus", "a", "user", "-", "owned", "file", ")" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L304-L320
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
execEmbCode
def execEmbCode(SCOPE, NAME, VAL, TEAL, codeStr): """ .cfgspc embedded code execution is done here, in a relatively confined space. The variables available to the code to be executed are: SCOPE, NAME, VAL, PARENT, TEAL The code string itself is expected to set a var named OUT """ ...
python
def execEmbCode(SCOPE, NAME, VAL, TEAL, codeStr): """ .cfgspc embedded code execution is done here, in a relatively confined space. The variables available to the code to be executed are: SCOPE, NAME, VAL, PARENT, TEAL The code string itself is expected to set a var named OUT """ ...
[ "def", "execEmbCode", "(", "SCOPE", ",", "NAME", ",", "VAL", ",", "TEAL", ",", "codeStr", ")", ":", "# This was all we needed in Python 2.x", "# OUT = None", "# exec codeStr", "# return OUT", "# In Python 3 (& 2.x) be more explicit: http://bugs.python.org/issue4831", "PA...
.cfgspc embedded code execution is done here, in a relatively confined space. The variables available to the code to be executed are: SCOPE, NAME, VAL, PARENT, TEAL The code string itself is expected to set a var named OUT
[ ".", "cfgspc", "embedded", "code", "execution", "is", "done", "here", "in", "a", "relatively", "confined", "space", ".", "The", "variables", "available", "to", "the", "code", "to", "be", "executed", "are", ":", "SCOPE", "NAME", "VAL", "PARENT", "TEAL", "Th...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L343-L361
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
print_tasknames
def print_tasknames(pkgName, aDir, term_width=80, always=False, hidden=None): """ Print a message listing TEAL-enabled tasks available under a given installation directory (where pkgName resides). If always is True, this will always print when tasks are found; otherwise i...
python
def print_tasknames(pkgName, aDir, term_width=80, always=False, hidden=None): """ Print a message listing TEAL-enabled tasks available under a given installation directory (where pkgName resides). If always is True, this will always print when tasks are found; otherwise i...
[ "def", "print_tasknames", "(", "pkgName", ",", "aDir", ",", "term_width", "=", "80", ",", "always", "=", "False", ",", "hidden", "=", "None", ")", ":", "# See if we can bail out early", "if", "not", "always", ":", "# We can't use the sys.ps1 check if in PyRAF since ...
Print a message listing TEAL-enabled tasks available under a given installation directory (where pkgName resides). If always is True, this will always print when tasks are found; otherwise it will only print found tasks when in interactive mode. The parameter 'hidden' supports a ...
[ "Print", "a", "message", "listing", "TEAL", "-", "enabled", "tasks", "available", "under", "a", "given", "installation", "directory", "(", "where", "pkgName", "resides", ")", ".", "If", "always", "is", "True", "this", "will", "always", "print", "when", "task...
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L365-L400
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
getHelpFileAsString
def getHelpFileAsString(taskname,taskpath): """ This functions will return useful help as a string read from a file in the task's installed directory called "<module>.help". If no such file can be found, it will simply return an empty string. Notes ----- The location of the actual help fil...
python
def getHelpFileAsString(taskname,taskpath): """ This functions will return useful help as a string read from a file in the task's installed directory called "<module>.help". If no such file can be found, it will simply return an empty string. Notes ----- The location of the actual help fil...
[ "def", "getHelpFileAsString", "(", "taskname", ",", "taskpath", ")", ":", "#get the local library directory where the code is stored", "pathsplit", "=", "os", ".", "path", ".", "split", "(", "taskpath", ")", "# taskpath should be task's __file__", "if", "taskname", ".", ...
This functions will return useful help as a string read from a file in the task's installed directory called "<module>.help". If no such file can be found, it will simply return an empty string. Notes ----- The location of the actual help file will be found under the task's installed directory...
[ "This", "functions", "will", "return", "useful", "help", "as", "a", "string", "read", "from", "a", "file", "in", "the", "task", "s", "installed", "directory", "called", "<module", ">", ".", "help", "." ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L402-L451
spacetelescope/stsci.tools
lib/stsci/tools/teal.py
cfgGetBool
def cfgGetBool(theObj, name, dflt): """ Get a stringified val from a ConfigObj obj and return it as bool """ strval = theObj.get(name, None) if strval is None: return dflt return strval.lower().strip() == 'true'
python
def cfgGetBool(theObj, name, dflt): """ Get a stringified val from a ConfigObj obj and return it as bool """ strval = theObj.get(name, None) if strval is None: return dflt return strval.lower().strip() == 'true'
[ "def", "cfgGetBool", "(", "theObj", ",", "name", ",", "dflt", ")", ":", "strval", "=", "theObj", ".", "get", "(", "name", ",", "None", ")", "if", "strval", "is", "None", ":", "return", "dflt", "return", "strval", ".", "lower", "(", ")", ".", "strip...
Get a stringified val from a ConfigObj obj and return it as bool
[ "Get", "a", "stringified", "val", "from", "a", "ConfigObj", "obj", "and", "return", "it", "as", "bool" ]
train
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L454-L459