Package gavo :: Package utils
[frames] | no frames]

Source Code for Package gavo.utils

 1  """ 
 2  Miscellaneous helper modules for DACHS' python modules. 
 3   
 4  This comprises helpers and wrappers that do not need gavo.base but for some 
 5  reason or another should be within the dc package. 
 6  """ 
 7   
 8  #c Copyright 2008-2019, the GAVO project 
 9  #c 
10  #c This program is free software, covered by the GNU GPL.  See the 
11  #c COPYING file in the source distribution. 
12   
13   
14  # Not checked by pyflakes: API file with gratuitous imports 
15   
16   
17  import os 
18   
19  from gavo.utils.algotricks import ( 
20          chunk, identity, topoSort, commonPrefixLength, uniqueItems) 
21   
22  from gavo.utils.autonode import AutoNode 
23   
24  from gavo.utils.codetricks import (silence, ensureExpression, compileFunction, 
25          loadPythonModule, DeferredImport, 
26          memoized, identity, runInSandbox, document,  
27          getKeyNoCase, 
28          buildClassResolver, CachedGetter, CachedResource, intToFunnyWord,  
29          IdManagerMixin, 
30          addDefaults, iterDerivedClasses, iterDerivedObjects, iterConsecutivePairs, 
31          importModule, loadInternalObject, printFrames, memoizeOn, forgetMemoized, 
32          sandbox, 
33          in_dir, memoizedMethod, getTracebackAsString, 
34          Infimum, Supremum, NullObject, 
35          stealVar, 
36          AllEncompassingSet, 
37          bytelist, intlist, floatlist, complexlist, 
38          EqualingRE) 
39  from __builtin__ import list 
40   
41  from gavo.utils.excs import * 
42   
43  # We reliably want the numpy version of pyfits.  Thus, always use 
44  # from gavo.utils import pyfits rather than a direct import;  the 
45  # "master import" is in fitstools, and we get pyfits from there. 
46   
47  from gavo.utils.fitstools import (readPrimaryHeaderQuick, pyfits, 
48          parseESODescriptors, shrinkWCSHeader, cutoutFITS, iterScaledRows, 
49          fitsLock, getWCSAxis) 
50   
51  from gavo.utils.mathtricks import * 
52   
53  from gavo.utils.misctricks import (Undefined, QuotedName, getfirst, 
54          logOldExc, sendUIEvent,  
55          pyparsingWhitechars, pyparsing, 
56          getWithCache, 
57          rstxToHTML, rstxToHTMLWithWarning,  
58          couldBeABibcode, 
59          pyparseString, pyparseTransform, parseKVLine, makeKVLine, 
60          StreamBuffer, CaseSemisensitiveDict, 
61          NotInstalledModuleStub, grouped) 
62   
63  from gavo.utils.ostricks import (safeclose, urlopenRemote,  
64          fgetmtime, cat, ensureDir, safeReplaced, 
65          Arg, exposedFunction, makeCLIParser) 
66   
67  from gavo.utils.plainxml import StartEndHandler, iterparse, traverseETree 
68   
69  from gavo.utils.serializers import (defaultMFRegistry, registerDefaultMF) 
70   
71  from gavo.utils.stanxml import (ElementTree, xmlrender,  
72          escapeAttrVal, escapePCDATA, registerPrefix, getPrefixInfo) 
73   
74  from gavo.utils.texttricks import (formatSize,  
75          makeEllipsis, makeLeftEllipsis, makeSourceEllipsis, 
76          floatRE, dateRE, datetimeRE, identifierPattern, looksLikeURLPat, 
77          datetimeToRFC2616,  
78          parseDefaultDatetime, parseDefaultDate, parseDefaultTime, 
79          parseAccept, 
80          isoTimestampFmt, isoTimestampFmtNoTZ, parseISODT, formatISODT, 
81          formatRFC2616Date, parseRFC2616Date, roundToSeconds, 
82          getFileStem, 
83          fixIndentation, parsePercentExpression, hmsToDeg, dmsToDeg, 
84          fracHoursToDeg, degToHms, degToDms, getRelativePath, parseAssignments,  
85          NameMap, formatSimpleTable, replaceXMLEntityRefs, 
86          ensureOneSlash, getRandomString, 
87          safe_str, iterSimpleText) 
88