text stringlengths 81 112k |
|---|
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... |
show a summary of all projects
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])
out... |
show current 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... |
start tracking for <project>
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... |
stop tracking for the active project
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 ... |
parses a stream with text formatted as a Timed logfile and shows a summary
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()]
# T... |
prints a newline-separated list of all projects
def projects(logfile, time_format):
"prints a newline-separated list of all projects"
print '\n'.join(server.list_projects(read(logfile, time_format))) |
Returns a formatted string with the current local time.
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 |
Returns a formatted string with the current date.
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 |
Convert DATE string into a decimal year.
def convertDate(date):
"""Convert DATE string into a decimal year."""
d, t = date.split('T')
return decimal_date(d, timeobs=t) |
Convert DATE-OBS (and optional TIME-OBS) into a decimal year.
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 ... |
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]
def interpretDQvalue(input):
"""
Converts an integer 'input' into its component bit values as a list of
power of 2 integers.
For example, the b... |
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... |
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.
d... |
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 ... |
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.
def buildNewRootname(filename, extn=None, extlist=None):
"""
Build rootname for a new file.
Use ... |
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
def buildRootname(filen... |
General, write-safe method for returning a keyword value from the header of
a IRAF recognized image.
Returns the value as a string.
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.... |
Return a copy of the PRIMARY header, along with any group/extension header
for this filename specification.
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(fi... |
Add/update keyword to header with given value.
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 hea... |
Build a new FITS filename for a GEIS input image.
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 _fitsn... |
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... |
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
def parseFilename(filename):
"""
Parse out filename from any specified extensions.
Returns rootname and string version of extension name.
"""
# Parse out any extension specified in filena... |
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
--------
... |
Return the number of 'extname' extensions, defaulting to counting the
number of SCI extensions.
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):
... |
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):
"""
R... |
Search a directory for full filename with optional path.
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
... |
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.
def checkFileExists(filename, directory=None):
"""
Checks to see if file specified exists in current or specified directory.
Default is current directory. ... |
Copy a file whole from input to output.
def copyFile(input, output, replace=None):
"""Copy a file whole from input to output."""
_found = findFile(output)
if not _found or (_found and replace):
shutil.copy2(input, output) |
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'.
def removeFile(inlist):
"""
Utility function for deleting a list of files or a single file.
This function will automatically delete both f... |
This function will return the index of the extension in a multi-extension
FITS file which contains the desired keyword with the given value.
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 k... |
Returns the list number of the extension corresponding to EXTNAME given.
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:
... |
Returns the next non-blank line in an ASCII file.
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 |
List IRAF variables.
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(w... |
Undo Python conversion of CL parameter or variable name.
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', '.')... |
Get value of IRAF or OS environment variable.
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 kn... |
Convert IRAF virtual path name to OS pathname.
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 p... |
Returns true if CL variable is defined.
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 ... |
Set IRAF environment variables.
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 ... |
Print value of IRAF or OS environment variables.
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 ... |
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.
def unset(*args, **kw):
"""
Unset IRAF environment var... |
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).
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)... |
Check if this is a legal date in the Julian calendar
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))
retu... |
Calculate Julian calendar date from Julian day
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 -... |
Convert to Julian day using astronomical years (0 = 1 BC, -1 = 2 BC)
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:
... |
Test for delay of start of new year and to avoid
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)
... |
Check for delay in start of new year due to length of adjacent years
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 presen... |
How many days are in a given month of a given year
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, VEAD... |
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... |
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):
"""
Initial... |
Yields the analysed wav data.
:param targetId:
:return:
def get(self, targetId):
"""
Yields the analysed wav data.
:param targetId:
:return:
"""
result = self._targetController.analyse(targetId)
if result:
if len(result) == 2:
... |
stores a new target.
:param targetId: the target to store.
:return:
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... |
Return a datetime for the input floating point Julian Day Count
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 ... |
Slightly introverted parser for lists of dot-notation nested fields
i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}}
def dict_from_qs(qs):
''' Slightly introverted parser for lists of dot-notation nested fields
i.e. "period.di,period.fhr" => {"period": {"di": {}, "fhr": {}}}
'''... |
Same as dict_from_qs, but in reverse
i.e. {"period": {"di": {}, "fhr": {}}} => "period.di,period.fhr"
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 ""
... |
Set up connection before executing function, commit and close connection
afterwards. Unless a connection already has been created.
def dbcon(func):
"""Set up connection before executing function, commit and close connection
afterwards. Unless a connection already has been created."""
@wraps(func)
d... |
Add new sensor to the database
Parameters
----------
sid : str
SensorId
token : str
def add(self, sid, token):
"""
Add new sensor to the database
Parameters
----------
sid : str
SensorId
token : str
"""
... |
Remove sensor from the database
Parameters
----------
sid : str
SensorID
def remove(self, sid):
"""
Remove sensor from the database
Parameters
----------
sid : str
SensorID
"""
self.dbcur.execute(SQL_SENSOR_DEL, (... |
Synchronise data
Parameters
----------
sids : list of str
SensorIDs to sync
Optional, leave empty to sync everything
def sync(self, *sids):
"""
Synchronise data
Parameters
----------
sids : list of str
SensorIDs to sy... |
List all tmpo-blocks in the database
Parameters
----------
sids : list of str
SensorID's for which to list blocks
Optional, leave empty to get them all
Returns
-------
list[list[tuple]]
def list(self, *sids):
"""
List all tmpo-bl... |
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 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
... |
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
def fir... |
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
def la... |
Parameters
----------
sid : str
SensorId
epoch : bool
default False
If True return as epoch
If False return as pd.Timestamp
Returns
-------
pd.Timestamp | int, float
def last_datapoint(self, sid, epoch=False):
"""
... |
Numpy: Modifying Array Values
http://docs.scipy.org/doc/numpy/reference/arrays.nditer.html
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"]):
de... |
Take a check function signature (string), and parse it to get a dict
of the keyword args and their values.
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 ... |
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)
def separateKeywords(kwArgsDict):
""" Look through the keywords passed and separate the special ones we
have added... |
Alter the passed function signature string to add the given kewords
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
fo... |
Defines the gaussian function to be used as the model.
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)
... |
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... |
filter lets django managers use `objects.filter` on a hashable object.
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.m... |
this method allows django managers use `objects.get_or_create` and
`objects.update_or_create` on a hashable object.
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.
... |
a private method that persists an estimator object to the filesystem
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... |
a private method that loads an estimator object from the filesystem
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... |
Return an Estimator object given the path of the file, relative to the MEDIA_ROOT
def create_from_file(cls, filename):
"""Return an Estimator object given the path of the file, relative to the MEDIA_ROOT"""
obj = cls()
obj.object_file = filename
obj.load()
return obj |
Return our application dir. Create it if it doesn't exist.
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)... |
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... |
Read a config file and pull out the value of a given keyword.
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 ... |
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... |
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 }
def findAllCfgTasksUnderDir(aDir):
""" Finds all installed tasks by examining any .cfg files found on disk
at a... |
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 ... |
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 ~/... |
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.
def getUsrCfgFilesForPyPkg(pkgName):
""" See if the user has one of their own local .cfg files for this task,
such as m... |
See if we have write-privileges to this file. If we do, and we
are not supposed to, then fix that case.
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):
... |
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.
def flattenDictTree(aDict):
""" Takes a dict of vals ... |
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.
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-sectio... |
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.
def findFirstPar(theDict, name, _depth=0):
""" Find the given par. Return tuple: (its own (sub-)dict, its val... |
Find the given par. Return tuple: (its own (sub-)dict, its value).
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 sta... |
Sets a par's value without having to give its scope/section.
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 |
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... |
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.
def findTheLost(config_file, configspec_file, skipHidden=True):
""" Find any lost/missing parameters in this cfg ... |
Return True if this string name denotes a hidden par or section
def isHiddenName(astr):
""" Return True if this string name denotes a hidden par or section """
if astr is not None and len(astr) > 2 and astr.startswith('_') and \
astr.endswith('_'):
return True
else:
return False |
Return 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 name of file where we are expected to be saved if no files
for this task have ever been saved, and the user wishes to save. If
stub is True, the result will be <dir>/<taskname>_stub.cfg instead of
<dir>/<taskname>.cfg.
def getDefaultSaveFilename(self, stub=False):
""" Return nam... |
Set or reset the internal param list from the dict's contents.
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
... |
Return a par list just like ours, but with all default values.
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 t... |
Find the ConfigObj entry. Update the __paramList.
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
... |
Write parameter data to filename (string or filehandle)
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.