partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
countExtn
Return the number of 'extname' extensions, defaulting to counting the number of SCI extensions.
lib/stsci/tools/fileutil.py
def countExtn(fimg, extname='SCI'): """ Return the number of 'extname' extensions, defaulting to counting the number of SCI extensions. """ closefits = False if isinstance(fimg, string_types): fimg = fits.open(fimg) closefits = True n = 0 for e in fimg: if 'extn...
def countExtn(fimg, extname='SCI'): """ Return the number of 'extname' extensions, defaulting to counting the number of SCI extensions. """ closefits = False if isinstance(fimg, string_types): fimg = fits.open(fimg) closefits = True n = 0 for e in fimg: if 'extn...
[ "Return", "the", "number", "of", "extname", "extensions", "defaulting", "to", "counting", "the", "number", "of", "SCI", "extensions", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L885-L904
[ "def", "countExtn", "(", "fimg", ",", "extname", "=", "'SCI'", ")", ":", "closefits", "=", "False", "if", "isinstance", "(", "fimg", ",", "string_types", ")", ":", "fimg", "=", "fits", ".", "open", "(", "fimg", ")", "closefits", "=", "True", "n", "="...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getExtn
Returns the PyFITS extension corresponding to extension specified in filename. Defaults to returning the first extension with data or the primary extension, if none have data. If a non-existent extension has been specified, it raises a `KeyError` exception.
lib/stsci/tools/fileutil.py
def getExtn(fimg, extn=None): """ Returns the PyFITS extension corresponding to extension specified in filename. Defaults to returning the first extension with data or the primary extension, if none have data. If a non-existent extension has been specified, it raises a `KeyError` exception. ...
def getExtn(fimg, extn=None): """ Returns the PyFITS extension corresponding to extension specified in filename. Defaults to returning the first extension with data or the primary extension, if none have data. If a non-existent extension has been specified, it raises a `KeyError` exception. ...
[ "Returns", "the", "PyFITS", "extension", "corresponding", "to", "extension", "specified", "in", "filename", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L907-L992
[ "def", "getExtn", "(", "fimg", ",", "extn", "=", "None", ")", ":", "# If no extension is provided, search for first extension", "# in FITS file with data associated with it.", "if", "extn", "is", "None", ":", "# Set up default to point to PRIMARY extension.", "_extn", "=", "f...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findFile
Search a directory for full filename with optional path.
lib/stsci/tools/fileutil.py
def findFile(input): """Search a directory for full filename with optional path.""" # If no input name is provided, default to returning 'no'(FALSE) if not input: return no # We use 'osfn' here to insure that any IRAF variables are # expanded out before splitting out the path... _fdir,...
def findFile(input): """Search a directory for full filename with optional path.""" # If no input name is provided, default to returning 'no'(FALSE) if not input: return no # We use 'osfn' here to insure that any IRAF variables are # expanded out before splitting out the path... _fdir,...
[ "Search", "a", "directory", "for", "full", "filename", "with", "optional", "path", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1001-L1058
[ "def", "findFile", "(", "input", ")", ":", "# If no input name is provided, default to returning 'no'(FALSE)", "if", "not", "input", ":", "return", "no", "# We use 'osfn' here to insure that any IRAF variables are", "# expanded out before splitting out the path...", "_fdir", ",", "...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
checkFileExists
Checks to see if file specified exists in current or specified directory. Default is current directory. Returns 1 if it exists, 0 if not found.
lib/stsci/tools/fileutil.py
def checkFileExists(filename, directory=None): """ Checks to see if file specified exists in current or specified directory. Default is current directory. Returns 1 if it exists, 0 if not found. """ if directory is not None: fname = os.path.join(directory,filename) else: fname...
def checkFileExists(filename, directory=None): """ Checks to see if file specified exists in current or specified directory. Default is current directory. Returns 1 if it exists, 0 if not found. """ if directory is not None: fname = os.path.join(directory,filename) else: fname...
[ "Checks", "to", "see", "if", "file", "specified", "exists", "in", "current", "or", "specified", "directory", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1061-L1073
[ "def", "checkFileExists", "(", "filename", ",", "directory", "=", "None", ")", ":", "if", "directory", "is", "not", "None", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "filename", ")", "else", ":", "fname", "=", "filename"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
copyFile
Copy a file whole from input to output.
lib/stsci/tools/fileutil.py
def copyFile(input, output, replace=None): """Copy a file whole from input to output.""" _found = findFile(output) if not _found or (_found and replace): shutil.copy2(input, output)
def copyFile(input, output, replace=None): """Copy a file whole from input to output.""" _found = findFile(output) if not _found or (_found and replace): shutil.copy2(input, output)
[ "Copy", "a", "file", "whole", "from", "input", "to", "output", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1076-L1081
[ "def", "copyFile", "(", "input", ",", "output", ",", "replace", "=", "None", ")", ":", "_found", "=", "findFile", "(", "output", ")", "if", "not", "_found", "or", "(", "_found", "and", "replace", ")", ":", "shutil", ".", "copy2", "(", "input", ",", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
removeFile
Utility function for deleting a list of files or a single file. This function will automatically delete both files of a GEIS image, just like 'iraf.imdelete'.
lib/stsci/tools/fileutil.py
def removeFile(inlist): """ Utility function for deleting a list of files or a single file. This function will automatically delete both files of a GEIS image, just like 'iraf.imdelete'. """ if not isinstance(inlist, string_types): # We do have a list, so delete all filenames in list. ...
def removeFile(inlist): """ Utility function for deleting a list of files or a single file. This function will automatically delete both files of a GEIS image, just like 'iraf.imdelete'. """ if not isinstance(inlist, string_types): # We do have a list, so delete all filenames in list. ...
[ "Utility", "function", "for", "deleting", "a", "list", "of", "files", "or", "a", "single", "file", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1111-L1138
[ "def", "removeFile", "(", "inlist", ")", ":", "if", "not", "isinstance", "(", "inlist", ",", "string_types", ")", ":", "# We do have a list, so delete all filenames in list.", "# Treat like a list of full filenames", "_ldir", "=", "os", ".", "listdir", "(", "'.'", ")"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findKeywordExtn
This function will return the index of the extension in a multi-extension FITS file which contains the desired keyword with the given value.
lib/stsci/tools/fileutil.py
def findKeywordExtn(ft, keyword, value=None): """ This function will return the index of the extension in a multi-extension FITS file which contains the desired keyword with the given value. """ i = 0 extnum = -1 # Search through all the extensions in the FITS object for chip in ft: ...
def findKeywordExtn(ft, keyword, value=None): """ This function will return the index of the extension in a multi-extension FITS file which contains the desired keyword with the given value. """ i = 0 extnum = -1 # Search through all the extensions in the FITS object for chip in ft: ...
[ "This", "function", "will", "return", "the", "index", "of", "the", "extension", "in", "a", "multi", "-", "extension", "FITS", "file", "which", "contains", "the", "desired", "keyword", "with", "the", "given", "value", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1141-L1166
[ "def", "findKeywordExtn", "(", "ft", ",", "keyword", ",", "value", "=", "None", ")", ":", "i", "=", "0", "extnum", "=", "-", "1", "# Search through all the extensions in the FITS object", "for", "chip", "in", "ft", ":", "hdr", "=", "chip", ".", "header", "...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findExtname
Returns the list number of the extension corresponding to EXTNAME given.
lib/stsci/tools/fileutil.py
def findExtname(fimg, extname, extver=None): """ Returns the list number of the extension corresponding to EXTNAME given. """ i = 0 extnum = None for chip in fimg: hdr = chip.header if 'EXTNAME' in hdr: if hdr['EXTNAME'].strip() == extname.upper(): if...
def findExtname(fimg, extname, extver=None): """ Returns the list number of the extension corresponding to EXTNAME given. """ i = 0 extnum = None for chip in fimg: hdr = chip.header if 'EXTNAME' in hdr: if hdr['EXTNAME'].strip() == extname.upper(): if...
[ "Returns", "the", "list", "number", "of", "the", "extension", "corresponding", "to", "EXTNAME", "given", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1169-L1184
[ "def", "findExtname", "(", "fimg", ",", "extname", ",", "extver", "=", "None", ")", ":", "i", "=", "0", "extnum", "=", "None", "for", "chip", "in", "fimg", ":", "hdr", "=", "chip", ".", "header", "if", "'EXTNAME'", "in", "hdr", ":", "if", "hdr", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
rAsciiLine
Returns the next non-blank line in an ASCII file.
lib/stsci/tools/fileutil.py
def rAsciiLine(ifile): """Returns the next non-blank line in an ASCII file.""" _line = ifile.readline().strip() while len(_line) == 0: _line = ifile.readline().strip() return _line
def rAsciiLine(ifile): """Returns the next non-blank line in an ASCII file.""" _line = ifile.readline().strip() while len(_line) == 0: _line = ifile.readline().strip() return _line
[ "Returns", "the", "next", "non", "-", "blank", "line", "in", "an", "ASCII", "file", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1187-L1193
[ "def", "rAsciiLine", "(", "ifile", ")", ":", "_line", "=", "ifile", ".", "readline", "(", ")", ".", "strip", "(", ")", "while", "len", "(", "_line", ")", "==", "0", ":", "_line", "=", "ifile", ".", "readline", "(", ")", ".", "strip", "(", ")", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
listVars
List IRAF variables.
lib/stsci/tools/fileutil.py
def listVars(prefix="", equals="\t= ", **kw): """List IRAF variables.""" keylist = getVarList() if len(keylist) == 0: print('No IRAF variables defined') else: keylist.sort() for word in keylist: print("%s%s%s%s" % (prefix, word, equals, envget(word)))
def listVars(prefix="", equals="\t= ", **kw): """List IRAF variables.""" keylist = getVarList() if len(keylist) == 0: print('No IRAF variables defined') else: keylist.sort() for word in keylist: print("%s%s%s%s" % (prefix, word, equals, envget(word)))
[ "List", "IRAF", "variables", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1279-L1288
[ "def", "listVars", "(", "prefix", "=", "\"\"", ",", "equals", "=", "\"\\t= \"", ",", "*", "*", "kw", ")", ":", "keylist", "=", "getVarList", "(", ")", "if", "len", "(", "keylist", ")", "==", "0", ":", "print", "(", "'No IRAF variables defined'", ")", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
untranslateName
Undo Python conversion of CL parameter or variable name.
lib/stsci/tools/fileutil.py
def untranslateName(s): """Undo Python conversion of CL parameter or variable name.""" s = s.replace('DOT', '.') s = s.replace('DOLLAR', '$') # delete 'PY' at start of name components if s[:2] == 'PY': s = s[2:] s = s.replace('.PY', '.') return s
def untranslateName(s): """Undo Python conversion of CL parameter or variable name.""" s = s.replace('DOT', '.') s = s.replace('DOLLAR', '$') # delete 'PY' at start of name components if s[:2] == 'PY': s = s[2:] s = s.replace('.PY', '.') return s
[ "Undo", "Python", "conversion", "of", "CL", "parameter", "or", "variable", "name", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1291-L1299
[ "def", "untranslateName", "(", "s", ")", ":", "s", "=", "s", ".", "replace", "(", "'DOT'", ",", "'.'", ")", "s", "=", "s", ".", "replace", "(", "'DOLLAR'", ",", "'$'", ")", "# delete 'PY' at start of name components", "if", "s", "[", ":", "2", "]", "...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
envget
Get value of IRAF or OS environment variable.
lib/stsci/tools/fileutil.py
def envget(var, default=None): """Get value of IRAF or OS environment variable.""" if 'pyraf' in sys.modules: #ONLY if pyraf is already loaded, import iraf into the namespace from pyraf import iraf else: # else set iraf to None so it knows to not use iraf's environment iraf ...
def envget(var, default=None): """Get value of IRAF or OS environment variable.""" if 'pyraf' in sys.modules: #ONLY if pyraf is already loaded, import iraf into the namespace from pyraf import iraf else: # else set iraf to None so it knows to not use iraf's environment iraf ...
[ "Get", "value", "of", "IRAF", "or", "OS", "environment", "variable", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1302-L1333
[ "def", "envget", "(", "var", ",", "default", "=", "None", ")", ":", "if", "'pyraf'", "in", "sys", ".", "modules", ":", "#ONLY if pyraf is already loaded, import iraf into the namespace", "from", "pyraf", "import", "iraf", "else", ":", "# else set iraf to None so it kn...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
osfn
Convert IRAF virtual path name to OS pathname.
lib/stsci/tools/fileutil.py
def osfn(filename): """Convert IRAF virtual path name to OS pathname.""" # Try to emulate the CL version closely: # # - expands IRAF virtual file names # - strips blanks around path components # - if no slashes or relative paths, return relative pathname # - otherwise return absolute pathna...
def osfn(filename): """Convert IRAF virtual path name to OS pathname.""" # Try to emulate the CL version closely: # # - expands IRAF virtual file names # - strips blanks around path components # - if no slashes or relative paths, return relative pathname # - otherwise return absolute pathna...
[ "Convert", "IRAF", "virtual", "path", "name", "to", "OS", "pathname", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1336-L1361
[ "def", "osfn", "(", "filename", ")", ":", "# Try to emulate the CL version closely:", "#", "# - expands IRAF virtual file names", "# - strips blanks around path components", "# - if no slashes or relative paths, return relative pathname", "# - otherwise return absolute pathname", "if", "fi...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
defvar
Returns true if CL variable is defined.
lib/stsci/tools/fileutil.py
def defvar(varname): """Returns true if CL variable is defined.""" if 'pyraf' in sys.modules: #ONLY if pyraf is already loaded, import iraf into the namespace from pyraf import iraf else: # else set iraf to None so it knows to not use iraf's environment iraf = None if i...
def defvar(varname): """Returns true if CL variable is defined.""" if 'pyraf' in sys.modules: #ONLY if pyraf is already loaded, import iraf into the namespace from pyraf import iraf else: # else set iraf to None so it knows to not use iraf's environment iraf = None if i...
[ "Returns", "true", "if", "CL", "variable", "is", "defined", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1364-L1378
[ "def", "defvar", "(", "varname", ")", ":", "if", "'pyraf'", "in", "sys", ".", "modules", ":", "#ONLY if pyraf is already loaded, import iraf into the namespace", "from", "pyraf", "import", "iraf", "else", ":", "# else set iraf to None so it knows to not use iraf's environment...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
set
Set IRAF environment variables.
lib/stsci/tools/fileutil.py
def set(*args, **kw): """Set IRAF environment variables.""" if len(args) == 0: if len(kw) != 0: # normal case is only keyword,value pairs for keyword, value in kw.items(): keyword = untranslateName(keyword) svalue = str(value) _var...
def set(*args, **kw): """Set IRAF environment variables.""" if len(args) == 0: if len(kw) != 0: # normal case is only keyword,value pairs for keyword, value in kw.items(): keyword = untranslateName(keyword) svalue = str(value) _var...
[ "Set", "IRAF", "environment", "variables", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1388-L1412
[ "def", "set", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "if", "len", "(", "kw", ")", "!=", "0", ":", "# normal case is only keyword,value pairs", "for", "keyword", ",", "value", "in", "kw", ".",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
show
Print value of IRAF or OS environment variables.
lib/stsci/tools/fileutil.py
def show(*args, **kw): """Print value of IRAF or OS environment variables.""" if len(kw): raise TypeError('unexpected keyword argument: %r' % list(kw)) if args: for arg in args: print(envget(arg)) else: # print them all listVars(prefix=" ", equals="=")
def show(*args, **kw): """Print value of IRAF or OS environment variables.""" if len(kw): raise TypeError('unexpected keyword argument: %r' % list(kw)) if args: for arg in args: print(envget(arg)) else: # print them all listVars(prefix=" ", equals="=")
[ "Print", "value", "of", "IRAF", "or", "OS", "environment", "variables", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1419-L1430
[ "def", "show", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "len", "(", "kw", ")", ":", "raise", "TypeError", "(", "'unexpected keyword argument: %r'", "%", "list", "(", "kw", ")", ")", "if", "args", ":", "for", "arg", "in", "args", ":", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
unset
Unset IRAF environment variables. This is not a standard IRAF task, but it is obviously useful. It makes the resulting variables undefined. It silently ignores variables that are not defined. It does not change the os environment variables.
lib/stsci/tools/fileutil.py
def unset(*args, **kw): """ Unset IRAF environment variables. This is not a standard IRAF task, but it is obviously useful. It makes the resulting variables undefined. It silently ignores variables that are not defined. It does not change the os environment variables. """ if len(kw) != ...
def unset(*args, **kw): """ Unset IRAF environment variables. This is not a standard IRAF task, but it is obviously useful. It makes the resulting variables undefined. It silently ignores variables that are not defined. It does not change the os environment variables. """ if len(kw) != ...
[ "Unset", "IRAF", "environment", "variables", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1433-L1447
[ "def", "unset", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "len", "(", "kw", ")", "!=", "0", ":", "raise", "SyntaxError", "(", "\"unset requires a list of variable names\"", ")", "for", "arg", "in", "args", ":", "if", "arg", "in", "_varDict...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
Expand
Expand a string with embedded IRAF variables (IRAF virtual filename). Allows comma-separated lists. Also uses os.path.expanduser to replace '~' symbols. Set the noerror flag to silently replace undefined variables with just the variable name or null (so Expand('abc$def') = 'abcdef' and Expand('(a...
lib/stsci/tools/fileutil.py
def Expand(instring, noerror=0): """ Expand a string with embedded IRAF variables (IRAF virtual filename). Allows comma-separated lists. Also uses os.path.expanduser to replace '~' symbols. Set the noerror flag to silently replace undefined variables with just the variable name or null (so Ex...
def Expand(instring, noerror=0): """ Expand a string with embedded IRAF variables (IRAF virtual filename). Allows comma-separated lists. Also uses os.path.expanduser to replace '~' symbols. Set the noerror flag to silently replace undefined variables with just the variable name or null (so Ex...
[ "Expand", "a", "string", "with", "embedded", "IRAF", "variables", "(", "IRAF", "virtual", "filename", ")", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1478-L1496
[ "def", "Expand", "(", "instring", ",", "noerror", "=", "0", ")", ":", "# call _expand1 for each entry in comma-separated list", "wordlist", "=", "instring", ".", "split", "(", "\",\"", ")", "outlist", "=", "[", "]", "for", "word", "in", "wordlist", ":", "outli...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
_expand1
Expand a string with embedded IRAF variables (IRAF virtual filename).
lib/stsci/tools/fileutil.py
def _expand1(instring, noerror): """Expand a string with embedded IRAF variables (IRAF virtual filename).""" # first expand names in parentheses # note this works on nested names too, expanding from the # inside out (just like IRAF) mm = __re_var_paren.search(instring) while mm is not None: ...
def _expand1(instring, noerror): """Expand a string with embedded IRAF variables (IRAF virtual filename).""" # first expand names in parentheses # note this works on nested names too, expanding from the # inside out (just like IRAF) mm = __re_var_paren.search(instring) while mm is not None: ...
[ "Expand", "a", "string", "with", "embedded", "IRAF", "variables", "(", "IRAF", "virtual", "filename", ")", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1499-L1535
[ "def", "_expand1", "(", "instring", ",", "noerror", ")", ":", "# first expand names in parentheses", "# note this works on nested names too, expanding from the", "# inside out (just like IRAF)", "mm", "=", "__re_var_paren", ".", "search", "(", "instring", ")", "while", "mm", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
legal_date
Check if this is a legal date in the Julian calendar
convertdate/julian.py
def legal_date(year, month, day): '''Check if this is a legal date in the Julian calendar''' daysinmonth = month_length(year, month) if not (0 < day <= daysinmonth): raise ValueError("Month {} doesn't have a day {}".format(month, day)) return True
def legal_date(year, month, day): '''Check if this is a legal date in the Julian calendar''' daysinmonth = month_length(year, month) if not (0 < day <= daysinmonth): raise ValueError("Month {} doesn't have a day {}".format(month, day)) return True
[ "Check", "if", "this", "is", "a", "legal", "date", "in", "the", "Julian", "calendar" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L42-L49
[ "def", "legal_date", "(", "year", ",", "month", ",", "day", ")", ":", "daysinmonth", "=", "month_length", "(", "year", ",", "month", ")", "if", "not", "(", "0", "<", "day", "<=", "daysinmonth", ")", ":", "raise", "ValueError", "(", "\"Month {} doesn't ha...
e920f168a87f99183b0aa7290d6c3af222582d43
train
from_jd
Calculate Julian calendar date from Julian day
convertdate/julian.py
def from_jd(jd): '''Calculate Julian calendar date from Julian day''' jd += 0.5 z = trunc(jd) a = z b = a + 1524 c = trunc((b - 122.1) / 365.25) d = trunc(365.25 * c) e = trunc((b - d) / 30.6001) if trunc(e < 14): month = e - 1 else: month = e - 13 if trun...
def from_jd(jd): '''Calculate Julian calendar date from Julian day''' jd += 0.5 z = trunc(jd) a = z b = a + 1524 c = trunc((b - 122.1) / 365.25) d = trunc(365.25 * c) e = trunc((b - d) / 30.6001) if trunc(e < 14): month = e - 1 else: month = e - 13 if trun...
[ "Calculate", "Julian", "calendar", "date", "from", "Julian", "day" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L52-L76
[ "def", "from_jd", "(", "jd", ")", ":", "jd", "+=", "0.5", "z", "=", "trunc", "(", "jd", ")", "a", "=", "z", "b", "=", "a", "+", "1524", "c", "=", "trunc", "(", "(", "b", "-", "122.1", ")", "/", "365.25", ")", "d", "=", "trunc", "(", "365....
e920f168a87f99183b0aa7290d6c3af222582d43
train
to_jd
Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)
convertdate/julian.py
def to_jd(year, month, day): '''Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)''' legal_date(year, month, day) # Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61 if month <= 2: year -= 1 month += 12 return (trunc((365.25 * (year + 471...
def to_jd(year, month, day): '''Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)''' legal_date(year, month, day) # Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61 if month <= 2: year -= 1 month += 12 return (trunc((365.25 * (year + 471...
[ "Convert", "to", "Julian", "day", "using", "astronomical", "years", "(", "0", "=", "1", "BC", "-", "1", "=", "2", "BC", ")" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L79-L90
[ "def", "to_jd", "(", "year", ",", "month", ",", "day", ")", ":", "legal_date", "(", "year", ",", "month", ",", "day", ")", "# Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61", "if", "month", "<=", "2", ":", "year", "-=", "1", "month", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
delay_1
Test for delay of start of new year and to avoid
convertdate/hebrew.py
def delay_1(year): '''Test for delay of start of new year and to avoid''' # Sunday, Wednesday, and Friday as start of the new year. months = trunc(((235 * year) - 234) / 19) parts = 12084 + (13753 * months) day = trunc((months * 29) + parts / 25920) if ((3 * (day + 1)) % 7) < 3: day += ...
def delay_1(year): '''Test for delay of start of new year and to avoid''' # Sunday, Wednesday, and Friday as start of the new year. months = trunc(((235 * year) - 234) / 19) parts = 12084 + (13753 * months) day = trunc((months * 29) + parts / 25920) if ((3 * (day + 1)) % 7) < 3: day += ...
[ "Test", "for", "delay", "of", "start", "of", "new", "year", "and", "to", "avoid" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L46-L56
[ "def", "delay_1", "(", "year", ")", ":", "# Sunday, Wednesday, and Friday as start of the new year.", "months", "=", "trunc", "(", "(", "(", "235", "*", "year", ")", "-", "234", ")", "/", "19", ")", "parts", "=", "12084", "+", "(", "13753", "*", "months", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
delay_2
Check for delay in start of new year due to length of adjacent years
convertdate/hebrew.py
def delay_2(year): '''Check for delay in start of new year due to length of adjacent years''' last = delay_1(year - 1) present = delay_1(year) next_ = delay_1(year + 1) if next_ - present == 356: return 2 elif present - last == 382: return 1 else: return 0
def delay_2(year): '''Check for delay in start of new year due to length of adjacent years''' last = delay_1(year - 1) present = delay_1(year) next_ = delay_1(year + 1) if next_ - present == 356: return 2 elif present - last == 382: return 1 else: return 0
[ "Check", "for", "delay", "in", "start", "of", "new", "year", "due", "to", "length", "of", "adjacent", "years" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L59-L71
[ "def", "delay_2", "(", "year", ")", ":", "last", "=", "delay_1", "(", "year", "-", "1", ")", "present", "=", "delay_1", "(", "year", ")", "next_", "=", "delay_1", "(", "year", "+", "1", ")", "if", "next_", "-", "present", "==", "356", ":", "retur...
e920f168a87f99183b0aa7290d6c3af222582d43
train
month_days
How many days are in a given month of a given year
convertdate/hebrew.py
def month_days(year, month): '''How many days are in a given month of a given year''' if month > 13: raise ValueError("Incorrect month index") # First of all, dispose of fixed-length 29 day months if month in (IYYAR, TAMMUZ, ELUL, TEVETH, VEADAR): return 29 # If it's not a leap yea...
def month_days(year, month): '''How many days are in a given month of a given year''' if month > 13: raise ValueError("Incorrect month index") # First of all, dispose of fixed-length 29 day months if month in (IYYAR, TAMMUZ, ELUL, TEVETH, VEADAR): return 29 # If it's not a leap yea...
[ "How", "many", "days", "are", "in", "a", "given", "month", "of", "a", "given", "year" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L79-L101
[ "def", "month_days", "(", "year", ",", "month", ")", ":", "if", "month", ">", "13", ":", "raise", "ValueError", "(", "\"Incorrect month index\"", ")", "# First of all, dispose of fixed-length 29 day months", "if", "month", "in", "(", "IYYAR", ",", "TAMMUZ", ",", ...
e920f168a87f99183b0aa7290d6c3af222582d43
train
byteswap
Input GEIS files "input" will be read and converted to a new GEIS file whose byte-order has been swapped from its original state. Parameters ---------- input - str Full filename with path of input GEIS image header file output - str Full filename with path of output GEIS image head...
lib/stsci/tools/swapgeis.py
def byteswap(input,output=None,clobber=True): """Input GEIS files "input" will be read and converted to a new GEIS file whose byte-order has been swapped from its original state. Parameters ---------- input - str Full filename with path of input GEIS image header file output - str ...
def byteswap(input,output=None,clobber=True): """Input GEIS files "input" will be read and converted to a new GEIS file whose byte-order has been swapped from its original state. Parameters ---------- input - str Full filename with path of input GEIS image header file output - str ...
[ "Input", "GEIS", "files", "input", "will", "be", "read", "and", "converted", "to", "a", "new", "GEIS", "file", "whose", "byte", "-", "order", "has", "been", "swapped", "from", "its", "original", "state", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/swapgeis.py#L92-L515
[ "def", "byteswap", "(", "input", ",", "output", "=", "None", ",", "clobber", "=", "True", ")", ":", "global", "dat", "cardLen", "=", "fits", ".", "Card", ".", "length", "# input file(s) must be of the form *.??h and *.??d", "if", "input", "[", "-", "1", "]",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
Accelerometer.start
Initialises the device if required then enters a read loop taking data from the provider and passing it to the handler. It will continue until either breakRead is true or the duration (if provided) has passed. :return:
backend/src/recorder/common/accelerometer.py
def start(self, measurementId, durationInSeconds=None): """ Initialises the device if required then enters a read loop taking data from the provider and passing it to the handler. It will continue until either breakRead is true or the duration (if provided) has passed. :return: ...
def start(self, measurementId, durationInSeconds=None): """ Initialises the device if required then enters a read loop taking data from the provider and passing it to the handler. It will continue until either breakRead is true or the duration (if provided) has passed. :return: ...
[ "Initialises", "the", "device", "if", "required", "then", "enters", "a", "read", "loop", "taking", "data", "from", "the", "provider", "and", "passing", "it", "to", "the", "handler", ".", "It", "will", "continue", "until", "either", "breakRead", "is", "true",...
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/accelerometer.py#L66-L115
[ "def", "start", "(", "self", ",", "measurementId", ",", "durationInSeconds", "=", "None", ")", ":", "logger", ".", "info", "(", "\">> measurement \"", "+", "measurementId", "+", "(", "(", "\" for \"", "+", "str", "(", "durationInSeconds", ")", ")", "if", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
Target.get
Yields the analysed wav data. :param targetId: :return:
backend/src/analyser/resources/target.py
def get(self, targetId): """ Yields the analysed wav data. :param targetId: :return: """ result = self._targetController.analyse(targetId) if result: if len(result) == 2: if result[1] == 404: return result ...
def get(self, targetId): """ Yields the analysed wav data. :param targetId: :return: """ result = self._targetController.analyse(targetId) if result: if len(result) == 2: if result[1] == 404: return result ...
[ "Yields", "the", "analysed", "wav", "data", ".", ":", "param", "targetId", ":", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/target.py#L13-L29
[ "def", "get", "(", "self", ",", "targetId", ")", ":", "result", "=", "self", ".", "_targetController", ".", "analyse", "(", "targetId", ")", "if", "result", ":", "if", "len", "(", "result", ")", "==", "2", ":", "if", "result", "[", "1", "]", "==", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
Target.put
stores a new target. :param targetId: the target to store. :return:
backend/src/analyser/resources/target.py
def put(self, targetId): """ stores a new target. :param targetId: the target to store. :return: """ json = request.get_json() if 'hinge' in json: logger.info('Storing target ' + targetId) if self._targetController.storeFromHinge(targetId, ...
def put(self, targetId): """ stores a new target. :param targetId: the target to store. :return: """ json = request.get_json() if 'hinge' in json: logger.info('Storing target ' + targetId) if self._targetController.storeFromHinge(targetId, ...
[ "stores", "a", "new", "target", ".", ":", "param", "targetId", ":", "the", "target", "to", "store", ".", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/target.py#L31-L46
[ "def", "put", "(", "self", ",", "targetId", ")", ":", "json", "=", "request", ".", "get_json", "(", ")", "if", "'hinge'", "in", "json", ":", "logger", ".", "info", "(", "'Storing target '", "+", "targetId", ")", "if", "self", ".", "_targetController", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
to_datetime
Return a datetime for the input floating point Julian Day Count
convertdate/julianday.py
def to_datetime(jdc): '''Return a datetime for the input floating point Julian Day Count''' year, month, day = gregorian.from_jd(jdc) # in jdc: 0.0 = noon, 0.5 = midnight # the 0.5 changes it to 0.0 = midnight, 0.5 = noon frac = (jdc + 0.5) % 1 hours = int(24 * frac) mfrac = frac * 24 - h...
def to_datetime(jdc): '''Return a datetime for the input floating point Julian Day Count''' year, month, day = gregorian.from_jd(jdc) # in jdc: 0.0 = noon, 0.5 = midnight # the 0.5 changes it to 0.0 = midnight, 0.5 = noon frac = (jdc + 0.5) % 1 hours = int(24 * frac) mfrac = frac * 24 - h...
[ "Return", "a", "datetime", "for", "the", "input", "floating", "point", "Julian", "Day", "Count" ]
fitnr/convertdate
python
https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julianday.py#L16-L37
[ "def", "to_datetime", "(", "jdc", ")", ":", "year", ",", "month", ",", "day", "=", "gregorian", ".", "from_jd", "(", "jdc", ")", "# in jdc: 0.0 = noon, 0.5 = midnight", "# the 0.5 changes it to 0.0 = midnight, 0.5 = noon", "frac", "=", "(", "jdc", "+", "0.5", ")",...
e920f168a87f99183b0aa7290d6c3af222582d43
train
dict_from_qs
Slightly introverted parser for lists of dot-notation nested fields i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}}
expander/parse_qs.py
def dict_from_qs(qs): ''' Slightly introverted parser for lists of dot-notation nested fields i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}} ''' entries = qs.split(',') if qs.strip() else [] entries = [entry.strip() for entry in entries] def _dict_from_qs(line, d): ...
def dict_from_qs(qs): ''' Slightly introverted parser for lists of dot-notation nested fields i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}} ''' entries = qs.split(',') if qs.strip() else [] entries = [entry.strip() for entry in entries] def _dict_from_qs(line, d): ...
[ "Slightly", "introverted", "parser", "for", "lists", "of", "dot", "-", "notation", "nested", "fields", "i", ".", "e", ".", "period", ".", "di", "period", ".", "fhr", "=", ">", "{", "period", ":", "{", "di", ":", "{}", "fhr", ":", "{}", "}}" ]
silverlogic/djangorestframework-expander
python
https://github.com/silverlogic/djangorestframework-expander/blob/b1cf60c7076169cbd6ad65350841c86080564f97/expander/parse_qs.py#L5-L26
[ "def", "dict_from_qs", "(", "qs", ")", ":", "entries", "=", "qs", ".", "split", "(", "','", ")", "if", "qs", ".", "strip", "(", ")", "else", "[", "]", "entries", "=", "[", "entry", ".", "strip", "(", ")", "for", "entry", "in", "entries", "]", "...
b1cf60c7076169cbd6ad65350841c86080564f97
train
qs_from_dict
Same as dict_from_qs, but in reverse i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr"
expander/parse_qs.py
def qs_from_dict(qsdict, prefix=""): ''' Same as dict_from_qs, but in reverse i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr" ''' prefix = prefix + '.' if prefix else "" def descend(qsd): for key, val in sorted(qsd.items()): if val: yield qs_...
def qs_from_dict(qsdict, prefix=""): ''' Same as dict_from_qs, but in reverse i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr" ''' prefix = prefix + '.' if prefix else "" def descend(qsd): for key, val in sorted(qsd.items()): if val: yield qs_...
[ "Same", "as", "dict_from_qs", "but", "in", "reverse", "i", ".", "e", ".", "{", "period", ":", "{", "di", ":", "{}", "fhr", ":", "{}", "}}", "=", ">", "period", ".", "di", "period", ".", "fhr" ]
silverlogic/djangorestframework-expander
python
https://github.com/silverlogic/djangorestframework-expander/blob/b1cf60c7076169cbd6ad65350841c86080564f97/expander/parse_qs.py#L29-L41
[ "def", "qs_from_dict", "(", "qsdict", ",", "prefix", "=", "\"\"", ")", ":", "prefix", "=", "prefix", "+", "'.'", "if", "prefix", "else", "\"\"", "def", "descend", "(", "qsd", ")", ":", "for", "key", ",", "val", "in", "sorted", "(", "qsd", ".", "ite...
b1cf60c7076169cbd6ad65350841c86080564f97
train
dbcon
Set up connection before executing function, commit and close connection afterwards. Unless a connection already has been created.
tmpo/__init__.py
def dbcon(func): """Set up connection before executing function, commit and close connection afterwards. Unless a connection already has been created.""" @wraps(func) def wrapper(*args, **kwargs): self = args[0] if self.dbcon is None: # set up connection self.dbco...
def dbcon(func): """Set up connection before executing function, commit and close connection afterwards. Unless a connection already has been created.""" @wraps(func) def wrapper(*args, **kwargs): self = args[0] if self.dbcon is None: # set up connection self.dbco...
[ "Set", "up", "connection", "before", "executing", "function", "commit", "and", "close", "connection", "afterwards", ".", "Unless", "a", "connection", "already", "has", "been", "created", "." ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L142-L175
[ "def", "dbcon", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "if", "self", ".", "dbcon", "is", "None", ":", "# set up connection"...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.add
Add new sensor to the database Parameters ---------- sid : str SensorId token : str
tmpo/__init__.py
def add(self, sid, token): """ Add new sensor to the database Parameters ---------- sid : str SensorId token : str """ try: self.dbcur.execute(SQL_SENSOR_INS, (sid, token)) except sqlite3.IntegrityError: # sensor entry exi...
def add(self, sid, token): """ Add new sensor to the database Parameters ---------- sid : str SensorId token : str """ try: self.dbcur.execute(SQL_SENSOR_INS, (sid, token)) except sqlite3.IntegrityError: # sensor entry exi...
[ "Add", "new", "sensor", "to", "the", "database" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L213-L226
[ "def", "add", "(", "self", ",", "sid", ",", "token", ")", ":", "try", ":", "self", ".", "dbcur", ".", "execute", "(", "SQL_SENSOR_INS", ",", "(", "sid", ",", "token", ")", ")", "except", "sqlite3", ".", "IntegrityError", ":", "# sensor entry exists", "...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.remove
Remove sensor from the database Parameters ---------- sid : str SensorID
tmpo/__init__.py
def remove(self, sid): """ Remove sensor from the database Parameters ---------- sid : str SensorID """ self.dbcur.execute(SQL_SENSOR_DEL, (sid,)) self.dbcur.execute(SQL_TMPO_DEL, (sid,))
def remove(self, sid): """ Remove sensor from the database Parameters ---------- sid : str SensorID """ self.dbcur.execute(SQL_SENSOR_DEL, (sid,)) self.dbcur.execute(SQL_TMPO_DEL, (sid,))
[ "Remove", "sensor", "from", "the", "database" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L229-L239
[ "def", "remove", "(", "self", ",", "sid", ")", ":", "self", ".", "dbcur", ".", "execute", "(", "SQL_SENSOR_DEL", ",", "(", "sid", ",", ")", ")", "self", ".", "dbcur", ".", "execute", "(", "SQL_TMPO_DEL", ",", "(", "sid", ",", ")", ")" ]
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.sync
Synchronise data Parameters ---------- sids : list of str SensorIDs to sync Optional, leave empty to sync everything
tmpo/__init__.py
def sync(self, *sids): """ Synchronise data Parameters ---------- sids : list of str SensorIDs to sync Optional, leave empty to sync everything """ if sids == (): sids = [sid for (sid,) in self.dbcur.execute(SQL_SENSOR_ALL)] ...
def sync(self, *sids): """ Synchronise data Parameters ---------- sids : list of str SensorIDs to sync Optional, leave empty to sync everything """ if sids == (): sids = [sid for (sid,) in self.dbcur.execute(SQL_SENSOR_ALL)] ...
[ "Synchronise", "data" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L254-L277
[ "def", "sync", "(", "self", ",", "*", "sids", ")", ":", "if", "sids", "==", "(", ")", ":", "sids", "=", "[", "sid", "for", "(", "sid", ",", ")", "in", "self", ".", "dbcur", ".", "execute", "(", "SQL_SENSOR_ALL", ")", "]", "for", "sid", "in", ...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.list
List all tmpo-blocks in the database Parameters ---------- sids : list of str SensorID's for which to list blocks Optional, leave empty to get them all Returns ------- list[list[tuple]]
tmpo/__init__.py
def list(self, *sids): """ List all tmpo-blocks in the database Parameters ---------- sids : list of str SensorID's for which to list blocks Optional, leave empty to get them all Returns ------- list[list[tuple]] """ ...
def list(self, *sids): """ List all tmpo-blocks in the database Parameters ---------- sids : list of str SensorID's for which to list blocks Optional, leave empty to get them all Returns ------- list[list[tuple]] """ ...
[ "List", "all", "tmpo", "-", "blocks", "in", "the", "database" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L280-L304
[ "def", "list", "(", "self", ",", "*", "sids", ")", ":", "if", "sids", "==", "(", ")", ":", "sids", "=", "[", "sid", "for", "(", "sid", ",", ")", "in", "self", ".", "dbcur", ".", "execute", "(", "SQL_SENSOR_ALL", ")", "]", "slist", "=", "[", "...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.series
Create data Series Parameters ---------- sid : str recycle_id : optional head : int | pandas.Timestamp, optional Start of the interval default earliest available tail : int | pandas.Timestamp, optional End of the interval d...
tmpo/__init__.py
def series(self, sid, recycle_id=None, head=None, tail=None, datetime=True): """ Create data Series Parameters ---------- sid : str recycle_id : optional head : int | pandas.Timestamp, optional Start of the interval default ...
def series(self, sid, recycle_id=None, head=None, tail=None, datetime=True): """ Create data Series Parameters ---------- sid : str recycle_id : optional head : int | pandas.Timestamp, optional Start of the interval default ...
[ "Create", "data", "Series" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L307-L357
[ "def", "series", "(", "self", ",", "sid", ",", "recycle_id", "=", "None", ",", "head", "=", "None", ",", "tail", "=", "None", ",", "datetime", "=", "True", ")", ":", "if", "head", "is", "None", ":", "head", "=", "0", "else", ":", "head", "=", "...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.dataframe
Create data frame Parameters ---------- sids : list[str] head : int | pandas.Timestamp, optional Start of the interval default earliest available tail : int | pandas.Timestamp, optional End of the interval default max epoch ...
tmpo/__init__.py
def dataframe(self, sids, head=0, tail=EPOCHS_MAX, datetime=True): """ Create data frame Parameters ---------- sids : list[str] head : int | pandas.Timestamp, optional Start of the interval default earliest available tail : int | pandas.Ti...
def dataframe(self, sids, head=0, tail=EPOCHS_MAX, datetime=True): """ Create data frame Parameters ---------- sids : list[str] head : int | pandas.Timestamp, optional Start of the interval default earliest available tail : int | pandas.Ti...
[ "Create", "data", "frame" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L360-L396
[ "def", "dataframe", "(", "self", ",", "sids", ",", "head", "=", "0", ",", "tail", "=", "EPOCHS_MAX", ",", "datetime", "=", "True", ")", ":", "if", "head", "is", "None", ":", "head", "=", "0", "else", ":", "head", "=", "self", ".", "_2epochs", "("...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.first_timestamp
Get the first available timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp Returns ------- pd.Timestamp | int
tmpo/__init__.py
def first_timestamp(self, sid, epoch=False): """ Get the first available timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp ...
def first_timestamp(self, sid, epoch=False): """ Get the first available timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp ...
[ "Get", "the", "first", "available", "timestamp", "for", "a", "sensor" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L399-L424
[ "def", "first_timestamp", "(", "self", ",", "sid", ",", "epoch", "=", "False", ")", ":", "first_block", "=", "self", ".", "dbcur", ".", "execute", "(", "SQL_TMPO_FIRST", ",", "(", "sid", ",", ")", ")", ".", "fetchone", "(", ")", "if", "first_block", ...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.last_timestamp
Get the theoretical last timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp Returns ------- pd.Timestamp | int
tmpo/__init__.py
def last_timestamp(self, sid, epoch=False): """ Get the theoretical last timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp ...
def last_timestamp(self, sid, epoch=False): """ Get the theoretical last timestamp for a sensor Parameters ---------- sid : str SensorID epoch : bool default False If True return as epoch If False return as pd.Timestamp ...
[ "Get", "the", "theoretical", "last", "timestamp", "for", "a", "sensor" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L426-L444
[ "def", "last_timestamp", "(", "self", ",", "sid", ",", "epoch", "=", "False", ")", ":", "timestamp", ",", "value", "=", "self", ".", "last_datapoint", "(", "sid", ",", "epoch", ")", "return", "timestamp" ]
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session.last_datapoint
Parameters ---------- sid : str SensorId epoch : bool default False If True return as epoch If False return as pd.Timestamp Returns ------- pd.Timestamp | int, float
tmpo/__init__.py
def last_datapoint(self, sid, epoch=False): """ Parameters ---------- sid : str SensorId epoch : bool default False If True return as epoch If False return as pd.Timestamp Returns ------- pd.Timestamp | int,...
def last_datapoint(self, sid, epoch=False): """ Parameters ---------- sid : str SensorId epoch : bool default False If True return as epoch If False return as pd.Timestamp Returns ------- pd.Timestamp | int,...
[ "Parameters", "----------", "sid", ":", "str", "SensorId", "epoch", ":", "bool", "default", "False", "If", "True", "return", "as", "epoch", "If", "False", "return", "as", "pd", ".", "Timestamp" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L446-L472
[ "def", "last_datapoint", "(", "self", ",", "sid", ",", "epoch", "=", "False", ")", ":", "block", "=", "self", ".", "_last_block", "(", "sid", ")", "if", "block", "is", "None", ":", "return", "None", ",", "None", "header", "=", "block", "[", "'h'", ...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
Session._npdelta
Numpy: Modifying Array Values http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html
tmpo/__init__.py
def _npdelta(self, a, delta): """Numpy: Modifying Array Values http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html""" for x in np.nditer(a, op_flags=["readwrite"]): delta += x x[...] = delta return a
def _npdelta(self, a, delta): """Numpy: Modifying Array Values http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html""" for x in np.nditer(a, op_flags=["readwrite"]): delta += x x[...] = delta return a
[ "Numpy", ":", "Modifying", "Array", "Values", "http", ":", "//", "docs", ".", "scipy", ".", "org", "/", "doc", "/", "numpy", "/", "reference", "/", "arrays", ".", "nditer", ".", "html" ]
flukso/tmpo-py
python
https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L522-L528
[ "def", "_npdelta", "(", "self", ",", "a", ",", "delta", ")", ":", "for", "x", "in", "np", ".", "nditer", "(", "a", ",", "op_flags", "=", "[", "\"readwrite\"", "]", ")", ":", "delta", "+=", "x", "x", "[", "...", "]", "=", "delta", "return", "a" ...
3c99e3d123bc985a6fba2558922b29430d2a0a94
train
sigStrToKwArgsDict
Take a check function signature (string), and parse it to get a dict of the keyword args and their values.
lib/stsci/tools/vtor_checks.py
def sigStrToKwArgsDict(checkFuncSig): """ Take a check function signature (string), and parse it to get a dict of the keyword args and their values. """ p1 = checkFuncSig.find('(') p2 = checkFuncSig.rfind(')') assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig argParts ...
def sigStrToKwArgsDict(checkFuncSig): """ Take a check function signature (string), and parse it to get a dict of the keyword args and their values. """ p1 = checkFuncSig.find('(') p2 = checkFuncSig.rfind(')') assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig argParts ...
[ "Take", "a", "check", "function", "signature", "(", "string", ")", "and", "parse", "it", "to", "get", "a", "dict", "of", "the", "keyword", "args", "and", "their", "values", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L18-L40
[ "def", "sigStrToKwArgsDict", "(", "checkFuncSig", ")", ":", "p1", "=", "checkFuncSig", ".", "find", "(", "'('", ")", "p2", "=", "checkFuncSig", ".", "rfind", "(", "')'", ")", "assert", "p1", ">", "0", "and", "p2", ">", "0", "and", "p2", ">", "p1", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
separateKeywords
Look through the keywords passed and separate the special ones we have added from the legal/standard ones. Return both sets as two dicts (in a tuple), as (standardKws, ourKws)
lib/stsci/tools/vtor_checks.py
def separateKeywords(kwArgsDict): """ Look through the keywords passed and separate the special ones we have added from the legal/standard ones. Return both sets as two dicts (in a tuple), as (standardKws, ourKws) """ standardKws = {} ourKws = {} for k in kwArgsDict: if k in STA...
def separateKeywords(kwArgsDict): """ Look through the keywords passed and separate the special ones we have added from the legal/standard ones. Return both sets as two dicts (in a tuple), as (standardKws, ourKws) """ standardKws = {} ourKws = {} for k in kwArgsDict: if k in STA...
[ "Look", "through", "the", "keywords", "passed", "and", "separate", "the", "special", "ones", "we", "have", "added", "from", "the", "legal", "/", "standard", "ones", ".", "Return", "both", "sets", "as", "two", "dicts", "(", "in", "a", "tuple", ")", "as", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L43-L54
[ "def", "separateKeywords", "(", "kwArgsDict", ")", ":", "standardKws", "=", "{", "}", "ourKws", "=", "{", "}", "for", "k", "in", "kwArgsDict", ":", "if", "k", "in", "STANDARD_KEYS", ":", "standardKws", "[", "k", "]", "=", "kwArgsDict", "[", "k", "]", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
addKwdArgsToSig
Alter the passed function signature string to add the given kewords
lib/stsci/tools/vtor_checks.py
def addKwdArgsToSig(sigStr, kwArgsDict): """ Alter the passed function signature string to add the given kewords """ retval = sigStr if len(kwArgsDict) > 0: retval = retval.strip(' ,)') # open up the r.h.s. for more args for k in kwArgsDict: if retval[-1] != '(': retval += ", " ...
def addKwdArgsToSig(sigStr, kwArgsDict): """ Alter the passed function signature string to add the given kewords """ retval = sigStr if len(kwArgsDict) > 0: retval = retval.strip(' ,)') # open up the r.h.s. for more args for k in kwArgsDict: if retval[-1] != '(': retval += ", " ...
[ "Alter", "the", "passed", "function", "signature", "string", "to", "add", "the", "given", "kewords" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L57-L67
[ "def", "addKwdArgsToSig", "(", "sigStr", ",", "kwArgsDict", ")", ":", "retval", "=", "sigStr", "if", "len", "(", "kwArgsDict", ")", ">", "0", ":", "retval", "=", "retval", ".", "strip", "(", "' ,)'", ")", "# open up the r.h.s. for more args", "for", "k", "...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
_gauss_funct
Defines the gaussian function to be used as the model.
lib/stsci/tools/gfit.py
def _gauss_funct(p, fjac=None, x=None, y=None, err=None, weights=None): """ Defines the gaussian function to be used as the model. """ if p[2] != 0.0: Z = (x - p[1]) / p[2] model = p[0] * np.e ** (-Z ** 2 / 2.0) else: model = np.zeros(np.size(x)) statu...
def _gauss_funct(p, fjac=None, x=None, y=None, err=None, weights=None): """ Defines the gaussian function to be used as the model. """ if p[2] != 0.0: Z = (x - p[1]) / p[2] model = p[0] * np.e ** (-Z ** 2 / 2.0) else: model = np.zeros(np.size(x)) statu...
[ "Defines", "the", "gaussian", "function", "to", "be", "used", "as", "the", "model", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/gfit.py#L27-L51
[ "def", "_gauss_funct", "(", "p", ",", "fjac", "=", "None", ",", "x", "=", "None", ",", "y", "=", "None", ",", "err", "=", "None", ",", "weights", "=", "None", ")", ":", "if", "p", "[", "2", "]", "!=", "0.0", ":", "Z", "=", "(", "x", "-", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
gfit1d
Return the gaussian fit as an object. Parameters ---------- y: 1D Numpy array The data to be fitted x: 1D Numpy array (optional) The x values of the y array. x and y must have the same shape. err: 1D Numpy array (optional) 1D array with measurement errors, must b...
lib/stsci/tools/gfit.py
def gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None, maxiter=200, quiet=0): """ Return the gaussian fit as an object. Parameters ---------- y: 1D Numpy array The data to be fitted x: 1D Numpy array (optional) The x values of the y array. x and y m...
def gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None, maxiter=200, quiet=0): """ Return the gaussian fit as an object. Parameters ---------- y: 1D Numpy array The data to be fitted x: 1D Numpy array (optional) The x values of the y array. x and y m...
[ "Return", "the", "gaussian", "fit", "as", "an", "object", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/gfit.py#L54-L133
[ "def", "gfit1d", "(", "y", ",", "x", "=", "None", ",", "err", "=", "None", ",", "weights", "=", "None", ",", "par", "=", "None", ",", "parinfo", "=", "None", ",", "maxiter", "=", "200", ",", "quiet", "=", "0", ")", ":", "y", "=", "y", ".", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
HashableFileQuerySet.filter
filter lets django managers use `objects.filter` on a hashable object.
estimators/models/base.py
def filter(self, *args, **kwargs): """filter lets django managers use `objects.filter` on a hashable object.""" obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] = self.model._compute_hash(obj) return super().filter(*args, **kwargs)
def filter(self, *args, **kwargs): """filter lets django managers use `objects.filter` on a hashable object.""" obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] = self.model._compute_hash(obj) return super().filter(*args, **kwargs)
[ "filter", "lets", "django", "managers", "use", "objects", ".", "filter", "on", "a", "hashable", "object", "." ]
fridiculous/django-estimators
python
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L23-L28
[ "def", "filter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "kwargs", ".", "pop", "(", "self", ".", "object_property_name", ",", "None", ")", "if", "obj", "is", "not", "None", ":", "kwargs", "[", "'object_hash'", ...
5dd72694dab6725335214543a59104c4de504037
train
HashableFileQuerySet._extract_model_params
this method allows django managers use `objects.get_or_create` and `objects.update_or_create` on a hashable object.
estimators/models/base.py
def _extract_model_params(self, defaults, **kwargs): """this method allows django managers use `objects.get_or_create` and `objects.update_or_create` on a hashable object. """ obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] ...
def _extract_model_params(self, defaults, **kwargs): """this method allows django managers use `objects.get_or_create` and `objects.update_or_create` on a hashable object. """ obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] ...
[ "this", "method", "allows", "django", "managers", "use", "objects", ".", "get_or_create", "and", "objects", ".", "update_or_create", "on", "a", "hashable", "object", "." ]
fridiculous/django-estimators
python
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L30-L41
[ "def", "_extract_model_params", "(", "self", ",", "defaults", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "kwargs", ".", "pop", "(", "self", ".", "object_property_name", ",", "None", ")", "if", "obj", "is", "not", "None", ":", "kwargs", "[", "'objec...
5dd72694dab6725335214543a59104c4de504037
train
HashableFileMixin.persist
a private method that persists an estimator object to the filesystem
estimators/models/base.py
def persist(self): """a private method that persists an estimator object to the filesystem""" if self.object_hash: data = dill.dumps(self.object_property) f = ContentFile(data) self.object_file.save(self.object_hash, f, save=False) f.close() se...
def persist(self): """a private method that persists an estimator object to the filesystem""" if self.object_hash: data = dill.dumps(self.object_property) f = ContentFile(data) self.object_file.save(self.object_hash, f, save=False) f.close() se...
[ "a", "private", "method", "that", "persists", "an", "estimator", "object", "to", "the", "filesystem" ]
fridiculous/django-estimators
python
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L99-L107
[ "def", "persist", "(", "self", ")", ":", "if", "self", ".", "object_hash", ":", "data", "=", "dill", ".", "dumps", "(", "self", ".", "object_property", ")", "f", "=", "ContentFile", "(", "data", ")", "self", ".", "object_file", ".", "save", "(", "sel...
5dd72694dab6725335214543a59104c4de504037
train
HashableFileMixin.load
a private method that loads an estimator object from the filesystem
estimators/models/base.py
def load(self): """a private method that loads an estimator object from the filesystem""" if self.is_file_persisted: self.object_file.open() temp = dill.loads(self.object_file.read()) self.set_object(temp) self.object_file.close()
def load(self): """a private method that loads an estimator object from the filesystem""" if self.is_file_persisted: self.object_file.open() temp = dill.loads(self.object_file.read()) self.set_object(temp) self.object_file.close()
[ "a", "private", "method", "that", "loads", "an", "estimator", "object", "from", "the", "filesystem" ]
fridiculous/django-estimators
python
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L109-L115
[ "def", "load", "(", "self", ")", ":", "if", "self", ".", "is_file_persisted", ":", "self", ".", "object_file", ".", "open", "(", ")", "temp", "=", "dill", ".", "loads", "(", "self", ".", "object_file", ".", "read", "(", ")", ")", "self", ".", "set_...
5dd72694dab6725335214543a59104c4de504037
train
HashableFileMixin.create_from_file
Return an Estimator object given the path of the file, relative to the MEDIA_ROOT
estimators/models/base.py
def create_from_file(cls, filename): """Return an Estimator object given the path of the file, relative to the MEDIA_ROOT""" obj = cls() obj.object_file = filename obj.load() return obj
def create_from_file(cls, filename): """Return an Estimator object given the path of the file, relative to the MEDIA_ROOT""" obj = cls() obj.object_file = filename obj.load() return obj
[ "Return", "an", "Estimator", "object", "given", "the", "path", "of", "the", "file", "relative", "to", "the", "MEDIA_ROOT" ]
fridiculous/django-estimators
python
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L128-L133
[ "def", "create_from_file", "(", "cls", ",", "filename", ")", ":", "obj", "=", "cls", "(", ")", "obj", ".", "object_file", "=", "filename", "obj", ".", "load", "(", ")", "return", "obj" ]
5dd72694dab6725335214543a59104c4de504037
train
getAppDir
Return our application dir. Create it if it doesn't exist.
lib/stsci/tools/cfgpars.py
def getAppDir(): """ Return our application dir. Create it if it doesn't exist. """ # Be sure the resource dir exists theDir = os.path.expanduser('~/.')+APP_NAME.lower() if not os.path.exists(theDir): try: os.mkdir(theDir) except OSError: print('Could not create ...
def getAppDir(): """ Return our application dir. Create it if it doesn't exist. """ # Be sure the resource dir exists theDir = os.path.expanduser('~/.')+APP_NAME.lower() if not os.path.exists(theDir): try: os.mkdir(theDir) except OSError: print('Could not create ...
[ "Return", "our", "application", "dir", ".", "Create", "it", "if", "it", "doesn", "t", "exist", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L32-L42
[ "def", "getAppDir", "(", ")", ":", "# Be sure the resource dir exists", "theDir", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.'", ")", "+", "APP_NAME", ".", "lower", "(", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "theDir", ")", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getObjectFromTaskArg
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...
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L45-L84
[ "def", "getObjectFromTaskArg", "(", "theTask", ",", "strict", ",", "setAllToDefaults", ")", ":", "# Already in the form we need (instance of us or of subclass)", "if", "isinstance", "(", "theTask", ",", "ConfigObjPars", ")", ":", "if", "setAllToDefaults", ":", "raise", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getEmbeddedKeyVal
Read a config file and pull out the value of a given keyword.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Read", "a", "config", "file", "and", "pull", "out", "the", "value", "of", "a", "given", "keyword", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L87-L120
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findCfgFileForPkg
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...
lib/stsci/tools/cfgpars.py
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): """ 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 '....
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L123-L193
[ "def", "findCfgFileForPkg", "(", "pkgName", ",", "theExt", ",", "pkgObj", "=", "None", ",", "taskName", "=", "None", ")", ":", "# arg check", "ext", "=", "theExt", "if", "ext", "[", "0", "]", "!=", "'.'", ":", "ext", "=", "'.'", "+", "theExt", "# Do ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findAllCfgTasksUnderDir
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 }
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L196-L204
[ "def", "findAllCfgTasksUnderDir", "(", "aDir", ")", ":", "retval", "=", "{", "}", "for", "f", "in", "irafutils", ".", "rglob", "(", "aDir", ",", "'*.cfg'", ")", ":", "retval", "[", "f", "]", "=", "getEmbeddedKeyVal", "(", "f", ",", "TASK_NAME_KEY", ","...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getCfgFilesInDirForTask
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 ...
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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",...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L207-L229
[ "def", "getCfgFilesInDirForTask", "(", "aDir", ",", "aTask", ",", "recurse", "=", "False", ")", ":", "if", "recurse", ":", "flist", "=", "irafutils", ".", "rglob", "(", "aDir", ",", "'*.cfg'", ")", "else", ":", "flist", "=", "glob", ".", "glob", "(", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getParsObjForPyPkg
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 ~/...
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Locate", "the", "appropriate", "ConfigObjPars", "(", "or", "subclass", ")", "within", "the", "given", "package", ".", "NOTE", "this", "begins", "the", "same", "way", "as", "getUsrCfgFilesForPyPkg", "()", ".", "Look", "for", ".", "cfg", "file", "matches", "i...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L232-L279
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
getUsrCfgFilesForPyPkg
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.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L282-L291
[ "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", "=...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
checkSetReadOnly
See if we have write-privileges to this file. If we do, and we are not supposed to, then fix that case.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "See", "if", "we", "have", "write", "-", "privileges", "to", "this", "file", ".", "If", "we", "do", "and", "we", "are", "not", "supposed", "to", "then", "fix", "that", "case", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L294-L301
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
flattenDictTree
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.
lib/stsci/tools/cfgpars.py
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): """ 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 = {} ...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L304-L331
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
countKey
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.
lib/stsci/tools/cfgpars.py
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): """ 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,...
[ "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", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L334-L349
[ "def", "countKey", "(", "theDict", ",", "name", ")", ":", "retval", "=", "0", "for", "key", "in", "theDict", ":", "val", "=", "theDict", "[", "key", "]", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "retval", "+=", "countKey", "(", "val",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findFirstPar
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.
lib/stsci/tools/cfgpars.py
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): """ 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] # ...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L352-L374
[ "def", "findFirstPar", "(", "theDict", ",", "name", ",", "_depth", "=", "0", ")", ":", "for", "key", "in", "theDict", ":", "val", "=", "theDict", "[", "key", "]", "# print _depth*' ', key, str(val)[:40]", "if", "isinstance", "(", "val", ",", "dict", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findScopedPar
Find the given par. Return tuple: (its own (sub-)dict, its value).
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Find", "the", "given", "par", ".", "Return", "tuple", ":", "(", "its", "own", "(", "sub", "-", ")", "dict", "its", "value", ")", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L377-L383
[ "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", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
setPar
Sets a par's value without having to give its scope/section.
lib/stsci/tools/cfgpars.py
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): """ 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
[ "Sets", "a", "par", "s", "value", "without", "having", "to", "give", "its", "scope", "/", "section", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L386-L390
[ "def", "setPar", "(", "theDict", ",", "name", ",", "value", ")", ":", "section", ",", "previousVal", "=", "findFirstPar", "(", "theDict", ",", "name", ")", "# \"section\" is the actual object, not a copy", "section", "[", "name", "]", "=", "value" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
mergeConfigObj
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...
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L393-L407
[ "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", ",",...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
findTheLost
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.
lib/stsci/tools/cfgpars.py
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): """ 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 (...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1244-L1281
[ "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", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
isHiddenName
Return True if this string name denotes a hidden par or section
lib/stsci/tools/cfgpars.py
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): """ 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
[ "Return", "True", "if", "this", "string", "name", "denotes", "a", "hidden", "par", "or", "section" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1284-L1290
[ "def", "isHiddenName", "(", "astr", ")", ":", "if", "astr", "is", "not", "None", "and", "len", "(", "astr", ")", ">", "2", "and", "astr", ".", "startswith", "(", "'_'", ")", "and", "astr", ".", "endswith", "(", "'_'", ")", ":", "return", "True", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
flattened2str
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 ...
lib/stsci/tools/cfgpars.py
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): """ 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 ...
[ "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...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1293-L1341
[ "def", "flattened2str", "(", "flattened", ",", "missing", "=", "False", ",", "extra", "=", "False", ")", ":", "if", "flattened", "is", "None", "or", "len", "(", "flattened", ")", "<", "1", ":", "return", "''", "retval", "=", "''", "for", "sections", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getDefaultSaveFilename
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.
lib/stsci/tools/cfgpars.py
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): """ 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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L628-L636
[ "def", "getDefaultSaveFilename", "(", "self", ",", "stub", "=", "False", ")", ":", "if", "stub", ":", "return", "self", ".", "_rcDir", "+", "os", ".", "sep", "+", "self", ".", "__taskName", "+", "'_stub.cfg'", "else", ":", "return", "self", ".", "_rcDi...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.syncParamList
Set or reset the internal param list from the dict's contents.
lib/stsci/tools/cfgpars.py
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): """ 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. ...
[ "Set", "or", "reset", "the", "internal", "param", "list", "from", "the", "dict", "s", "contents", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L638-L669
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getDefaultParList
Return a par list just like ours, but with all default values.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Return", "a", "par", "list", "just", "like", "ours", "but", "with", "all", "default", "values", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L680-L694
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.setParam
Find the ConfigObj entry. Update the __paramList.
lib/stsci/tools/cfgpars.py
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): """ 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] ...
[ "Find", "the", "ConfigObj", "entry", ".", "Update", "the", "__paramList", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L723-L750
[ "def", "setParam", "(", "self", ",", "name", ",", "val", ",", "scope", "=", "''", ",", "check", "=", "1", ",", "idxHint", "=", "None", ")", ":", "theDict", ",", "oldVal", "=", "findScopedPar", "(", "self", ",", "scope", ",", "name", ")", "# Set the...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.saveParList
Write parameter data to filename (string or filehandle)
lib/stsci/tools/cfgpars.py
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): """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 ...
[ "Write", "parameter", "data", "to", "filename", "(", "string", "or", "filehandle", ")" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L752-L790
[ "def", "saveParList", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "'filename'", "in", "kw", ":", "filename", "=", "kw", "[", "'filename'", "]", "if", "not", "filename", ":", "filename", "=", "self", ".", "getFilename", "(", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.run
This may be overridden by a subclass.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "This", "may", "be", "overridden", "by", "a", "subclass", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L792-L803
[ "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", "(", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.triggerLogicToStr
Print all the trigger logic to a string and return it.
lib/stsci/tools/cfgpars.py
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): """ 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) ...
[ "Print", "all", "the", "trigger", "logic", "to", "a", "string", "and", "return", "it", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L805-L815
[ "def", "triggerLogicToStr", "(", "self", ")", ":", "try", ":", "import", "json", "except", "ImportError", ":", "return", "\"Cannot dump triggers/dependencies/executes (need json)\"", "retval", "=", "\"TRIGGERS:\\n\"", "+", "json", ".", "dumps", "(", "self", ".", "_a...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars._findAssociatedConfigSpecFile
Given a config file, find its associated config-spec file, and return the full pathname of the file.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Given", "a", "config", "file", "find", "its", "associated", "config", "-", "spec", "file", "and", "return", "the", "full", "pathname", "of", "the", "file", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L828-L860
[ "def", "_findAssociatedConfigSpecFile", "(", "self", ",", "cfgFileName", ")", ":", "# Handle simplest 2 cases first: co-located or local .cfgspc file", "retval", "=", "\".\"", "+", "os", ".", "sep", "+", "self", ".", "__taskName", "+", "\".cfgspc\"", "if", "os", ".", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars._getParamsFromConfigDict
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.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L863-L1084
[ "def", "_getParamsFromConfigDict", "(", "self", ",", "cfgObj", ",", "scopePrefix", "=", "''", ",", "initialPass", "=", "False", ",", "dumpCfgspcTo", "=", "None", ")", ":", "# init", "retval", "=", "[", "]", "if", "initialPass", "and", "len", "(", "scopePre...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getTriggerStrings
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.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1087-L1093
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getExecuteStrings
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.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1104-L1110
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getPosArgs
Return a list, in order, of any parameters marked with "pos=N" in the .cfgspc file.
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "Return", "a", "list", "in", "order", "of", "any", "parameters", "marked", "with", "pos", "=", "N", "in", "the", ".", "cfgspc", "file", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1113-L1124
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.getKwdArgs
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).
lib/stsci/tools/cfgpars.py
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): """ 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...
[ "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...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1127-L1155
[ "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 ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.tryValue
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)...
lib/stsci/tools/cfgpars.py
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=''): """ 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...
[ "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", ...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1169-L1203
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ConfigObjPars.listTheExtras
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.
lib/stsci/tools/cfgpars.py
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): """ 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 ...
[ "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",...
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1206-L1238
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
ReloadMeasurement.get
Reloads the measurements from the backing store. :return: 200 if success.
backend/src/analyser/resources/measurements.py
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): """ 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") ...
[ "Reloads", "the", "measurements", "from", "the", "backing", "store", ".", ":", "return", ":", "200", "if", "success", "." ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurements.py#L29-L39
[ "def", "get", "(", "self", ")", ":", "try", ":", "self", ".", "_measurementController", ".", "reloadCompletedMeasurements", "(", ")", "return", "None", ",", "200", "except", ":", "logger", ".", "exception", "(", "\"Failed to reload measurements\"", ")", "return"...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
CSVLogger.handle
Writes each sample to a csv file. :param data: the samples. :return:
backend/src/core/handler.py
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): """ 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 ...
[ "Writes", "each", "sample", "to", "a", "csv", "file", ".", ":", "param", "data", ":", "the", "samples", ".", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L93-L111
[ "def", "handle", "(", "self", ",", "data", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Handling \"", "+", "str", "(", "len", "(", "data", ")", ")", "+", "\" data items\"", ")", "for", "datum", "in", "data", ":", "if", "isinstance", "(", ...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
HttpPoster.start
Posts to the target to tell it a named measurement is starting. :param measurementId:
backend/src/core/handler.py
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): """ 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)
[ "Posts", "to", "the", "target", "to", "tell", "it", "a", "named", "measurement", "is", "starting", ".", ":", "param", "measurementId", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L188-L194
[ "def", "start", "(", "self", ",", "measurementId", ")", ":", "self", ".", "sendURL", "=", "self", ".", "rootURL", "+", "measurementId", "+", "'/'", "+", "self", ".", "deviceName", "self", ".", "startResponseCode", "=", "self", ".", "_doPut", "(", "self",...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
HttpPoster.handle
puts the data in the target. :param data: the data to post. :return:
backend/src/core/handler.py
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): """ puts the data in the target. :param data: the data to post. :return: """ self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data))
[ "puts", "the", "data", "in", "the", "target", ".", ":", "param", "data", ":", "the", "data", "to", "post", ".", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L204-L210
[ "def", "handle", "(", "self", ",", "data", ")", ":", "self", ".", "dataResponseCode", ".", "append", "(", "self", ".", "_doPut", "(", "self", ".", "sendURL", "+", "'/data'", ",", "data", "=", "data", ")", ")" ]
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
HttpPoster.stop
informs the target the named measurement has completed :param measurementId: the measurement that has completed. :return:
backend/src/core/handler.py
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): """ 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...
[ "informs", "the", "target", "the", "named", "measurement", "has", "completed", ":", "param", "measurementId", ":", "the", "measurement", "that", "has", "completed", ".", ":", "return", ":" ]
3ll3d00d/vibe
python
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L212-L222
[ "def", "stop", "(", "self", ",", "measurementId", ",", "failureReason", "=", "None", ")", ":", "if", "failureReason", "is", "None", ":", "self", ".", "endResponseCode", "=", "self", ".", "_doPut", "(", "self", ".", "sendURL", "+", "\"/complete\"", ")", "...
124b029f13ac746723e92cb47e9cb56edd2e54b5
train
dottedQuadToNum
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...
lib/stsci/tools/validate.py
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): """ 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...
[ "Convert", "decimal", "dotted", "quad", "string", "to", "long", "integer" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L274-L301
[ "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", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
numToDottedQuad
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...
lib/stsci/tools/validate.py
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): """ 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...
[ "Convert", "long", "int", "to", "dotted", "quad", "string" ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L304-L336
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
_is_num_param
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...
lib/stsci/tools/validate.py
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): """ 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...
[ "Return", "numbers", "from", "inputs", "or", "raise", "VdtParamError", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L740-L768
[ "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...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_integer
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('...
lib/stsci/tools/validate.py
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): """ 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...
[ "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", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L777-L831
[ "def", "is_integer", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_val", ",", "max_val", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ")", "if", "not", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_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...
lib/stsci/tools/validate.py
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): """ 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...
[ "A", "check", "that", "tests", "that", "a", "given", "value", "is", "a", "float", "(", "an", "integer", "will", "be", "accepted", ")", "and", "optionally", "-", "that", "it", "is", "between", "bounds", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L834-L884
[ "def", "is_float", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_val", ",", "max_val", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ",", "to_float", "=", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_boolean
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') ...
lib/stsci/tools/validate.py
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): """ 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 >...
[ "Check", "if", "the", "value", "represents", "a", "boolean", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L893-L951
[ "def", "is_boolean", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "try", ":", "return", "bool_dict", "[", "value", ".", "lower", "(", ")", "]", "except", "KeyError", ":", "raise", "VdtTypeError", "(", "value", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_ip_addr
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...
lib/stsci/tools/validate.py
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): """ 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 ')...
[ "Check", "that", "the", "supplied", "value", "is", "an", "Internet", "Protocol", "address", "v", ".", "4", "represented", "by", "a", "dotted", "-", "quad", "string", "i", ".", "e", ".", "1", ".", "2", ".", "3", ".", "4", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L954-L989
[ "def", "is_ip_addr", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "string_types", ")", ":", "raise", "VdtTypeError", "(", "value", ")", "value", "=", "value", ".", "strip", "(", ")", "try", ":", "dottedQuadToNum", "(", "value", ...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_list
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...
lib/stsci/tools/validate.py
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): """ 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', []) [] >>> ...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "values", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L992-L1035
[ "def", "is_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "(", "min_len", ",", "max_len", ")", "=", "_is_num_param", "(", "(", "'min'", ",", "'max'", ")", ",", "(", "min", ",", "max", ")", ")", "if", "isinstance"...
9a022503ad24ca54ce83331482dfa3ff6de9f403
train
is_int_list
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...
lib/stsci/tools/validate.py
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): """ 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(...
[ "Check", "that", "the", "value", "is", "a", "list", "of", "integers", "." ]
spacetelescope/stsci.tools
python
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1110-L1131
[ "def", "is_int_list", "(", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "return", "[", "is_integer", "(", "mem", ")", "for", "mem", "in", "is_list", "(", "value", ",", "min", ",", "max", ")", "]" ]
9a022503ad24ca54ce83331482dfa3ff6de9f403