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/parseinput.py | countinputs | def countinputs(inputlist):
"""
Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by th... | python | def countinputs(inputlist):
"""
Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by th... | [
"def",
"countinputs",
"(",
"inputlist",
")",
":",
"# Initialize return values",
"numInputs",
"=",
"0",
"numASNfiles",
"=",
"0",
"# User irafglob to count the number of inputfiles",
"files",
"=",
"irafglob",
"(",
"inputlist",
",",
"atfile",
"=",
"None",
")",
"# Use the... | Determine the number of inputfiles provided by the user and the
number of those files that are association tables
Parameters
----------
inputlist : string
the user input
Returns
-------
numInputs: int
number of inputs provided by the user
numASNfiles: int
numb... | [
"Determine",
"the",
"number",
"of",
"inputfiles",
"provided",
"by",
"the",
"user",
"and",
"the",
"number",
"of",
"those",
"files",
"that",
"are",
"association",
"tables"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/parseinput.py#L185-L218 | train |
adeel/timed | timed/client.py | summary | def summary(logfile, time_format):
"show a summary of all projects"
def output(summary):
width = max([len(p[0]) for p in summary]) + 3
print '\n'.join([
"%s%s%s" % (p[0], ' ' * (width - len(p[0])),
colored(minutes_to_txt(p[1]), 'red')) for p in summary])
output(server.summarize(read(logfil... | python | def summary(logfile, time_format):
"show a summary of all projects"
def output(summary):
width = max([len(p[0]) for p in summary]) + 3
print '\n'.join([
"%s%s%s" % (p[0], ' ' * (width - len(p[0])),
colored(minutes_to_txt(p[1]), 'red')) for p in summary])
output(server.summarize(read(logfil... | [
"def",
"summary",
"(",
"logfile",
",",
"time_format",
")",
":",
"def",
"output",
"(",
"summary",
")",
":",
"width",
"=",
"max",
"(",
"[",
"len",
"(",
"p",
"[",
"0",
"]",
")",
"for",
"p",
"in",
"summary",
"]",
")",
"+",
"3",
"print",
"'\\n'",
".... | show a summary of all projects | [
"show",
"a",
"summary",
"of",
"all",
"projects"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L21-L30 | train |
adeel/timed | timed/client.py | status | def status(logfile, time_format):
"show current status"
try:
r = read(logfile, time_format)[-1]
if r[1][1]:
return summary(logfile, time_format)
else:
print "working on %s" % colored(r[0], attrs=['bold'])
print " since %s" % colored(
server.date_to_txt(r[1][0], time_format... | python | def status(logfile, time_format):
"show current status"
try:
r = read(logfile, time_format)[-1]
if r[1][1]:
return summary(logfile, time_format)
else:
print "working on %s" % colored(r[0], attrs=['bold'])
print " since %s" % colored(
server.date_to_txt(r[1][0], time_format... | [
"def",
"status",
"(",
"logfile",
",",
"time_format",
")",
":",
"try",
":",
"r",
"=",
"read",
"(",
"logfile",
",",
"time_format",
")",
"[",
"-",
"1",
"]",
"if",
"r",
"[",
"1",
"]",
"[",
"1",
"]",
":",
"return",
"summary",
"(",
"logfile",
",",
"t... | show current status | [
"show",
"current",
"status"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L34-L49 | train |
adeel/timed | timed/client.py | start | def start(project, logfile, time_format):
"start tracking for <project>"
records = read(logfile, time_format)
if records and not records[-1][1][1]:
print "error: there is a project already active"
return
write(server.start(project, records), logfile, time_format)
print "starting work on %s" % color... | python | def start(project, logfile, time_format):
"start tracking for <project>"
records = read(logfile, time_format)
if records and not records[-1][1][1]:
print "error: there is a project already active"
return
write(server.start(project, records), logfile, time_format)
print "starting work on %s" % color... | [
"def",
"start",
"(",
"project",
",",
"logfile",
",",
"time_format",
")",
":",
"records",
"=",
"read",
"(",
"logfile",
",",
"time_format",
")",
"if",
"records",
"and",
"not",
"records",
"[",
"-",
"1",
"]",
"[",
"1",
"]",
"[",
"1",
"]",
":",
"print",... | start tracking for <project> | [
"start",
"tracking",
"for",
"<project",
">"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L52-L63 | train |
adeel/timed | timed/client.py | stop | def stop(logfile, time_format):
"stop tracking for the active project"
def save_and_output(records):
records = server.stop(records)
write(records, logfile, time_format)
def output(r):
print "worked on %s" % colored(r[0], attrs=['bold'])
print " from %s" % colored(
server.date_t... | python | def stop(logfile, time_format):
"stop tracking for the active project"
def save_and_output(records):
records = server.stop(records)
write(records, logfile, time_format)
def output(r):
print "worked on %s" % colored(r[0], attrs=['bold'])
print " from %s" % colored(
server.date_t... | [
"def",
"stop",
"(",
"logfile",
",",
"time_format",
")",
":",
"def",
"save_and_output",
"(",
"records",
")",
":",
"records",
"=",
"server",
".",
"stop",
"(",
"records",
")",
"write",
"(",
"records",
",",
"logfile",
",",
"time_format",
")",
"def",
"output"... | stop tracking for the active project | [
"stop",
"tracking",
"for",
"the",
"active",
"project"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L66-L84 | train |
adeel/timed | timed/client.py | parse | def parse(logfile, time_format):
"parses a stream with text formatted as a Timed logfile and shows a summary"
records = [server.record_from_txt(line, only_elapsed=True,
time_format=time_format) for line in sys.stdin.readlines()]
# TODO: make this code better.
def output(summary):
width = max([len(p[0]... | python | def parse(logfile, time_format):
"parses a stream with text formatted as a Timed logfile and shows a summary"
records = [server.record_from_txt(line, only_elapsed=True,
time_format=time_format) for line in sys.stdin.readlines()]
# TODO: make this code better.
def output(summary):
width = max([len(p[0]... | [
"def",
"parse",
"(",
"logfile",
",",
"time_format",
")",
":",
"records",
"=",
"[",
"server",
".",
"record_from_txt",
"(",
"line",
",",
"only_elapsed",
"=",
"True",
",",
"time_format",
"=",
"time_format",
")",
"for",
"line",
"in",
"sys",
".",
"stdin",
"."... | parses a stream with text formatted as a Timed logfile and shows a summary | [
"parses",
"a",
"stream",
"with",
"text",
"formatted",
"as",
"a",
"Timed",
"logfile",
"and",
"shows",
"a",
"summary"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L87-L100 | train |
adeel/timed | timed/client.py | projects | def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print '\n'.join(server.list_projects(read(logfile, time_format))) | python | def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print '\n'.join(server.list_projects(read(logfile, time_format))) | [
"def",
"projects",
"(",
"logfile",
",",
"time_format",
")",
":",
"print",
"'\\n'",
".",
"join",
"(",
"server",
".",
"list_projects",
"(",
"read",
"(",
"logfile",
",",
"time_format",
")",
")",
")"
] | prints a newline-separated list of all projects | [
"prints",
"a",
"newline",
"-",
"separated",
"list",
"of",
"all",
"projects"
] | 9f85e004de491cd4863d31b09991a1e2591b1b66 | https://github.com/adeel/timed/blob/9f85e004de491cd4863d31b09991a1e2591b1b66/timed/client.py#L103-L106 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getLTime | def getLTime():
"""Returns a formatted string with the current local time."""
_ltime = _time.localtime(_time.time())
tlm_str = _time.strftime('%H:%M:%S (%d/%m/%Y)', _ltime)
return tlm_str | python | def getLTime():
"""Returns a formatted string with the current local time."""
_ltime = _time.localtime(_time.time())
tlm_str = _time.strftime('%H:%M:%S (%d/%m/%Y)', _ltime)
return tlm_str | [
"def",
"getLTime",
"(",
")",
":",
"_ltime",
"=",
"_time",
".",
"localtime",
"(",
"_time",
".",
"time",
"(",
")",
")",
"tlm_str",
"=",
"_time",
".",
"strftime",
"(",
"'%H:%M:%S (%d/%m/%Y)'",
",",
"_ltime",
")",
"return",
"tlm_str"
] | Returns a formatted string with the current local time. | [
"Returns",
"a",
"formatted",
"string",
"with",
"the",
"current",
"local",
"time",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L154-L159 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getDate | def getDate():
"""Returns a formatted string with the current date."""
_ltime = _time.localtime(_time.time())
date_str = _time.strftime('%Y-%m-%dT%H:%M:%S',_ltime)
return date_str | python | def getDate():
"""Returns a formatted string with the current date."""
_ltime = _time.localtime(_time.time())
date_str = _time.strftime('%Y-%m-%dT%H:%M:%S',_ltime)
return date_str | [
"def",
"getDate",
"(",
")",
":",
"_ltime",
"=",
"_time",
".",
"localtime",
"(",
"_time",
".",
"time",
"(",
")",
")",
"date_str",
"=",
"_time",
".",
"strftime",
"(",
"'%Y-%m-%dT%H:%M:%S'",
",",
"_ltime",
")",
"return",
"date_str"
] | Returns a formatted string with the current date. | [
"Returns",
"a",
"formatted",
"string",
"with",
"the",
"current",
"date",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L162-L168 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | convertDate | def convertDate(date):
"""Convert DATE string into a decimal year."""
d, t = date.split('T')
return decimal_date(d, timeobs=t) | python | def convertDate(date):
"""Convert DATE string into a decimal year."""
d, t = date.split('T')
return decimal_date(d, timeobs=t) | [
"def",
"convertDate",
"(",
"date",
")",
":",
"d",
",",
"t",
"=",
"date",
".",
"split",
"(",
"'T'",
")",
"return",
"decimal_date",
"(",
"d",
",",
"timeobs",
"=",
"t",
")"
] | Convert DATE string into a decimal year. | [
"Convert",
"DATE",
"string",
"into",
"a",
"decimal",
"year",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L171-L175 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | decimal_date | def decimal_date(dateobs, timeobs=None):
"""Convert DATE-OBS (and optional TIME-OBS) into a decimal year."""
year, month, day = dateobs.split('-')
if timeobs is not None:
hr, min, sec = timeobs.split(':')
else:
hr, min, sec = 0, 0, 0
rdate = datetime.datetime(int(year), int(month),... | python | def decimal_date(dateobs, timeobs=None):
"""Convert DATE-OBS (and optional TIME-OBS) into a decimal year."""
year, month, day = dateobs.split('-')
if timeobs is not None:
hr, min, sec = timeobs.split(':')
else:
hr, min, sec = 0, 0, 0
rdate = datetime.datetime(int(year), int(month),... | [
"def",
"decimal_date",
"(",
"dateobs",
",",
"timeobs",
"=",
"None",
")",
":",
"year",
",",
"month",
",",
"day",
"=",
"dateobs",
".",
"split",
"(",
"'-'",
")",
"if",
"timeobs",
"is",
"not",
"None",
":",
"hr",
",",
"min",
",",
"sec",
"=",
"timeobs",
... | Convert DATE-OBS (and optional TIME-OBS) into a decimal year. | [
"Convert",
"DATE",
"-",
"OBS",
"(",
"and",
"optional",
"TIME",
"-",
"OBS",
")",
"into",
"a",
"decimal",
"year",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L178-L193 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | interpretDQvalue | def interpretDQvalue(input):
"""
Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024]
"""
nbits = 16
# We will only support integer values up to 2**128
for iexp in [16, 32, 64, 128]:
... | python | def interpretDQvalue(input):
"""
Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024]
"""
nbits = 16
# We will only support integer values up to 2**128
for iexp in [16, 32, 64, 128]:
... | [
"def",
"interpretDQvalue",
"(",
"input",
")",
":",
"nbits",
"=",
"16",
"# We will only support integer values up to 2**128",
"for",
"iexp",
"in",
"[",
"16",
",",
"32",
",",
"64",
",",
"128",
"]",
":",
"# Find out whether the input value is less than 2**iexp",
"if",
... | Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the bit value 1027 would return [1, 2, 1024] | [
"Converts",
"an",
"integer",
"input",
"into",
"its",
"component",
"bit",
"values",
"as",
"a",
"list",
"of",
"power",
"of",
"2",
"integers",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L196-L229 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | isFits | def isFits(input):
"""
Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
... | python | def isFits(input):
"""
Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
... | [
"def",
"isFits",
"(",
"input",
")",
":",
"isfits",
"=",
"False",
"fitstype",
"=",
"None",
"names",
"=",
"[",
"'fits'",
",",
"'fit'",
",",
"'FITS'",
",",
"'FIT'",
"]",
"#determine if input is a fits file based on extension",
"# Only check type of FITS file if filename ... | Returns
--------
isFits: tuple
An ``(isfits, fitstype)`` tuple. The values of ``isfits`` and
``fitstype`` are specified as:
- ``isfits``: True|False
- ``fitstype``: if True, one of 'waiver', 'mef', 'simple'; if False, None
Notes
-----
Input images which do not ha... | [
"Returns",
"--------",
"isFits",
":",
"tuple",
"An",
"(",
"isfits",
"fitstype",
")",
"tuple",
".",
"The",
"values",
"of",
"isfits",
"and",
"fitstype",
"are",
"specified",
"as",
":"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L232-L289 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | verifyWriteMode | def verifyWriteMode(files):
"""
Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out... | python | def verifyWriteMode(files):
"""
Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out... | [
"def",
"verifyWriteMode",
"(",
"files",
")",
":",
"# Start by insuring that input is a list of filenames,",
"# if only a single filename has been given as input,",
"# convert it to a list with len == 1.",
"if",
"not",
"isinstance",
"(",
"files",
",",
"list",
")",
":",
"files",
... | Checks whether files are writable. It is up to the calling routine to raise
an Exception, if desired.
This function returns True, if all files are writable and False, if any are
not writable. In addition, for all files found to not be writable, it will
print out the list of names of affected files. | [
"Checks",
"whether",
"files",
"are",
"writable",
".",
"It",
"is",
"up",
"to",
"the",
"calling",
"routine",
"to",
"raise",
"an",
"Exception",
"if",
"desired",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L308-L343 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getFilterNames | def getFilterNames(header, filternames=None):
"""
Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keywor... | python | def getFilterNames(header, filternames=None):
"""
Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keywor... | [
"def",
"getFilterNames",
"(",
"header",
",",
"filternames",
"=",
"None",
")",
":",
"# Define the keyword names for each instrument",
"_keydict",
"=",
"{",
"'ACS'",
":",
"[",
"'FILTER1'",
",",
"'FILTER2'",
"]",
",",
"'WFPC2'",
":",
"[",
"'FILTNAM1'",
",",
"'FILTN... | Returns a comma-separated string of filter names extracted from the input
header (PyFITS header object). This function has been hard-coded to
support the following instruments:
ACS, WFPC2, STIS
This function relies on the 'INSTRUME' keyword to define what instrument
has been used to generate ... | [
"Returns",
"a",
"comma",
"-",
"separated",
"string",
"of",
"filter",
"names",
"extracted",
"from",
"the",
"input",
"header",
"(",
"PyFITS",
"header",
"object",
")",
".",
"This",
"function",
"has",
"been",
"hard",
"-",
"coded",
"to",
"support",
"the",
"foll... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L346-L397 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | buildNewRootname | def buildNewRootname(filename, extn=None, extlist=None):
"""
Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename.
"""
# Search known suffixes to r... | python | def buildNewRootname(filename, extn=None, extlist=None):
"""
Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename.
"""
# Search known suffixes to r... | [
"def",
"buildNewRootname",
"(",
"filename",
",",
"extn",
"=",
"None",
",",
"extlist",
"=",
"None",
")",
":",
"# Search known suffixes to replace ('_crj.fits',...)",
"_extlist",
"=",
"copy",
".",
"deepcopy",
"(",
"EXTLIST",
")",
"# Also, add a default where '_dth.fits' r... | Build rootname for a new file.
Use 'extn' for new filename if given, does NOT append a suffix/extension at
all.
Does NOT check to see if it exists already. Will ALWAYS return a new
filename. | [
"Build",
"rootname",
"for",
"a",
"new",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L400-L436 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | buildRootname | def buildRootname(filename, ext=None):
"""
Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth... | python | def buildRootname(filename, ext=None):
"""
Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth... | [
"def",
"buildRootname",
"(",
"filename",
",",
"ext",
"=",
"None",
")",
":",
"if",
"filename",
"in",
"[",
"''",
",",
"' '",
",",
"None",
"]",
":",
"return",
"None",
"fpath",
",",
"fname",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filename",
")",
... | Build a new rootname for an existing file and given extension.
Any user supplied extensions to use for searching for file need to be
provided as a list of extensions.
Examples
--------
::
>>> rootname = buildRootname(filename, ext=['_dth.fits']) # doctest: +SKIP | [
"Build",
"a",
"new",
"rootname",
"for",
"an",
"existing",
"file",
"and",
"given",
"extension",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L439-L530 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getKeyword | def getKeyword(filename, keyword, default=None, handle=None):
"""
General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string.
"""
# Insure that there is at least 1 extension specified...
if filename.find('[') < 0:
... | python | def getKeyword(filename, keyword, default=None, handle=None):
"""
General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string.
"""
# Insure that there is at least 1 extension specified...
if filename.find('[') < 0:
... | [
"def",
"getKeyword",
"(",
"filename",
",",
"keyword",
",",
"default",
"=",
"None",
",",
"handle",
"=",
"None",
")",
":",
"# Insure that there is at least 1 extension specified...",
"if",
"filename",
".",
"find",
"(",
"'['",
")",
"<",
"0",
":",
"filename",
"+="... | General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string. | [
"General",
"write",
"-",
"safe",
"method",
"for",
"returning",
"a",
"keyword",
"value",
"from",
"the",
"header",
"of",
"a",
"IRAF",
"recognized",
"image",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L533-L598 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getHeader | def getHeader(filename, handle=None):
"""
Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification.
"""
_fname, _extn = parseFilename(filename)
# Allow the user to provide an already opened PyFITS object
# to derive the header from...
#
... | python | def getHeader(filename, handle=None):
"""
Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification.
"""
_fname, _extn = parseFilename(filename)
# Allow the user to provide an already opened PyFITS object
# to derive the header from...
#
... | [
"def",
"getHeader",
"(",
"filename",
",",
"handle",
"=",
"None",
")",
":",
"_fname",
",",
"_extn",
"=",
"parseFilename",
"(",
"filename",
")",
"# Allow the user to provide an already opened PyFITS object",
"# to derive the header from...",
"#",
"if",
"not",
"handle",
... | Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification. | [
"Return",
"a",
"copy",
"of",
"the",
"PRIMARY",
"header",
"along",
"with",
"any",
"group",
"/",
"extension",
"header",
"for",
"this",
"filename",
"specification",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L601-L640 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | updateKeyword | def updateKeyword(filename, key, value,show=yes):
"""Add/update keyword to header with given value."""
_fname, _extn = parseFilename(filename)
# Open image whether it is FITS or GEIS
_fimg = openImage(_fname, mode='update')
# Address the correct header
_hdr = getExtn(_fimg, _extn).header
... | python | def updateKeyword(filename, key, value,show=yes):
"""Add/update keyword to header with given value."""
_fname, _extn = parseFilename(filename)
# Open image whether it is FITS or GEIS
_fimg = openImage(_fname, mode='update')
# Address the correct header
_hdr = getExtn(_fimg, _extn).header
... | [
"def",
"updateKeyword",
"(",
"filename",
",",
"key",
",",
"value",
",",
"show",
"=",
"yes",
")",
":",
"_fname",
",",
"_extn",
"=",
"parseFilename",
"(",
"filename",
")",
"# Open image whether it is FITS or GEIS",
"_fimg",
"=",
"openImage",
"(",
"_fname",
",",
... | Add/update keyword to header with given value. | [
"Add",
"/",
"update",
"keyword",
"to",
"header",
"with",
"given",
"value",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L643-L664 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | buildFITSName | def buildFITSName(geisname):
"""Build a new FITS filename for a GEIS input image."""
# User wants to make a FITS copy and update it...
_indx = geisname.rfind('.')
_fitsname = geisname[:_indx] + '_' + geisname[_indx + 1:-1] + 'h.fits'
return _fitsname | python | def buildFITSName(geisname):
"""Build a new FITS filename for a GEIS input image."""
# User wants to make a FITS copy and update it...
_indx = geisname.rfind('.')
_fitsname = geisname[:_indx] + '_' + geisname[_indx + 1:-1] + 'h.fits'
return _fitsname | [
"def",
"buildFITSName",
"(",
"geisname",
")",
":",
"# User wants to make a FITS copy and update it...",
"_indx",
"=",
"geisname",
".",
"rfind",
"(",
"'.'",
")",
"_fitsname",
"=",
"geisname",
"[",
":",
"_indx",
"]",
"+",
"'_'",
"+",
"geisname",
"[",
"_indx",
"+... | Build a new FITS filename for a GEIS input image. | [
"Build",
"a",
"new",
"FITS",
"filename",
"for",
"a",
"GEIS",
"input",
"image",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L667-L674 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | openImage | def openImage(filename, mode='readonly', memmap=False, writefits=True,
clobber=True, fitsname=None):
"""
Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
... | python | def openImage(filename, mode='readonly', memmap=False, writefits=True,
clobber=True, fitsname=None):
"""
Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
... | [
"def",
"openImage",
"(",
"filename",
",",
"mode",
"=",
"'readonly'",
",",
"memmap",
"=",
"False",
",",
"writefits",
"=",
"True",
",",
"clobber",
"=",
"True",
",",
"fitsname",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"filename",
",",
"fits... | Opens file and returns PyFITS object. Works on both FITS and GEIS
formatted images.
Notes
-----
If a GEIS or waivered FITS image is used as input, it will convert it to a
MEF object and only if ``writefits = True`` will write it out to a file. If
``fitsname = None``, the name used to write out... | [
"Opens",
"file",
"and",
"returns",
"PyFITS",
"object",
".",
"Works",
"on",
"both",
"FITS",
"and",
"GEIS",
"formatted",
"images",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L677-L823 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | parseFilename | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
"""
# Parse out any extension specified in filename
_indx = filename.find('[')
if _indx > 0:
# Read extension name provided
_fname = fil... | python | def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
"""
# Parse out any extension specified in filename
_indx = filename.find('[')
if _indx > 0:
# Read extension name provided
_fname = fil... | [
"def",
"parseFilename",
"(",
"filename",
")",
":",
"# Parse out any extension specified in filename",
"_indx",
"=",
"filename",
".",
"find",
"(",
"'['",
")",
"if",
"_indx",
">",
"0",
":",
"# Read extension name provided",
"_fname",
"=",
"filename",
"[",
":",
"_ind... | Parse out filename from any specified extensions.
Returns rootname and string version of extension name. | [
"Parse",
"out",
"filename",
"from",
"any",
"specified",
"extensions",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L826-L843 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | parseExtn | def parseExtn(extn=None):
"""
Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fit... | python | def parseExtn(extn=None):
"""
Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fit... | [
"def",
"parseExtn",
"(",
"extn",
"=",
"None",
")",
":",
"if",
"not",
"extn",
":",
"return",
"(",
"''",
",",
"0",
")",
"try",
":",
"lext",
"=",
"extn",
".",
"split",
"(",
"','",
")",
"except",
":",
"return",
"(",
"''",
",",
"1",
")",
"if",
"le... | Parse a string representing a qualified fits extension name as in the
output of `parseFilename` and return a tuple ``(str(extname),
int(extver))``, which can be passed to `astropy.io.fits` functions using
the 'ext' kw.
Default return is the first extension in a fits file.
Examples
--------
... | [
"Parse",
"a",
"string",
"representing",
"a",
"qualified",
"fits",
"extension",
"name",
"as",
"in",
"the",
"output",
"of",
"parseFilename",
"and",
"return",
"a",
"tuple",
"(",
"str",
"(",
"extname",
")",
"int",
"(",
"extver",
"))",
"which",
"can",
"be",
"... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L846-L882 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | countExtn | def countExtn(fimg, extname='SCI'):
"""
Return the number of 'extname' extensions, defaulting to counting the
number of SCI extensions.
"""
closefits = False
if isinstance(fimg, string_types):
fimg = fits.open(fimg)
closefits = True
n = 0
for e in fimg:
if 'extn... | python | def countExtn(fimg, extname='SCI'):
"""
Return the number of 'extname' extensions, defaulting to counting the
number of SCI extensions.
"""
closefits = False
if isinstance(fimg, string_types):
fimg = fits.open(fimg)
closefits = True
n = 0
for e in fimg:
if 'extn... | [
"def",
"countExtn",
"(",
"fimg",
",",
"extname",
"=",
"'SCI'",
")",
":",
"closefits",
"=",
"False",
"if",
"isinstance",
"(",
"fimg",
",",
"string_types",
")",
":",
"fimg",
"=",
"fits",
".",
"open",
"(",
"fimg",
")",
"closefits",
"=",
"True",
"n",
"="... | Return the number of 'extname' extensions, defaulting to counting the
number of SCI extensions. | [
"Return",
"the",
"number",
"of",
"extname",
"extensions",
"defaulting",
"to",
"counting",
"the",
"number",
"of",
"SCI",
"extensions",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L885-L904 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | getExtn | def getExtn(fimg, extn=None):
"""
Returns the PyFITS extension corresponding to extension specified in
filename.
Defaults to returning the first extension with data or the primary
extension, if none have data. If a non-existent extension has been
specified, it raises a `KeyError` exception.
... | python | def getExtn(fimg, extn=None):
"""
Returns the PyFITS extension corresponding to extension specified in
filename.
Defaults to returning the first extension with data or the primary
extension, if none have data. If a non-existent extension has been
specified, it raises a `KeyError` exception.
... | [
"def",
"getExtn",
"(",
"fimg",
",",
"extn",
"=",
"None",
")",
":",
"# If no extension is provided, search for first extension",
"# in FITS file with data associated with it.",
"if",
"extn",
"is",
"None",
":",
"# Set up default to point to PRIMARY extension.",
"_extn",
"=",
"f... | Returns the PyFITS extension corresponding to extension specified in
filename.
Defaults to returning the first extension with data or the primary
extension, if none have data. If a non-existent extension has been
specified, it raises a `KeyError` exception. | [
"Returns",
"the",
"PyFITS",
"extension",
"corresponding",
"to",
"extension",
"specified",
"in",
"filename",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L907-L992 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | findFile | def findFile(input):
"""Search a directory for full filename with optional path."""
# If no input name is provided, default to returning 'no'(FALSE)
if not input:
return no
# We use 'osfn' here to insure that any IRAF variables are
# expanded out before splitting out the path...
_fdir,... | python | def findFile(input):
"""Search a directory for full filename with optional path."""
# If no input name is provided, default to returning 'no'(FALSE)
if not input:
return no
# We use 'osfn' here to insure that any IRAF variables are
# expanded out before splitting out the path...
_fdir,... | [
"def",
"findFile",
"(",
"input",
")",
":",
"# If no input name is provided, default to returning 'no'(FALSE)",
"if",
"not",
"input",
":",
"return",
"no",
"# We use 'osfn' here to insure that any IRAF variables are",
"# expanded out before splitting out the path...",
"_fdir",
",",
"... | Search a directory for full filename with optional path. | [
"Search",
"a",
"directory",
"for",
"full",
"filename",
"with",
"optional",
"path",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1001-L1058 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | checkFileExists | def checkFileExists(filename, directory=None):
"""
Checks to see if file specified exists in current or specified directory.
Default is current directory. Returns 1 if it exists, 0 if not found.
"""
if directory is not None:
fname = os.path.join(directory,filename)
else:
fname... | python | def checkFileExists(filename, directory=None):
"""
Checks to see if file specified exists in current or specified directory.
Default is current directory. Returns 1 if it exists, 0 if not found.
"""
if directory is not None:
fname = os.path.join(directory,filename)
else:
fname... | [
"def",
"checkFileExists",
"(",
"filename",
",",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"is",
"not",
"None",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filename",
")",
"else",
":",
"fname",
"=",
"filename"... | Checks to see if file specified exists in current or specified directory.
Default is current directory. Returns 1 if it exists, 0 if not found. | [
"Checks",
"to",
"see",
"if",
"file",
"specified",
"exists",
"in",
"current",
"or",
"specified",
"directory",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1061-L1073 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | copyFile | def copyFile(input, output, replace=None):
"""Copy a file whole from input to output."""
_found = findFile(output)
if not _found or (_found and replace):
shutil.copy2(input, output) | python | def copyFile(input, output, replace=None):
"""Copy a file whole from input to output."""
_found = findFile(output)
if not _found or (_found and replace):
shutil.copy2(input, output) | [
"def",
"copyFile",
"(",
"input",
",",
"output",
",",
"replace",
"=",
"None",
")",
":",
"_found",
"=",
"findFile",
"(",
"output",
")",
"if",
"not",
"_found",
"or",
"(",
"_found",
"and",
"replace",
")",
":",
"shutil",
".",
"copy2",
"(",
"input",
",",
... | Copy a file whole from input to output. | [
"Copy",
"a",
"file",
"whole",
"from",
"input",
"to",
"output",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1076-L1081 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | removeFile | def removeFile(inlist):
"""
Utility function for deleting a list of files or a single file.
This function will automatically delete both files of a GEIS image, just
like 'iraf.imdelete'.
"""
if not isinstance(inlist, string_types):
# We do have a list, so delete all filenames in list.
... | python | def removeFile(inlist):
"""
Utility function for deleting a list of files or a single file.
This function will automatically delete both files of a GEIS image, just
like 'iraf.imdelete'.
"""
if not isinstance(inlist, string_types):
# We do have a list, so delete all filenames in list.
... | [
"def",
"removeFile",
"(",
"inlist",
")",
":",
"if",
"not",
"isinstance",
"(",
"inlist",
",",
"string_types",
")",
":",
"# We do have a list, so delete all filenames in list.",
"# Treat like a list of full filenames",
"_ldir",
"=",
"os",
".",
"listdir",
"(",
"'.'",
")"... | Utility function for deleting a list of files or a single file.
This function will automatically delete both files of a GEIS image, just
like 'iraf.imdelete'. | [
"Utility",
"function",
"for",
"deleting",
"a",
"list",
"of",
"files",
"or",
"a",
"single",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1111-L1138 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | findKeywordExtn | def findKeywordExtn(ft, keyword, value=None):
"""
This function will return the index of the extension in a multi-extension
FITS file which contains the desired keyword with the given value.
"""
i = 0
extnum = -1
# Search through all the extensions in the FITS object
for chip in ft:
... | python | def findKeywordExtn(ft, keyword, value=None):
"""
This function will return the index of the extension in a multi-extension
FITS file which contains the desired keyword with the given value.
"""
i = 0
extnum = -1
# Search through all the extensions in the FITS object
for chip in ft:
... | [
"def",
"findKeywordExtn",
"(",
"ft",
",",
"keyword",
",",
"value",
"=",
"None",
")",
":",
"i",
"=",
"0",
"extnum",
"=",
"-",
"1",
"# Search through all the extensions in the FITS object",
"for",
"chip",
"in",
"ft",
":",
"hdr",
"=",
"chip",
".",
"header",
"... | This function will return the index of the extension in a multi-extension
FITS file which contains the desired keyword with the given value. | [
"This",
"function",
"will",
"return",
"the",
"index",
"of",
"the",
"extension",
"in",
"a",
"multi",
"-",
"extension",
"FITS",
"file",
"which",
"contains",
"the",
"desired",
"keyword",
"with",
"the",
"given",
"value",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1141-L1166 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | findExtname | def findExtname(fimg, extname, extver=None):
"""
Returns the list number of the extension corresponding to EXTNAME given.
"""
i = 0
extnum = None
for chip in fimg:
hdr = chip.header
if 'EXTNAME' in hdr:
if hdr['EXTNAME'].strip() == extname.upper():
if... | python | def findExtname(fimg, extname, extver=None):
"""
Returns the list number of the extension corresponding to EXTNAME given.
"""
i = 0
extnum = None
for chip in fimg:
hdr = chip.header
if 'EXTNAME' in hdr:
if hdr['EXTNAME'].strip() == extname.upper():
if... | [
"def",
"findExtname",
"(",
"fimg",
",",
"extname",
",",
"extver",
"=",
"None",
")",
":",
"i",
"=",
"0",
"extnum",
"=",
"None",
"for",
"chip",
"in",
"fimg",
":",
"hdr",
"=",
"chip",
".",
"header",
"if",
"'EXTNAME'",
"in",
"hdr",
":",
"if",
"hdr",
... | Returns the list number of the extension corresponding to EXTNAME given. | [
"Returns",
"the",
"list",
"number",
"of",
"the",
"extension",
"corresponding",
"to",
"EXTNAME",
"given",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1169-L1184 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | rAsciiLine | def rAsciiLine(ifile):
"""Returns the next non-blank line in an ASCII file."""
_line = ifile.readline().strip()
while len(_line) == 0:
_line = ifile.readline().strip()
return _line | python | def rAsciiLine(ifile):
"""Returns the next non-blank line in an ASCII file."""
_line = ifile.readline().strip()
while len(_line) == 0:
_line = ifile.readline().strip()
return _line | [
"def",
"rAsciiLine",
"(",
"ifile",
")",
":",
"_line",
"=",
"ifile",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"while",
"len",
"(",
"_line",
")",
"==",
"0",
":",
"_line",
"=",
"ifile",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
... | Returns the next non-blank line in an ASCII file. | [
"Returns",
"the",
"next",
"non",
"-",
"blank",
"line",
"in",
"an",
"ASCII",
"file",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1187-L1193 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | listVars | def listVars(prefix="", equals="\t= ", **kw):
"""List IRAF variables."""
keylist = getVarList()
if len(keylist) == 0:
print('No IRAF variables defined')
else:
keylist.sort()
for word in keylist:
print("%s%s%s%s" % (prefix, word, equals, envget(word))) | python | def listVars(prefix="", equals="\t= ", **kw):
"""List IRAF variables."""
keylist = getVarList()
if len(keylist) == 0:
print('No IRAF variables defined')
else:
keylist.sort()
for word in keylist:
print("%s%s%s%s" % (prefix, word, equals, envget(word))) | [
"def",
"listVars",
"(",
"prefix",
"=",
"\"\"",
",",
"equals",
"=",
"\"\\t= \"",
",",
"*",
"*",
"kw",
")",
":",
"keylist",
"=",
"getVarList",
"(",
")",
"if",
"len",
"(",
"keylist",
")",
"==",
"0",
":",
"print",
"(",
"'No IRAF variables defined'",
")",
... | List IRAF variables. | [
"List",
"IRAF",
"variables",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1279-L1288 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | untranslateName | def untranslateName(s):
"""Undo Python conversion of CL parameter or variable name."""
s = s.replace('DOT', '.')
s = s.replace('DOLLAR', '$')
# delete 'PY' at start of name components
if s[:2] == 'PY': s = s[2:]
s = s.replace('.PY', '.')
return s | python | def untranslateName(s):
"""Undo Python conversion of CL parameter or variable name."""
s = s.replace('DOT', '.')
s = s.replace('DOLLAR', '$')
# delete 'PY' at start of name components
if s[:2] == 'PY': s = s[2:]
s = s.replace('.PY', '.')
return s | [
"def",
"untranslateName",
"(",
"s",
")",
":",
"s",
"=",
"s",
".",
"replace",
"(",
"'DOT'",
",",
"'.'",
")",
"s",
"=",
"s",
".",
"replace",
"(",
"'DOLLAR'",
",",
"'$'",
")",
"# delete 'PY' at start of name components",
"if",
"s",
"[",
":",
"2",
"]",
"... | Undo Python conversion of CL parameter or variable name. | [
"Undo",
"Python",
"conversion",
"of",
"CL",
"parameter",
"or",
"variable",
"name",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1291-L1299 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | envget | def envget(var, default=None):
"""Get value of IRAF or OS environment variable."""
if 'pyraf' in sys.modules:
#ONLY if pyraf is already loaded, import iraf into the namespace
from pyraf import iraf
else:
# else set iraf to None so it knows to not use iraf's environment
iraf ... | python | def envget(var, default=None):
"""Get value of IRAF or OS environment variable."""
if 'pyraf' in sys.modules:
#ONLY if pyraf is already loaded, import iraf into the namespace
from pyraf import iraf
else:
# else set iraf to None so it knows to not use iraf's environment
iraf ... | [
"def",
"envget",
"(",
"var",
",",
"default",
"=",
"None",
")",
":",
"if",
"'pyraf'",
"in",
"sys",
".",
"modules",
":",
"#ONLY if pyraf is already loaded, import iraf into the namespace",
"from",
"pyraf",
"import",
"iraf",
"else",
":",
"# else set iraf to None so it kn... | Get value of IRAF or OS environment variable. | [
"Get",
"value",
"of",
"IRAF",
"or",
"OS",
"environment",
"variable",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1302-L1333 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | osfn | def osfn(filename):
"""Convert IRAF virtual path name to OS pathname."""
# Try to emulate the CL version closely:
#
# - expands IRAF virtual file names
# - strips blanks around path components
# - if no slashes or relative paths, return relative pathname
# - otherwise return absolute pathna... | python | def osfn(filename):
"""Convert IRAF virtual path name to OS pathname."""
# Try to emulate the CL version closely:
#
# - expands IRAF virtual file names
# - strips blanks around path components
# - if no slashes or relative paths, return relative pathname
# - otherwise return absolute pathna... | [
"def",
"osfn",
"(",
"filename",
")",
":",
"# Try to emulate the CL version closely:",
"#",
"# - expands IRAF virtual file names",
"# - strips blanks around path components",
"# - if no slashes or relative paths, return relative pathname",
"# - otherwise return absolute pathname",
"if",
"fi... | Convert IRAF virtual path name to OS pathname. | [
"Convert",
"IRAF",
"virtual",
"path",
"name",
"to",
"OS",
"pathname",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1336-L1361 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | defvar | def defvar(varname):
"""Returns true if CL variable is defined."""
if 'pyraf' in sys.modules:
#ONLY if pyraf is already loaded, import iraf into the namespace
from pyraf import iraf
else:
# else set iraf to None so it knows to not use iraf's environment
iraf = None
if i... | python | def defvar(varname):
"""Returns true if CL variable is defined."""
if 'pyraf' in sys.modules:
#ONLY if pyraf is already loaded, import iraf into the namespace
from pyraf import iraf
else:
# else set iraf to None so it knows to not use iraf's environment
iraf = None
if i... | [
"def",
"defvar",
"(",
"varname",
")",
":",
"if",
"'pyraf'",
"in",
"sys",
".",
"modules",
":",
"#ONLY if pyraf is already loaded, import iraf into the namespace",
"from",
"pyraf",
"import",
"iraf",
"else",
":",
"# else set iraf to None so it knows to not use iraf's environment... | Returns true if CL variable is defined. | [
"Returns",
"true",
"if",
"CL",
"variable",
"is",
"defined",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1364-L1378 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | set | def set(*args, **kw):
"""Set IRAF environment variables."""
if len(args) == 0:
if len(kw) != 0:
# normal case is only keyword,value pairs
for keyword, value in kw.items():
keyword = untranslateName(keyword)
svalue = str(value)
_var... | python | def set(*args, **kw):
"""Set IRAF environment variables."""
if len(args) == 0:
if len(kw) != 0:
# normal case is only keyword,value pairs
for keyword, value in kw.items():
keyword = untranslateName(keyword)
svalue = str(value)
_var... | [
"def",
"set",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"if",
"len",
"(",
"kw",
")",
"!=",
"0",
":",
"# normal case is only keyword,value pairs",
"for",
"keyword",
",",
"value",
"in",
"kw",
".",... | Set IRAF environment variables. | [
"Set",
"IRAF",
"environment",
"variables",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1388-L1412 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | show | def show(*args, **kw):
"""Print value of IRAF or OS environment variables."""
if len(kw):
raise TypeError('unexpected keyword argument: %r' % list(kw))
if args:
for arg in args:
print(envget(arg))
else:
# print them all
listVars(prefix=" ", equals="=") | python | def show(*args, **kw):
"""Print value of IRAF or OS environment variables."""
if len(kw):
raise TypeError('unexpected keyword argument: %r' % list(kw))
if args:
for arg in args:
print(envget(arg))
else:
# print them all
listVars(prefix=" ", equals="=") | [
"def",
"show",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"kw",
")",
":",
"raise",
"TypeError",
"(",
"'unexpected keyword argument: %r'",
"%",
"list",
"(",
"kw",
")",
")",
"if",
"args",
":",
"for",
"arg",
"in",
"args",
":",
... | Print value of IRAF or OS environment variables. | [
"Print",
"value",
"of",
"IRAF",
"or",
"OS",
"environment",
"variables",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1419-L1430 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | unset | def unset(*args, **kw):
"""
Unset IRAF environment variables.
This is not a standard IRAF task, but it is obviously useful. It makes the
resulting variables undefined. It silently ignores variables that are not
defined. It does not change the os environment variables.
"""
if len(kw) != ... | python | def unset(*args, **kw):
"""
Unset IRAF environment variables.
This is not a standard IRAF task, but it is obviously useful. It makes the
resulting variables undefined. It silently ignores variables that are not
defined. It does not change the os environment variables.
"""
if len(kw) != ... | [
"def",
"unset",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"kw",
")",
"!=",
"0",
":",
"raise",
"SyntaxError",
"(",
"\"unset requires a list of variable names\"",
")",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"in",
"_varDict... | Unset IRAF environment variables.
This is not a standard IRAF task, but it is obviously useful. It makes the
resulting variables undefined. It silently ignores variables that are not
defined. It does not change the os environment variables. | [
"Unset",
"IRAF",
"environment",
"variables",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1433-L1447 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | Expand | def Expand(instring, noerror=0):
"""
Expand a string with embedded IRAF variables (IRAF virtual filename).
Allows comma-separated lists. Also uses os.path.expanduser to replace '~'
symbols.
Set the noerror flag to silently replace undefined variables with just the
variable name or null (so Ex... | python | def Expand(instring, noerror=0):
"""
Expand a string with embedded IRAF variables (IRAF virtual filename).
Allows comma-separated lists. Also uses os.path.expanduser to replace '~'
symbols.
Set the noerror flag to silently replace undefined variables with just the
variable name or null (so Ex... | [
"def",
"Expand",
"(",
"instring",
",",
"noerror",
"=",
"0",
")",
":",
"# call _expand1 for each entry in comma-separated list",
"wordlist",
"=",
"instring",
".",
"split",
"(",
"\",\"",
")",
"outlist",
"=",
"[",
"]",
"for",
"word",
"in",
"wordlist",
":",
"outli... | Expand a string with embedded IRAF variables (IRAF virtual filename).
Allows comma-separated lists. Also uses os.path.expanduser to replace '~'
symbols.
Set the noerror flag to silently replace undefined variables with just the
variable name or null (so Expand('abc$def') = 'abcdef' and
Expand('(a... | [
"Expand",
"a",
"string",
"with",
"embedded",
"IRAF",
"variables",
"(",
"IRAF",
"virtual",
"filename",
")",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1478-L1496 | train |
spacetelescope/stsci.tools | lib/stsci/tools/fileutil.py | _expand1 | def _expand1(instring, noerror):
"""Expand a string with embedded IRAF variables (IRAF virtual filename)."""
# first expand names in parentheses
# note this works on nested names too, expanding from the
# inside out (just like IRAF)
mm = __re_var_paren.search(instring)
while mm is not None:
... | python | def _expand1(instring, noerror):
"""Expand a string with embedded IRAF variables (IRAF virtual filename)."""
# first expand names in parentheses
# note this works on nested names too, expanding from the
# inside out (just like IRAF)
mm = __re_var_paren.search(instring)
while mm is not None:
... | [
"def",
"_expand1",
"(",
"instring",
",",
"noerror",
")",
":",
"# first expand names in parentheses",
"# note this works on nested names too, expanding from the",
"# inside out (just like IRAF)",
"mm",
"=",
"__re_var_paren",
".",
"search",
"(",
"instring",
")",
"while",
"mm",
... | Expand a string with embedded IRAF variables (IRAF virtual filename). | [
"Expand",
"a",
"string",
"with",
"embedded",
"IRAF",
"variables",
"(",
"IRAF",
"virtual",
"filename",
")",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/fileutil.py#L1499-L1535 | train |
fitnr/convertdate | convertdate/julian.py | legal_date | def legal_date(year, month, day):
'''Check if this is a legal date in the Julian calendar'''
daysinmonth = month_length(year, month)
if not (0 < day <= daysinmonth):
raise ValueError("Month {} doesn't have a day {}".format(month, day))
return True | python | def legal_date(year, month, day):
'''Check if this is a legal date in the Julian calendar'''
daysinmonth = month_length(year, month)
if not (0 < day <= daysinmonth):
raise ValueError("Month {} doesn't have a day {}".format(month, day))
return True | [
"def",
"legal_date",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"daysinmonth",
"=",
"month_length",
"(",
"year",
",",
"month",
")",
"if",
"not",
"(",
"0",
"<",
"day",
"<=",
"daysinmonth",
")",
":",
"raise",
"ValueError",
"(",
"\"Month {} doesn't ha... | Check if this is a legal date in the Julian calendar | [
"Check",
"if",
"this",
"is",
"a",
"legal",
"date",
"in",
"the",
"Julian",
"calendar"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L42-L49 | train |
fitnr/convertdate | convertdate/julian.py | from_jd | def from_jd(jd):
'''Calculate Julian calendar date from Julian day'''
jd += 0.5
z = trunc(jd)
a = z
b = a + 1524
c = trunc((b - 122.1) / 365.25)
d = trunc(365.25 * c)
e = trunc((b - d) / 30.6001)
if trunc(e < 14):
month = e - 1
else:
month = e - 13
if trun... | python | def from_jd(jd):
'''Calculate Julian calendar date from Julian day'''
jd += 0.5
z = trunc(jd)
a = z
b = a + 1524
c = trunc((b - 122.1) / 365.25)
d = trunc(365.25 * c)
e = trunc((b - d) / 30.6001)
if trunc(e < 14):
month = e - 1
else:
month = e - 13
if trun... | [
"def",
"from_jd",
"(",
"jd",
")",
":",
"jd",
"+=",
"0.5",
"z",
"=",
"trunc",
"(",
"jd",
")",
"a",
"=",
"z",
"b",
"=",
"a",
"+",
"1524",
"c",
"=",
"trunc",
"(",
"(",
"b",
"-",
"122.1",
")",
"/",
"365.25",
")",
"d",
"=",
"trunc",
"(",
"365.... | Calculate Julian calendar date from Julian day | [
"Calculate",
"Julian",
"calendar",
"date",
"from",
"Julian",
"day"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L52-L76 | train |
fitnr/convertdate | convertdate/julian.py | to_jd | def to_jd(year, month, day):
'''Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)'''
legal_date(year, month, day)
# Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61
if month <= 2:
year -= 1
month += 12
return (trunc((365.25 * (year + 471... | python | def to_jd(year, month, day):
'''Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)'''
legal_date(year, month, day)
# Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61
if month <= 2:
year -= 1
month += 12
return (trunc((365.25 * (year + 471... | [
"def",
"to_jd",
"(",
"year",
",",
"month",
",",
"day",
")",
":",
"legal_date",
"(",
"year",
",",
"month",
",",
"day",
")",
"# Algorithm as given in Meeus, Astronomical Algorithms, Chapter 7, page 61",
"if",
"month",
"<=",
"2",
":",
"year",
"-=",
"1",
"month",
... | Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC) | [
"Convert",
"to",
"Julian",
"day",
"using",
"astronomical",
"years",
"(",
"0",
"=",
"1",
"BC",
"-",
"1",
"=",
"2",
"BC",
")"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julian.py#L79-L90 | train |
fitnr/convertdate | convertdate/hebrew.py | delay_1 | def delay_1(year):
'''Test for delay of start of new year and to avoid'''
# Sunday, Wednesday, and Friday as start of the new year.
months = trunc(((235 * year) - 234) / 19)
parts = 12084 + (13753 * months)
day = trunc((months * 29) + parts / 25920)
if ((3 * (day + 1)) % 7) < 3:
day += ... | python | def delay_1(year):
'''Test for delay of start of new year and to avoid'''
# Sunday, Wednesday, and Friday as start of the new year.
months = trunc(((235 * year) - 234) / 19)
parts = 12084 + (13753 * months)
day = trunc((months * 29) + parts / 25920)
if ((3 * (day + 1)) % 7) < 3:
day += ... | [
"def",
"delay_1",
"(",
"year",
")",
":",
"# Sunday, Wednesday, and Friday as start of the new year.",
"months",
"=",
"trunc",
"(",
"(",
"(",
"235",
"*",
"year",
")",
"-",
"234",
")",
"/",
"19",
")",
"parts",
"=",
"12084",
"+",
"(",
"13753",
"*",
"months",
... | Test for delay of start of new year and to avoid | [
"Test",
"for",
"delay",
"of",
"start",
"of",
"new",
"year",
"and",
"to",
"avoid"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L46-L56 | train |
fitnr/convertdate | convertdate/hebrew.py | delay_2 | def delay_2(year):
'''Check for delay in start of new year due to length of adjacent years'''
last = delay_1(year - 1)
present = delay_1(year)
next_ = delay_1(year + 1)
if next_ - present == 356:
return 2
elif present - last == 382:
return 1
else:
return 0 | python | def delay_2(year):
'''Check for delay in start of new year due to length of adjacent years'''
last = delay_1(year - 1)
present = delay_1(year)
next_ = delay_1(year + 1)
if next_ - present == 356:
return 2
elif present - last == 382:
return 1
else:
return 0 | [
"def",
"delay_2",
"(",
"year",
")",
":",
"last",
"=",
"delay_1",
"(",
"year",
"-",
"1",
")",
"present",
"=",
"delay_1",
"(",
"year",
")",
"next_",
"=",
"delay_1",
"(",
"year",
"+",
"1",
")",
"if",
"next_",
"-",
"present",
"==",
"356",
":",
"retur... | Check for delay in start of new year due to length of adjacent years | [
"Check",
"for",
"delay",
"in",
"start",
"of",
"new",
"year",
"due",
"to",
"length",
"of",
"adjacent",
"years"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L59-L71 | train |
fitnr/convertdate | convertdate/hebrew.py | month_days | def month_days(year, month):
'''How many days are in a given month of a given year'''
if month > 13:
raise ValueError("Incorrect month index")
# First of all, dispose of fixed-length 29 day months
if month in (IYYAR, TAMMUZ, ELUL, TEVETH, VEADAR):
return 29
# If it's not a leap yea... | python | def month_days(year, month):
'''How many days are in a given month of a given year'''
if month > 13:
raise ValueError("Incorrect month index")
# First of all, dispose of fixed-length 29 day months
if month in (IYYAR, TAMMUZ, ELUL, TEVETH, VEADAR):
return 29
# If it's not a leap yea... | [
"def",
"month_days",
"(",
"year",
",",
"month",
")",
":",
"if",
"month",
">",
"13",
":",
"raise",
"ValueError",
"(",
"\"Incorrect month index\"",
")",
"# First of all, dispose of fixed-length 29 day months",
"if",
"month",
"in",
"(",
"IYYAR",
",",
"TAMMUZ",
",",
... | How many days are in a given month of a given year | [
"How",
"many",
"days",
"are",
"in",
"a",
"given",
"month",
"of",
"a",
"given",
"year"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/hebrew.py#L79-L101 | train |
spacetelescope/stsci.tools | lib/stsci/tools/swapgeis.py | byteswap | def byteswap(input,output=None,clobber=True):
"""Input GEIS files "input" will be read and converted to a new GEIS file
whose byte-order has been swapped from its original state.
Parameters
----------
input - str
Full filename with path of input GEIS image header file
output - str
... | python | def byteswap(input,output=None,clobber=True):
"""Input GEIS files "input" will be read and converted to a new GEIS file
whose byte-order has been swapped from its original state.
Parameters
----------
input - str
Full filename with path of input GEIS image header file
output - str
... | [
"def",
"byteswap",
"(",
"input",
",",
"output",
"=",
"None",
",",
"clobber",
"=",
"True",
")",
":",
"global",
"dat",
"cardLen",
"=",
"fits",
".",
"Card",
".",
"length",
"# input file(s) must be of the form *.??h and *.??d",
"if",
"input",
"[",
"-",
"1",
"]",... | Input GEIS files "input" will be read and converted to a new GEIS file
whose byte-order has been swapped from its original state.
Parameters
----------
input - str
Full filename with path of input GEIS image header file
output - str
Full filename with path of output GEIS image head... | [
"Input",
"GEIS",
"files",
"input",
"will",
"be",
"read",
"and",
"converted",
"to",
"a",
"new",
"GEIS",
"file",
"whose",
"byte",
"-",
"order",
"has",
"been",
"swapped",
"from",
"its",
"original",
"state",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/swapgeis.py#L92-L515 | train |
3ll3d00d/vibe | backend/src/recorder/common/accelerometer.py | Accelerometer.start | def start(self, measurementId, durationInSeconds=None):
"""
Initialises the device if required then enters a read loop taking data from the provider and passing it to the
handler. It will continue until either breakRead is true or the duration (if provided) has passed.
:return:
... | python | def start(self, measurementId, durationInSeconds=None):
"""
Initialises the device if required then enters a read loop taking data from the provider and passing it to the
handler. It will continue until either breakRead is true or the duration (if provided) has passed.
:return:
... | [
"def",
"start",
"(",
"self",
",",
"measurementId",
",",
"durationInSeconds",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"\">> measurement \"",
"+",
"measurementId",
"+",
"(",
"(",
"\" for \"",
"+",
"str",
"(",
"durationInSeconds",
")",
")",
"if",
"... | Initialises the device if required then enters a read loop taking data from the provider and passing it to the
handler. It will continue until either breakRead is true or the duration (if provided) has passed.
:return: | [
"Initialises",
"the",
"device",
"if",
"required",
"then",
"enters",
"a",
"read",
"loop",
"taking",
"data",
"from",
"the",
"provider",
"and",
"passing",
"it",
"to",
"the",
"handler",
".",
"It",
"will",
"continue",
"until",
"either",
"breakRead",
"is",
"true",... | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/accelerometer.py#L66-L115 | train |
3ll3d00d/vibe | backend/src/analyser/resources/target.py | Target.get | def get(self, targetId):
"""
Yields the analysed wav data.
:param targetId:
:return:
"""
result = self._targetController.analyse(targetId)
if result:
if len(result) == 2:
if result[1] == 404:
return result
... | python | def get(self, targetId):
"""
Yields the analysed wav data.
:param targetId:
:return:
"""
result = self._targetController.analyse(targetId)
if result:
if len(result) == 2:
if result[1] == 404:
return result
... | [
"def",
"get",
"(",
"self",
",",
"targetId",
")",
":",
"result",
"=",
"self",
".",
"_targetController",
".",
"analyse",
"(",
"targetId",
")",
"if",
"result",
":",
"if",
"len",
"(",
"result",
")",
"==",
"2",
":",
"if",
"result",
"[",
"1",
"]",
"==",
... | Yields the analysed wav data.
:param targetId:
:return: | [
"Yields",
"the",
"analysed",
"wav",
"data",
".",
":",
"param",
"targetId",
":",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/target.py#L13-L29 | train |
3ll3d00d/vibe | backend/src/analyser/resources/target.py | Target.put | def put(self, targetId):
"""
stores a new target.
:param targetId: the target to store.
:return:
"""
json = request.get_json()
if 'hinge' in json:
logger.info('Storing target ' + targetId)
if self._targetController.storeFromHinge(targetId, ... | python | def put(self, targetId):
"""
stores a new target.
:param targetId: the target to store.
:return:
"""
json = request.get_json()
if 'hinge' in json:
logger.info('Storing target ' + targetId)
if self._targetController.storeFromHinge(targetId, ... | [
"def",
"put",
"(",
"self",
",",
"targetId",
")",
":",
"json",
"=",
"request",
".",
"get_json",
"(",
")",
"if",
"'hinge'",
"in",
"json",
":",
"logger",
".",
"info",
"(",
"'Storing target '",
"+",
"targetId",
")",
"if",
"self",
".",
"_targetController",
... | stores a new target.
:param targetId: the target to store.
:return: | [
"stores",
"a",
"new",
"target",
".",
":",
"param",
"targetId",
":",
"the",
"target",
"to",
"store",
".",
":",
"return",
":"
] | 124b029f13ac746723e92cb47e9cb56edd2e54b5 | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/target.py#L31-L46 | train |
fitnr/convertdate | convertdate/julianday.py | to_datetime | def to_datetime(jdc):
'''Return a datetime for the input floating point Julian Day Count'''
year, month, day = gregorian.from_jd(jdc)
# in jdc: 0.0 = noon, 0.5 = midnight
# the 0.5 changes it to 0.0 = midnight, 0.5 = noon
frac = (jdc + 0.5) % 1
hours = int(24 * frac)
mfrac = frac * 24 - h... | python | def to_datetime(jdc):
'''Return a datetime for the input floating point Julian Day Count'''
year, month, day = gregorian.from_jd(jdc)
# in jdc: 0.0 = noon, 0.5 = midnight
# the 0.5 changes it to 0.0 = midnight, 0.5 = noon
frac = (jdc + 0.5) % 1
hours = int(24 * frac)
mfrac = frac * 24 - h... | [
"def",
"to_datetime",
"(",
"jdc",
")",
":",
"year",
",",
"month",
",",
"day",
"=",
"gregorian",
".",
"from_jd",
"(",
"jdc",
")",
"# in jdc: 0.0 = noon, 0.5 = midnight",
"# the 0.5 changes it to 0.0 = midnight, 0.5 = noon",
"frac",
"=",
"(",
"jdc",
"+",
"0.5",
")",... | Return a datetime for the input floating point Julian Day Count | [
"Return",
"a",
"datetime",
"for",
"the",
"input",
"floating",
"point",
"Julian",
"Day",
"Count"
] | e920f168a87f99183b0aa7290d6c3af222582d43 | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/julianday.py#L16-L37 | train |
silverlogic/djangorestframework-expander | expander/parse_qs.py | dict_from_qs | def dict_from_qs(qs):
''' Slightly introverted parser for lists of dot-notation nested fields
i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}}
'''
entries = qs.split(',') if qs.strip() else []
entries = [entry.strip() for entry in entries]
def _dict_from_qs(line, d):
... | python | def dict_from_qs(qs):
''' Slightly introverted parser for lists of dot-notation nested fields
i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}}
'''
entries = qs.split(',') if qs.strip() else []
entries = [entry.strip() for entry in entries]
def _dict_from_qs(line, d):
... | [
"def",
"dict_from_qs",
"(",
"qs",
")",
":",
"entries",
"=",
"qs",
".",
"split",
"(",
"','",
")",
"if",
"qs",
".",
"strip",
"(",
")",
"else",
"[",
"]",
"entries",
"=",
"[",
"entry",
".",
"strip",
"(",
")",
"for",
"entry",
"in",
"entries",
"]",
"... | Slightly introverted parser for lists of dot-notation nested fields
i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}} | [
"Slightly",
"introverted",
"parser",
"for",
"lists",
"of",
"dot",
"-",
"notation",
"nested",
"fields",
"i",
".",
"e",
".",
"period",
".",
"di",
"period",
".",
"fhr",
"=",
">",
"{",
"period",
":",
"{",
"di",
":",
"{}",
"fhr",
":",
"{}",
"}}"
] | b1cf60c7076169cbd6ad65350841c86080564f97 | https://github.com/silverlogic/djangorestframework-expander/blob/b1cf60c7076169cbd6ad65350841c86080564f97/expander/parse_qs.py#L5-L26 | train |
silverlogic/djangorestframework-expander | expander/parse_qs.py | qs_from_dict | def qs_from_dict(qsdict, prefix=""):
''' Same as dict_from_qs, but in reverse
i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr"
'''
prefix = prefix + '.' if prefix else ""
def descend(qsd):
for key, val in sorted(qsd.items()):
if val:
yield qs_... | python | def qs_from_dict(qsdict, prefix=""):
''' Same as dict_from_qs, but in reverse
i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr"
'''
prefix = prefix + '.' if prefix else ""
def descend(qsd):
for key, val in sorted(qsd.items()):
if val:
yield qs_... | [
"def",
"qs_from_dict",
"(",
"qsdict",
",",
"prefix",
"=",
"\"\"",
")",
":",
"prefix",
"=",
"prefix",
"+",
"'.'",
"if",
"prefix",
"else",
"\"\"",
"def",
"descend",
"(",
"qsd",
")",
":",
"for",
"key",
",",
"val",
"in",
"sorted",
"(",
"qsd",
".",
"ite... | Same as dict_from_qs, but in reverse
i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr" | [
"Same",
"as",
"dict_from_qs",
"but",
"in",
"reverse",
"i",
".",
"e",
".",
"{",
"period",
":",
"{",
"di",
":",
"{}",
"fhr",
":",
"{}",
"}}",
"=",
">",
"period",
".",
"di",
"period",
".",
"fhr"
] | b1cf60c7076169cbd6ad65350841c86080564f97 | https://github.com/silverlogic/djangorestframework-expander/blob/b1cf60c7076169cbd6ad65350841c86080564f97/expander/parse_qs.py#L29-L41 | train |
flukso/tmpo-py | tmpo/__init__.py | dbcon | def dbcon(func):
"""Set up connection before executing function, commit and close connection
afterwards. Unless a connection already has been created."""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.dbcon is None:
# set up connection
self.dbco... | python | def dbcon(func):
"""Set up connection before executing function, commit and close connection
afterwards. Unless a connection already has been created."""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.dbcon is None:
# set up connection
self.dbco... | [
"def",
"dbcon",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"dbcon",
"is",
"None",
":",
"# set up connection"... | Set up connection before executing function, commit and close connection
afterwards. Unless a connection already has been created. | [
"Set",
"up",
"connection",
"before",
"executing",
"function",
"commit",
"and",
"close",
"connection",
"afterwards",
".",
"Unless",
"a",
"connection",
"already",
"has",
"been",
"created",
"."
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L142-L175 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.add | def add(self, sid, token):
"""
Add new sensor to the database
Parameters
----------
sid : str
SensorId
token : str
"""
try:
self.dbcur.execute(SQL_SENSOR_INS, (sid, token))
except sqlite3.IntegrityError: # sensor entry exi... | python | def add(self, sid, token):
"""
Add new sensor to the database
Parameters
----------
sid : str
SensorId
token : str
"""
try:
self.dbcur.execute(SQL_SENSOR_INS, (sid, token))
except sqlite3.IntegrityError: # sensor entry exi... | [
"def",
"add",
"(",
"self",
",",
"sid",
",",
"token",
")",
":",
"try",
":",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_SENSOR_INS",
",",
"(",
"sid",
",",
"token",
")",
")",
"except",
"sqlite3",
".",
"IntegrityError",
":",
"# sensor entry exists",
"... | Add new sensor to the database
Parameters
----------
sid : str
SensorId
token : str | [
"Add",
"new",
"sensor",
"to",
"the",
"database"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L213-L226 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.remove | def remove(self, sid):
"""
Remove sensor from the database
Parameters
----------
sid : str
SensorID
"""
self.dbcur.execute(SQL_SENSOR_DEL, (sid,))
self.dbcur.execute(SQL_TMPO_DEL, (sid,)) | python | def remove(self, sid):
"""
Remove sensor from the database
Parameters
----------
sid : str
SensorID
"""
self.dbcur.execute(SQL_SENSOR_DEL, (sid,))
self.dbcur.execute(SQL_TMPO_DEL, (sid,)) | [
"def",
"remove",
"(",
"self",
",",
"sid",
")",
":",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_SENSOR_DEL",
",",
"(",
"sid",
",",
")",
")",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_TMPO_DEL",
",",
"(",
"sid",
",",
")",
")"
] | Remove sensor from the database
Parameters
----------
sid : str
SensorID | [
"Remove",
"sensor",
"from",
"the",
"database"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L229-L239 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.sync | def sync(self, *sids):
"""
Synchronise data
Parameters
----------
sids : list of str
SensorIDs to sync
Optional, leave empty to sync everything
"""
if sids == ():
sids = [sid for (sid,) in self.dbcur.execute(SQL_SENSOR_ALL)]
... | python | def sync(self, *sids):
"""
Synchronise data
Parameters
----------
sids : list of str
SensorIDs to sync
Optional, leave empty to sync everything
"""
if sids == ():
sids = [sid for (sid,) in self.dbcur.execute(SQL_SENSOR_ALL)]
... | [
"def",
"sync",
"(",
"self",
",",
"*",
"sids",
")",
":",
"if",
"sids",
"==",
"(",
")",
":",
"sids",
"=",
"[",
"sid",
"for",
"(",
"sid",
",",
")",
"in",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_SENSOR_ALL",
")",
"]",
"for",
"sid",
"in",
... | Synchronise data
Parameters
----------
sids : list of str
SensorIDs to sync
Optional, leave empty to sync everything | [
"Synchronise",
"data"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L254-L277 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.list | def list(self, *sids):
"""
List all tmpo-blocks in the database
Parameters
----------
sids : list of str
SensorID's for which to list blocks
Optional, leave empty to get them all
Returns
-------
list[list[tuple]]
"""
... | python | def list(self, *sids):
"""
List all tmpo-blocks in the database
Parameters
----------
sids : list of str
SensorID's for which to list blocks
Optional, leave empty to get them all
Returns
-------
list[list[tuple]]
"""
... | [
"def",
"list",
"(",
"self",
",",
"*",
"sids",
")",
":",
"if",
"sids",
"==",
"(",
")",
":",
"sids",
"=",
"[",
"sid",
"for",
"(",
"sid",
",",
")",
"in",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_SENSOR_ALL",
")",
"]",
"slist",
"=",
"[",
"... | List all tmpo-blocks in the database
Parameters
----------
sids : list of str
SensorID's for which to list blocks
Optional, leave empty to get them all
Returns
-------
list[list[tuple]] | [
"List",
"all",
"tmpo",
"-",
"blocks",
"in",
"the",
"database"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L280-L304 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.series | def series(self, sid, recycle_id=None, head=None, tail=None,
datetime=True):
"""
Create data Series
Parameters
----------
sid : str
recycle_id : optional
head : int | pandas.Timestamp, optional
Start of the interval
default ... | python | def series(self, sid, recycle_id=None, head=None, tail=None,
datetime=True):
"""
Create data Series
Parameters
----------
sid : str
recycle_id : optional
head : int | pandas.Timestamp, optional
Start of the interval
default ... | [
"def",
"series",
"(",
"self",
",",
"sid",
",",
"recycle_id",
"=",
"None",
",",
"head",
"=",
"None",
",",
"tail",
"=",
"None",
",",
"datetime",
"=",
"True",
")",
":",
"if",
"head",
"is",
"None",
":",
"head",
"=",
"0",
"else",
":",
"head",
"=",
"... | Create data Series
Parameters
----------
sid : str
recycle_id : optional
head : int | pandas.Timestamp, optional
Start of the interval
default earliest available
tail : int | pandas.Timestamp, optional
End of the interval
d... | [
"Create",
"data",
"Series"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L307-L357 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.dataframe | def dataframe(self, sids, head=0, tail=EPOCHS_MAX, datetime=True):
"""
Create data frame
Parameters
----------
sids : list[str]
head : int | pandas.Timestamp, optional
Start of the interval
default earliest available
tail : int | pandas.Ti... | python | def dataframe(self, sids, head=0, tail=EPOCHS_MAX, datetime=True):
"""
Create data frame
Parameters
----------
sids : list[str]
head : int | pandas.Timestamp, optional
Start of the interval
default earliest available
tail : int | pandas.Ti... | [
"def",
"dataframe",
"(",
"self",
",",
"sids",
",",
"head",
"=",
"0",
",",
"tail",
"=",
"EPOCHS_MAX",
",",
"datetime",
"=",
"True",
")",
":",
"if",
"head",
"is",
"None",
":",
"head",
"=",
"0",
"else",
":",
"head",
"=",
"self",
".",
"_2epochs",
"("... | Create data frame
Parameters
----------
sids : list[str]
head : int | pandas.Timestamp, optional
Start of the interval
default earliest available
tail : int | pandas.Timestamp, optional
End of the interval
default max epoch
... | [
"Create",
"data",
"frame"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L360-L396 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.first_timestamp | def first_timestamp(self, sid, epoch=False):
"""
Get the first available timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
... | python | def first_timestamp(self, sid, epoch=False):
"""
Get the first available timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
... | [
"def",
"first_timestamp",
"(",
"self",
",",
"sid",
",",
"epoch",
"=",
"False",
")",
":",
"first_block",
"=",
"self",
".",
"dbcur",
".",
"execute",
"(",
"SQL_TMPO_FIRST",
",",
"(",
"sid",
",",
")",
")",
".",
"fetchone",
"(",
")",
"if",
"first_block",
... | Get the first available timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int | [
"Get",
"the",
"first",
"available",
"timestamp",
"for",
"a",
"sensor"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L399-L424 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.last_timestamp | def last_timestamp(self, sid, epoch=False):
"""
Get the theoretical last timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
... | python | def last_timestamp(self, sid, epoch=False):
"""
Get the theoretical last timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
... | [
"def",
"last_timestamp",
"(",
"self",
",",
"sid",
",",
"epoch",
"=",
"False",
")",
":",
"timestamp",
",",
"value",
"=",
"self",
".",
"last_datapoint",
"(",
"sid",
",",
"epoch",
")",
"return",
"timestamp"
] | Get the theoretical last timestamp for a sensor
Parameters
----------
sid : str
SensorID
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int | [
"Get",
"the",
"theoretical",
"last",
"timestamp",
"for",
"a",
"sensor"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L426-L444 | train |
flukso/tmpo-py | tmpo/__init__.py | Session.last_datapoint | def last_datapoint(self, sid, epoch=False):
"""
Parameters
----------
sid : str
SensorId
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int,... | python | def last_datapoint(self, sid, epoch=False):
"""
Parameters
----------
sid : str
SensorId
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int,... | [
"def",
"last_datapoint",
"(",
"self",
",",
"sid",
",",
"epoch",
"=",
"False",
")",
":",
"block",
"=",
"self",
".",
"_last_block",
"(",
"sid",
")",
"if",
"block",
"is",
"None",
":",
"return",
"None",
",",
"None",
"header",
"=",
"block",
"[",
"'h'",
... | Parameters
----------
sid : str
SensorId
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int, float | [
"Parameters",
"----------",
"sid",
":",
"str",
"SensorId",
"epoch",
":",
"bool",
"default",
"False",
"If",
"True",
"return",
"as",
"epoch",
"If",
"False",
"return",
"as",
"pd",
".",
"Timestamp"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L446-L472 | train |
flukso/tmpo-py | tmpo/__init__.py | Session._npdelta | def _npdelta(self, a, delta):
"""Numpy: Modifying Array Values
http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html"""
for x in np.nditer(a, op_flags=["readwrite"]):
delta += x
x[...] = delta
return a | python | def _npdelta(self, a, delta):
"""Numpy: Modifying Array Values
http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html"""
for x in np.nditer(a, op_flags=["readwrite"]):
delta += x
x[...] = delta
return a | [
"def",
"_npdelta",
"(",
"self",
",",
"a",
",",
"delta",
")",
":",
"for",
"x",
"in",
"np",
".",
"nditer",
"(",
"a",
",",
"op_flags",
"=",
"[",
"\"readwrite\"",
"]",
")",
":",
"delta",
"+=",
"x",
"x",
"[",
"...",
"]",
"=",
"delta",
"return",
"a"
... | Numpy: Modifying Array Values
http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html | [
"Numpy",
":",
"Modifying",
"Array",
"Values",
"http",
":",
"//",
"docs",
".",
"scipy",
".",
"org",
"/",
"doc",
"/",
"numpy",
"/",
"reference",
"/",
"arrays",
".",
"nditer",
".",
"html"
] | 3c99e3d123bc985a6fba2558922b29430d2a0a94 | https://github.com/flukso/tmpo-py/blob/3c99e3d123bc985a6fba2558922b29430d2a0a94/tmpo/__init__.py#L522-L528 | train |
spacetelescope/stsci.tools | lib/stsci/tools/vtor_checks.py | sigStrToKwArgsDict | def sigStrToKwArgsDict(checkFuncSig):
""" Take a check function signature (string), and parse it to get a dict
of the keyword args and their values. """
p1 = checkFuncSig.find('(')
p2 = checkFuncSig.rfind(')')
assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig
argParts ... | python | def sigStrToKwArgsDict(checkFuncSig):
""" Take a check function signature (string), and parse it to get a dict
of the keyword args and their values. """
p1 = checkFuncSig.find('(')
p2 = checkFuncSig.rfind(')')
assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig
argParts ... | [
"def",
"sigStrToKwArgsDict",
"(",
"checkFuncSig",
")",
":",
"p1",
"=",
"checkFuncSig",
".",
"find",
"(",
"'('",
")",
"p2",
"=",
"checkFuncSig",
".",
"rfind",
"(",
"')'",
")",
"assert",
"p1",
">",
"0",
"and",
"p2",
">",
"0",
"and",
"p2",
">",
"p1",
... | Take a check function signature (string), and parse it to get a dict
of the keyword args and their values. | [
"Take",
"a",
"check",
"function",
"signature",
"(",
"string",
")",
"and",
"parse",
"it",
"to",
"get",
"a",
"dict",
"of",
"the",
"keyword",
"args",
"and",
"their",
"values",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L18-L40 | train |
spacetelescope/stsci.tools | lib/stsci/tools/vtor_checks.py | separateKeywords | def separateKeywords(kwArgsDict):
""" Look through the keywords passed and separate the special ones we
have added from the legal/standard ones. Return both sets as two
dicts (in a tuple), as (standardKws, ourKws) """
standardKws = {}
ourKws = {}
for k in kwArgsDict:
if k in STA... | python | def separateKeywords(kwArgsDict):
""" Look through the keywords passed and separate the special ones we
have added from the legal/standard ones. Return both sets as two
dicts (in a tuple), as (standardKws, ourKws) """
standardKws = {}
ourKws = {}
for k in kwArgsDict:
if k in STA... | [
"def",
"separateKeywords",
"(",
"kwArgsDict",
")",
":",
"standardKws",
"=",
"{",
"}",
"ourKws",
"=",
"{",
"}",
"for",
"k",
"in",
"kwArgsDict",
":",
"if",
"k",
"in",
"STANDARD_KEYS",
":",
"standardKws",
"[",
"k",
"]",
"=",
"kwArgsDict",
"[",
"k",
"]",
... | Look through the keywords passed and separate the special ones we
have added from the legal/standard ones. Return both sets as two
dicts (in a tuple), as (standardKws, ourKws) | [
"Look",
"through",
"the",
"keywords",
"passed",
"and",
"separate",
"the",
"special",
"ones",
"we",
"have",
"added",
"from",
"the",
"legal",
"/",
"standard",
"ones",
".",
"Return",
"both",
"sets",
"as",
"two",
"dicts",
"(",
"in",
"a",
"tuple",
")",
"as",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L43-L54 | train |
spacetelescope/stsci.tools | lib/stsci/tools/vtor_checks.py | addKwdArgsToSig | def addKwdArgsToSig(sigStr, kwArgsDict):
""" Alter the passed function signature string to add the given kewords """
retval = sigStr
if len(kwArgsDict) > 0:
retval = retval.strip(' ,)') # open up the r.h.s. for more args
for k in kwArgsDict:
if retval[-1] != '(': retval += ", "
... | python | def addKwdArgsToSig(sigStr, kwArgsDict):
""" Alter the passed function signature string to add the given kewords """
retval = sigStr
if len(kwArgsDict) > 0:
retval = retval.strip(' ,)') # open up the r.h.s. for more args
for k in kwArgsDict:
if retval[-1] != '(': retval += ", "
... | [
"def",
"addKwdArgsToSig",
"(",
"sigStr",
",",
"kwArgsDict",
")",
":",
"retval",
"=",
"sigStr",
"if",
"len",
"(",
"kwArgsDict",
")",
">",
"0",
":",
"retval",
"=",
"retval",
".",
"strip",
"(",
"' ,)'",
")",
"# open up the r.h.s. for more args",
"for",
"k",
"... | Alter the passed function signature string to add the given kewords | [
"Alter",
"the",
"passed",
"function",
"signature",
"string",
"to",
"add",
"the",
"given",
"kewords"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L57-L67 | train |
spacetelescope/stsci.tools | lib/stsci/tools/gfit.py | _gauss_funct | def _gauss_funct(p, fjac=None, x=None, y=None, err=None,
weights=None):
"""
Defines the gaussian function to be used as the model.
"""
if p[2] != 0.0:
Z = (x - p[1]) / p[2]
model = p[0] * np.e ** (-Z ** 2 / 2.0)
else:
model = np.zeros(np.size(x))
statu... | python | def _gauss_funct(p, fjac=None, x=None, y=None, err=None,
weights=None):
"""
Defines the gaussian function to be used as the model.
"""
if p[2] != 0.0:
Z = (x - p[1]) / p[2]
model = p[0] * np.e ** (-Z ** 2 / 2.0)
else:
model = np.zeros(np.size(x))
statu... | [
"def",
"_gauss_funct",
"(",
"p",
",",
"fjac",
"=",
"None",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"err",
"=",
"None",
",",
"weights",
"=",
"None",
")",
":",
"if",
"p",
"[",
"2",
"]",
"!=",
"0.0",
":",
"Z",
"=",
"(",
"x",
"-",
... | Defines the gaussian function to be used as the model. | [
"Defines",
"the",
"gaussian",
"function",
"to",
"be",
"used",
"as",
"the",
"model",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/gfit.py#L27-L51 | train |
spacetelescope/stsci.tools | lib/stsci/tools/gfit.py | gfit1d | def gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None,
maxiter=200, quiet=0):
"""
Return the gaussian fit as an object.
Parameters
----------
y: 1D Numpy array
The data to be fitted
x: 1D Numpy array
(optional) The x values of the y array. x and y m... | python | def gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None,
maxiter=200, quiet=0):
"""
Return the gaussian fit as an object.
Parameters
----------
y: 1D Numpy array
The data to be fitted
x: 1D Numpy array
(optional) The x values of the y array. x and y m... | [
"def",
"gfit1d",
"(",
"y",
",",
"x",
"=",
"None",
",",
"err",
"=",
"None",
",",
"weights",
"=",
"None",
",",
"par",
"=",
"None",
",",
"parinfo",
"=",
"None",
",",
"maxiter",
"=",
"200",
",",
"quiet",
"=",
"0",
")",
":",
"y",
"=",
"y",
".",
... | Return the gaussian fit as an object.
Parameters
----------
y: 1D Numpy array
The data to be fitted
x: 1D Numpy array
(optional) The x values of the y array. x and y must
have the same shape.
err: 1D Numpy array
(optional) 1D array with measurement errors, must b... | [
"Return",
"the",
"gaussian",
"fit",
"as",
"an",
"object",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/gfit.py#L54-L133 | train |
fridiculous/django-estimators | estimators/models/base.py | HashableFileQuerySet.filter | def filter(self, *args, **kwargs):
"""filter lets django managers use `objects.filter` on a hashable object."""
obj = kwargs.pop(self.object_property_name, None)
if obj is not None:
kwargs['object_hash'] = self.model._compute_hash(obj)
return super().filter(*args, **kwargs) | python | def filter(self, *args, **kwargs):
"""filter lets django managers use `objects.filter` on a hashable object."""
obj = kwargs.pop(self.object_property_name, None)
if obj is not None:
kwargs['object_hash'] = self.model._compute_hash(obj)
return super().filter(*args, **kwargs) | [
"def",
"filter",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"kwargs",
".",
"pop",
"(",
"self",
".",
"object_property_name",
",",
"None",
")",
"if",
"obj",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'object_hash'",
... | filter lets django managers use `objects.filter` on a hashable object. | [
"filter",
"lets",
"django",
"managers",
"use",
"objects",
".",
"filter",
"on",
"a",
"hashable",
"object",
"."
] | 5dd72694dab6725335214543a59104c4de504037 | https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L23-L28 | train |
fridiculous/django-estimators | estimators/models/base.py | HashableFileQuerySet._extract_model_params | def _extract_model_params(self, defaults, **kwargs):
"""this method allows django managers use `objects.get_or_create` and
`objects.update_or_create` on a hashable object.
"""
obj = kwargs.pop(self.object_property_name, None)
if obj is not None:
kwargs['object_hash'] ... | python | def _extract_model_params(self, defaults, **kwargs):
"""this method allows django managers use `objects.get_or_create` and
`objects.update_or_create` on a hashable object.
"""
obj = kwargs.pop(self.object_property_name, None)
if obj is not None:
kwargs['object_hash'] ... | [
"def",
"_extract_model_params",
"(",
"self",
",",
"defaults",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"kwargs",
".",
"pop",
"(",
"self",
".",
"object_property_name",
",",
"None",
")",
"if",
"obj",
"is",
"not",
"None",
":",
"kwargs",
"[",
"'objec... | this method allows django managers use `objects.get_or_create` and
`objects.update_or_create` on a hashable object. | [
"this",
"method",
"allows",
"django",
"managers",
"use",
"objects",
".",
"get_or_create",
"and",
"objects",
".",
"update_or_create",
"on",
"a",
"hashable",
"object",
"."
] | 5dd72694dab6725335214543a59104c4de504037 | https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L30-L41 | train |
fridiculous/django-estimators | estimators/models/base.py | HashableFileMixin.persist | def persist(self):
"""a private method that persists an estimator object to the filesystem"""
if self.object_hash:
data = dill.dumps(self.object_property)
f = ContentFile(data)
self.object_file.save(self.object_hash, f, save=False)
f.close()
se... | python | def persist(self):
"""a private method that persists an estimator object to the filesystem"""
if self.object_hash:
data = dill.dumps(self.object_property)
f = ContentFile(data)
self.object_file.save(self.object_hash, f, save=False)
f.close()
se... | [
"def",
"persist",
"(",
"self",
")",
":",
"if",
"self",
".",
"object_hash",
":",
"data",
"=",
"dill",
".",
"dumps",
"(",
"self",
".",
"object_property",
")",
"f",
"=",
"ContentFile",
"(",
"data",
")",
"self",
".",
"object_file",
".",
"save",
"(",
"sel... | a private method that persists an estimator object to the filesystem | [
"a",
"private",
"method",
"that",
"persists",
"an",
"estimator",
"object",
"to",
"the",
"filesystem"
] | 5dd72694dab6725335214543a59104c4de504037 | https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L99-L107 | train |
fridiculous/django-estimators | estimators/models/base.py | HashableFileMixin.load | def load(self):
"""a private method that loads an estimator object from the filesystem"""
if self.is_file_persisted:
self.object_file.open()
temp = dill.loads(self.object_file.read())
self.set_object(temp)
self.object_file.close() | python | def load(self):
"""a private method that loads an estimator object from the filesystem"""
if self.is_file_persisted:
self.object_file.open()
temp = dill.loads(self.object_file.read())
self.set_object(temp)
self.object_file.close() | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_file_persisted",
":",
"self",
".",
"object_file",
".",
"open",
"(",
")",
"temp",
"=",
"dill",
".",
"loads",
"(",
"self",
".",
"object_file",
".",
"read",
"(",
")",
")",
"self",
".",
"set_... | a private method that loads an estimator object from the filesystem | [
"a",
"private",
"method",
"that",
"loads",
"an",
"estimator",
"object",
"from",
"the",
"filesystem"
] | 5dd72694dab6725335214543a59104c4de504037 | https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L109-L115 | train |
fridiculous/django-estimators | estimators/models/base.py | HashableFileMixin.create_from_file | def create_from_file(cls, filename):
"""Return an Estimator object given the path of the file, relative to the MEDIA_ROOT"""
obj = cls()
obj.object_file = filename
obj.load()
return obj | python | def create_from_file(cls, filename):
"""Return an Estimator object given the path of the file, relative to the MEDIA_ROOT"""
obj = cls()
obj.object_file = filename
obj.load()
return obj | [
"def",
"create_from_file",
"(",
"cls",
",",
"filename",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"obj",
".",
"object_file",
"=",
"filename",
"obj",
".",
"load",
"(",
")",
"return",
"obj"
] | Return an Estimator object given the path of the file, relative to the MEDIA_ROOT | [
"Return",
"an",
"Estimator",
"object",
"given",
"the",
"path",
"of",
"the",
"file",
"relative",
"to",
"the",
"MEDIA_ROOT"
] | 5dd72694dab6725335214543a59104c4de504037 | https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L128-L133 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getAppDir | def getAppDir():
""" Return our application dir. Create it if it doesn't exist. """
# Be sure the resource dir exists
theDir = os.path.expanduser('~/.')+APP_NAME.lower()
if not os.path.exists(theDir):
try:
os.mkdir(theDir)
except OSError:
print('Could not create ... | python | def getAppDir():
""" Return our application dir. Create it if it doesn't exist. """
# Be sure the resource dir exists
theDir = os.path.expanduser('~/.')+APP_NAME.lower()
if not os.path.exists(theDir):
try:
os.mkdir(theDir)
except OSError:
print('Could not create ... | [
"def",
"getAppDir",
"(",
")",
":",
"# Be sure the resource dir exists",
"theDir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.'",
")",
"+",
"APP_NAME",
".",
"lower",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"theDir",
")",
... | Return our application dir. Create it if it doesn't exist. | [
"Return",
"our",
"application",
"dir",
".",
"Create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L32-L42 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getObjectFromTaskArg | def getObjectFromTaskArg(theTask, strict, setAllToDefaults):
""" Take the arg (usually called theTask), which can be either a subclass
of ConfigObjPars, or a string package name, or a .cfg filename - no matter
what it is - take it and return a ConfigObjPars object.
strict - bool - warning severity, pass... | python | def getObjectFromTaskArg(theTask, strict, setAllToDefaults):
""" Take the arg (usually called theTask), which can be either a subclass
of ConfigObjPars, or a string package name, or a .cfg filename - no matter
what it is - take it and return a ConfigObjPars object.
strict - bool - warning severity, pass... | [
"def",
"getObjectFromTaskArg",
"(",
"theTask",
",",
"strict",
",",
"setAllToDefaults",
")",
":",
"# Already in the form we need (instance of us or of subclass)",
"if",
"isinstance",
"(",
"theTask",
",",
"ConfigObjPars",
")",
":",
"if",
"setAllToDefaults",
":",
"raise",
... | Take the arg (usually called theTask), which can be either a subclass
of ConfigObjPars, or a string package name, or a .cfg filename - no matter
what it is - take it and return a ConfigObjPars object.
strict - bool - warning severity, passed to the ConfigObjPars() ctor
setAllToDefaults - bool - if theTa... | [
"Take",
"the",
"arg",
"(",
"usually",
"called",
"theTask",
")",
"which",
"can",
"be",
"either",
"a",
"subclass",
"of",
"ConfigObjPars",
"or",
"a",
"string",
"package",
"name",
"or",
"a",
".",
"cfg",
"filename",
"-",
"no",
"matter",
"what",
"it",
"is",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L45-L84 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getEmbeddedKeyVal | def getEmbeddedKeyVal(cfgFileName, kwdName, dflt=None):
""" Read a config file and pull out the value of a given keyword. """
# Assume this is a ConfigObj file. Use that s/w to quickly read it and
# put it in dict format. Assume kwd is at top level (not in a section).
# The input may also be a .cfgspc... | python | def getEmbeddedKeyVal(cfgFileName, kwdName, dflt=None):
""" Read a config file and pull out the value of a given keyword. """
# Assume this is a ConfigObj file. Use that s/w to quickly read it and
# put it in dict format. Assume kwd is at top level (not in a section).
# The input may also be a .cfgspc... | [
"def",
"getEmbeddedKeyVal",
"(",
"cfgFileName",
",",
"kwdName",
",",
"dflt",
"=",
"None",
")",
":",
"# Assume this is a ConfigObj file. Use that s/w to quickly read it and",
"# put it in dict format. Assume kwd is at top level (not in a section).",
"# The input may also be a .cfgspc fi... | Read a config file and pull out the value of a given keyword. | [
"Read",
"a",
"config",
"file",
"and",
"pull",
"out",
"the",
"value",
"of",
"a",
"given",
"keyword",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L87-L120 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | findCfgFileForPkg | def findCfgFileForPkg(pkgName, theExt, pkgObj=None, taskName=None):
""" Locate the configuration files for/from/within a given python package.
pkgName is a string python package name. This is used unless pkgObj
is given, in which case pkgName is taken from pkgObj.__name__.
theExt is either '.cfg' or '.... | python | def findCfgFileForPkg(pkgName, theExt, pkgObj=None, taskName=None):
""" Locate the configuration files for/from/within a given python package.
pkgName is a string python package name. This is used unless pkgObj
is given, in which case pkgName is taken from pkgObj.__name__.
theExt is either '.cfg' or '.... | [
"def",
"findCfgFileForPkg",
"(",
"pkgName",
",",
"theExt",
",",
"pkgObj",
"=",
"None",
",",
"taskName",
"=",
"None",
")",
":",
"# arg check",
"ext",
"=",
"theExt",
"if",
"ext",
"[",
"0",
"]",
"!=",
"'.'",
":",
"ext",
"=",
"'.'",
"+",
"theExt",
"# Do ... | Locate the configuration files for/from/within a given python package.
pkgName is a string python package name. This is used unless pkgObj
is given, in which case pkgName is taken from pkgObj.__name__.
theExt is either '.cfg' or '.cfgspc'. If the task name is known, it is
given as taskName, otherwise o... | [
"Locate",
"the",
"configuration",
"files",
"for",
"/",
"from",
"/",
"within",
"a",
"given",
"python",
"package",
".",
"pkgName",
"is",
"a",
"string",
"python",
"package",
"name",
".",
"This",
"is",
"used",
"unless",
"pkgObj",
"is",
"given",
"in",
"which",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L123-L193 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | findAllCfgTasksUnderDir | def findAllCfgTasksUnderDir(aDir):
""" Finds all installed tasks by examining any .cfg files found on disk
at and under the given directory, as an installation might be.
This returns a dict of { file name : task name }
"""
retval = {}
for f in irafutils.rglob(aDir, '*.cfg'):
retv... | python | def findAllCfgTasksUnderDir(aDir):
""" Finds all installed tasks by examining any .cfg files found on disk
at and under the given directory, as an installation might be.
This returns a dict of { file name : task name }
"""
retval = {}
for f in irafutils.rglob(aDir, '*.cfg'):
retv... | [
"def",
"findAllCfgTasksUnderDir",
"(",
"aDir",
")",
":",
"retval",
"=",
"{",
"}",
"for",
"f",
"in",
"irafutils",
".",
"rglob",
"(",
"aDir",
",",
"'*.cfg'",
")",
":",
"retval",
"[",
"f",
"]",
"=",
"getEmbeddedKeyVal",
"(",
"f",
",",
"TASK_NAME_KEY",
","... | Finds all installed tasks by examining any .cfg files found on disk
at and under the given directory, as an installation might be.
This returns a dict of { file name : task name } | [
"Finds",
"all",
"installed",
"tasks",
"by",
"examining",
"any",
".",
"cfg",
"files",
"found",
"on",
"disk",
"at",
"and",
"under",
"the",
"given",
"directory",
"as",
"an",
"installation",
"might",
"be",
".",
"This",
"returns",
"a",
"dict",
"of",
"{",
"fil... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L196-L204 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getCfgFilesInDirForTask | def getCfgFilesInDirForTask(aDir, aTask, recurse=False):
""" This is a specialized function which is meant only to keep the
same code from needlessly being much repeated throughout this
application. This must be kept as fast and as light as possible.
This checks a given directory for .cfg f... | python | def getCfgFilesInDirForTask(aDir, aTask, recurse=False):
""" This is a specialized function which is meant only to keep the
same code from needlessly being much repeated throughout this
application. This must be kept as fast and as light as possible.
This checks a given directory for .cfg f... | [
"def",
"getCfgFilesInDirForTask",
"(",
"aDir",
",",
"aTask",
",",
"recurse",
"=",
"False",
")",
":",
"if",
"recurse",
":",
"flist",
"=",
"irafutils",
".",
"rglob",
"(",
"aDir",
",",
"'*.cfg'",
")",
"else",
":",
"flist",
"=",
"glob",
".",
"glob",
"(",
... | This is a specialized function which is meant only to keep the
same code from needlessly being much repeated throughout this
application. This must be kept as fast and as light as possible.
This checks a given directory for .cfg files matching a given
task. If recurse is True, it will ... | [
"This",
"is",
"a",
"specialized",
"function",
"which",
"is",
"meant",
"only",
"to",
"keep",
"the",
"same",
"code",
"from",
"needlessly",
"being",
"much",
"repeated",
"throughout",
"this",
"application",
".",
"This",
"must",
"be",
"kept",
"as",
"fast",
"and",... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L207-L229 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getParsObjForPyPkg | def getParsObjForPyPkg(pkgName, strict):
""" Locate the appropriate ConfigObjPars (or subclass) within the given
package. NOTE this begins the same way as getUsrCfgFilesForPyPkg().
Look for .cfg file matches in these places, in this order:
1 - any named .cfg file in current directory match... | python | def getParsObjForPyPkg(pkgName, strict):
""" Locate the appropriate ConfigObjPars (or subclass) within the given
package. NOTE this begins the same way as getUsrCfgFilesForPyPkg().
Look for .cfg file matches in these places, in this order:
1 - any named .cfg file in current directory match... | [
"def",
"getParsObjForPyPkg",
"(",
"pkgName",
",",
"strict",
")",
":",
"# Get the python package and it's .cfg file - need this no matter what",
"installedPkg",
",",
"installedFile",
"=",
"findCfgFileForPkg",
"(",
"pkgName",
",",
"'.cfg'",
")",
"theFile",
"=",
"None",
"tna... | Locate the appropriate ConfigObjPars (or subclass) within the given
package. NOTE this begins the same way as getUsrCfgFilesForPyPkg().
Look for .cfg file matches in these places, in this order:
1 - any named .cfg file in current directory matching given task
2 - if there exists a ~/... | [
"Locate",
"the",
"appropriate",
"ConfigObjPars",
"(",
"or",
"subclass",
")",
"within",
"the",
"given",
"package",
".",
"NOTE",
"this",
"begins",
"the",
"same",
"way",
"as",
"getUsrCfgFilesForPyPkg",
"()",
".",
"Look",
"for",
".",
"cfg",
"file",
"matches",
"i... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L232-L279 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | getUsrCfgFilesForPyPkg | def getUsrCfgFilesForPyPkg(pkgName):
""" See if the user has one of their own local .cfg files for this task,
such as might be created automatically during the save of a read-only
package, and return their names. """
# Get the python package and it's .cfg file
thePkg, theFile = findCfgFileFo... | python | def getUsrCfgFilesForPyPkg(pkgName):
""" See if the user has one of their own local .cfg files for this task,
such as might be created automatically during the save of a read-only
package, and return their names. """
# Get the python package and it's .cfg file
thePkg, theFile = findCfgFileFo... | [
"def",
"getUsrCfgFilesForPyPkg",
"(",
"pkgName",
")",
":",
"# Get the python package and it's .cfg file",
"thePkg",
",",
"theFile",
"=",
"findCfgFileForPkg",
"(",
"pkgName",
",",
"'.cfg'",
")",
"# See if the user has any of their own local .cfg files for this task",
"tname",
"=... | See if the user has one of their own local .cfg files for this task,
such as might be created automatically during the save of a read-only
package, and return their names. | [
"See",
"if",
"the",
"user",
"has",
"one",
"of",
"their",
"own",
"local",
".",
"cfg",
"files",
"for",
"this",
"task",
"such",
"as",
"might",
"be",
"created",
"automatically",
"during",
"the",
"save",
"of",
"a",
"read",
"-",
"only",
"package",
"and",
"re... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L282-L291 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | checkSetReadOnly | def checkSetReadOnly(fname, raiseOnErr = False):
""" See if we have write-privileges to this file. If we do, and we
are not supposed to, then fix that case. """
if os.access(fname, os.W_OK):
# We can write to this but it is supposed to be read-only. Fix it.
# Take away usr-write, leave grou... | python | def checkSetReadOnly(fname, raiseOnErr = False):
""" See if we have write-privileges to this file. If we do, and we
are not supposed to, then fix that case. """
if os.access(fname, os.W_OK):
# We can write to this but it is supposed to be read-only. Fix it.
# Take away usr-write, leave grou... | [
"def",
"checkSetReadOnly",
"(",
"fname",
",",
"raiseOnErr",
"=",
"False",
")",
":",
"if",
"os",
".",
"access",
"(",
"fname",
",",
"os",
".",
"W_OK",
")",
":",
"# We can write to this but it is supposed to be read-only. Fix it.",
"# Take away usr-write, leave group and o... | See if we have write-privileges to this file. If we do, and we
are not supposed to, then fix that case. | [
"See",
"if",
"we",
"have",
"write",
"-",
"privileges",
"to",
"this",
"file",
".",
"If",
"we",
"do",
"and",
"we",
"are",
"not",
"supposed",
"to",
"then",
"fix",
"that",
"case",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L294-L301 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | flattenDictTree | def flattenDictTree(aDict):
""" Takes a dict of vals and dicts (so, a tree) as input, and returns
a flat dict (only one level) as output. All key-vals are moved to
the top level. Sub-section dict names (keys) are ignored/dropped.
If there are name collisions, an error is raised. """
retval = {}
... | python | def flattenDictTree(aDict):
""" Takes a dict of vals and dicts (so, a tree) as input, and returns
a flat dict (only one level) as output. All key-vals are moved to
the top level. Sub-section dict names (keys) are ignored/dropped.
If there are name collisions, an error is raised. """
retval = {}
... | [
"def",
"flattenDictTree",
"(",
"aDict",
")",
":",
"retval",
"=",
"{",
"}",
"for",
"k",
"in",
"aDict",
":",
"val",
"=",
"aDict",
"[",
"k",
"]",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"# This val is a dict, get its data (recursively) into a fla... | Takes a dict of vals and dicts (so, a tree) as input, and returns
a flat dict (only one level) as output. All key-vals are moved to
the top level. Sub-section dict names (keys) are ignored/dropped.
If there are name collisions, an error is raised. | [
"Takes",
"a",
"dict",
"of",
"vals",
"and",
"dicts",
"(",
"so",
"a",
"tree",
")",
"as",
"input",
"and",
"returns",
"a",
"flat",
"dict",
"(",
"only",
"one",
"level",
")",
"as",
"output",
".",
"All",
"key",
"-",
"vals",
"are",
"moved",
"to",
"the",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L304-L331 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | countKey | def countKey(theDict, name):
""" Return the number of times the given par exists in this dict-tree,
since the same key name may be used in different sections/sub-sections. """
retval = 0
for key in theDict:
val = theDict[key]
if isinstance(val, dict):
retval += countKey(val,... | python | def countKey(theDict, name):
""" Return the number of times the given par exists in this dict-tree,
since the same key name may be used in different sections/sub-sections. """
retval = 0
for key in theDict:
val = theDict[key]
if isinstance(val, dict):
retval += countKey(val,... | [
"def",
"countKey",
"(",
"theDict",
",",
"name",
")",
":",
"retval",
"=",
"0",
"for",
"key",
"in",
"theDict",
":",
"val",
"=",
"theDict",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"retval",
"+=",
"countKey",
"(",
"val",... | Return the number of times the given par exists in this dict-tree,
since the same key name may be used in different sections/sub-sections. | [
"Return",
"the",
"number",
"of",
"times",
"the",
"given",
"par",
"exists",
"in",
"this",
"dict",
"-",
"tree",
"since",
"the",
"same",
"key",
"name",
"may",
"be",
"used",
"in",
"different",
"sections",
"/",
"sub",
"-",
"sections",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L334-L349 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | findFirstPar | def findFirstPar(theDict, name, _depth=0):
""" Find the given par. Return tuple: (its own (sub-)dict, its value).
Returns the first match found, without checking whether the given key name
is unique or whether it is used in multiple sections. """
for key in theDict:
val = theDict[key]
# ... | python | def findFirstPar(theDict, name, _depth=0):
""" Find the given par. Return tuple: (its own (sub-)dict, its value).
Returns the first match found, without checking whether the given key name
is unique or whether it is used in multiple sections. """
for key in theDict:
val = theDict[key]
# ... | [
"def",
"findFirstPar",
"(",
"theDict",
",",
"name",
",",
"_depth",
"=",
"0",
")",
":",
"for",
"key",
"in",
"theDict",
":",
"val",
"=",
"theDict",
"[",
"key",
"]",
"# print _depth*' ', key, str(val)[:40]",
"if",
"isinstance",
"(",
"val",
",",
"dict",
... | Find the given par. Return tuple: (its own (sub-)dict, its value).
Returns the first match found, without checking whether the given key name
is unique or whether it is used in multiple sections. | [
"Find",
"the",
"given",
"par",
".",
"Return",
"tuple",
":",
"(",
"its",
"own",
"(",
"sub",
"-",
")",
"dict",
"its",
"value",
")",
".",
"Returns",
"the",
"first",
"match",
"found",
"without",
"checking",
"whether",
"the",
"given",
"key",
"name",
"is",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L352-L374 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | findScopedPar | def findScopedPar(theDict, scope, name):
""" Find the given par. Return tuple: (its own (sub-)dict, its value). """
# Do not search (like findFirstPar), but go right to the correct
# sub-section, and pick it up. Assume it is there as stated.
if len(scope):
theDict = theDict[scope] # ! only goe... | python | def findScopedPar(theDict, scope, name):
""" Find the given par. Return tuple: (its own (sub-)dict, its value). """
# Do not search (like findFirstPar), but go right to the correct
# sub-section, and pick it up. Assume it is there as stated.
if len(scope):
theDict = theDict[scope] # ! only goe... | [
"def",
"findScopedPar",
"(",
"theDict",
",",
"scope",
",",
"name",
")",
":",
"# Do not search (like findFirstPar), but go right to the correct",
"# sub-section, and pick it up. Assume it is there as stated.",
"if",
"len",
"(",
"scope",
")",
":",
"theDict",
"=",
"theDict",
... | Find the given par. Return tuple: (its own (sub-)dict, its value). | [
"Find",
"the",
"given",
"par",
".",
"Return",
"tuple",
":",
"(",
"its",
"own",
"(",
"sub",
"-",
")",
"dict",
"its",
"value",
")",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L377-L383 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | setPar | def setPar(theDict, name, value):
""" Sets a par's value without having to give its scope/section. """
section, previousVal = findFirstPar(theDict, name)
# "section" is the actual object, not a copy
section[name] = value | python | def setPar(theDict, name, value):
""" Sets a par's value without having to give its scope/section. """
section, previousVal = findFirstPar(theDict, name)
# "section" is the actual object, not a copy
section[name] = value | [
"def",
"setPar",
"(",
"theDict",
",",
"name",
",",
"value",
")",
":",
"section",
",",
"previousVal",
"=",
"findFirstPar",
"(",
"theDict",
",",
"name",
")",
"# \"section\" is the actual object, not a copy",
"section",
"[",
"name",
"]",
"=",
"value"
] | Sets a par's value without having to give its scope/section. | [
"Sets",
"a",
"par",
"s",
"value",
"without",
"having",
"to",
"give",
"its",
"scope",
"/",
"section",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L386-L390 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | mergeConfigObj | def mergeConfigObj(configObj, inputDict):
""" Merge the inputDict values into an existing given configObj instance.
The inputDict is a "flat" dict - it has no sections/sub-sections. The
configObj may have sub-sections nested to any depth. This will raise a
DuplicateKeyError if one of the inputDict key... | python | def mergeConfigObj(configObj, inputDict):
""" Merge the inputDict values into an existing given configObj instance.
The inputDict is a "flat" dict - it has no sections/sub-sections. The
configObj may have sub-sections nested to any depth. This will raise a
DuplicateKeyError if one of the inputDict key... | [
"def",
"mergeConfigObj",
"(",
"configObj",
",",
"inputDict",
")",
":",
"# Expanded upon Warren's version in astrodrizzle",
"# Verify that all inputDict keys in configObj are unique within configObj",
"for",
"key",
"in",
"inputDict",
":",
"if",
"countKey",
"(",
"configObj",
",",... | Merge the inputDict values into an existing given configObj instance.
The inputDict is a "flat" dict - it has no sections/sub-sections. The
configObj may have sub-sections nested to any depth. This will raise a
DuplicateKeyError if one of the inputDict keys is used more than once in
configObj (e.g. wi... | [
"Merge",
"the",
"inputDict",
"values",
"into",
"an",
"existing",
"given",
"configObj",
"instance",
".",
"The",
"inputDict",
"is",
"a",
"flat",
"dict",
"-",
"it",
"has",
"no",
"sections",
"/",
"sub",
"-",
"sections",
".",
"The",
"configObj",
"may",
"have",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L393-L407 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | findTheLost | def findTheLost(config_file, configspec_file, skipHidden=True):
""" Find any lost/missing parameters in this cfg file, compared to what
the .cfgspc says should be there. This method is recommended by the
ConfigObj docs. Return a stringified list of item errors. """
# do some sanity checking, but don't (... | python | def findTheLost(config_file, configspec_file, skipHidden=True):
""" Find any lost/missing parameters in this cfg file, compared to what
the .cfgspc says should be there. This method is recommended by the
ConfigObj docs. Return a stringified list of item errors. """
# do some sanity checking, but don't (... | [
"def",
"findTheLost",
"(",
"config_file",
",",
"configspec_file",
",",
"skipHidden",
"=",
"True",
")",
":",
"# do some sanity checking, but don't (yet) make this a serious error",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_file",
")",
":",
"print",
... | Find any lost/missing parameters in this cfg file, compared to what
the .cfgspc says should be there. This method is recommended by the
ConfigObj docs. Return a stringified list of item errors. | [
"Find",
"any",
"lost",
"/",
"missing",
"parameters",
"in",
"this",
"cfg",
"file",
"compared",
"to",
"what",
"the",
".",
"cfgspc",
"says",
"should",
"be",
"there",
".",
"This",
"method",
"is",
"recommended",
"by",
"the",
"ConfigObj",
"docs",
".",
"Return",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1244-L1281 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | isHiddenName | def isHiddenName(astr):
""" Return True if this string name denotes a hidden par or section """
if astr is not None and len(astr) > 2 and astr.startswith('_') and \
astr.endswith('_'):
return True
else:
return False | python | def isHiddenName(astr):
""" Return True if this string name denotes a hidden par or section """
if astr is not None and len(astr) > 2 and astr.startswith('_') and \
astr.endswith('_'):
return True
else:
return False | [
"def",
"isHiddenName",
"(",
"astr",
")",
":",
"if",
"astr",
"is",
"not",
"None",
"and",
"len",
"(",
"astr",
")",
">",
"2",
"and",
"astr",
".",
"startswith",
"(",
"'_'",
")",
"and",
"astr",
".",
"endswith",
"(",
"'_'",
")",
":",
"return",
"True",
... | Return True if this string name denotes a hidden par or section | [
"Return",
"True",
"if",
"this",
"string",
"name",
"denotes",
"a",
"hidden",
"par",
"or",
"section"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1284-L1290 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | flattened2str | def flattened2str(flattened, missing=False, extra=False):
""" Return a pretty-printed multi-line string version of the output of
flatten_errors. Know that flattened comes in the form of a list
of keys that failed. Each member of the list is a tuple::
([list of sections...], key, result)
so we ... | python | def flattened2str(flattened, missing=False, extra=False):
""" Return a pretty-printed multi-line string version of the output of
flatten_errors. Know that flattened comes in the form of a list
of keys that failed. Each member of the list is a tuple::
([list of sections...], key, result)
so we ... | [
"def",
"flattened2str",
"(",
"flattened",
",",
"missing",
"=",
"False",
",",
"extra",
"=",
"False",
")",
":",
"if",
"flattened",
"is",
"None",
"or",
"len",
"(",
"flattened",
")",
"<",
"1",
":",
"return",
"''",
"retval",
"=",
"''",
"for",
"sections",
... | Return a pretty-printed multi-line string version of the output of
flatten_errors. Know that flattened comes in the form of a list
of keys that failed. Each member of the list is a tuple::
([list of sections...], key, result)
so we turn that into a string. Set missing to True if all the input
... | [
"Return",
"a",
"pretty",
"-",
"printed",
"multi",
"-",
"line",
"string",
"version",
"of",
"the",
"output",
"of",
"flatten_errors",
".",
"Know",
"that",
"flattened",
"comes",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"keys",
"that",
"failed",
".",
"Ea... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L1293-L1341 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getDefaultSaveFilename | def getDefaultSaveFilename(self, stub=False):
""" Return name of file where we are expected to be saved if no files
for this task have ever been saved, and the user wishes to save. If
stub is True, the result will be <dir>/<taskname>_stub.cfg instead of
<dir>/<taskname>.cfg. """
... | python | def getDefaultSaveFilename(self, stub=False):
""" Return name of file where we are expected to be saved if no files
for this task have ever been saved, and the user wishes to save. If
stub is True, the result will be <dir>/<taskname>_stub.cfg instead of
<dir>/<taskname>.cfg. """
... | [
"def",
"getDefaultSaveFilename",
"(",
"self",
",",
"stub",
"=",
"False",
")",
":",
"if",
"stub",
":",
"return",
"self",
".",
"_rcDir",
"+",
"os",
".",
"sep",
"+",
"self",
".",
"__taskName",
"+",
"'_stub.cfg'",
"else",
":",
"return",
"self",
".",
"_rcDi... | Return name of file where we are expected to be saved if no files
for this task have ever been saved, and the user wishes to save. If
stub is True, the result will be <dir>/<taskname>_stub.cfg instead of
<dir>/<taskname>.cfg. | [
"Return",
"name",
"of",
"file",
"where",
"we",
"are",
"expected",
"to",
"be",
"saved",
"if",
"no",
"files",
"for",
"this",
"task",
"have",
"ever",
"been",
"saved",
"and",
"the",
"user",
"wishes",
"to",
"save",
".",
"If",
"stub",
"is",
"True",
"the",
... | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L628-L636 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.syncParamList | def syncParamList(self, firstTime, preserve_order=True):
""" Set or reset the internal param list from the dict's contents. """
# See the note in setParam about this design.
# Get latest par values from dict. Make sure we do not
# change the id of the __paramList pointer here.
... | python | def syncParamList(self, firstTime, preserve_order=True):
""" Set or reset the internal param list from the dict's contents. """
# See the note in setParam about this design.
# Get latest par values from dict. Make sure we do not
# change the id of the __paramList pointer here.
... | [
"def",
"syncParamList",
"(",
"self",
",",
"firstTime",
",",
"preserve_order",
"=",
"True",
")",
":",
"# See the note in setParam about this design.",
"# Get latest par values from dict. Make sure we do not",
"# change the id of the __paramList pointer here.",
"new_list",
"=",
"sel... | Set or reset the internal param list from the dict's contents. | [
"Set",
"or",
"reset",
"the",
"internal",
"param",
"list",
"from",
"the",
"dict",
"s",
"contents",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L638-L669 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.getDefaultParList | def getDefaultParList(self):
""" Return a par list just like ours, but with all default values. """
# The code below (create a new set-to-dflts obj) is correct, but it
# adds a tenth of a second to startup. Clicking "Defaults" in the
# GUI does not call this. But this can be used to se... | python | def getDefaultParList(self):
""" Return a par list just like ours, but with all default values. """
# The code below (create a new set-to-dflts obj) is correct, but it
# adds a tenth of a second to startup. Clicking "Defaults" in the
# GUI does not call this. But this can be used to se... | [
"def",
"getDefaultParList",
"(",
"self",
")",
":",
"# The code below (create a new set-to-dflts obj) is correct, but it",
"# adds a tenth of a second to startup. Clicking \"Defaults\" in the",
"# GUI does not call this. But this can be used to set the order seen.",
"# But first check for rare ca... | Return a par list just like ours, but with all default values. | [
"Return",
"a",
"par",
"list",
"just",
"like",
"ours",
"but",
"with",
"all",
"default",
"values",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L680-L694 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.setParam | def setParam(self, name, val, scope='', check=1, idxHint=None):
""" Find the ConfigObj entry. Update the __paramList. """
theDict, oldVal = findScopedPar(self, scope, name)
# Set the value, even if invalid. It needs to be set before
# the validation step (next).
theDict[name] ... | python | def setParam(self, name, val, scope='', check=1, idxHint=None):
""" Find the ConfigObj entry. Update the __paramList. """
theDict, oldVal = findScopedPar(self, scope, name)
# Set the value, even if invalid. It needs to be set before
# the validation step (next).
theDict[name] ... | [
"def",
"setParam",
"(",
"self",
",",
"name",
",",
"val",
",",
"scope",
"=",
"''",
",",
"check",
"=",
"1",
",",
"idxHint",
"=",
"None",
")",
":",
"theDict",
",",
"oldVal",
"=",
"findScopedPar",
"(",
"self",
",",
"scope",
",",
"name",
")",
"# Set the... | Find the ConfigObj entry. Update the __paramList. | [
"Find",
"the",
"ConfigObj",
"entry",
".",
"Update",
"the",
"__paramList",
"."
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L723-L750 | train |
spacetelescope/stsci.tools | lib/stsci/tools/cfgpars.py | ConfigObjPars.saveParList | def saveParList(self, *args, **kw):
"""Write parameter data to filename (string or filehandle)"""
if 'filename' in kw:
filename = kw['filename']
if not filename:
filename = self.getFilename()
if not filename:
raise ValueError("No filename specified to ... | python | def saveParList(self, *args, **kw):
"""Write parameter data to filename (string or filehandle)"""
if 'filename' in kw:
filename = kw['filename']
if not filename:
filename = self.getFilename()
if not filename:
raise ValueError("No filename specified to ... | [
"def",
"saveParList",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"'filename'",
"in",
"kw",
":",
"filename",
"=",
"kw",
"[",
"'filename'",
"]",
"if",
"not",
"filename",
":",
"filename",
"=",
"self",
".",
"getFilename",
"(",
... | Write parameter data to filename (string or filehandle) | [
"Write",
"parameter",
"data",
"to",
"filename",
"(",
"string",
"or",
"filehandle",
")"
] | 9a022503ad24ca54ce83331482dfa3ff6de9f403 | https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/cfgpars.py#L752-L790 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.