From 7c05753052eaf91fc41eff6351e798ac0bd8eb2a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 8 Feb 2014 12:34:08 -0500 Subject: [PATCH] allow support module name in info() tag Gives the option of reducing the input link length and preventing runtime switching of module. --- devsupApp/src/devsup/db.py | 14 +++++++++++--- documentation/interfaces.rst | 13 +++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/devsupApp/src/devsup/db.py b/devsupApp/src/devsup/db.py index c337682..5c4176e 100644 --- a/devsupApp/src/devsup/db.py +++ b/devsupApp/src/devsup/db.py @@ -320,11 +320,19 @@ def processLink(name, lstr): """Process the INP or OUT link Expects lstr to be "module arg1 arg2" + if the 'pySupportMod' info tag is not given. + When it is, the link string is passed + to the module build() function without + processing. - Returns (callable, Record, "arg1 arg2") + Returns (Record, Support) """ rec = getRecord(name) - parts = lstr.split(None,1) - modname, args = parts[0], parts[1] if len(parts)>1 else None + modname = rec.info('pySupportMod', None) + if not modname: + parts = lstr.split(None,1) + modname, args = parts[0], parts[1] if len(parts)>1 else None + else: + args = lstr mod = importmod(modname) return rec, mod.build(rec, args) diff --git a/documentation/interfaces.rst b/documentation/interfaces.rst index 9ff7466..d68228f 100644 --- a/documentation/interfaces.rst +++ b/documentation/interfaces.rst @@ -150,13 +150,22 @@ This support code can then be referenced from records. :: record(longin, "my:int:counter") { field(DTYP, "Python Device") - field(INP , "counter hello world") + field(INP , "@counter hello world") } The following will fail to associate. :: record(longin, "my:int:counter") { field(DTYP, "Python Device") - field(INP , "counter do what I say") + field(INP , "@counter do what I say") } +If a shorter INP link string is necessary, or to prevent +runtime switching of modules, the module name may also +be given in the *pySupportMod* info() tag. :: + + record(longin, "my:int:counter") { + field(DTYP, "Python Device") + field(INP , "@hello world") + info("pySupportMod", "counter") + }