Package gavo :: Package base :: Module macros :: Class MacroPackage
[frames] | no frames]

Class MacroPackage

source code

object --+
         |
        MacroPackage
Known Subclasses:

is a function dispatcher for MacroExpander.

Basically, you inherit from this class and define macro_xxx functions. MacroExpander can then call \xxx, possibly with arguments.

Instance Methods
 
listMacros(self) source code
 
execMacro(self, macName, args) source code
 
getExpander(self) source code
 
expand(self, stuff) source code
 
macro_quote(self, arg)
returns the argument in quotes (with internal quotes backslash-escaped if necessary).
source code
 
macro_sqlquote(self, arg)
returns the argument as a quoted string, unless it is 'NULL' or None, in which case just NULL is returned.
source code
 
macro_sql_standardPubDID(self, fromCol='accref')
returns a SQL expression returning a DaCHS standard pubDID generated from the accref (or something overridden) column.
source code
 
macro_reSub(self, pattern, replacement, string)
returns the string with the python RE pattern replaced with replacement.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

macro_sql_standardPubDID(self, fromCol='accref')

source code 

returns a SQL expression returning a DaCHS standard pubDID generated from the accref (or something overridden) column.

This is convenient in obscore or ssa views when the underlying table just has accrefs. If your code actually uses the pubDID to search in the table (and it probably shouldn't), better use an actual column and index it.

macro_reSub(self, pattern, replacement, string)

source code 

returns the string with the python RE pattern replaced with replacement.

This is directly handed through to python re.sub, so you can (but probably shouldn't) play all the RE tricks you can in python (e.g., back references).

If you find yourself having to use reSub, you should regard that as an alarm sign that you're probably doing it wrong.

Oh: closing curly braces can be included in the argument by backslash-escaping them.