( self, operands )
| 211 | |
| 212 | |
| 213 | def doOperation( self, operands ) : |
| 214 | |
| 215 | # recursively find sequences |
| 216 | baseDirectory = operands["dir"].value |
| 217 | if baseDirectory != "/" and baseDirectory[-1] == '/' : |
| 218 | baseDirectory = baseDirectory[:-1] |
| 219 | |
| 220 | sequences = IECore.ls( baseDirectory, operands["minSequenceSize"].value ) |
| 221 | |
| 222 | # If we've passed in a directory which isn't the current one it is convenient to get that included in the returned sequence names |
| 223 | relDir = os.path.normpath( baseDirectory ) != "." |
| 224 | |
| 225 | if relDir : |
| 226 | for s in sequences : |
| 227 | s.fileName = os.path.join( baseDirectory, s.fileName ) |
| 228 | |
| 229 | if operands["recurse"].value : |
| 230 | # \todo Can safely use os.walk here after Python 2.6, which introduced the followlinks parameter |
| 231 | for root, dirs, files in IECore.SequenceLsOp.__walk( baseDirectory, topdown = True, followlinks = operands["followLinks"].value ) : |
| 232 | relRoot = root[len(baseDirectory)+1:] |
| 233 | if relRoot!="" : |
| 234 | depth = len( relRoot.split( "/" ) ) |
| 235 | else : |
| 236 | depth = 0 |
| 237 | |
| 238 | if depth>=operands["maxDepth"].value : |
| 239 | dirs[:] = [] |
| 240 | |
| 241 | for d in dirs : |
| 242 | ss = IECore.ls( os.path.join( root, d ), operands["minSequenceSize"].value ) |
| 243 | if ss : |
| 244 | for s in ss : |
| 245 | |
| 246 | if relDir : |
| 247 | s.fileName = os.path.join( baseDirectory, relRoot, d, s.fileName ) |
| 248 | else : |
| 249 | s.fileName = os.path.join( relRoot, d, s.fileName ) |
| 250 | sequences.append( s ) |
| 251 | |
| 252 | |
| 253 | # \todo This Op would benefit considerably from dynamic parameters |
| 254 | # NB. Ordering of filters could have considerable impact on execution time. The most expensive filters should be specified last. |
| 255 | filters = [] |
| 256 | |
| 257 | # filter sequences based on type |
| 258 | if operands["type"].value != "any" : |
| 259 | |
| 260 | if operands["type"].value == "files" : |
| 261 | fileTypeTest = os.path.isfile |
| 262 | else : |
| 263 | assert( operands["type"].value == "directories" ) |
| 264 | fileTypeTest = os.path.isdir |
| 265 | |
| 266 | def matchType( sequence ) : |
| 267 | for sequenceFile in sequence.fileNames() : |
| 268 | if not fileTypeTest( sequenceFile ) : |
| 269 | return False |
| 270 |
nothing calls this directly
no test coverage detected