Package gavo :: Package grammars :: Module common :: Class GrammarMacroMixin
[frames] | no frames]

Class GrammarMacroMixin

source code

                object --+        
                         |        
  base.macros.MacroPackage --+    
                             |    
base.macros.StandardMacroMixin --+
                                 |
                                GrammarMacroMixin
Known Subclasses:

A collection of macros available to rowfilters.

NOTE: All macros should return only one single physical python line, or they will mess up the calculation of what constructs caused errors.

Instance Methods
 
macro_inputRelativePath(self, liberalChars='True')
returns an expression giving the current source's path relative to inputsDir
source code
 
macro_fullDLURL(self, dlService)
returns a python expression giving a link to the full current data set retrieved through the datalink service.
source code
 
macro_dlMetaURI(self, dlService)
like fullDLURL, except it points to the datalink metadata.
source code
 
macro_standardPreviewPath(self)
returns an expression for the standard path for a custom preview.
source code
 
macro_splitPreviewPath(self, ext)
returns an expression for the split standard path for a custom preview.
source code
 
macro_rowsProcessed(self)
returns an expression giving the number of records already ingested for this source.
source code
 
macro_sourceDate(self)
returns an expression giving the timestamp of the current source.
source code
 
macro_srcstem(self)
returns python code for the stem of the source file currently parsed in a rowmaker.
source code
 
macro_lastSourceElements(self, numElements)
returns an expression calling rmkfuncs.lastSourceElements on the current input path.
source code
 
macro_rootlessPath(self)
returns an expression giving the current source's path with the resource descriptor's root removed.
source code
 
macro_inputSize(self)
returns an expression giving the size of the current source.
source code
 
macro_colNames(self, tableRef)
returns a comma-separated list of column names for a table reference.
source code
 
macro_property(self, property)
returns the value of property on the parent DD.
source code

Inherited from base.macros.StandardMacroMixin: macro_RSTservicelink, macro_RSTtable, macro_decapitalize, macro_getConfig, macro_internallink, macro_magicEmpty, macro_metaSeq, macro_metaString, macro_rdId, macro_rdIdDotted, macro_schema, macro_test, macro_today, macro_upper, macro_urlquote

Inherited from base.macros.MacroPackage: execMacro, expand, getExpander, listMacros, macro_quote, macro_reSub, macro_sql_standardPubDID, macro_sqlquote

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_inputRelativePath(self, liberalChars='True')

source code 

returns an expression giving the current source's path relative to inputsDir

liberalChars can be a boolean literal (True, False, etc); if false, a value error is raised if characters that will result in trouble with the product mixin are within the result path.

In rowmakers fed by grammars with //products#define, better use @prodtblAccref.

macro_fullDLURL(self, dlService)

source code 

returns a python expression giving a link to the full current data set retrieved through the datalink service.

You would write \fullDLURdlsvc here, and the macro will expand into something like http://yourserver/currd/dlsvc/dlget?ID=ivo://whatever.

dlService is the id of the datalink service in the current RD.

This is intended for "virtual" data where the dataset is generated on the fly through datalink.

macro_dlMetaURI(self, dlService)

source code 

like fullDLURL, except it points to the datalink metadata.

This is intended for binding to //products#define's datalink parameter.

If you need the value in a rowmaker, grab it from @prodtblDatalink.

macro_standardPreviewPath(self)

source code 

returns an expression for the standard path for a custom preview.

This consists of resdir, the name of the previewDir property on the embedding DD, and the flat name of the accref (which this macro assumes to see in its namespace as accref; this is usually the case in //products#define, which is where this macro would typically be used).

As an alternative, there is the splitPreviewPath macro, which does not mogrify the file name. In particular, do not use standardPreviewPath when you have more than a few 1e4 files, as it will have all these files in a single, flat directory, and that can become a chore.

See the introduction to custom previews for details.

macro_splitPreviewPath(self, ext)

source code 

returns an expression for the split standard path for a custom preview.

As standardPreviewPath, except that the directory hierarchy of the data files will be reproduced in previews. For ext, you should typically pass the extension appropriate for the preview (like {.png} or {.jpeg}).

See the introduction to custom previews for details.

macro_srcstem(self)

source code 

returns python code for the stem of the source file currently parsed in a rowmaker.

Example: if you're currently parsing /tmp/foo.bar, the stem is foo.

macro_colNames(self, tableRef)

source code 

returns a comma-separated list of column names for a table reference.

This is convenient if an input file matches the table structure; you can then simply say things like <reGrammar names="\\colName{someTable}"/>.