repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.run | def run(self, *args, **kw):
""" This may be overridden by a subclass. """
if self._runFunc is not None:
# remove the two args sent by EditParDialog which we do not use
if 'mode' in kw: kw.pop('mode')
if '_save' in kw: kw.pop('_save')
return self._runFunc(s... | python | def run(self, *args, **kw):
""" This may be overridden by a subclass. """
if self._runFunc is not None:
# remove the two args sent by EditParDialog which we do not use
if 'mode' in kw: kw.pop('mode')
if '_save' in kw: kw.pop('_save')
return self._runFunc(s... | [
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"_runFunc",
"is",
"not",
"None",
":",
"# remove the two args sent by EditParDialog which we do not use",
"if",
"'mode'",
"in",
"kw",
":",
"kw",
".",
"pop",
"(",
... | This may be overridden by a subclass. | [
"This",
"may",
"be",
"overridden",
"by",
"a",
"subclass",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L792-L803 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.triggerLogicToStr | def triggerLogicToStr(self):
""" Print all the trigger logic to a string and return it. """
try:
import json
except ImportError:
return "Cannot dump triggers/dependencies/executes (need json)"
retval = "TRIGGERS:\n"+json.dumps(self._allTriggers, indent=3)
... | python | def triggerLogicToStr(self):
""" Print all the trigger logic to a string and return it. """
try:
import json
except ImportError:
return "Cannot dump triggers/dependencies/executes (need json)"
retval = "TRIGGERS:\n"+json.dumps(self._allTriggers, indent=3)
... | [
"def",
"triggerLogicToStr",
"(",
"self",
")",
":",
"try",
":",
"import",
"json",
"except",
"ImportError",
":",
"return",
"\"Cannot dump triggers/dependencies/executes (need json)\"",
"retval",
"=",
"\"TRIGGERS:\\n\"",
"+",
"json",
".",
"dumps",
"(",
"self",
".",
"_a... | Print all the trigger logic to a string and return it. | [
"Print",
"all",
"the",
"trigger",
"logic",
"to",
"a",
"string",
"and",
"return",
"it",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L805-L815 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars._findAssociatedConfigSpecFile | def _findAssociatedConfigSpecFile(self, cfgFileName):
""" Given a config file, find its associated config-spec file, and
return the full pathname of the file. """
# Handle simplest 2 cases first: co-located or local .cfgspc file
retval = "."+os.sep+self.__taskName+".cfgspc"
if o... | python | def _findAssociatedConfigSpecFile(self, cfgFileName):
""" Given a config file, find its associated config-spec file, and
return the full pathname of the file. """
# Handle simplest 2 cases first: co-located or local .cfgspc file
retval = "."+os.sep+self.__taskName+".cfgspc"
if o... | [
"def",
"_findAssociatedConfigSpecFile",
"(",
"self",
",",
"cfgFileName",
")",
":",
"# Handle simplest 2 cases first: co-located or local .cfgspc file",
"retval",
"=",
"\".\"",
"+",
"os",
".",
"sep",
"+",
"self",
".",
"__taskName",
"+",
"\".cfgspc\"",
"if",
"os",
".",
... | Given a config file, find its associated config-spec file, and
return the full pathname of the file. | [
"Given",
"a",
"config",
"file",
"find",
"its",
"associated",
"config",
"-",
"spec",
"file",
"and",
"return",
"the",
"full",
"pathname",
"of",
"the",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L828-L860 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars._getParamsFromConfigDict | def _getParamsFromConfigDict(self, cfgObj, scopePrefix='',
initialPass=False, dumpCfgspcTo=None):
""" Walk the given ConfigObj dict pulling out IRAF-like parameters into
a list. Since this operates on a dict this can be called recursively.
This is also our chance... | python | def _getParamsFromConfigDict(self, cfgObj, scopePrefix='',
initialPass=False, dumpCfgspcTo=None):
""" Walk the given ConfigObj dict pulling out IRAF-like parameters into
a list. Since this operates on a dict this can be called recursively.
This is also our chance... | [
"def",
"_getParamsFromConfigDict",
"(",
"self",
",",
"cfgObj",
",",
"scopePrefix",
"=",
"''",
",",
"initialPass",
"=",
"False",
",",
"dumpCfgspcTo",
"=",
"None",
")",
":",
"# init",
"retval",
"=",
"[",
"]",
"if",
"initialPass",
"and",
"len",
"(",
"scopePre... | Walk the given ConfigObj dict pulling out IRAF-like parameters into
a list. Since this operates on a dict this can be called recursively.
This is also our chance to find and pull out triggers and such
dependencies. | [
"Walk",
"the",
"given",
"ConfigObj",
"dict",
"pulling",
"out",
"IRAF",
"-",
"like",
"parameters",
"into",
"a",
"list",
".",
"Since",
"this",
"operates",
"on",
"a",
"dict",
"this",
"can",
"be",
"called",
"recursively",
".",
"This",
"is",
"also",
"our",
"c... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L863-L1084 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getTriggerStrings | def getTriggerStrings(self, parScope, parName):
""" For a given item (scope + name), return all strings (in a tuple)
that it is meant to trigger, if any exist. Returns None is none. """
# The data structure of _allTriggers was chosen for how easily/quickly
# this particular access can b... | python | def getTriggerStrings(self, parScope, parName):
""" For a given item (scope + name), return all strings (in a tuple)
that it is meant to trigger, if any exist. Returns None is none. """
# The data structure of _allTriggers was chosen for how easily/quickly
# this particular access can b... | [
"def",
"getTriggerStrings",
"(",
"self",
",",
"parScope",
",",
"parName",
")",
":",
"# The data structure of _allTriggers was chosen for how easily/quickly",
"# this particular access can be made here.",
"fullName",
"=",
"parScope",
"+",
"'.'",
"+",
"parName",
"return",
"self... | For a given item (scope + name), return all strings (in a tuple)
that it is meant to trigger, if any exist. Returns None is none. | [
"For",
"a",
"given",
"item",
"(",
"scope",
"+",
"name",
")",
"return",
"all",
"strings",
"(",
"in",
"a",
"tuple",
")",
"that",
"it",
"is",
"meant",
"to",
"trigger",
"if",
"any",
"exist",
".",
"Returns",
"None",
"is",
"none",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1087-L1093 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getExecuteStrings | def getExecuteStrings(self, parScope, parName):
""" For a given item (scope + name), return all strings (in a tuple)
that it is meant to execute, if any exist. Returns None is none. """
# The data structure of _allExecutes was chosen for how easily/quickly
# this particular access can b... | python | def getExecuteStrings(self, parScope, parName):
""" For a given item (scope + name), return all strings (in a tuple)
that it is meant to execute, if any exist. Returns None is none. """
# The data structure of _allExecutes was chosen for how easily/quickly
# this particular access can b... | [
"def",
"getExecuteStrings",
"(",
"self",
",",
"parScope",
",",
"parName",
")",
":",
"# The data structure of _allExecutes was chosen for how easily/quickly",
"# this particular access can be made here.",
"fullName",
"=",
"parScope",
"+",
"'.'",
"+",
"parName",
"return",
"self... | For a given item (scope + name), return all strings (in a tuple)
that it is meant to execute, if any exist. Returns None is none. | [
"For",
"a",
"given",
"item",
"(",
"scope",
"+",
"name",
")",
"return",
"all",
"strings",
"(",
"in",
"a",
"tuple",
")",
"that",
"it",
"is",
"meant",
"to",
"execute",
"if",
"any",
"exist",
".",
"Returns",
"None",
"is",
"none",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1104-L1110 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getPosArgs | def getPosArgs(self):
""" Return a list, in order, of any parameters marked with "pos=N" in
the .cfgspc file. """
if len(self._posArgs) < 1: return []
# The first item in the tuple is the index, so we now sort by it
self._posArgs.sort()
# Build a return list
r... | python | def getPosArgs(self):
""" Return a list, in order, of any parameters marked with "pos=N" in
the .cfgspc file. """
if len(self._posArgs) < 1: return []
# The first item in the tuple is the index, so we now sort by it
self._posArgs.sort()
# Build a return list
r... | [
"def",
"getPosArgs",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_posArgs",
")",
"<",
"1",
":",
"return",
"[",
"]",
"# The first item in the tuple is the index, so we now sort by it",
"self",
".",
"_posArgs",
".",
"sort",
"(",
")",
"# Build a return l... | Return a list, in order, of any parameters marked with "pos=N" in
the .cfgspc file. | [
"Return",
"a",
"list",
"in",
"order",
"of",
"any",
"parameters",
"marked",
"with",
"pos",
"=",
"N",
"in",
"the",
".",
"cfgspc",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1113-L1124 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getKwdArgs | def getKwdArgs(self, flatten = False):
""" Return a dict of all normal dict parameters - that is, all
parameters NOT marked with "pos=N" in the .cfgspc file. This will
also exclude all hidden parameters (metadata, rules, etc). """
# Start with a full deep-copy. What complicate... | python | def getKwdArgs(self, flatten = False):
""" Return a dict of all normal dict parameters - that is, all
parameters NOT marked with "pos=N" in the .cfgspc file. This will
also exclude all hidden parameters (metadata, rules, etc). """
# Start with a full deep-copy. What complicate... | [
"def",
"getKwdArgs",
"(",
"self",
",",
"flatten",
"=",
"False",
")",
":",
"# Start with a full deep-copy. What complicates this method is the",
"# idea of sub-sections. This dict can have dicts as values, and so on.",
"dcopy",
"=",
"self",
".",
"dict",
"(",
")",
"# ConfigObj ... | Return a dict of all normal dict parameters - that is, all
parameters NOT marked with "pos=N" in the .cfgspc file. This will
also exclude all hidden parameters (metadata, rules, etc). | [
"Return",
"a",
"dict",
"of",
"all",
"normal",
"dict",
"parameters",
"-",
"that",
"is",
"all",
"parameters",
"NOT",
"marked",
"with",
"pos",
"=",
"N",
"in",
"the",
".",
"cfgspc",
"file",
".",
"This",
"will",
"also",
"exclude",
"all",
"hidden",
"parameters... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1127-L1155 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.tryValue | def tryValue(self, name, val, scope=''):
""" For the given item name (and scope), we are being asked to try
the given value to see if it would pass validation. We are not
to set it, but just try it. We return a tuple:
If it fails, we return: (False, the last known valid va... | python | def tryValue(self, name, val, scope=''):
""" For the given item name (and scope), we are being asked to try
the given value to see if it would pass validation. We are not
to set it, but just try it. We return a tuple:
If it fails, we return: (False, the last known valid va... | [
"def",
"tryValue",
"(",
"self",
",",
"name",
",",
"val",
",",
"scope",
"=",
"''",
")",
":",
"# SIMILARITY BETWEEN THIS AND setParam() SHOULD BE CONSOLIDATED!",
"# Set the value, even if invalid. It needs to be set before",
"# the validation step (next).",
"theDict",
",",
"oldV... | For the given item name (and scope), we are being asked to try
the given value to see if it would pass validation. We are not
to set it, but just try it. We return a tuple:
If it fails, we return: (False, the last known valid value).
On success, we return: (True, None)... | [
"For",
"the",
"given",
"item",
"name",
"(",
"and",
"scope",
")",
"we",
"are",
"being",
"asked",
"to",
"try",
"the",
"given",
"value",
"to",
"see",
"if",
"it",
"would",
"pass",
"validation",
".",
"We",
"are",
"not",
"to",
"set",
"it",
"but",
"just",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1169-L1203 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.listTheExtras | def listTheExtras(self, deleteAlso):
""" Use ConfigObj's get_extra_values() call to find any extra/unknown
parameters we may have loaded. Return a string similar to findTheLost.
If deleteAlso is True, this will also delete any extra/unknown items.
"""
# get list of extras
... | python | def listTheExtras(self, deleteAlso):
""" Use ConfigObj's get_extra_values() call to find any extra/unknown
parameters we may have loaded. Return a string similar to findTheLost.
If deleteAlso is True, this will also delete any extra/unknown items.
"""
# get list of extras
... | [
"def",
"listTheExtras",
"(",
"self",
",",
"deleteAlso",
")",
":",
"# get list of extras",
"extras",
"=",
"configobj",
".",
"get_extra_values",
"(",
"self",
")",
"# extras is in format: [(sections, key), (sections, key), ]",
"# but we need: [(sections, key, result), ...] - set all... | Use ConfigObj's get_extra_values() call to find any extra/unknown
parameters we may have loaded. Return a string similar to findTheLost.
If deleteAlso is True, this will also delete any extra/unknown items. | [
"Use",
"ConfigObj",
"s",
"get_extra_values",
"()",
"call",
"to",
"find",
"any",
"extra",
"/",
"unknown",
"parameters",
"we",
"may",
"have",
"loaded",
".",
"Return",
"a",
"string",
"similar",
"to",
"findTheLost",
".",
"If",
"deleteAlso",
"is",
"True",
"this",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1206-L1238 | train |
3ll3d00d/vibe | backend/src/analyser/resources/measurements.py | ReloadMeasurement.get | def get(self):
"""
Reloads the measurements from the backing store.
:return: 200 if success.
"""
try:
self._measurementController.reloadCompletedMeasurements()
return None, 200
except:
logger.exception("Failed to reload measurements")
... | python | def get(self):
"""
Reloads the measurements from the backing store.
:return: 200 if success.
"""
try:
self._measurementController.reloadCompletedMeasurements()
return None, 200
except:
logger.exception("Failed to reload measurements")
... | [
"def",
"get",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_measurementController",
".",
"reloadCompletedMeasurements",
"(",
")",
"return",
"None",
",",
"200",
"except",
":",
"logger",
".",
"exception",
"(",
"\"Failed to reload measurements\"",
")",
"return"... | Reloads the measurements from the backing store.
:return: 200 if success. | [
"Reloads",
"the",
"measurements",
"from",
"the",
"backing",
"store",
".",
":",
"return",
":",
"200",
"if",
"success",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurements.py#L29-L39 | train |
3ll3d00d/vibe | backend/src/core/handler.py | CSVLogger.handle | def handle(self, data):
"""
Writes each sample to a csv file.
:param data: the samples.
:return:
"""
self.logger.debug("Handling " + str(len(data)) + " data items")
for datum in data:
if isinstance(datum, dict):
# these have to wrapped ... | python | def handle(self, data):
"""
Writes each sample to a csv file.
:param data: the samples.
:return:
"""
self.logger.debug("Handling " + str(len(data)) + " data items")
for datum in data:
if isinstance(datum, dict):
# these have to wrapped ... | [
"def",
"handle",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Handling \"",
"+",
"str",
"(",
"len",
"(",
"data",
")",
")",
"+",
"\" data items\"",
")",
"for",
"datum",
"in",
"data",
":",
"if",
"isinstance",
"(",
... | Writes each sample to a csv file.
:param data: the samples.
:return: | [
"Writes",
"each",
"sample",
"to",
"a",
"csv",
"file",
".",
":",
"param",
"data",
":",
"the",
"samples",
".",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L93-L111 | train |
3ll3d00d/vibe | backend/src/core/handler.py | HttpPoster.start | def start(self, measurementId):
"""
Posts to the target to tell it a named measurement is starting.
:param measurementId:
"""
self.sendURL = self.rootURL + measurementId + '/' + self.deviceName
self.startResponseCode = self._doPut(self.sendURL) | python | def start(self, measurementId):
"""
Posts to the target to tell it a named measurement is starting.
:param measurementId:
"""
self.sendURL = self.rootURL + measurementId + '/' + self.deviceName
self.startResponseCode = self._doPut(self.sendURL) | [
"def",
"start",
"(",
"self",
",",
"measurementId",
")",
":",
"self",
".",
"sendURL",
"=",
"self",
".",
"rootURL",
"+",
"measurementId",
"+",
"'/'",
"+",
"self",
".",
"deviceName",
"self",
".",
"startResponseCode",
"=",
"self",
".",
"_doPut",
"(",
"self",... | Posts to the target to tell it a named measurement is starting.
:param measurementId: | [
"Posts",
"to",
"the",
"target",
"to",
"tell",
"it",
"a",
"named",
"measurement",
"is",
"starting",
".",
":",
"param",
"measurementId",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L188-L194 | train |
3ll3d00d/vibe | backend/src/core/handler.py | HttpPoster.handle | def handle(self, data):
"""
puts the data in the target.
:param data: the data to post.
:return:
"""
self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data)) | python | def handle(self, data):
"""
puts the data in the target.
:param data: the data to post.
:return:
"""
self.dataResponseCode.append(self._doPut(self.sendURL + '/data', data=data)) | [
"def",
"handle",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"dataResponseCode",
".",
"append",
"(",
"self",
".",
"_doPut",
"(",
"self",
".",
"sendURL",
"+",
"'/data'",
",",
"data",
"=",
"data",
")",
")"
] | puts the data in the target.
:param data: the data to post.
:return: | [
"puts",
"the",
"data",
"in",
"the",
"target",
".",
":",
"param",
"data",
":",
"the",
"data",
"to",
"post",
".",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L204-L210 | train |
3ll3d00d/vibe | backend/src/core/handler.py | HttpPoster.stop | def stop(self, measurementId, failureReason=None):
"""
informs the target the named measurement has completed
:param measurementId: the measurement that has completed.
:return:
"""
if failureReason is None:
self.endResponseCode = self._doPut(self.sendURL + "/c... | python | def stop(self, measurementId, failureReason=None):
"""
informs the target the named measurement has completed
:param measurementId: the measurement that has completed.
:return:
"""
if failureReason is None:
self.endResponseCode = self._doPut(self.sendURL + "/c... | [
"def",
"stop",
"(",
"self",
",",
"measurementId",
",",
"failureReason",
"=",
"None",
")",
":",
"if",
"failureReason",
"is",
"None",
":",
"self",
".",
"endResponseCode",
"=",
"self",
".",
"_doPut",
"(",
"self",
".",
"sendURL",
"+",
"\"/complete\"",
")",
"... | informs the target the named measurement has completed
:param measurementId: the measurement that has completed.
:return: | [
"informs",
"the",
"target",
"the",
"named",
"measurement",
"has",
"completed",
":",
"param",
"measurementId",
":",
"the",
"measurement",
"that",
"has",
"completed",
".",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/handler.py#L212-L222 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | dottedQuadToNum | def dottedQuadToNum(ip):
"""
Convert decimal dotted quad string to long integer
>>> int(dottedQuadToNum('1 '))
1
>>> int(dottedQuadToNum(' 1.2'))
16777218
>>> int(dottedQuadToNum(' 1.2.3 '))
16908291
>>> int(dottedQuadToNum('1.2.3.4'))
16909060
>>> dottedQuadToNum('255.255.2... | python | def dottedQuadToNum(ip):
"""
Convert decimal dotted quad string to long integer
>>> int(dottedQuadToNum('1 '))
1
>>> int(dottedQuadToNum(' 1.2'))
16777218
>>> int(dottedQuadToNum(' 1.2.3 '))
16908291
>>> int(dottedQuadToNum('1.2.3.4'))
16909060
>>> dottedQuadToNum('255.255.2... | [
"def",
"dottedQuadToNum",
"(",
"ip",
")",
":",
"# import here to avoid it when ip_addr values are not used",
"import",
"socket",
",",
"struct",
"try",
":",
"return",
"struct",
".",
"unpack",
"(",
"'!L'",
",",
"socket",
".",
"inet_aton",
"(",
"ip",
".",
"strip",
... | Convert decimal dotted quad string to long integer
>>> int(dottedQuadToNum('1 '))
1
>>> int(dottedQuadToNum(' 1.2'))
16777218
>>> int(dottedQuadToNum(' 1.2.3 '))
16908291
>>> int(dottedQuadToNum('1.2.3.4'))
16909060
>>> dottedQuadToNum('255.255.255.255')
4294967295
>>> dotte... | [
"Convert",
"decimal",
"dotted",
"quad",
"string",
"to",
"long",
"integer"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L274-L301 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | numToDottedQuad | def numToDottedQuad(num):
"""
Convert long int to dotted quad string
>>> numToDottedQuad(long(-1))
Traceback (most recent call last):
ValueError: Not a good numeric IP: -1
>>> numToDottedQuad(long(1))
'0.0.0.1'
>>> numToDottedQuad(long(16777218))
'1.0.0.2'
>>> numToDottedQuad(lo... | python | def numToDottedQuad(num):
"""
Convert long int to dotted quad string
>>> numToDottedQuad(long(-1))
Traceback (most recent call last):
ValueError: Not a good numeric IP: -1
>>> numToDottedQuad(long(1))
'0.0.0.1'
>>> numToDottedQuad(long(16777218))
'1.0.0.2'
>>> numToDottedQuad(lo... | [
"def",
"numToDottedQuad",
"(",
"num",
")",
":",
"# import here to avoid it when ip_addr values are not used",
"import",
"socket",
",",
"struct",
"# no need to intercept here, 4294967295 is fine",
"if",
"num",
">",
"4294967295",
"or",
"num",
"<",
"0",
":",
"raise",
"ValueE... | Convert long int to dotted quad string
>>> numToDottedQuad(long(-1))
Traceback (most recent call last):
ValueError: Not a good numeric IP: -1
>>> numToDottedQuad(long(1))
'0.0.0.1'
>>> numToDottedQuad(long(16777218))
'1.0.0.2'
>>> numToDottedQuad(long(16908291))
'1.2.0.3'
>>> nu... | [
"Convert",
"long",
"int",
"to",
"dotted",
"quad",
"string"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L304-L336 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | _is_num_param | def _is_num_param(names, values, to_float=False):
"""
Return numbers from inputs or raise VdtParamError.
Lets ``None`` pass through.
Pass in keyword argument ``to_float=True`` to
use float for the conversion rather than int.
>>> _is_num_param(('', ''), (0, 1.0))
[0, 1]
>>> _is_num_para... | python | def _is_num_param(names, values, to_float=False):
"""
Return numbers from inputs or raise VdtParamError.
Lets ``None`` pass through.
Pass in keyword argument ``to_float=True`` to
use float for the conversion rather than int.
>>> _is_num_param(('', ''), (0, 1.0))
[0, 1]
>>> _is_num_para... | [
"def",
"_is_num_param",
"(",
"names",
",",
"values",
",",
"to_float",
"=",
"False",
")",
":",
"fun",
"=",
"to_float",
"and",
"float",
"or",
"int",
"out_params",
"=",
"[",
"]",
"for",
"(",
"name",
",",
"val",
")",
"in",
"zip",
"(",
"names",
",",
"va... | Return numbers from inputs or raise VdtParamError.
Lets ``None`` pass through.
Pass in keyword argument ``to_float=True`` to
use float for the conversion rather than int.
>>> _is_num_param(('', ''), (0, 1.0))
[0, 1]
>>> _is_num_param(('', ''), (0, 1.0), to_float=True)
[0.0, 1.0]
>>> _i... | [
"Return",
"numbers",
"from",
"inputs",
"or",
"raise",
"VdtParamError",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L740-L768 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_integer | def is_integer(value, min=None, max=None):
"""
A check that tests that a given value is an integer (int, or long)
and optionally, between bounds. A negative value is accepted, while
a float will fail.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is r... | python | def is_integer(value, min=None, max=None):
"""
A check that tests that a given value is an integer (int, or long)
and optionally, between bounds. A negative value is accepted, while
a float will fail.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is r... | [
"def",
"is_integer",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"(",
"min_val",
",",
"max_val",
")",
"=",
"_is_num_param",
"(",
"(",
"'min'",
",",
"'max'",
")",
",",
"(",
"min",
",",
"max",
")",
")",
"if",
"not",
... | A check that tests that a given value is an integer (int, or long)
and optionally, between bounds. A negative value is accepted, while
a float will fail.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is raised.
>>> vtor = Validator()
>>> vtor.check('... | [
"A",
"check",
"that",
"tests",
"that",
"a",
"given",
"value",
"is",
"an",
"integer",
"(",
"int",
"or",
"long",
")",
"and",
"optionally",
"between",
"bounds",
".",
"A",
"negative",
"value",
"is",
"accepted",
"while",
"a",
"float",
"will",
"fail",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L777-L831 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_float | def is_float(value, min=None, max=None):
"""
A check that tests that a given value is a float
(an integer will be accepted), and optionally - that it is between bounds.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is raised.
This can accept negative... | python | def is_float(value, min=None, max=None):
"""
A check that tests that a given value is a float
(an integer will be accepted), and optionally - that it is between bounds.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is raised.
This can accept negative... | [
"def",
"is_float",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"(",
"min_val",
",",
"max_val",
")",
"=",
"_is_num_param",
"(",
"(",
"'min'",
",",
"'max'",
")",
",",
"(",
"min",
",",
"max",
")",
",",
"to_float",
"=",
... | A check that tests that a given value is a float
(an integer will be accepted), and optionally - that it is between bounds.
If the value is a string, then the conversion is done - if possible.
Otherwise a VdtError is raised.
This can accept negative values.
>>> vtor = Validator()
>>> vtor.che... | [
"A",
"check",
"that",
"tests",
"that",
"a",
"given",
"value",
"is",
"a",
"float",
"(",
"an",
"integer",
"will",
"be",
"accepted",
")",
"and",
"optionally",
"-",
"that",
"it",
"is",
"between",
"bounds",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L834-L884 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_boolean | def is_boolean(value):
"""
Check if the value represents a boolean.
>>> vtor = Validator()
>>> vtor.check('boolean', 0)
0
>>> vtor.check('boolean', False)
0
>>> vtor.check('boolean', '0')
0
>>> vtor.check('boolean', 'off')
0
>>> vtor.check('boolean', 'false')
0
>... | python | def is_boolean(value):
"""
Check if the value represents a boolean.
>>> vtor = Validator()
>>> vtor.check('boolean', 0)
0
>>> vtor.check('boolean', False)
0
>>> vtor.check('boolean', '0')
0
>>> vtor.check('boolean', 'off')
0
>>> vtor.check('boolean', 'false')
0
>... | [
"def",
"is_boolean",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"try",
":",
"return",
"bool_dict",
"[",
"value",
".",
"lower",
"(",
")",
"]",
"except",
"KeyError",
":",
"raise",
"VdtTypeError",
"(",
"value",
... | Check if the value represents a boolean.
>>> vtor = Validator()
>>> vtor.check('boolean', 0)
0
>>> vtor.check('boolean', False)
0
>>> vtor.check('boolean', '0')
0
>>> vtor.check('boolean', 'off')
0
>>> vtor.check('boolean', 'false')
0
>>> vtor.check('boolean', 'no')
... | [
"Check",
"if",
"the",
"value",
"represents",
"a",
"boolean",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L893-L951 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_ip_addr | def is_ip_addr(value):
"""
Check that the supplied value is an Internet Protocol address, v.4,
represented by a dotted-quad string, i.e. '1.2.3.4'.
>>> vtor = Validator()
>>> vtor.check('ip_addr', '1 ')
'1'
>>> vtor.check('ip_addr', ' 1.2')
'1.2'
>>> vtor.check('ip_addr', ' 1.2.3 ')... | python | def is_ip_addr(value):
"""
Check that the supplied value is an Internet Protocol address, v.4,
represented by a dotted-quad string, i.e. '1.2.3.4'.
>>> vtor = Validator()
>>> vtor.check('ip_addr', '1 ')
'1'
>>> vtor.check('ip_addr', ' 1.2')
'1.2'
>>> vtor.check('ip_addr', ' 1.2.3 ')... | [
"def",
"is_ip_addr",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"raise",
"VdtTypeError",
"(",
"value",
")",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"try",
":",
"dottedQuadToNum",
"(",
"value",
... | Check that the supplied value is an Internet Protocol address, v.4,
represented by a dotted-quad string, i.e. '1.2.3.4'.
>>> vtor = Validator()
>>> vtor.check('ip_addr', '1 ')
'1'
>>> vtor.check('ip_addr', ' 1.2')
'1.2'
>>> vtor.check('ip_addr', ' 1.2.3 ')
'1.2.3'
>>> vtor.check('ip... | [
"Check",
"that",
"the",
"supplied",
"value",
"is",
"an",
"Internet",
"Protocol",
"address",
"v",
".",
"4",
"represented",
"by",
"a",
"dotted",
"-",
"quad",
"string",
"i",
".",
"e",
".",
"1",
".",
"2",
".",
"3",
".",
"4",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L954-L989 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_list | def is_list(value, min=None, max=None):
"""
Check that the value is a list of values.
You can optionally specify the minimum and maximum number of members.
It does no check on list members.
>>> vtor = Validator()
>>> vtor.check('list', ())
[]
>>> vtor.check('list', [])
[]
>>> ... | python | def is_list(value, min=None, max=None):
"""
Check that the value is a list of values.
You can optionally specify the minimum and maximum number of members.
It does no check on list members.
>>> vtor = Validator()
>>> vtor.check('list', ())
[]
>>> vtor.check('list', [])
[]
>>> ... | [
"def",
"is_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"(",
"min_len",
",",
"max_len",
")",
"=",
"_is_num_param",
"(",
"(",
"'min'",
",",
"'max'",
")",
",",
"(",
"min",
",",
"max",
")",
")",
"if",
"isinstance"... | Check that the value is a list of values.
You can optionally specify the minimum and maximum number of members.
It does no check on list members.
>>> vtor = Validator()
>>> vtor.check('list', ())
[]
>>> vtor.check('list', [])
[]
>>> vtor.check('list', (1, 2))
[1, 2]
>>> vtor.c... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"values",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L992-L1035 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_int_list | def is_int_list(value, min=None, max=None):
"""
Check that the value is a list of integers.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an integer.
>>> vtor = Validator()
>>> vtor.check('int_list', ())
[]
>>> vtor.check(... | python | def is_int_list(value, min=None, max=None):
"""
Check that the value is a list of integers.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an integer.
>>> vtor = Validator()
>>> vtor.check('int_list', ())
[]
>>> vtor.check(... | [
"def",
"is_int_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"return",
"[",
"is_integer",
"(",
"mem",
")",
"for",
"mem",
"in",
"is_list",
"(",
"value",
",",
"min",
",",
"max",
")",
"]"
] | Check that the value is a list of integers.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an integer.
>>> vtor = Validator()
>>> vtor.check('int_list', ())
[]
>>> vtor.check('int_list', [])
[]
>>> vtor.check('int_list', (1... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"integers",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1110-L1131 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_bool_list | def is_bool_list(value, min=None, max=None):
"""
Check that the value is a list of booleans.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a boolean.
>>> vtor = Validator()
>>> vtor.check('bool_list', ())
[]
>>> vtor.check... | python | def is_bool_list(value, min=None, max=None):
"""
Check that the value is a list of booleans.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a boolean.
>>> vtor = Validator()
>>> vtor.check('bool_list', ())
[]
>>> vtor.check... | [
"def",
"is_bool_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"return",
"[",
"is_boolean",
"(",
"mem",
")",
"for",
"mem",
"in",
"is_list",
"(",
"value",
",",
"min",
",",
"max",
")",
"]"
] | Check that the value is a list of booleans.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a boolean.
>>> vtor = Validator()
>>> vtor.check('bool_list', ())
[]
>>> vtor.check('bool_list', [])
[]
>>> check_res = vtor.check('... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"booleans",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1134-L1157 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_float_list | def is_float_list(value, min=None, max=None):
"""
Check that the value is a list of floats.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a float.
>>> vtor = Validator()
>>> vtor.check('float_list', ())
[]
>>> vtor.check('... | python | def is_float_list(value, min=None, max=None):
"""
Check that the value is a list of floats.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a float.
>>> vtor = Validator()
>>> vtor.check('float_list', ())
[]
>>> vtor.check('... | [
"def",
"is_float_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"return",
"[",
"is_float",
"(",
"mem",
")",
"for",
"mem",
"in",
"is_list",
"(",
"value",
",",
"min",
",",
"max",
")",
"]"
] | Check that the value is a list of floats.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a float.
>>> vtor = Validator()
>>> vtor.check('float_list', ())
[]
>>> vtor.check('float_list', [])
[]
>>> vtor.check('float_list', (... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"floats",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1160-L1181 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_string_list | def is_string_list(value, min=None, max=None):
"""
Check that the value is a list of strings.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a string.
>>> vtor = Validator()
>>> vtor.check('string_list', ())
[]
>>> vtor.che... | python | def is_string_list(value, min=None, max=None):
"""
Check that the value is a list of strings.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a string.
>>> vtor = Validator()
>>> vtor.check('string_list', ())
[]
>>> vtor.che... | [
"def",
"is_string_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"raise",
"VdtTypeError",
"(",
"value",
")",
"return",
"[",
"is_string",
"(",
"mem",
")",... | Check that the value is a list of strings.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is a string.
>>> vtor = Validator()
>>> vtor.check('string_list', ())
[]
>>> vtor.check('string_list', [])
[]
>>> vtor.check('string_lis... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"strings",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1184-L1208 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_ip_addr_list | def is_ip_addr_list(value, min=None, max=None):
"""
Check that the value is a list of IP addresses.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an IP address.
>>> vtor = Validator()
>>> vtor.check('ip_addr_list', ())
[]
... | python | def is_ip_addr_list(value, min=None, max=None):
"""
Check that the value is a list of IP addresses.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an IP address.
>>> vtor = Validator()
>>> vtor.check('ip_addr_list', ())
[]
... | [
"def",
"is_ip_addr_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"return",
"[",
"is_ip_addr",
"(",
"mem",
")",
"for",
"mem",
"in",
"is_list",
"(",
"value",
",",
"min",
",",
"max",
")",
"]"
] | Check that the value is a list of IP addresses.
You can optionally specify the minimum and maximum number of members.
Each list member is checked that it is an IP address.
>>> vtor = Validator()
>>> vtor.check('ip_addr_list', ())
[]
>>> vtor.check('ip_addr_list', [])
[]
>>> vtor.check... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"IP",
"addresses",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1211-L1230 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | force_list | def force_list(value, min=None, max=None):
"""
Check that a value is a list, coercing strings into
a list with one member. Useful where users forget the
trailing comma that turns a single value into a list.
You can optionally specify the minimum and maximum number of members.
A minumum of great... | python | def force_list(value, min=None, max=None):
"""
Check that a value is a list, coercing strings into
a list with one member. Useful where users forget the
trailing comma that turns a single value into a list.
You can optionally specify the minimum and maximum number of members.
A minumum of great... | [
"def",
"force_list",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"value",
"=",
"[",
"value",
"]",
"return",
"is_list",
"(",
"val... | Check that a value is a list, coercing strings into
a list with one member. Useful where users forget the
trailing comma that turns a single value into a list.
You can optionally specify the minimum and maximum number of members.
A minumum of greater than one will fail if the user only supplies a
s... | [
"Check",
"that",
"a",
"value",
"is",
"a",
"list",
"coercing",
"strings",
"into",
"a",
"list",
"with",
"one",
"member",
".",
"Useful",
"where",
"users",
"forget",
"the",
"trailing",
"comma",
"that",
"turns",
"a",
"single",
"value",
"into",
"a",
"list",
".... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1233-L1253 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_mixed_list | def is_mixed_list(value, *args):
"""
Check that the value is a list.
Allow specifying the type of each member.
Work on lists of specific lengths.
You specify each member as a positional argument specifying type
Each type should be one of the following strings :
'integer', 'float', 'ip_ad... | python | def is_mixed_list(value, *args):
"""
Check that the value is a list.
Allow specifying the type of each member.
Work on lists of specific lengths.
You specify each member as a positional argument specifying type
Each type should be one of the following strings :
'integer', 'float', 'ip_ad... | [
"def",
"is_mixed_list",
"(",
"value",
",",
"*",
"args",
")",
":",
"try",
":",
"length",
"=",
"len",
"(",
"value",
")",
"except",
"TypeError",
":",
"raise",
"VdtTypeError",
"(",
"value",
")",
"if",
"length",
"<",
"len",
"(",
"args",
")",
":",
"raise",... | Check that the value is a list.
Allow specifying the type of each member.
Work on lists of specific lengths.
You specify each member as a positional argument specifying type
Each type should be one of the following strings :
'integer', 'float', 'ip_addr', 'string', 'boolean'
So you can spec... | [
"Check",
"that",
"the",
"value",
"is",
"a",
"list",
".",
"Allow",
"specifying",
"the",
"type",
"of",
"each",
"member",
".",
"Work",
"on",
"lists",
"of",
"specific",
"lengths",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1265-L1331 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | is_option | def is_option(value, *options):
"""
This check matches the value to any of a set of options.
>>> vtor = Validator()
>>> vtor.check('option("yoda", "jedi")', 'yoda')
'yoda'
>>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP
Traceback (most recent call last):
VdtValueError:... | python | def is_option(value, *options):
"""
This check matches the value to any of a set of options.
>>> vtor = Validator()
>>> vtor.check('option("yoda", "jedi")', 'yoda')
'yoda'
>>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP
Traceback (most recent call last):
VdtValueError:... | [
"def",
"is_option",
"(",
"value",
",",
"*",
"options",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"raise",
"VdtTypeError",
"(",
"value",
")",
"if",
"not",
"value",
"in",
"options",
":",
"raise",
"VdtValueError",
"("... | This check matches the value to any of a set of options.
>>> vtor = Validator()
>>> vtor.check('option("yoda", "jedi")', 'yoda')
'yoda'
>>> vtor.check('option("yoda", "jedi")', 'jed') # doctest: +SKIP
Traceback (most recent call last):
VdtValueError: the value "jed" is unacceptable.
>>> vt... | [
"This",
"check",
"matches",
"the",
"value",
"to",
"any",
"of",
"a",
"set",
"of",
"options",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L1334-L1352 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | Validator.check | def check(self, check, value, missing=False):
"""
Usage: check(check, value)
Arguments:
check: string representing check to apply (including arguments)
value: object to be checked
Returns value, converted to correct type if necessary
If the check fails, ... | python | def check(self, check, value, missing=False):
"""
Usage: check(check, value)
Arguments:
check: string representing check to apply (including arguments)
value: object to be checked
Returns value, converted to correct type if necessary
If the check fails, ... | [
"def",
"check",
"(",
"self",
",",
"check",
",",
"value",
",",
"missing",
"=",
"False",
")",
":",
"fun_name",
",",
"fun_args",
",",
"fun_kwargs",
",",
"default",
"=",
"self",
".",
"_parse_with_caching",
"(",
"check",
")",
"if",
"missing",
":",
"if",
"de... | Usage: check(check, value)
Arguments:
check: string representing check to apply (including arguments)
value: object to be checked
Returns value, converted to correct type if necessary
If the check fails, raises a ``ValidateError`` subclass.
>>> vtor = Validator... | [
"Usage",
":",
"check",
"(",
"check",
"value",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L575-L608 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | Validator._unquote | def _unquote(self, val):
"""Unquote a value if necessary."""
if (len(val) >= 2) and (val[0] in ("'", '"')) and (val[0] == val[-1]):
val = val[1:-1]
return val | python | def _unquote(self, val):
"""Unquote a value if necessary."""
if (len(val) >= 2) and (val[0] in ("'", '"')) and (val[0] == val[-1]):
val = val[1:-1]
return val | [
"def",
"_unquote",
"(",
"self",
",",
"val",
")",
":",
"if",
"(",
"len",
"(",
"val",
")",
">=",
"2",
")",
"and",
"(",
"val",
"[",
"0",
"]",
"in",
"(",
"\"'\"",
",",
"'\"'",
")",
")",
"and",
"(",
"val",
"[",
"0",
"]",
"==",
"val",
"[",
"-",... | Unquote a value if necessary. | [
"Unquote",
"a",
"value",
"if",
"necessary",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L693-L697 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | Validator._list_handle | def _list_handle(self, listmatch):
"""Take apart a ``keyword=list('val, 'val')`` type string."""
out = []
name = listmatch.group(1)
args = listmatch.group(2)
for arg in self._list_members.findall(args):
out.append(self._unquote(arg))
return name, out | python | def _list_handle(self, listmatch):
"""Take apart a ``keyword=list('val, 'val')`` type string."""
out = []
name = listmatch.group(1)
args = listmatch.group(2)
for arg in self._list_members.findall(args):
out.append(self._unquote(arg))
return name, out | [
"def",
"_list_handle",
"(",
"self",
",",
"listmatch",
")",
":",
"out",
"=",
"[",
"]",
"name",
"=",
"listmatch",
".",
"group",
"(",
"1",
")",
"args",
"=",
"listmatch",
".",
"group",
"(",
"2",
")",
"for",
"arg",
"in",
"self",
".",
"_list_members",
".... | Take apart a ``keyword=list('val, 'val')`` type string. | [
"Take",
"apart",
"a",
"keyword",
"=",
"list",
"(",
"val",
"val",
")",
"type",
"string",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L700-L707 | train |
spacetelescope/stsci.tools | lib/stsci/tools/validate.py | Validator.get_default_value | def get_default_value(self, check):
"""
Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised.
"""
fun_name, fun_args, fun_kwargs, default = self._parse... | python | def get_default_value(self, check):
"""
Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised.
"""
fun_name, fun_args, fun_kwargs, default = self._parse... | [
"def",
"get_default_value",
"(",
"self",
",",
"check",
")",
":",
"fun_name",
",",
"fun_args",
",",
"fun_kwargs",
",",
"default",
"=",
"self",
".",
"_parse_with_caching",
"(",
"check",
")",
"if",
"default",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"'Che... | Given a check, return the default value for the check
(converted to the right type).
If the check doesn't specify a default value then a
``KeyError`` will be raised. | [
"Given",
"a",
"check",
"return",
"the",
"default",
"value",
"for",
"the",
"check",
"(",
"converted",
"to",
"the",
"right",
"type",
")",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/validate.py#L723-L737 | train |
spacetelescope/stsci.tools | lib/stsci/tools/stpyfits.py | _ConstantValueImageBaseHDU.match_header | def match_header(cls, header):
"""A constant value HDU will only be recognized as such if the header
contains a valid PIXVALUE and NAXIS == 0.
"""
pixvalue = header.get('PIXVALUE')
naxis = header.get('NAXIS', 0)
return (super(_ConstantValueImageBaseHDU, cls).match_heade... | python | def match_header(cls, header):
"""A constant value HDU will only be recognized as such if the header
contains a valid PIXVALUE and NAXIS == 0.
"""
pixvalue = header.get('PIXVALUE')
naxis = header.get('NAXIS', 0)
return (super(_ConstantValueImageBaseHDU, cls).match_heade... | [
"def",
"match_header",
"(",
"cls",
",",
"header",
")",
":",
"pixvalue",
"=",
"header",
".",
"get",
"(",
"'PIXVALUE'",
")",
"naxis",
"=",
"header",
".",
"get",
"(",
"'NAXIS'",
",",
"0",
")",
"return",
"(",
"super",
"(",
"_ConstantValueImageBaseHDU",
",",
... | A constant value HDU will only be recognized as such if the header
contains a valid PIXVALUE and NAXIS == 0. | [
"A",
"constant",
"value",
"HDU",
"will",
"only",
"be",
"recognized",
"as",
"such",
"if",
"the",
"header",
"contains",
"a",
"valid",
"PIXVALUE",
"and",
"NAXIS",
"==",
"0",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/stpyfits.py#L230-L240 | train |
spacetelescope/stsci.tools | lib/stsci/tools/stpyfits.py | _ConstantValueImageBaseHDU._check_constant_value_data | def _check_constant_value_data(self, data):
"""Verify that the HDU's data is a constant value array."""
arrayval = data.flat[0]
if np.all(data == arrayval):
return arrayval
return None | python | def _check_constant_value_data(self, data):
"""Verify that the HDU's data is a constant value array."""
arrayval = data.flat[0]
if np.all(data == arrayval):
return arrayval
return None | [
"def",
"_check_constant_value_data",
"(",
"self",
",",
"data",
")",
":",
"arrayval",
"=",
"data",
".",
"flat",
"[",
"0",
"]",
"if",
"np",
".",
"all",
"(",
"data",
"==",
"arrayval",
")",
":",
"return",
"arrayval",
"return",
"None"
] | Verify that the HDU's data is a constant value array. | [
"Verify",
"that",
"the",
"HDU",
"s",
"data",
"is",
"a",
"constant",
"value",
"array",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/stpyfits.py#L307-L313 | train |
spacetelescope/stsci.tools | lib/stsci/tools/listdlg.py | ListSingleSelectDialog.get_current_index | def get_current_index(self):
""" Return currently selected index (or -1) """
# Need to convert to int; currently API returns a tuple of string
curSel = self.__lb.curselection()
if curSel and len(curSel) > 0:
return int(curSel[0])
else:
return -1 | python | def get_current_index(self):
""" Return currently selected index (or -1) """
# Need to convert to int; currently API returns a tuple of string
curSel = self.__lb.curselection()
if curSel and len(curSel) > 0:
return int(curSel[0])
else:
return -1 | [
"def",
"get_current_index",
"(",
"self",
")",
":",
"# Need to convert to int; currently API returns a tuple of string",
"curSel",
"=",
"self",
".",
"__lb",
".",
"curselection",
"(",
")",
"if",
"curSel",
"and",
"len",
"(",
"curSel",
")",
">",
"0",
":",
"return",
... | Return currently selected index (or -1) | [
"Return",
"currently",
"selected",
"index",
"(",
"or",
"-",
"1",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/listdlg.py#L40-L48 | train |
spacetelescope/stsci.tools | lib/stsci/tools/convertgeis.py | convert | def convert(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.C... | python | def convert(input):
"""Input GEIS files "input" will be read and a HDUList object will
be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF.
The user can use the writeto method to write the HDUList object to
a FITS file.
"""
global dat
cardLen = fits.C... | [
"def",
"convert",
"(",
"input",
")",
":",
"global",
"dat",
"cardLen",
"=",
"fits",
".",
"Card",
".",
"length",
"# input file(s) must be of the form *.??h and *.??d",
"if",
"input",
"[",
"-",
"1",
"]",
"!=",
"'h'",
"or",
"input",
"[",
"-",
"4",
"]",
"!=",
... | Input GEIS files "input" will be read and a HDUList object will
be returned that matches the waiver-FITS format written out by 'stwfits' in IRAF.
The user can use the writeto method to write the HDUList object to
a FITS file. | [
"Input",
"GEIS",
"files",
"input",
"will",
"be",
"read",
"and",
"a",
"HDUList",
"object",
"will",
"be",
"returned",
"that",
"matches",
"the",
"waiver",
"-",
"FITS",
"format",
"written",
"out",
"by",
"stwfits",
"in",
"IRAF",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/convertgeis.py#L102-L361 | train |
3ll3d00d/vibe | backend/src/core/BaseConfig.py | BaseConfig._loadConfig | def _loadConfig(self):
"""
loads configuration from some predictable locations.
:return: the config.
"""
configPath = path.join(self._getConfigPath(), self._name + ".yml")
if os.path.exists(configPath):
self.logger.warning("Loading config from " + configPath)
... | python | def _loadConfig(self):
"""
loads configuration from some predictable locations.
:return: the config.
"""
configPath = path.join(self._getConfigPath(), self._name + ".yml")
if os.path.exists(configPath):
self.logger.warning("Loading config from " + configPath)
... | [
"def",
"_loadConfig",
"(",
"self",
")",
":",
"configPath",
"=",
"path",
".",
"join",
"(",
"self",
".",
"_getConfigPath",
"(",
")",
",",
"self",
".",
"_name",
"+",
"\".yml\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"configPath",
")",
":",
... | loads configuration from some predictable locations.
:return: the config. | [
"loads",
"configuration",
"from",
"some",
"predictable",
"locations",
".",
":",
"return",
":",
"the",
"config",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L54-L66 | train |
3ll3d00d/vibe | backend/src/core/BaseConfig.py | BaseConfig._storeConfig | def _storeConfig(self, config, configPath):
"""
Writes the config to the configPath.
:param config a dict of config.
:param configPath the path to the file to write to, intermediate dirs will be created as necessary.
"""
self.logger.info("Writing to " + str(configPath))
... | python | def _storeConfig(self, config, configPath):
"""
Writes the config to the configPath.
:param config a dict of config.
:param configPath the path to the file to write to, intermediate dirs will be created as necessary.
"""
self.logger.info("Writing to " + str(configPath))
... | [
"def",
"_storeConfig",
"(",
"self",
",",
"config",
",",
"configPath",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Writing to \"",
"+",
"str",
"(",
"configPath",
")",
")",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"... | Writes the config to the configPath.
:param config a dict of config.
:param configPath the path to the file to write to, intermediate dirs will be created as necessary. | [
"Writes",
"the",
"config",
"to",
"the",
"configPath",
".",
":",
"param",
"config",
"a",
"dict",
"of",
"config",
".",
":",
"param",
"configPath",
"the",
"path",
"to",
"the",
"file",
"to",
"write",
"to",
"intermediate",
"dirs",
"will",
"be",
"created",
"as... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L68-L77 | train |
3ll3d00d/vibe | backend/src/core/BaseConfig.py | BaseConfig._getConfigPath | def _getConfigPath(self):
"""
Gets the currently configured config path.
:return: the path, raises ValueError if it doesn't exist.
"""
confHome = environ.get('VIBE_CONFIG_HOME')
return confHome if confHome is not None else path.join(path.expanduser("~"), '.vibe') | python | def _getConfigPath(self):
"""
Gets the currently configured config path.
:return: the path, raises ValueError if it doesn't exist.
"""
confHome = environ.get('VIBE_CONFIG_HOME')
return confHome if confHome is not None else path.join(path.expanduser("~"), '.vibe') | [
"def",
"_getConfigPath",
"(",
"self",
")",
":",
"confHome",
"=",
"environ",
".",
"get",
"(",
"'VIBE_CONFIG_HOME'",
")",
"return",
"confHome",
"if",
"confHome",
"is",
"not",
"None",
"else",
"path",
".",
"join",
"(",
"path",
".",
"expanduser",
"(",
"\"~\"",
... | Gets the currently configured config path.
:return: the path, raises ValueError if it doesn't exist. | [
"Gets",
"the",
"currently",
"configured",
"config",
"path",
".",
":",
"return",
":",
"the",
"path",
"raises",
"ValueError",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L87-L93 | train |
3ll3d00d/vibe | backend/src/core/BaseConfig.py | BaseConfig.configureLogger | def configureLogger(self):
"""
Configures the python logging system to log to a debug file and to stdout for warn and above.
:return: the base logger.
"""
baseLogLevel = logging.DEBUG if self.isDebugLogging() else logging.INFO
# create recorder app root logger
log... | python | def configureLogger(self):
"""
Configures the python logging system to log to a debug file and to stdout for warn and above.
:return: the base logger.
"""
baseLogLevel = logging.DEBUG if self.isDebugLogging() else logging.INFO
# create recorder app root logger
log... | [
"def",
"configureLogger",
"(",
"self",
")",
":",
"baseLogLevel",
"=",
"logging",
".",
"DEBUG",
"if",
"self",
".",
"isDebugLogging",
"(",
")",
"else",
"logging",
".",
"INFO",
"# create recorder app root logger",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
... | Configures the python logging system to log to a debug file and to stdout for warn and above.
:return: the base logger. | [
"Configures",
"the",
"python",
"logging",
"system",
"to",
"log",
"to",
"a",
"debug",
"file",
"and",
"to",
"stdout",
"for",
"warn",
"and",
"above",
".",
":",
"return",
":",
"the",
"base",
"logger",
"."
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/core/BaseConfig.py#L95-L118 | train |
selik/xport | xport/v56.py | ibm_to_ieee | def ibm_to_ieee(ibm):
'''
Translate IBM-format floating point numbers (as bytes) to IEEE 754
64-bit floating point format (as Python float).
'''
# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)
# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)
# Pad-out to 8 bytes ... | python | def ibm_to_ieee(ibm):
'''
Translate IBM-format floating point numbers (as bytes) to IEEE 754
64-bit floating point format (as Python float).
'''
# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)
# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)
# Pad-out to 8 bytes ... | [
"def",
"ibm_to_ieee",
"(",
"ibm",
")",
":",
"# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)",
"# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)",
"# Pad-out to 8 bytes if necessary. We expect 2 to 8 bytes, but",
"# there's no need to check; bizarre sizes will cause a s... | Translate IBM-format floating point numbers (as bytes) to IEEE 754
64-bit floating point format (as Python float). | [
"Translate",
"IBM",
"-",
"format",
"floating",
"point",
"numbers",
"(",
"as",
"bytes",
")",
"to",
"IEEE",
"754",
"64",
"-",
"bit",
"floating",
"point",
"format",
"(",
"as",
"Python",
"float",
")",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L36-L96 | train |
selik/xport | xport/v56.py | ieee_to_ibm | def ieee_to_ibm(ieee):
'''
Translate Python floating point numbers to IBM-format (as bytes).
'''
# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)
# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)
if ieee == 0.0:
return b'\x00' * 8
if ieee is None or math.is... | python | def ieee_to_ibm(ieee):
'''
Translate Python floating point numbers to IBM-format (as bytes).
'''
# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)
# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)
if ieee == 0.0:
return b'\x00' * 8
if ieee is None or math.is... | [
"def",
"ieee_to_ibm",
"(",
"ieee",
")",
":",
"# Python uses IEEE: sign * 1.mantissa * 2 ** (exponent - 1023)",
"# IBM mainframe: sign * 0.mantissa * 16 ** (exponent - 64)",
"if",
"ieee",
"==",
"0.0",
":",
"return",
"b'\\x00'",
"*",
"8",
"if",
"ieee",
"is",
"None",
"or",
... | Translate Python floating point numbers to IBM-format (as bytes). | [
"Translate",
"Python",
"floating",
"point",
"numbers",
"to",
"IBM",
"-",
"format",
"(",
"as",
"bytes",
")",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L600-L657 | train |
selik/xport | xport/v56.py | dumps | def dumps(columns):
'''
Serialize ``columns`` to a JSON formatted ``bytes`` object.
'''
fp = BytesIO()
dump(columns, fp)
fp.seek(0)
return fp.read() | python | def dumps(columns):
'''
Serialize ``columns`` to a JSON formatted ``bytes`` object.
'''
fp = BytesIO()
dump(columns, fp)
fp.seek(0)
return fp.read() | [
"def",
"dumps",
"(",
"columns",
")",
":",
"fp",
"=",
"BytesIO",
"(",
")",
"dump",
"(",
"columns",
",",
"fp",
")",
"fp",
".",
"seek",
"(",
"0",
")",
"return",
"fp",
".",
"read",
"(",
")"
] | Serialize ``columns`` to a JSON formatted ``bytes`` object. | [
"Serialize",
"columns",
"to",
"a",
"JSON",
"formatted",
"bytes",
"object",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L669-L676 | train |
selik/xport | xport/v56.py | Library.match | def match(header):
'''
Parse the 3-line (240-byte) header of a SAS XPORT file.
'''
mo = Library.header_re.match(header)
if mo is None:
raise ValueError(f'Not a SAS Version 5 or 6 XPORT file')
return {
'created': strptime(mo['created']),
... | python | def match(header):
'''
Parse the 3-line (240-byte) header of a SAS XPORT file.
'''
mo = Library.header_re.match(header)
if mo is None:
raise ValueError(f'Not a SAS Version 5 or 6 XPORT file')
return {
'created': strptime(mo['created']),
... | [
"def",
"match",
"(",
"header",
")",
":",
"mo",
"=",
"Library",
".",
"header_re",
".",
"match",
"(",
"header",
")",
"if",
"mo",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"f'Not a SAS Version 5 or 6 XPORT file'",
")",
"return",
"{",
"'created'",
":",
"s... | Parse the 3-line (240-byte) header of a SAS XPORT file. | [
"Parse",
"the",
"3",
"-",
"line",
"(",
"240",
"-",
"byte",
")",
"header",
"of",
"a",
"SAS",
"XPORT",
"file",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L146-L158 | train |
selik/xport | xport/v56.py | Member.header_match | def header_match(cls, header):
'''
Parse the 4-line (320-byte) library member header.
'''
mo = cls.header_re.match(header)
if mo is None:
msg = f'Expected {cls.header_re.pattern!r}, got {header!r}'
raise ValueError(msg)
return {
'name':... | python | def header_match(cls, header):
'''
Parse the 4-line (320-byte) library member header.
'''
mo = cls.header_re.match(header)
if mo is None:
msg = f'Expected {cls.header_re.pattern!r}, got {header!r}'
raise ValueError(msg)
return {
'name':... | [
"def",
"header_match",
"(",
"cls",
",",
"header",
")",
":",
"mo",
"=",
"cls",
".",
"header_re",
".",
"match",
"(",
"header",
")",
"if",
"mo",
"is",
"None",
":",
"msg",
"=",
"f'Expected {cls.header_re.pattern!r}, got {header!r}'",
"raise",
"ValueError",
"(",
... | Parse the 4-line (320-byte) library member header. | [
"Parse",
"the",
"4",
"-",
"line",
"(",
"320",
"-",
"byte",
")",
"library",
"member",
"header",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L292-L309 | train |
selik/xport | xport/v56.py | Variable.header_match | def header_match(cls, data):
'''
Parse a member namestrs header (1 line, 80 bytes).
'''
mo = cls.header_re.match(data)
return int(mo['n_variables']) | python | def header_match(cls, data):
'''
Parse a member namestrs header (1 line, 80 bytes).
'''
mo = cls.header_re.match(data)
return int(mo['n_variables']) | [
"def",
"header_match",
"(",
"cls",
",",
"data",
")",
":",
"mo",
"=",
"cls",
".",
"header_re",
".",
"match",
"(",
"data",
")",
"return",
"int",
"(",
"mo",
"[",
"'n_variables'",
"]",
")"
] | Parse a member namestrs header (1 line, 80 bytes). | [
"Parse",
"a",
"member",
"namestrs",
"header",
"(",
"1",
"line",
"80",
"bytes",
")",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L421-L426 | train |
selik/xport | xport/v56.py | Variable.readall | def readall(cls, member, size):
'''
Parse variable metadata for a XPORT file member.
'''
fp = member.library.fp
LINE = member.library.LINE
n = cls.header_match(fp.read(LINE))
namestrs = [fp.read(size) for i in range(n)]
# Each namestr field is 140 bytes ... | python | def readall(cls, member, size):
'''
Parse variable metadata for a XPORT file member.
'''
fp = member.library.fp
LINE = member.library.LINE
n = cls.header_match(fp.read(LINE))
namestrs = [fp.read(size) for i in range(n)]
# Each namestr field is 140 bytes ... | [
"def",
"readall",
"(",
"cls",
",",
"member",
",",
"size",
")",
":",
"fp",
"=",
"member",
".",
"library",
".",
"fp",
"LINE",
"=",
"member",
".",
"library",
".",
"LINE",
"n",
"=",
"cls",
".",
"header_match",
"(",
"fp",
".",
"read",
"(",
"LINE",
")"... | Parse variable metadata for a XPORT file member. | [
"Parse",
"variable",
"metadata",
"for",
"a",
"XPORT",
"file",
"member",
"."
] | fafd15a24ccd102fc92d0c0123b9877a0c752182 | https://github.com/selik/xport/blob/fafd15a24ccd102fc92d0c0123b9877a0c752182/xport/v56.py#L464-L489 | train |
fitnr/convertdate | convertdate/islamic.py | to_jd | def to_jd(year, month, day):
'''Determine Julian day count from Islamic date'''
return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1 | python | def to_jd(year, month, day):
'''Determine Julian day count from Islamic date'''
return (day + ceil(29.5 * (month - 1)) + (year - 1) * 354 + trunc((3 + (11 * year)) / 30) + EPOCH) - 1 | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"return",
"(",
"day",
"+",
"ceil",
"(",
"29.5",
"*",
"(",
"month",
"-",
"1",
")",
")",
"+",
"(",
"year",
"-",
"1",
")",
"*",
"354",
"+",
"trunc",
"(",
"(",
"3",
"+",
"(",
"1... | Determine Julian day count from Islamic date | [
"Determine",
"Julian",
"day",
"count",
"from",
"Islamic",
"date"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/islamic.py#L28-L30 | train |
fitnr/convertdate | convertdate/islamic.py | from_jd | def from_jd(jd):
'''Calculate Islamic date from Julian day'''
jd = trunc(jd) + 0.5
year = trunc(((30 * (jd - EPOCH)) + 10646) / 10631)
month = min(12, ceil((jd - (29 + to_jd(year, 1, 1))) / 29.5) + 1)
day = int(jd - to_jd(year, month, 1)) + 1
return (year, month, day) | python | def from_jd(jd):
'''Calculate Islamic date from Julian day'''
jd = trunc(jd) + 0.5
year = trunc(((30 * (jd - EPOCH)) + 10646) / 10631)
month = min(12, ceil((jd - (29 + to_jd(year, 1, 1))) / 29.5) + 1)
day = int(jd - to_jd(year, month, 1)) + 1
return (year, month, day) | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"jd",
"=",
"trunc",
"(",
"jd",
")",
"+",
"0.5",
"year",
"=",
"trunc",
"(",
"(",
"(",
"30",
"*",
"(",
"jd",
"-",
"EPOCH",
")",
")",
"+",
"10646",
")",
"/",
"10631",
")",
"month",
"=",
"min",
"(",
"12",
... | Calculate Islamic date from Julian day | [
"Calculate",
"Islamic",
"date",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/islamic.py#L33-L40 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.checkAllTriggers | def checkAllTriggers(self, action):
""" Go over all widgets and let them know they have been edited
recently and they need to check for any trigger actions. This
would be used right after all the widgets have their values
set or forced (e.g. via setAllEntriesFromParList). ""... | python | def checkAllTriggers(self, action):
""" Go over all widgets and let them know they have been edited
recently and they need to check for any trigger actions. This
would be used right after all the widgets have their values
set or forced (e.g. via setAllEntriesFromParList). ""... | [
"def",
"checkAllTriggers",
"(",
"self",
",",
"action",
")",
":",
"for",
"entry",
"in",
"self",
".",
"entryNo",
":",
"entry",
".",
"widgetEdited",
"(",
"action",
"=",
"action",
",",
"skipDups",
"=",
"False",
")"
] | Go over all widgets and let them know they have been edited
recently and they need to check for any trigger actions. This
would be used right after all the widgets have their values
set or forced (e.g. via setAllEntriesFromParList). | [
"Go",
"over",
"all",
"widgets",
"and",
"let",
"them",
"know",
"they",
"have",
"been",
"edited",
"recently",
"and",
"they",
"need",
"to",
"check",
"for",
"any",
"trigger",
"actions",
".",
"This",
"would",
"be",
"used",
"right",
"after",
"all",
"the",
"wid... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L417-L423 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.freshenFocus | def freshenFocus(self):
""" Did something which requires a new look. Move scrollbar up.
This often needs to be delayed a bit however, to let other
events in the queue through first. """
self.top.update_idletasks()
self.top.after(10, self.setViewAtTop) | python | def freshenFocus(self):
""" Did something which requires a new look. Move scrollbar up.
This often needs to be delayed a bit however, to let other
events in the queue through first. """
self.top.update_idletasks()
self.top.after(10, self.setViewAtTop) | [
"def",
"freshenFocus",
"(",
"self",
")",
":",
"self",
".",
"top",
".",
"update_idletasks",
"(",
")",
"self",
".",
"top",
".",
"after",
"(",
"10",
",",
"self",
".",
"setViewAtTop",
")"
] | Did something which requires a new look. Move scrollbar up.
This often needs to be delayed a bit however, to let other
events in the queue through first. | [
"Did",
"something",
"which",
"requires",
"a",
"new",
"look",
".",
"Move",
"scrollbar",
"up",
".",
"This",
"often",
"needs",
"to",
"be",
"delayed",
"a",
"bit",
"however",
"to",
"let",
"other",
"events",
"in",
"the",
"queue",
"through",
"first",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L426-L431 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.mwl | def mwl(self, event):
"""Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this """
if event.num == 4: # up on Linux
self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units')
elif event.num == 5: # down on Linux
self.top.f.canvas.yview_scroll(1*self._tmwm, 'units')
... | python | def mwl(self, event):
"""Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this """
if event.num == 4: # up on Linux
self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units')
elif event.num == 5: # down on Linux
self.top.f.canvas.yview_scroll(1*self._tmwm, 'units')
... | [
"def",
"mwl",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"num",
"==",
"4",
":",
"# up on Linux",
"self",
".",
"top",
".",
"f",
".",
"canvas",
".",
"yview_scroll",
"(",
"-",
"1",
"*",
"self",
".",
"_tmwm",
",",
"'units'",
")",
"elif"... | Mouse Wheel - under tkinter we seem to need Tk v8.5+ for this | [
"Mouse",
"Wheel",
"-",
"under",
"tkinter",
"we",
"seem",
"to",
"need",
"Tk",
"v8",
".",
"5",
"+",
"for",
"this"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L444-L451 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.focusNext | def focusNext(self, event):
"""Set focus to next item in sequence"""
try:
event.widget.tk_focusNext().focus_set()
except TypeError:
# see tkinter equivalent code for tk_focusNext to see
# commented original version
name = event.widget.tk.call('tk_f... | python | def focusNext(self, event):
"""Set focus to next item in sequence"""
try:
event.widget.tk_focusNext().focus_set()
except TypeError:
# see tkinter equivalent code for tk_focusNext to see
# commented original version
name = event.widget.tk.call('tk_f... | [
"def",
"focusNext",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"event",
".",
"widget",
".",
"tk_focusNext",
"(",
")",
".",
"focus_set",
"(",
")",
"except",
"TypeError",
":",
"# see tkinter equivalent code for tk_focusNext to see",
"# commented original version... | Set focus to next item in sequence | [
"Set",
"focus",
"to",
"next",
"item",
"in",
"sequence"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L458-L466 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.focusPrev | def focusPrev(self, event):
"""Set focus to previous item in sequence"""
try:
event.widget.tk_focusPrev().focus_set()
except TypeError:
# see tkinter equivalent code for tk_focusPrev to see
# commented original version
name = event.widget.tk.call('... | python | def focusPrev(self, event):
"""Set focus to previous item in sequence"""
try:
event.widget.tk_focusPrev().focus_set()
except TypeError:
# see tkinter equivalent code for tk_focusPrev to see
# commented original version
name = event.widget.tk.call('... | [
"def",
"focusPrev",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"event",
".",
"widget",
".",
"tk_focusPrev",
"(",
")",
".",
"focus_set",
"(",
")",
"except",
"TypeError",
":",
"# see tkinter equivalent code for tk_focusPrev to see",
"# commented original version... | Set focus to previous item in sequence | [
"Set",
"focus",
"to",
"previous",
"item",
"in",
"sequence"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L468-L476 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.doScroll | def doScroll(self, event):
"""Scroll the panel down to ensure widget with focus to be visible
Tracks the last widget that doScroll was called for and ignores
repeated calls. That handles the case where the focus moves not
between parameter entries but to someplace outside the hierarchy... | python | def doScroll(self, event):
"""Scroll the panel down to ensure widget with focus to be visible
Tracks the last widget that doScroll was called for and ignores
repeated calls. That handles the case where the focus moves not
between parameter entries but to someplace outside the hierarchy... | [
"def",
"doScroll",
"(",
"self",
",",
"event",
")",
":",
"canvas",
"=",
"self",
".",
"top",
".",
"f",
".",
"canvas",
"widgetWithFocus",
"=",
"event",
".",
"widget",
"if",
"widgetWithFocus",
"is",
"self",
".",
"lastFocusWidget",
":",
"return",
"FALSE",
"se... | Scroll the panel down to ensure widget with focus to be visible
Tracks the last widget that doScroll was called for and ignores
repeated calls. That handles the case where the focus moves not
between parameter entries but to someplace outside the hierarchy.
In that case the scrolling i... | [
"Scroll",
"the",
"panel",
"down",
"to",
"ensure",
"widget",
"with",
"focus",
"to",
"be",
"visible"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L478-L508 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog._handleParListMismatch | def _handleParListMismatch(self, probStr, extra=False):
""" Handle the situation where two par lists do not match.
This is meant to allow subclasses to override. Note that this only
handles "missing" pars and "extra" pars, not wrong-type pars. """
errmsg = 'ERROR: mismatch between defau... | python | def _handleParListMismatch(self, probStr, extra=False):
""" Handle the situation where two par lists do not match.
This is meant to allow subclasses to override. Note that this only
handles "missing" pars and "extra" pars, not wrong-type pars. """
errmsg = 'ERROR: mismatch between defau... | [
"def",
"_handleParListMismatch",
"(",
"self",
",",
"probStr",
",",
"extra",
"=",
"False",
")",
":",
"errmsg",
"=",
"'ERROR: mismatch between default and current par lists '",
"+",
"'for task \"'",
"+",
"self",
".",
"taskName",
"+",
"'\"'",
"if",
"probStr",
":",
"e... | Handle the situation where two par lists do not match.
This is meant to allow subclasses to override. Note that this only
handles "missing" pars and "extra" pars, not wrong-type pars. | [
"Handle",
"the",
"situation",
"where",
"two",
"par",
"lists",
"do",
"not",
"match",
".",
"This",
"is",
"meant",
"to",
"allow",
"subclasses",
"to",
"override",
".",
"Note",
"that",
"this",
"only",
"handles",
"missing",
"pars",
"and",
"extra",
"pars",
"not",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L511-L522 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog._setupDefaultParamList | def _setupDefaultParamList(self):
""" This creates self.defaultParamList. It also does some checks
on the paramList, sets its order if needed, and deletes any extra
or unknown pars if found. We assume the order of self.defaultParamList
is the correct order. """
# Obtain the def... | python | def _setupDefaultParamList(self):
""" This creates self.defaultParamList. It also does some checks
on the paramList, sets its order if needed, and deletes any extra
or unknown pars if found. We assume the order of self.defaultParamList
is the correct order. """
# Obtain the def... | [
"def",
"_setupDefaultParamList",
"(",
"self",
")",
":",
"# Obtain the default parameter list",
"self",
".",
"defaultParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getDefaultParList",
"(",
")",
"theParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
... | This creates self.defaultParamList. It also does some checks
on the paramList, sets its order if needed, and deletes any extra
or unknown pars if found. We assume the order of self.defaultParamList
is the correct order. | [
"This",
"creates",
"self",
".",
"defaultParamList",
".",
"It",
"also",
"does",
"some",
"checks",
"on",
"the",
"paramList",
"sets",
"its",
"order",
"if",
"needed",
"and",
"deletes",
"any",
"extra",
"or",
"unknown",
"pars",
"if",
"found",
".",
"We",
"assume"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L525-L579 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog._toggleSectionActiveState | def _toggleSectionActiveState(self, sectionName, state, skipList):
""" Make an entire section (minus skipList items) either active or
inactive. sectionName is the same as the param's scope. """
# Get model data, the list of pars
theParamList = self._taskParsObj.getParList()
... | python | def _toggleSectionActiveState(self, sectionName, state, skipList):
""" Make an entire section (minus skipList items) either active or
inactive. sectionName is the same as the param's scope. """
# Get model data, the list of pars
theParamList = self._taskParsObj.getParList()
... | [
"def",
"_toggleSectionActiveState",
"(",
"self",
",",
"sectionName",
",",
"state",
",",
"skipList",
")",
":",
"# Get model data, the list of pars",
"theParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
"(",
")",
"# Loop over their assoc. entries",
"for",
... | Make an entire section (minus skipList items) either active or
inactive. sectionName is the same as the param's scope. | [
"Make",
"an",
"entire",
"section",
"(",
"minus",
"skipList",
"items",
")",
"either",
"active",
"or",
"inactive",
".",
"sectionName",
"is",
"the",
"same",
"as",
"the",
"param",
"s",
"scope",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L645-L659 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.saveAs | def saveAs(self, event=None):
""" Save the parameter settings to a user-specified file. Any
changes here must be coordinated with the corresponding tpar save_as
function. """
self.debug('Clicked Save as...')
# On Linux Pers..Dlg causes the cwd to change, so get a copy of curren... | python | def saveAs(self, event=None):
""" Save the parameter settings to a user-specified file. Any
changes here must be coordinated with the corresponding tpar save_as
function. """
self.debug('Clicked Save as...')
# On Linux Pers..Dlg causes the cwd to change, so get a copy of curren... | [
"def",
"saveAs",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"self",
".",
"debug",
"(",
"'Clicked Save as...'",
")",
"# On Linux Pers..Dlg causes the cwd to change, so get a copy of current",
"curdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"# The user wishes to sa... | Save the parameter settings to a user-specified file. Any
changes here must be coordinated with the corresponding tpar save_as
function. | [
"Save",
"the",
"parameter",
"settings",
"to",
"a",
"user",
"-",
"specified",
"file",
".",
"Any",
"changes",
"here",
"must",
"be",
"coordinated",
"with",
"the",
"corresponding",
"tpar",
"save_as",
"function",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1122-L1190 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.htmlHelp | def htmlHelp(self, helpString=None, title=None, istask=False, tag=None):
""" Pop up the help in a browser window. By default, this tries to
show the help for the current task. With the option arguments, it can
be used to show any help string. """
# Check the help string. If it turns o... | python | def htmlHelp(self, helpString=None, title=None, istask=False, tag=None):
""" Pop up the help in a browser window. By default, this tries to
show the help for the current task. With the option arguments, it can
be used to show any help string. """
# Check the help string. If it turns o... | [
"def",
"htmlHelp",
"(",
"self",
",",
"helpString",
"=",
"None",
",",
"title",
"=",
"None",
",",
"istask",
"=",
"False",
",",
"tag",
"=",
"None",
")",
":",
"# Check the help string. If it turns out to be a URL, launch that,",
"# if not, dump it to a quick and dirty tmp ... | Pop up the help in a browser window. By default, this tries to
show the help for the current task. With the option arguments, it can
be used to show any help string. | [
"Pop",
"up",
"the",
"help",
"in",
"a",
"browser",
"window",
".",
"By",
"default",
"this",
"tries",
"to",
"show",
"the",
"help",
"for",
"the",
"current",
"task",
".",
"With",
"the",
"option",
"arguments",
"it",
"can",
"be",
"used",
"to",
"show",
"any",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1298-L1329 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog._showAnyHelp | def _showAnyHelp(self, kind, tag=None):
""" Invoke task/epar/etc. help and put the page in a window.
This same logic is used for GUI help, task help, log msgs, etc. """
# sanity check
assert kind in ('epar', 'task', 'log'), 'Unknown help kind: '+str(kind)
#---------------------... | python | def _showAnyHelp(self, kind, tag=None):
""" Invoke task/epar/etc. help and put the page in a window.
This same logic is used for GUI help, task help, log msgs, etc. """
# sanity check
assert kind in ('epar', 'task', 'log'), 'Unknown help kind: '+str(kind)
#---------------------... | [
"def",
"_showAnyHelp",
"(",
"self",
",",
"kind",
",",
"tag",
"=",
"None",
")",
":",
"# sanity check",
"assert",
"kind",
"in",
"(",
"'epar'",
",",
"'task'",
",",
"'log'",
")",
",",
"'Unknown help kind: '",
"+",
"str",
"(",
"kind",
")",
"#-------------------... | Invoke task/epar/etc. help and put the page in a window.
This same logic is used for GUI help, task help, log msgs, etc. | [
"Invoke",
"task",
"/",
"epar",
"/",
"etc",
".",
"help",
"and",
"put",
"the",
"page",
"in",
"a",
"window",
".",
"This",
"same",
"logic",
"is",
"used",
"for",
"GUI",
"help",
"task",
"help",
"log",
"msgs",
"etc",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1332-L1383 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.setAllEntriesFromParList | def setAllEntriesFromParList(self, aParList, updateModel=False):
""" Set all the parameter entry values in the GUI to the values
in the given par list. If 'updateModel' is True, the internal
param list will be updated to the new values as well as the GUI
entries (slower and n... | python | def setAllEntriesFromParList(self, aParList, updateModel=False):
""" Set all the parameter entry values in the GUI to the values
in the given par list. If 'updateModel' is True, the internal
param list will be updated to the new values as well as the GUI
entries (slower and n... | [
"def",
"setAllEntriesFromParList",
"(",
"self",
",",
"aParList",
",",
"updateModel",
"=",
"False",
")",
":",
"# Get model data, the list of pars",
"theParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
"(",
")",
"# we may modify members",
"if",
"len",
... | Set all the parameter entry values in the GUI to the values
in the given par list. If 'updateModel' is True, the internal
param list will be updated to the new values as well as the GUI
entries (slower and not always necessary). Note the
corresponding TparDisplay method. | [
"Set",
"all",
"the",
"parameter",
"entry",
"values",
"in",
"the",
"GUI",
"to",
"the",
"values",
"in",
"the",
"given",
"par",
"list",
".",
"If",
"updateModel",
"is",
"True",
"the",
"internal",
"param",
"list",
"will",
"be",
"updated",
"to",
"the",
"new",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1473-L1530 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.getValue | def getValue(self, name, scope=None, native=False):
""" Return current par value from the GUI. This does not do any
validation, and it it not necessarily the same value saved in the
model, which is always behind the GUI setting, in time. This is NOT
to be used to get all the values - it ... | python | def getValue(self, name, scope=None, native=False):
""" Return current par value from the GUI. This does not do any
validation, and it it not necessarily the same value saved in the
model, which is always behind the GUI setting, in time. This is NOT
to be used to get all the values - it ... | [
"def",
"getValue",
"(",
"self",
",",
"name",
",",
"scope",
"=",
"None",
",",
"native",
"=",
"False",
")",
":",
"# Get model data, the list of pars",
"theParamList",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
"(",
")",
"# NOTE: If par scope is given, it w... | Return current par value from the GUI. This does not do any
validation, and it it not necessarily the same value saved in the
model, which is always behind the GUI setting, in time. This is NOT
to be used to get all the values - it would not be efficient. | [
"Return",
"current",
"par",
"value",
"from",
"the",
"GUI",
".",
"This",
"does",
"not",
"do",
"any",
"validation",
"and",
"it",
"it",
"not",
"necessarily",
"the",
"same",
"value",
"saved",
"in",
"the",
"model",
"which",
"is",
"always",
"behind",
"the",
"G... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1540-L1564 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.checkSetSaveChildren | def checkSetSaveChildren(self, doSave=True):
"""Check, then set, then save the parameter settings for
all child (pset) windows.
Prompts if any problems are found. Returns None
on success, list of bad entries on failure.
"""
if self.isChild:
return
#... | python | def checkSetSaveChildren(self, doSave=True):
"""Check, then set, then save the parameter settings for
all child (pset) windows.
Prompts if any problems are found. Returns None
on success, list of bad entries on failure.
"""
if self.isChild:
return
#... | [
"def",
"checkSetSaveChildren",
"(",
"self",
",",
"doSave",
"=",
"True",
")",
":",
"if",
"self",
".",
"isChild",
":",
"return",
"# Need to get all the entries and verify them.",
"# Save the children in backwards order to coincide with the",
"# display of the dialogs (LIFO)",
"fo... | Check, then set, then save the parameter settings for
all child (pset) windows.
Prompts if any problems are found. Returns None
on success, list of bad entries on failure. | [
"Check",
"then",
"set",
"then",
"save",
"the",
"parameter",
"settings",
"for",
"all",
"child",
"(",
"pset",
")",
"windows",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1658-L1685 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog._pushMessages | def _pushMessages(self):
""" Internal callback used to make sure the msg list keeps moving. """
# This continues to get itself called until no msgs are left in list.
self.showStatus('')
if len(self._statusMsgsToShow) > 0:
self.top.after(200, self._pushMessages) | python | def _pushMessages(self):
""" Internal callback used to make sure the msg list keeps moving. """
# This continues to get itself called until no msgs are left in list.
self.showStatus('')
if len(self._statusMsgsToShow) > 0:
self.top.after(200, self._pushMessages) | [
"def",
"_pushMessages",
"(",
"self",
")",
":",
"# This continues to get itself called until no msgs are left in list.",
"self",
".",
"showStatus",
"(",
"''",
")",
"if",
"len",
"(",
"self",
".",
"_statusMsgsToShow",
")",
">",
"0",
":",
"self",
".",
"top",
".",
"a... | Internal callback used to make sure the msg list keeps moving. | [
"Internal",
"callback",
"used",
"to",
"make",
"sure",
"the",
"msg",
"list",
"keeps",
"moving",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1688-L1693 | train |
spacetelescope/stsci.tools | lib/stsci/tools/editpar.py | EditParDialog.showStatus | def showStatus(self, msg, keep=0, cat=None):
""" Show the given status string, but not until any given delay from
the previous message has expired. keep is a time (secs) to force
the message to remain without being overwritten or cleared. cat
is a string category used only in... | python | def showStatus(self, msg, keep=0, cat=None):
""" Show the given status string, but not until any given delay from
the previous message has expired. keep is a time (secs) to force
the message to remain without being overwritten or cleared. cat
is a string category used only in... | [
"def",
"showStatus",
"(",
"self",
",",
"msg",
",",
"keep",
"=",
"0",
",",
"cat",
"=",
"None",
")",
":",
"# prep it, space-wise",
"msg",
"=",
"msg",
".",
"strip",
"(",
")",
"if",
"len",
"(",
"msg",
")",
">",
"0",
":",
"# right here is the ideal place to... | Show the given status string, but not until any given delay from
the previous message has expired. keep is a time (secs) to force
the message to remain without being overwritten or cleared. cat
is a string category used only in the historical log. | [
"Show",
"the",
"given",
"status",
"string",
"but",
"not",
"until",
"any",
"given",
"delay",
"from",
"the",
"previous",
"message",
"has",
"expired",
".",
"keep",
"is",
"a",
"time",
"(",
"secs",
")",
"to",
"force",
"the",
"message",
"to",
"remain",
"withou... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/editpar.py#L1701-L1749 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | teal | def teal(theTask, parent=None, loadOnly=False, returnAs="dict",
canExecute=True, strict=False, errorsToTerm=False,
autoClose=True, defaults=False):
# overrides=None):
""" Start the GUI session, or simply load a task's ConfigObj. """
if loadOnly: # this forces returnAs="dict"
obj... | python | def teal(theTask, parent=None, loadOnly=False, returnAs="dict",
canExecute=True, strict=False, errorsToTerm=False,
autoClose=True, defaults=False):
# overrides=None):
""" Start the GUI session, or simply load a task's ConfigObj. """
if loadOnly: # this forces returnAs="dict"
obj... | [
"def",
"teal",
"(",
"theTask",
",",
"parent",
"=",
"None",
",",
"loadOnly",
"=",
"False",
",",
"returnAs",
"=",
"\"dict\"",
",",
"canExecute",
"=",
"True",
",",
"strict",
"=",
"False",
",",
"errorsToTerm",
"=",
"False",
",",
"autoClose",
"=",
"True",
"... | Start the GUI session, or simply load a task's ConfigObj. | [
"Start",
"the",
"GUI",
"session",
"or",
"simply",
"load",
"a",
"task",
"s",
"ConfigObj",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L167-L227 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | load | def load(theTask, canExecute=True, strict=True, defaults=False):
""" Shortcut to load TEAL .cfg files for non-GUI access where
loadOnly=True. """
return teal(theTask, parent=None, loadOnly=True, returnAs="dict",
canExecute=canExecute, strict=strict, errorsToTerm=True,
default... | python | def load(theTask, canExecute=True, strict=True, defaults=False):
""" Shortcut to load TEAL .cfg files for non-GUI access where
loadOnly=True. """
return teal(theTask, parent=None, loadOnly=True, returnAs="dict",
canExecute=canExecute, strict=strict, errorsToTerm=True,
default... | [
"def",
"load",
"(",
"theTask",
",",
"canExecute",
"=",
"True",
",",
"strict",
"=",
"True",
",",
"defaults",
"=",
"False",
")",
":",
"return",
"teal",
"(",
"theTask",
",",
"parent",
"=",
"None",
",",
"loadOnly",
"=",
"True",
",",
"returnAs",
"=",
"\"d... | Shortcut to load TEAL .cfg files for non-GUI access where
loadOnly=True. | [
"Shortcut",
"to",
"load",
"TEAL",
".",
"cfg",
"files",
"for",
"non",
"-",
"GUI",
"access",
"where",
"loadOnly",
"=",
"True",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L232-L237 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | unlearn | def unlearn(taskPkgName, deleteAll=False):
""" Find the task named taskPkgName, and delete any/all user-owned
.cfg files in the user's resource directory which apply to that task.
Like a unix utility, this returns 0 on success (no files found or only
1 found but deleted). For multiple files found, this... | python | def unlearn(taskPkgName, deleteAll=False):
""" Find the task named taskPkgName, and delete any/all user-owned
.cfg files in the user's resource directory which apply to that task.
Like a unix utility, this returns 0 on success (no files found or only
1 found but deleted). For multiple files found, this... | [
"def",
"unlearn",
"(",
"taskPkgName",
",",
"deleteAll",
"=",
"False",
")",
":",
"# this WILL throw an exception if the taskPkgName isn't found",
"flist",
"=",
"cfgpars",
".",
"getUsrCfgFilesForPyPkg",
"(",
"taskPkgName",
")",
"# can raise",
"if",
"flist",
"is",
"None",
... | Find the task named taskPkgName, and delete any/all user-owned
.cfg files in the user's resource directory which apply to that task.
Like a unix utility, this returns 0 on success (no files found or only
1 found but deleted). For multiple files found, this uses deleteAll,
returning the file-name-list i... | [
"Find",
"the",
"task",
"named",
"taskPkgName",
"and",
"delete",
"any",
"/",
"all",
"user",
"-",
"owned",
".",
"cfg",
"files",
"in",
"the",
"user",
"s",
"resource",
"directory",
"which",
"apply",
"to",
"that",
"task",
".",
"Like",
"a",
"unix",
"utility",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L248-L270 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | diffFromDefaults | def diffFromDefaults(theTask, report=False):
""" Load the given file (or existing object), and return a dict
of its values which are different from the default values. If report
is set, print to stdout the differences. """
# get the 2 dicts (trees: dicts of dicts)
defaultTree = load(theTask, canExe... | python | def diffFromDefaults(theTask, report=False):
""" Load the given file (or existing object), and return a dict
of its values which are different from the default values. If report
is set, print to stdout the differences. """
# get the 2 dicts (trees: dicts of dicts)
defaultTree = load(theTask, canExe... | [
"def",
"diffFromDefaults",
"(",
"theTask",
",",
"report",
"=",
"False",
")",
":",
"# get the 2 dicts (trees: dicts of dicts)",
"defaultTree",
"=",
"load",
"(",
"theTask",
",",
"canExecute",
"=",
"False",
",",
"strict",
"=",
"True",
",",
"defaults",
"=",
"True",
... | Load the given file (or existing object), and return a dict
of its values which are different from the default values. If report
is set, print to stdout the differences. | [
"Load",
"the",
"given",
"file",
"(",
"or",
"existing",
"object",
")",
"and",
"return",
"a",
"dict",
"of",
"its",
"values",
"which",
"are",
"different",
"from",
"the",
"default",
"values",
".",
"If",
"report",
"is",
"set",
"print",
"to",
"stdout",
"the",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L273-L297 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | _isInstalled | def _isInstalled(fullFname):
""" Return True if the given file name is located in an
installed area (versus a user-owned file) """
if not fullFname: return False
if not os.path.exists(fullFname): return False
instAreas = []
try:
import site
instAreas = site.getsitepackages()
... | python | def _isInstalled(fullFname):
""" Return True if the given file name is located in an
installed area (versus a user-owned file) """
if not fullFname: return False
if not os.path.exists(fullFname): return False
instAreas = []
try:
import site
instAreas = site.getsitepackages()
... | [
"def",
"_isInstalled",
"(",
"fullFname",
")",
":",
"if",
"not",
"fullFname",
":",
"return",
"False",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fullFname",
")",
":",
"return",
"False",
"instAreas",
"=",
"[",
"]",
"try",
":",
"import",
"site",... | Return True if the given file name is located in an
installed area (versus a user-owned file) | [
"Return",
"True",
"if",
"the",
"given",
"file",
"name",
"is",
"located",
"in",
"an",
"installed",
"area",
"(",
"versus",
"a",
"user",
"-",
"owned",
"file",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L304-L320 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | execEmbCode | def execEmbCode(SCOPE, NAME, VAL, TEAL, codeStr):
""" .cfgspc embedded code execution is done here, in a relatively confined
space. The variables available to the code to be executed are:
SCOPE, NAME, VAL, PARENT, TEAL
The code string itself is expected to set a var named OUT
"""
... | python | def execEmbCode(SCOPE, NAME, VAL, TEAL, codeStr):
""" .cfgspc embedded code execution is done here, in a relatively confined
space. The variables available to the code to be executed are:
SCOPE, NAME, VAL, PARENT, TEAL
The code string itself is expected to set a var named OUT
"""
... | [
"def",
"execEmbCode",
"(",
"SCOPE",
",",
"NAME",
",",
"VAL",
",",
"TEAL",
",",
"codeStr",
")",
":",
"# This was all we needed in Python 2.x",
"# OUT = None",
"# exec codeStr",
"# return OUT",
"# In Python 3 (& 2.x) be more explicit: http://bugs.python.org/issue4831",
"PA... | .cfgspc embedded code execution is done here, in a relatively confined
space. The variables available to the code to be executed are:
SCOPE, NAME, VAL, PARENT, TEAL
The code string itself is expected to set a var named OUT | [
".",
"cfgspc",
"embedded",
"code",
"execution",
"is",
"done",
"here",
"in",
"a",
"relatively",
"confined",
"space",
".",
"The",
"variables",
"available",
"to",
"the",
"code",
"to",
"be",
"executed",
"are",
":",
"SCOPE",
"NAME",
"VAL",
"PARENT",
"TEAL",
"Th... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L343-L361 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | print_tasknames | def print_tasknames(pkgName, aDir, term_width=80, always=False,
hidden=None):
""" Print a message listing TEAL-enabled tasks available under a
given installation directory (where pkgName resides).
If always is True, this will always print when tasks are
found; otherwise i... | python | def print_tasknames(pkgName, aDir, term_width=80, always=False,
hidden=None):
""" Print a message listing TEAL-enabled tasks available under a
given installation directory (where pkgName resides).
If always is True, this will always print when tasks are
found; otherwise i... | [
"def",
"print_tasknames",
"(",
"pkgName",
",",
"aDir",
",",
"term_width",
"=",
"80",
",",
"always",
"=",
"False",
",",
"hidden",
"=",
"None",
")",
":",
"# See if we can bail out early",
"if",
"not",
"always",
":",
"# We can't use the sys.ps1 check if in PyRAF since ... | Print a message listing TEAL-enabled tasks available under a
given installation directory (where pkgName resides).
If always is True, this will always print when tasks are
found; otherwise it will only print found tasks when in interactive
mode.
The parameter 'hidden' supports a ... | [
"Print",
"a",
"message",
"listing",
"TEAL",
"-",
"enabled",
"tasks",
"available",
"under",
"a",
"given",
"installation",
"directory",
"(",
"where",
"pkgName",
"resides",
")",
".",
"If",
"always",
"is",
"True",
"this",
"will",
"always",
"print",
"when",
"task... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L365-L400 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | getHelpFileAsString | def getHelpFileAsString(taskname,taskpath):
"""
This functions will return useful help as a string read from a file
in the task's installed directory called "<module>.help".
If no such file can be found, it will simply return an empty string.
Notes
-----
The location of the actual help fil... | python | def getHelpFileAsString(taskname,taskpath):
"""
This functions will return useful help as a string read from a file
in the task's installed directory called "<module>.help".
If no such file can be found, it will simply return an empty string.
Notes
-----
The location of the actual help fil... | [
"def",
"getHelpFileAsString",
"(",
"taskname",
",",
"taskpath",
")",
":",
"#get the local library directory where the code is stored",
"pathsplit",
"=",
"os",
".",
"path",
".",
"split",
"(",
"taskpath",
")",
"# taskpath should be task's __file__",
"if",
"taskname",
".",
... | This functions will return useful help as a string read from a file
in the task's installed directory called "<module>.help".
If no such file can be found, it will simply return an empty string.
Notes
-----
The location of the actual help file will be found under the task's
installed directory... | [
"This",
"functions",
"will",
"return",
"useful",
"help",
"as",
"a",
"string",
"read",
"from",
"a",
"file",
"in",
"the",
"task",
"s",
"installed",
"directory",
"called",
"<module",
">",
".",
"help",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L402-L451 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | cfgGetBool | def cfgGetBool(theObj, name, dflt):
""" Get a stringified val from a ConfigObj obj and return it as bool """
strval = theObj.get(name, None)
if strval is None:
return dflt
return strval.lower().strip() == 'true' | python | def cfgGetBool(theObj, name, dflt):
""" Get a stringified val from a ConfigObj obj and return it as bool """
strval = theObj.get(name, None)
if strval is None:
return dflt
return strval.lower().strip() == 'true' | [
"def",
"cfgGetBool",
"(",
"theObj",
",",
"name",
",",
"dflt",
")",
":",
"strval",
"=",
"theObj",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"strval",
"is",
"None",
":",
"return",
"dflt",
"return",
"strval",
".",
"lower",
"(",
")",
".",
"strip... | Get a stringified val from a ConfigObj obj and return it as bool | [
"Get",
"a",
"stringified",
"val",
"from",
"a",
"ConfigObj",
"obj",
"and",
"return",
"it",
"as",
"bool"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L454-L459 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._overrideMasterSettings | def _overrideMasterSettings(self):
""" Override so that we can run in a different mode. """
# config-obj dict of defaults
cod = self._getGuiSettings()
# our own GUI setup
self._appName = APP_NAME
self._appHelpString = tealHelpString
self._useS... | python | def _overrideMasterSettings(self):
""" Override so that we can run in a different mode. """
# config-obj dict of defaults
cod = self._getGuiSettings()
# our own GUI setup
self._appName = APP_NAME
self._appHelpString = tealHelpString
self._useS... | [
"def",
"_overrideMasterSettings",
"(",
"self",
")",
":",
"# config-obj dict of defaults",
"cod",
"=",
"self",
".",
"_getGuiSettings",
"(",
")",
"# our own GUI setup",
"self",
".",
"_appName",
"=",
"APP_NAME",
"self",
".",
"_appHelpString",
"=",
"tealHelpString",
"se... | Override so that we can run in a different mode. | [
"Override",
"so",
"that",
"we",
"can",
"run",
"in",
"a",
"different",
"mode",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L488-L531 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._doActualSave | def _doActualSave(self, fname, comment, set_ro=False, overwriteRO=False):
""" Override this so we can handle case of file not writable, as
well as to make our _lastSavedState copy. """
self.debug('Saving, file name given: '+str(fname)+', set_ro: '+\
str(set_ro)+', overwrit... | python | def _doActualSave(self, fname, comment, set_ro=False, overwriteRO=False):
""" Override this so we can handle case of file not writable, as
well as to make our _lastSavedState copy. """
self.debug('Saving, file name given: '+str(fname)+', set_ro: '+\
str(set_ro)+', overwrit... | [
"def",
"_doActualSave",
"(",
"self",
",",
"fname",
",",
"comment",
",",
"set_ro",
"=",
"False",
",",
"overwriteRO",
"=",
"False",
")",
":",
"self",
".",
"debug",
"(",
"'Saving, file name given: '",
"+",
"str",
"(",
"fname",
")",
"+",
"', set_ro: '",
"+",
... | Override this so we can handle case of file not writable, as
well as to make our _lastSavedState copy. | [
"Override",
"this",
"so",
"we",
"can",
"handle",
"case",
"of",
"file",
"not",
"writable",
"as",
"well",
"as",
"to",
"make",
"our",
"_lastSavedState",
"copy",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L540-L586 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.hasUnsavedChanges | def hasUnsavedChanges(self):
""" Determine if there are any edits in the GUI that have not yet been
saved (e.g. to a file). """
# Sanity check - this case shouldn't occur
assert self._lastSavedState is not None, \
"BUG: Please report this as it should never occur."
... | python | def hasUnsavedChanges(self):
""" Determine if there are any edits in the GUI that have not yet been
saved (e.g. to a file). """
# Sanity check - this case shouldn't occur
assert self._lastSavedState is not None, \
"BUG: Please report this as it should never occur."
... | [
"def",
"hasUnsavedChanges",
"(",
"self",
")",
":",
"# Sanity check - this case shouldn't occur",
"assert",
"self",
".",
"_lastSavedState",
"is",
"not",
"None",
",",
"\"BUG: Please report this as it should never occur.\"",
"# Force the current GUI values into our model in memory, but ... | Determine if there are any edits in the GUI that have not yet been
saved (e.g. to a file). | [
"Determine",
"if",
"there",
"are",
"any",
"edits",
"in",
"the",
"GUI",
"that",
"have",
"not",
"yet",
"been",
"saved",
"(",
"e",
".",
"g",
".",
"to",
"a",
"file",
")",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L594-L615 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._defineEditedCallbackObjectFor | def _defineEditedCallbackObjectFor(self, parScope, parName):
""" Override to allow us to use an edited callback. """
# We know that the _taskParsObj is a ConfigObjPars
triggerStrs = self._taskParsObj.getTriggerStrings(parScope, parName)
# Some items will have a trigger, but likely most... | python | def _defineEditedCallbackObjectFor(self, parScope, parName):
""" Override to allow us to use an edited callback. """
# We know that the _taskParsObj is a ConfigObjPars
triggerStrs = self._taskParsObj.getTriggerStrings(parScope, parName)
# Some items will have a trigger, but likely most... | [
"def",
"_defineEditedCallbackObjectFor",
"(",
"self",
",",
"parScope",
",",
"parName",
")",
":",
"# We know that the _taskParsObj is a ConfigObjPars",
"triggerStrs",
"=",
"self",
".",
"_taskParsObj",
".",
"getTriggerStrings",
"(",
"parScope",
",",
"parName",
")",
"# Som... | Override to allow us to use an edited callback. | [
"Override",
"to",
"allow",
"us",
"to",
"use",
"an",
"edited",
"callback",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L619-L629 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.updateTitle | def updateTitle(self, atitle):
""" Override so we can append read-only status. """
if atitle and os.path.exists(atitle):
if _isInstalled(atitle):
atitle += ' [installed]'
elif not os.access(atitle, os.W_OK):
atitle += ' [read only]'
super... | python | def updateTitle(self, atitle):
""" Override so we can append read-only status. """
if atitle and os.path.exists(atitle):
if _isInstalled(atitle):
atitle += ' [installed]'
elif not os.access(atitle, os.W_OK):
atitle += ' [read only]'
super... | [
"def",
"updateTitle",
"(",
"self",
",",
"atitle",
")",
":",
"if",
"atitle",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"atitle",
")",
":",
"if",
"_isInstalled",
"(",
"atitle",
")",
":",
"atitle",
"+=",
"' [installed]'",
"elif",
"not",
"os",
".",
... | Override so we can append read-only status. | [
"Override",
"so",
"we",
"can",
"append",
"read",
"-",
"only",
"status",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L643-L650 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.edited | def edited(self, scope, name, lastSavedVal, newVal, action):
""" This is the callback function invoked when an item is edited.
This is only called for those items which were previously
specified to use this mechanism. We do not turn this on for
all items because the performa... | python | def edited(self, scope, name, lastSavedVal, newVal, action):
""" This is the callback function invoked when an item is edited.
This is only called for those items which were previously
specified to use this mechanism. We do not turn this on for
all items because the performa... | [
"def",
"edited",
"(",
"self",
",",
"scope",
",",
"name",
",",
"lastSavedVal",
",",
"newVal",
",",
"action",
")",
":",
"# Get name(s) of any triggers that this par triggers",
"triggerNamesTup",
"=",
"self",
".",
"_taskParsObj",
".",
"getTriggerStrings",
"(",
"scope",... | This is the callback function invoked when an item is edited.
This is only called for those items which were previously
specified to use this mechanism. We do not turn this on for
all items because the performance might be prohibitive.
This kicks off any previously regis... | [
"This",
"is",
"the",
"callback",
"function",
"invoked",
"when",
"an",
"item",
"is",
"edited",
".",
"This",
"is",
"only",
"called",
"for",
"those",
"items",
"which",
"were",
"previously",
"specified",
"to",
"use",
"this",
"mechanism",
".",
"We",
"do",
"not"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L653-L755 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.findNextSection | def findNextSection(self, scope, name):
""" Starts with given par (scope+name) and looks further down the list
of parameters until one of a different non-null scope is found. Upon
success, returns the (scope, name) tuple, otherwise (None, None). """
# first find index of starting point
... | python | def findNextSection(self, scope, name):
""" Starts with given par (scope+name) and looks further down the list
of parameters until one of a different non-null scope is found. Upon
success, returns the (scope, name) tuple, otherwise (None, None). """
# first find index of starting point
... | [
"def",
"findNextSection",
"(",
"self",
",",
"scope",
",",
"name",
")",
":",
"# first find index of starting point",
"plist",
"=",
"self",
".",
"_taskParsObj",
".",
"getParList",
"(",
")",
"start",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"plis... | Starts with given par (scope+name) and looks further down the list
of parameters until one of a different non-null scope is found. Upon
success, returns the (scope, name) tuple, otherwise (None, None). | [
"Starts",
"with",
"given",
"par",
"(",
"scope",
"+",
"name",
")",
"and",
"looks",
"further",
"down",
"the",
"list",
"of",
"parameters",
"until",
"one",
"of",
"a",
"different",
"non",
"-",
"null",
"scope",
"is",
"found",
".",
"Upon",
"success",
"returns",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L758-L778 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._setTaskParsObj | def _setTaskParsObj(self, theTask):
""" Overridden version for ConfigObj. theTask can be either
a .cfg file name or a ConfigObjPars object. """
# Create the ConfigObjPars obj
self._taskParsObj = cfgpars.getObjectFromTaskArg(theTask,
self._strict, F... | python | def _setTaskParsObj(self, theTask):
""" Overridden version for ConfigObj. theTask can be either
a .cfg file name or a ConfigObjPars object. """
# Create the ConfigObjPars obj
self._taskParsObj = cfgpars.getObjectFromTaskArg(theTask,
self._strict, F... | [
"def",
"_setTaskParsObj",
"(",
"self",
",",
"theTask",
")",
":",
"# Create the ConfigObjPars obj",
"self",
".",
"_taskParsObj",
"=",
"cfgpars",
".",
"getObjectFromTaskArg",
"(",
"theTask",
",",
"self",
".",
"_strict",
",",
"False",
")",
"# Tell it that we can be use... | Overridden version for ConfigObj. theTask can be either
a .cfg file name or a ConfigObjPars object. | [
"Overridden",
"version",
"for",
"ConfigObj",
".",
"theTask",
"can",
"be",
"either",
"a",
".",
"cfg",
"file",
"name",
"or",
"a",
"ConfigObjPars",
"object",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L781-L792 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._getSaveAsFilter | def _getSaveAsFilter(self):
""" Return a string to be used as the filter arg to the save file
dialog during Save-As. """
# figure the dir to use, start with the one from the file
absRcDir = os.path.abspath(self._rcDir)
thedir = os.path.abspath(os.path.dirname(self._taskParsOb... | python | def _getSaveAsFilter(self):
""" Return a string to be used as the filter arg to the save file
dialog during Save-As. """
# figure the dir to use, start with the one from the file
absRcDir = os.path.abspath(self._rcDir)
thedir = os.path.abspath(os.path.dirname(self._taskParsOb... | [
"def",
"_getSaveAsFilter",
"(",
"self",
")",
":",
"# figure the dir to use, start with the one from the file",
"absRcDir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"_rcDir",
")",
"thedir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
"."... | Return a string to be used as the filter arg to the save file
dialog during Save-As. | [
"Return",
"a",
"string",
"to",
"be",
"used",
"as",
"the",
"filter",
"arg",
"to",
"the",
"save",
"file",
"dialog",
"during",
"Save",
"-",
"As",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L797-L813 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._getOpenChoices | def _getOpenChoices(self):
""" Go through all possible sites to find applicable .cfg files.
Return as an iterable. """
tsk = self._taskParsObj.getName()
taskFiles = set()
dirsSoFar = [] # this helps speed this up (skip unneeded globs)
# last dir
aDir = os.pat... | python | def _getOpenChoices(self):
""" Go through all possible sites to find applicable .cfg files.
Return as an iterable. """
tsk = self._taskParsObj.getName()
taskFiles = set()
dirsSoFar = [] # this helps speed this up (skip unneeded globs)
# last dir
aDir = os.pat... | [
"def",
"_getOpenChoices",
"(",
"self",
")",
":",
"tsk",
"=",
"self",
".",
"_taskParsObj",
".",
"getName",
"(",
")",
"taskFiles",
"=",
"set",
"(",
")",
"dirsSoFar",
"=",
"[",
"]",
"# this helps speed this up (skip unneeded globs)",
"# last dir",
"aDir",
"=",
"o... | Go through all possible sites to find applicable .cfg files.
Return as an iterable. | [
"Go",
"through",
"all",
"possible",
"sites",
"to",
"find",
"applicable",
".",
"cfg",
"files",
".",
"Return",
"as",
"an",
"iterable",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L816-L863 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.pfopen | def pfopen(self, event=None):
""" Load the parameter settings from a user-specified file. """
# Get the selected file name
fname = self._openMenuChoice.get()
# Also allow them to simply find any file - do not check _task_name_...
# (could use tkinter's FileDialog, but this one ... | python | def pfopen(self, event=None):
""" Load the parameter settings from a user-specified file. """
# Get the selected file name
fname = self._openMenuChoice.get()
# Also allow them to simply find any file - do not check _task_name_...
# (could use tkinter's FileDialog, but this one ... | [
"def",
"pfopen",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Get the selected file name",
"fname",
"=",
"self",
".",
"_openMenuChoice",
".",
"get",
"(",
")",
"# Also allow them to simply find any file - do not check _task_name_...",
"# (could use tkinter's FileDial... | Load the parameter settings from a user-specified file. | [
"Load",
"the",
"parameter",
"settings",
"from",
"a",
"user",
"-",
"specified",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L867-L934 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._handleParListMismatch | def _handleParListMismatch(self, probStr, extra=False):
""" Override to include ConfigObj filename and specific errors.
Note that this only handles "missing" pars and "extra" pars, not
wrong-type pars. So it isn't that big of a deal. """
# keep down the duplicate errors
if extr... | python | def _handleParListMismatch(self, probStr, extra=False):
""" Override to include ConfigObj filename and specific errors.
Note that this only handles "missing" pars and "extra" pars, not
wrong-type pars. So it isn't that big of a deal. """
# keep down the duplicate errors
if extr... | [
"def",
"_handleParListMismatch",
"(",
"self",
",",
"probStr",
",",
"extra",
"=",
"False",
")",
":",
"# keep down the duplicate errors",
"if",
"extra",
":",
"return",
"True",
"# the base class is already stating it will be ignored",
"# find the actual errors, and then add that t... | Override to include ConfigObj filename and specific errors.
Note that this only handles "missing" pars and "extra" pars, not
wrong-type pars. So it isn't that big of a deal. | [
"Override",
"to",
"include",
"ConfigObj",
"filename",
"and",
"specific",
"errors",
".",
"Note",
"that",
"this",
"only",
"handles",
"missing",
"pars",
"and",
"extra",
"pars",
"not",
"wrong",
"-",
"type",
"pars",
".",
"So",
"it",
"isn",
"t",
"that",
"big",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L944-L965 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._setToDefaults | def _setToDefaults(self):
""" Load the default parameter settings into the GUI. """
# Create an empty object, where every item is set to it's default value
try:
tmpObj = cfgpars.ConfigObjPars(self._taskParsObj.filename,
associatedPkg=\
... | python | def _setToDefaults(self):
""" Load the default parameter settings into the GUI. """
# Create an empty object, where every item is set to it's default value
try:
tmpObj = cfgpars.ConfigObjPars(self._taskParsObj.filename,
associatedPkg=\
... | [
"def",
"_setToDefaults",
"(",
"self",
")",
":",
"# Create an empty object, where every item is set to it's default value",
"try",
":",
"tmpObj",
"=",
"cfgpars",
".",
"ConfigObjPars",
"(",
"self",
".",
"_taskParsObj",
".",
"filename",
",",
"associatedPkg",
"=",
"self",
... | Load the default parameter settings into the GUI. | [
"Load",
"the",
"default",
"parameter",
"settings",
"into",
"the",
"GUI",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L968-L993 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.getDict | def getDict(self):
""" Retrieve the current parameter settings from the GUI."""
# We are going to have to return the dict so let's
# first make sure all of our models are up to date with the values in
# the GUI right now.
badList = self.checkSetSaveEntries(doSave=False)
i... | python | def getDict(self):
""" Retrieve the current parameter settings from the GUI."""
# We are going to have to return the dict so let's
# first make sure all of our models are up to date with the values in
# the GUI right now.
badList = self.checkSetSaveEntries(doSave=False)
i... | [
"def",
"getDict",
"(",
"self",
")",
":",
"# We are going to have to return the dict so let's",
"# first make sure all of our models are up to date with the values in",
"# the GUI right now.",
"badList",
"=",
"self",
".",
"checkSetSaveEntries",
"(",
"doSave",
"=",
"False",
")",
... | Retrieve the current parameter settings from the GUI. | [
"Retrieve",
"the",
"current",
"parameter",
"settings",
"from",
"the",
"GUI",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L995-L1003 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog.loadDict | def loadDict(self, theDict):
""" Load the parameter settings from a given dict into the GUI. """
# We are going to have to merge this info into ourselves so let's
# first make sure all of our models are up to date with the values in
# the GUI right now.
badList = self.checkSetSav... | python | def loadDict(self, theDict):
""" Load the parameter settings from a given dict into the GUI. """
# We are going to have to merge this info into ourselves so let's
# first make sure all of our models are up to date with the values in
# the GUI right now.
badList = self.checkSetSav... | [
"def",
"loadDict",
"(",
"self",
",",
"theDict",
")",
":",
"# We are going to have to merge this info into ourselves so let's",
"# first make sure all of our models are up to date with the values in",
"# the GUI right now.",
"badList",
"=",
"self",
".",
"checkSetSaveEntries",
"(",
"... | Load the parameter settings from a given dict into the GUI. | [
"Load",
"the",
"parameter",
"settings",
"from",
"a",
"given",
"dict",
"into",
"the",
"GUI",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L1005-L1030 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._getGuiSettings | def _getGuiSettings(self):
""" Return a dict (ConfigObj) of all user settings found in rcFile. """
# Put the settings into a ConfigObj dict (don't use a config-spec)
rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
if os.path.exists(rcFile):
try:
return con... | python | def _getGuiSettings(self):
""" Return a dict (ConfigObj) of all user settings found in rcFile. """
# Put the settings into a ConfigObj dict (don't use a config-spec)
rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
if os.path.exists(rcFile):
try:
return con... | [
"def",
"_getGuiSettings",
"(",
"self",
")",
":",
"# Put the settings into a ConfigObj dict (don't use a config-spec)",
"rcFile",
"=",
"self",
".",
"_rcDir",
"+",
"os",
".",
"sep",
"+",
"APP_NAME",
".",
"lower",
"(",
")",
"+",
"'.cfg'",
"if",
"os",
".",
"path",
... | Return a dict (ConfigObj) of all user settings found in rcFile. | [
"Return",
"a",
"dict",
"(",
"ConfigObj",
")",
"of",
"all",
"user",
"settings",
"found",
"in",
"rcFile",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L1033-L1046 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._saveGuiSettings | def _saveGuiSettings(self):
""" The base class doesn't implement this, so we will - save settings
(only GUI stuff, not task related) to a file. """
# Put the settings into a ConfigObj dict (don't use a config-spec)
rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
#
if ... | python | def _saveGuiSettings(self):
""" The base class doesn't implement this, so we will - save settings
(only GUI stuff, not task related) to a file. """
# Put the settings into a ConfigObj dict (don't use a config-spec)
rcFile = self._rcDir+os.sep+APP_NAME.lower()+'.cfg'
#
if ... | [
"def",
"_saveGuiSettings",
"(",
"self",
")",
":",
"# Put the settings into a ConfigObj dict (don't use a config-spec)",
"rcFile",
"=",
"self",
".",
"_rcDir",
"+",
"os",
".",
"sep",
"+",
"APP_NAME",
".",
"lower",
"(",
")",
"+",
"'.cfg'",
"#",
"if",
"os",
".",
"... | The base class doesn't implement this, so we will - save settings
(only GUI stuff, not task related) to a file. | [
"The",
"base",
"class",
"doesn",
"t",
"implement",
"this",
"so",
"we",
"will",
"-",
"save",
"settings",
"(",
"only",
"GUI",
"stuff",
"not",
"task",
"related",
")",
"to",
"a",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L1049-L1072 | train |
spacetelescope/stsci.tools | lib/stsci/tools/teal.py | ConfigObjEparDialog._applyTriggerValue | def _applyTriggerValue(self, triggerName, outval):
""" Here we look through the entire .cfgspc to see if any parameters
are affected by this trigger. For those that are, we apply the action
to the GUI widget. The action is specified by depType. """
# First find which items are dependen... | python | def _applyTriggerValue(self, triggerName, outval):
""" Here we look through the entire .cfgspc to see if any parameters
are affected by this trigger. For those that are, we apply the action
to the GUI widget. The action is specified by depType. """
# First find which items are dependen... | [
"def",
"_applyTriggerValue",
"(",
"self",
",",
"triggerName",
",",
"outval",
")",
":",
"# First find which items are dependent upon this trigger (cached)",
"# e.g. { scope1.name1 : dep'cy-type, scope2.name2 : dep'cy-type, ... }",
"depParsDict",
"=",
"self",
".",
"_taskParsObj",
"."... | Here we look through the entire .cfgspc to see if any parameters
are affected by this trigger. For those that are, we apply the action
to the GUI widget. The action is specified by depType. | [
"Here",
"we",
"look",
"through",
"the",
"entire",
".",
"cfgspc",
"to",
"see",
"if",
"any",
"parameters",
"are",
"affected",
"by",
"this",
"trigger",
".",
"For",
"those",
"that",
"are",
"we",
"apply",
"the",
"action",
"to",
"the",
"GUI",
"widget",
".",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/teal.py#L1075-L1161 | train |
spacetelescope/stsci.tools | lib/stsci/tools/asnutil.py | readASNTable | def readASNTable(fname, output=None, prodonly=False):
"""
Given a fits filename repesenting an association table reads in the table as a
dictionary which can be used by pydrizzle and multidrizzle.
An association table is a FITS binary table with 2 required columns: 'MEMNAME',
'MEMTYPE'. It checks '... | python | def readASNTable(fname, output=None, prodonly=False):
"""
Given a fits filename repesenting an association table reads in the table as a
dictionary which can be used by pydrizzle and multidrizzle.
An association table is a FITS binary table with 2 required columns: 'MEMNAME',
'MEMTYPE'. It checks '... | [
"def",
"readASNTable",
"(",
"fname",
",",
"output",
"=",
"None",
",",
"prodonly",
"=",
"False",
")",
":",
"try",
":",
"f",
"=",
"fits",
".",
"open",
"(",
"fu",
".",
"osfn",
"(",
"fname",
")",
")",
"except",
":",
"raise",
"IOError",
"(",
"\"Can't op... | Given a fits filename repesenting an association table reads in the table as a
dictionary which can be used by pydrizzle and multidrizzle.
An association table is a FITS binary table with 2 required columns: 'MEMNAME',
'MEMTYPE'. It checks 'MEMPRSNT' column and removes all files for which its value is 'no'... | [
"Given",
"a",
"fits",
"filename",
"repesenting",
"an",
"association",
"table",
"reads",
"in",
"the",
"table",
"as",
"a",
"dictionary",
"which",
"can",
"be",
"used",
"by",
"pydrizzle",
"and",
"multidrizzle",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/asnutil.py#L24-L168 | train |
spacetelescope/stsci.tools | lib/stsci/tools/asnutil.py | ASNTable.write | def write(self, output=None):
"""
Write association table to a file.
"""
if not output:
outfile = self['output']+'_asn.fits'
output = self['output']
else:
outfile = output
# Delete the file if it exists.
if os.path.exists(outf... | python | def write(self, output=None):
"""
Write association table to a file.
"""
if not output:
outfile = self['output']+'_asn.fits'
output = self['output']
else:
outfile = output
# Delete the file if it exists.
if os.path.exists(outf... | [
"def",
"write",
"(",
"self",
",",
"output",
"=",
"None",
")",
":",
"if",
"not",
"output",
":",
"outfile",
"=",
"self",
"[",
"'output'",
"]",
"+",
"'_asn.fits'",
"output",
"=",
"self",
"[",
"'output'",
"]",
"else",
":",
"outfile",
"=",
"output",
"# De... | Write association table to a file. | [
"Write",
"association",
"table",
"to",
"a",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/asnutil.py#L353-L429 | train |
spacetelescope/stsci.tools | lib/stsci/tools/asnutil.py | ShiftFile.readShiftFile | def readShiftFile(self, filename):
"""
Reads a shift file from disk and populates a dictionary.
"""
order = []
fshift = open(filename,'r')
flines = fshift.readlines()
fshift.close()
common = [f.strip('#').strip() for f in flines if f.startswith('#')]
... | python | def readShiftFile(self, filename):
"""
Reads a shift file from disk and populates a dictionary.
"""
order = []
fshift = open(filename,'r')
flines = fshift.readlines()
fshift.close()
common = [f.strip('#').strip() for f in flines if f.startswith('#')]
... | [
"def",
"readShiftFile",
"(",
"self",
",",
"filename",
")",
":",
"order",
"=",
"[",
"]",
"fshift",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"flines",
"=",
"fshift",
".",
"readlines",
"(",
")",
"fshift",
".",
"close",
"(",
")",
"common",
"=",
"... | Reads a shift file from disk and populates a dictionary. | [
"Reads",
"a",
"shift",
"file",
"from",
"disk",
"and",
"populates",
"a",
"dictionary",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/asnutil.py#L616-L675 | train |
spacetelescope/stsci.tools | lib/stsci/tools/asnutil.py | ShiftFile.writeShiftFile | def writeShiftFile(self, filename="shifts.txt"):
"""
Writes a shift file object to a file on disk using the convention for shift file format.
"""
lines = ['# frame: ', self['frame'], '\n',
'# refimage: ', self['refimage'], '\n',
'# form: ', self['form'],... | python | def writeShiftFile(self, filename="shifts.txt"):
"""
Writes a shift file object to a file on disk using the convention for shift file format.
"""
lines = ['# frame: ', self['frame'], '\n',
'# refimage: ', self['refimage'], '\n',
'# form: ', self['form'],... | [
"def",
"writeShiftFile",
"(",
"self",
",",
"filename",
"=",
"\"shifts.txt\"",
")",
":",
"lines",
"=",
"[",
"'# frame: '",
",",
"self",
"[",
"'frame'",
"]",
",",
"'\\n'",
",",
"'# refimage: '",
",",
"self",
"[",
"'refimage'",
"]",
",",
"'\\n'",
",",
"'# f... | Writes a shift file object to a file on disk using the convention for shift file format. | [
"Writes",
"a",
"shift",
"file",
"object",
"to",
"a",
"file",
"on",
"disk",
"using",
"the",
"convention",
"for",
"shift",
"file",
"format",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/asnutil.py#L686-L704 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.