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

Method repr

src/IECorePython/CompoundDataBinding.cpp:431–476  ·  view source on GitHub ↗

\todo Move outside template so that it specialises the repr() in IECoreBinding.h

Source from the content-addressed store, hash-verified

429
430 /// \todo Move outside template so that it specialises the repr() in IECoreBinding.h
431 static std::string repr( CompoundData &x )
432 {
433 std::stringstream s;
434
435 s << "IECore." << x.typeName() << "(";
436
437 bool added = false;
438 for (
439 CompoundDataMap::const_iterator it = x.readable().begin();
440 it != x.readable().end();
441 ++it )
442 {
443 const std::string &key = it->first;
444
445 object item( it->second );
446
447 if ( item.attr( "__repr__" ) != object() )
448 {
449 std::string v = call_method< std::string >( item.ptr(), "__repr__" );
450
451 if ( !added )
452 {
453 added = true;
454 s << "{";
455 }
456 else
457 {
458 s << ",";
459 }
460
461 s << "'";
462 s << key;
463 s << "':";
464 s << v;
465 }
466 }
467
468 if ( added )
469 {
470 s << "}";
471 }
472
473 s << ")";
474
475 return s.str();
476 }
477
478 protected:
479 /*

Callers 2

testMethod · 0.80
testInfinityMethod · 0.80

Calls 4

typeNameMethod · 0.80
readableMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by 2

testMethod · 0.64
testInfinityMethod · 0.64