(self, args, parameters)
| 60 | # these flagless parameters are parsed in the order they are specified in the data element. |
| 61 | # If parsing fails at any time then a descriptive exception is raised. |
| 62 | def parse(self, args, parameters): |
| 63 | |
| 64 | if not type( args ) is list : |
| 65 | raise TypeError( "args must be a python list!" ) |
| 66 | |
| 67 | flagless = None |
| 68 | flaglessIndex = 0 |
| 69 | if "parser" in parameters.userData() : |
| 70 | if "flagless" in parameters.userData()["parser"] : |
| 71 | flagless = parameters.userData()["parser"]["flagless"] |
| 72 | if not flagless.isInstanceOf( IECore.StringVectorData.staticTypeId() ) : |
| 73 | raise TypeError( "\"flagless\" parameters must be specified by a StringVectorData instance." ) |
| 74 | |
| 75 | parmsFound = {} |
| 76 | result = parameters.defaultValue |
| 77 | args = args[:] # a copy we can mess around with |
| 78 | while len(args): |
| 79 | |
| 80 | # get the name of the parameter being specified |
| 81 | if len( args[0] ) and args[0][0]=="-" : |
| 82 | name = args[0][1:] |
| 83 | del args[0] |
| 84 | elif flagless and flaglessIndex < flagless.size() : |
| 85 | name = flagless[flaglessIndex] |
| 86 | flaglessIndex += 1 |
| 87 | else : |
| 88 | raise SyntaxError( "Expected a flag argument (beginning with \"-\")" ) |
| 89 | |
| 90 | # find the parameter being specified. this might be the child of a compound |
| 91 | # denoted by "." separated names. |
| 92 | nameSplit = name.split( "." ) |
| 93 | |
| 94 | # recurses down the parameters tree |
| 95 | p = parameters |
| 96 | |
| 97 | if p.__class__.__name__ == 'CompoundParameter': |
| 98 | for i in range(0, len(nameSplit)): |
| 99 | if not nameSplit[i] in p: |
| 100 | raise SyntaxError( "\"%s\" is not a parameter name." % name ) |
| 101 | p = p[nameSplit[i]] |
| 102 | |
| 103 | if len( args ) : |
| 104 | |
| 105 | # see if the argument being specified is a preset name, in which case we |
| 106 | # don't need a special parser. |
| 107 | if args[0] in p.getPresets() : |
| 108 | |
| 109 | p.setValue( args[0] ) |
| 110 | del args[0] |
| 111 | continue |
| 112 | |
| 113 | # or if it's asking us to read a value from a file, in which case we |
| 114 | # also don't need a special parser |
| 115 | if args[0].startswith( "read:" ) : |
| 116 | |
| 117 | fileName = args[0][5:] |
| 118 | r = IECore.Reader.create( fileName ) |
| 119 | if not r : |
nothing calls this directly
no test coverage detected