Skip to content

Commit 9011f4b

Browse files
SwooshyCuebalanking
authored andcommitted
[#183] better handling of rule INPUT and OUTPUT variables
With this change, global_vars is deprecated and replaced with irods_rule_vars, which is available in more contexts.
1 parent 0f5df8f commit 9011f4b

58 files changed

Lines changed: 191 additions & 168 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ Aug 8 20:57:43 pid:23802 NOTICE: writeLine: inString = PYTHON - acPostProcForPu
134134

135135
# Python globals and built-in modules
136136
These built-in objects are set up at plugin initialization time and available in the python interpreter that loads `core.py` or, as the case may be, the Python rule file:
137-
- `global_vars` - a dictionary for accessing variables of the form `*var` from the `INPUT` line, if present.
137+
- `irods_rule_vars` - a dictionary for accessing variables of the form `*var` from the `INPUT` line, if present.
138138
- `irods_types` - a module containing common struct types used for communicating with microservices.
139139
- `irods_errors` - a module mapping well-known iRODS error names to their corresponding integer values.
140+
- `global_vars` - deprecated alias for `irods_rule_vars`; only available in some contexts. Will be removed in a future release.
140141

141142
By using the `irods_errors` built-in, policy may indicate how the framework is to continue through the use of a symbolic name, rather than a cryptic number reference:
142143
```
@@ -165,7 +166,7 @@ def testRule(rule_args, callback, rei):
165166
and a rule script file (named `call_testRule.r`) which calls `testRule` with a data path argument:
166167
```
167168
def main(_,callback,rei):
168-
data_path = global_vars[ '*dataPath' ][1:-1]
169+
data_path = irods_rule_vars[ '*dataPath' ][1:-1]
169170
retval = callback.testRule( data_path )
170171
callback.writeLine( "stdout", retval['arguments'][0])
171172
INPUT *dataPath=""

python_rules/rulegenerateBagIt.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def main(rule_args, callback, rei):
2-
bagIt_data = global_vars['*BAGITDATA'][1:-1]
3-
new_bagIt_root = global_vars['*NEWBAGITROOT'][1:-1]
2+
bagIt_data = irods_rule_vars['*BAGITDATA'][1:-1]
3+
new_bagIt_root = irods_rule_vars['*NEWBAGITROOT'][1:-1]
44

55
print_size = 0
66
print_unit = ''

python_rules/rulemsiAddConditionToGenQuery.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
def main(rule_args, callback, rei):
2-
select = global_vars['*Select'][1:-1]
3-
attribute = global_vars['*Attribute'][1:-1]
4-
operator = global_vars['*Operator'][1:-1]
5-
value = global_vars['*Value'][1:-1]
2+
select = irods_rule_vars['*Select'][1:-1]
3+
attribute = irods_rule_vars['*Attribute'][1:-1]
4+
operator = irods_rule_vars['*Operator'][1:-1]
5+
value = irods_rule_vars['*Value'][1:-1]
66

77
ret_val = {}
88

python_rules/rulemsiAddKeyValToMspStr.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def main(rule_args, callback, rei):
2-
attr_name = global_vars['*AttrName'][1:-1]
3-
attr_value = global_vars['*AttrValue'][1:-1]
2+
attr_name = irods_rule_vars['*AttrName'][1:-1]
3+
attr_value = irods_rule_vars['*AttrValue'][1:-1]
44

55
out_str = '='.join([attr_name, attr_value])
66

python_rules/rulemsiAddSelectFieldToGenQuery.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def main(rule_args, callback, rei):
2-
select = global_vars['*Select'][1:-1]
3-
select_add = global_vars['*SelectAdd'][1:-1]
4-
fcn = global_vars['*Function'][1:-1]
2+
select = irods_rule_vars['*Select'][1:-1]
3+
select_add = irods_rule_vars['*SelectAdd'][1:-1]
4+
fcn = irods_rule_vars['*Function'][1:-1]
55

66
# Initial select is on COLL_NAME
77
ret_val = callback.msiMakeGenQuery(select, "COLL_NAME like '/tempZone/home/rods/%%'", irods_types.GenQueryInp())

python_rules/rulemsiCheckAccess.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def main(rule_args, callback, rei):
2-
path = global_vars['*Path'][1:-1]
3-
acl = global_vars['*Acl'][1:-1]
2+
path = irods_rule_vars['*Path'][1:-1]
3+
acl = irods_rule_vars['*Acl'][1:-1]
44

55
ret_val = callback.msiCheckAccess(path, acl, 0)
66
result = ret_val['arguments'][2]

python_rules/rulemsiCollCreate.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def main(rule_args, callback, rei):
2-
path = global_vars['*Path'][1:-1]
2+
path = irods_rule_vars['*Path'][1:-1]
33

44
callback.msiCollCreate(path, '0', 0)
55

python_rules/rulemsiCollRsync.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def main(rule_args, callback, rei):
2-
src_coll = global_vars['*srcColl'][1:-1]
3-
dest_coll = global_vars['*destColl'][1:-1]
4-
resource = global_vars['*Resource'][1:-1]
2+
src_coll = irods_rule_vars['*srcColl'][1:-1]
3+
dest_coll = irods_rule_vars['*destColl'][1:-1]
4+
resource = irods_rule_vars['*Resource'][1:-1]
55

66
callback.msiCollRsync(src_coll, dest_coll, resource, 'IRODS_TO_IRODS', 0)
77

python_rules/rulemsiDataObjChksum.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def main(rule_args, callback, rei):
2-
data_object = global_vars['*dataObject'][1:-1]
3-
flags = global_vars['*Flags'][1:-1]
2+
data_object = irods_rule_vars['*dataObject'][1:-1]
3+
flags = irods_rule_vars['*Flags'][1:-1]
44

55
import os
66
(coll, file) = os.path.split(data_object)

python_rules/rulemsiDataObjClose.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def main(rule_args, callback, rei):
2-
resc = global_vars['*Resc'][1:-1]
3-
obj = global_vars['*Obj'][1:-1]
4-
oflags = global_vars['*OFlags'][1:-1]
2+
resc = irods_rule_vars['*Resc'][1:-1]
3+
obj = irods_rule_vars['*Obj'][1:-1]
4+
oflags = irods_rule_vars['*OFlags'][1:-1]
55

66
ret_val = callback.msiDataObjCreate(obj, oflags, 0)
77
file_desc = ret_val['arguments'][2]

0 commit comments

Comments
 (0)