MCPcopy Create free account
hub / github.com/ImageEngine/cortex / __serialiseStringArrayWithEscape

Function __serialiseStringArrayWithEscape

python/IECore/ParameterParser.py:499–513  ·  view source on GitHub ↗
( parameter, value )

Source from the content-addressed store, hash-verified

497 return list(value)
498
499def __serialiseStringArrayWithEscape( parameter, value ) :
500
501 acceptFlags = False
502 if "parser" in parameter.userData() and "acceptFlags" in parameter.userData()["parser"] :
503 acceptFlags = parameter.userData()["parser"]["acceptFlags"].value
504
505 if acceptFlags :
506 return list(value)
507 else :
508 # when serialising string arrays that can start with "-"
509 # we take care to escape it with a leading "\",
510 # so it won't be confused with a new argument name
511 # we also escape anything that starts with any number of "\" followed by a "-"
512 # so they don't confused with an intentional escape
513 return [ "\\{}".format( x ) if re.match( r"^\\*-.*", x ) else x for x in value ]
514
515def __serialiseUsingStr( parameter, value ) :
516

Callers

nothing calls this directly

Calls 2

matchMethod · 0.80
userDataMethod · 0.45

Tested by

no test coverage detected