body
stringlengths 26
98.2k
| body_hash
int64 -9,222,864,604,528,158,000
9,221,803,474B
| docstring
stringlengths 1
16.8k
| path
stringlengths 5
230
| name
stringlengths 1
96
| repository_name
stringlengths 7
89
| lang
stringclasses 1
value | body_without_docstring
stringlengths 20
98.2k
|
|---|---|---|---|---|---|---|---|
def test_from_xml_generates_correct_sequencer_hierarchy(self):
'testing if from_xml method will generate Sequences and shots\n correctly\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.from_xml(path)
sequences = sm.sequences.get()
self.assertEqual(len(sequences), 1)
sequencer = sequences[0]
self.assertIsInstance(sequencer, pymel.core.nt.Sequencer)
self.assertEqual(sequencer.duration, 111)
self.assertEqual(sequencer.sequence_name.get(), 'SEQ001_HSNI_003')
self.assertEqual(pymel.core.currentUnit(q=1, t=1), 'film')
time = pymel.core.PyNode('time1')
self.assertEqual(time.timecodeProductionStart.get(), 0.0)
shots = sequencer.shots.get()
self.assertEqual(len(shots), 3)
shot1 = shots[0]
shot2 = shots[1]
shot3 = shots[2]
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1024, shot1.wResolution.get())
self.assertEqual(778, shot1.hResolution.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(34.0, shot1.sequenceEndFrame.get())
self.assertEqual(34.0, shot1.duration)
self.assertEqual(10.0, shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0010_v001.mov', shot1.output.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1024, shot2.wResolution.get())
self.assertEqual(778, shot2.hResolution.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(35.0, shot2.sequenceStartFrame.get())
self.assertEqual(65.0, shot2.sequenceEndFrame.get())
self.assertEqual(31.0, shot2.duration)
self.assertEqual(10.0, shot2.startFrame.get())
self.assertEqual(40.0, shot2.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0020_v001.mov', shot2.output.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1024, shot3.wResolution.get())
self.assertEqual(778, shot3.hResolution.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(66.0, shot3.sequenceStartFrame.get())
self.assertEqual(111.0, shot3.sequenceEndFrame.get())
self.assertEqual(46.0, shot3.duration)
self.assertEqual(10.0, shot3.startFrame.get())
self.assertEqual(55.0, shot3.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0030_v001.mov', shot3.output.get())
| 2,028,905,924,533,081,000
|
testing if from_xml method will generate Sequences and shots
correctly
|
tests/previs/test_sequence_manager_extension.py
|
test_from_xml_generates_correct_sequencer_hierarchy
|
Khosiyat/anima
|
python
|
def test_from_xml_generates_correct_sequencer_hierarchy(self):
'testing if from_xml method will generate Sequences and shots\n correctly\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.from_xml(path)
sequences = sm.sequences.get()
self.assertEqual(len(sequences), 1)
sequencer = sequences[0]
self.assertIsInstance(sequencer, pymel.core.nt.Sequencer)
self.assertEqual(sequencer.duration, 111)
self.assertEqual(sequencer.sequence_name.get(), 'SEQ001_HSNI_003')
self.assertEqual(pymel.core.currentUnit(q=1, t=1), 'film')
time = pymel.core.PyNode('time1')
self.assertEqual(time.timecodeProductionStart.get(), 0.0)
shots = sequencer.shots.get()
self.assertEqual(len(shots), 3)
shot1 = shots[0]
shot2 = shots[1]
shot3 = shots[2]
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1024, shot1.wResolution.get())
self.assertEqual(778, shot1.hResolution.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(34.0, shot1.sequenceEndFrame.get())
self.assertEqual(34.0, shot1.duration)
self.assertEqual(10.0, shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0010_v001.mov', shot1.output.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1024, shot2.wResolution.get())
self.assertEqual(778, shot2.hResolution.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(35.0, shot2.sequenceStartFrame.get())
self.assertEqual(65.0, shot2.sequenceEndFrame.get())
self.assertEqual(31.0, shot2.duration)
self.assertEqual(10.0, shot2.startFrame.get())
self.assertEqual(40.0, shot2.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0020_v001.mov', shot2.output.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1024, shot3.wResolution.get())
self.assertEqual(778, shot3.hResolution.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(66.0, shot3.sequenceStartFrame.get())
self.assertEqual(111.0, shot3.sequenceEndFrame.get())
self.assertEqual(46.0, shot3.duration)
self.assertEqual(10.0, shot3.startFrame.get())
self.assertEqual(55.0, shot3.endFrame.get())
self.assertEqual('/tmp/SEQ001_HSNI_003_0030_v001.mov', shot3.output.get())
|
def test_from_xml_updates_sequencer_hierarchy_with_shots_expanded_and_contracted(self):
'testing if from_xml method will update Sequences and shots\n correctly with the xml file\n '
path = os.path.abspath('./test_data/test_v002.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_xml(path)
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(75.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(64.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(76.0, shot3.sequenceStartFrame.get())
self.assertEqual(131.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(120.0, shot3.endFrame.get())
| 7,175,552,414,838,216,000
|
testing if from_xml method will update Sequences and shots
correctly with the xml file
|
tests/previs/test_sequence_manager_extension.py
|
test_from_xml_updates_sequencer_hierarchy_with_shots_expanded_and_contracted
|
Khosiyat/anima
|
python
|
def test_from_xml_updates_sequencer_hierarchy_with_shots_expanded_and_contracted(self):
'testing if from_xml method will update Sequences and shots\n correctly with the xml file\n '
path = os.path.abspath('./test_data/test_v002.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_xml(path)
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(75.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(64.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(76.0, shot3.sequenceStartFrame.get())
self.assertEqual(131.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(120.0, shot3.endFrame.get())
|
def test_from_edl_updates_sequencer_hierarchy_with_shots_expanded_and_contracted(self):
'testing if from_edl method will update Sequences and shots\n correctly with the edl file\n '
path = os.path.abspath('./test_data/test_v002.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_edl(path)
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(76.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(65.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(77.0, shot3.sequenceStartFrame.get())
self.assertEqual(133.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(121.0, shot3.endFrame.get())
| 4,609,666,304,671,865,000
|
testing if from_edl method will update Sequences and shots
correctly with the edl file
|
tests/previs/test_sequence_manager_extension.py
|
test_from_edl_updates_sequencer_hierarchy_with_shots_expanded_and_contracted
|
Khosiyat/anima
|
python
|
def test_from_edl_updates_sequencer_hierarchy_with_shots_expanded_and_contracted(self):
'testing if from_edl method will update Sequences and shots\n correctly with the edl file\n '
path = os.path.abspath('./test_data/test_v002.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_edl(path)
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(76.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(65.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(77.0, shot3.sequenceStartFrame.get())
self.assertEqual(133.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(121.0, shot3.endFrame.get())
|
def test_from_edl_updates_sequencer_hierarchy_with_shots_used_more_than_one_times(self):
'testing if from_edl method will update Sequences and shots correctly\n with shot are used more than once\n '
path = os.path.abspath('./test_data/test_v004.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
shot3.set_camera('persp')
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_edl(path)
self.assertEqual(4, len(seq.shots.get()))
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(76.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(65.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(77.0, shot3.sequenceStartFrame.get())
self.assertEqual(133.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(121.0, shot3.endFrame.get())
shot4 = seq.shots.get()[(- 1)]
self.assertEqual('0030', shot4.shotName.get())
self.assertEqual(1, shot4.track.get())
self.assertEqual(133.0, shot4.sequenceStartFrame.get())
self.assertEqual(189.0, shot4.sequenceEndFrame.get())
self.assertEqual(65.0, shot4.startFrame.get())
self.assertEqual(121.0, shot4.endFrame.get())
self.assertEqual(shot3.get_camera(), shot4.get_camera())
| -77,258,966,698,139,840
|
testing if from_edl method will update Sequences and shots correctly
with shot are used more than once
|
tests/previs/test_sequence_manager_extension.py
|
test_from_edl_updates_sequencer_hierarchy_with_shots_used_more_than_one_times
|
Khosiyat/anima
|
python
|
def test_from_edl_updates_sequencer_hierarchy_with_shots_used_more_than_one_times(self):
'testing if from_edl method will update Sequences and shots correctly\n with shot are used more than once\n '
path = os.path.abspath('./test_data/test_v004.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
shot3.set_camera('persp')
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_edl(path)
self.assertEqual(4, len(seq.shots.get()))
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0020', shot2.shotName.get())
self.assertEqual(1, shot2.track.get())
self.assertEqual(55.0, shot2.sequenceStartFrame.get())
self.assertEqual(76.0, shot2.sequenceEndFrame.get())
self.assertEqual(44.0, shot2.startFrame.get())
self.assertEqual(65.0, shot2.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(77.0, shot3.sequenceStartFrame.get())
self.assertEqual(133.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(121.0, shot3.endFrame.get())
shot4 = seq.shots.get()[(- 1)]
self.assertEqual('0030', shot4.shotName.get())
self.assertEqual(1, shot4.track.get())
self.assertEqual(133.0, shot4.sequenceStartFrame.get())
self.assertEqual(189.0, shot4.sequenceEndFrame.get())
self.assertEqual(65.0, shot4.startFrame.get())
self.assertEqual(121.0, shot4.endFrame.get())
self.assertEqual(shot3.get_camera(), shot4.get_camera())
|
def test_from_xml_updates_sequencer_hierarchy_with_shots_removed(self):
'testing if from_xml method will update Sequences and shots\n correctly with the xml file\n '
path = os.path.abspath('./test_data/test_v003.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_xml(path)
self.assertEqual(2, len(seq.shots.get()))
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(55.0, shot3.sequenceStartFrame.get())
self.assertEqual(110.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(120.0, shot3.endFrame.get())
| -8,870,989,929,307,009,000
|
testing if from_xml method will update Sequences and shots
correctly with the xml file
|
tests/previs/test_sequence_manager_extension.py
|
test_from_xml_updates_sequencer_hierarchy_with_shots_removed
|
Khosiyat/anima
|
python
|
def test_from_xml_updates_sequencer_hierarchy_with_shots_removed(self):
'testing if from_xml method will update Sequences and shots\n correctly with the xml file\n '
path = os.path.abspath('./test_data/test_v003.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
seq = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
sm.from_xml(path)
self.assertEqual(2, len(seq.shots.get()))
self.assertEqual('0010', shot1.shotName.get())
self.assertEqual(1, shot1.track.get())
self.assertEqual(1.0, shot1.sequenceStartFrame.get())
self.assertEqual(54.0, shot1.sequenceEndFrame.get())
self.assertEqual((- 10.0), shot1.startFrame.get())
self.assertEqual(43.0, shot1.endFrame.get())
self.assertEqual('0030', shot3.shotName.get())
self.assertEqual(1, shot3.track.get())
self.assertEqual(55.0, shot3.sequenceStartFrame.get())
self.assertEqual(110.0, shot3.sequenceEndFrame.get())
self.assertEqual(65.0, shot3.startFrame.get())
self.assertEqual(120.0, shot3.endFrame.get())
|
def test_to_xml_will_generate_proper_xml_string(self):
'testing if a proper xml compatible string will be generated with\n to_xml() method\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
result = sm.to_xml()
with open(path) as f:
expected = f.read()
self.maxDiff = None
self.assertEqual(expected, result)
| -6,445,851,399,143,669,000
|
testing if a proper xml compatible string will be generated with
to_xml() method
|
tests/previs/test_sequence_manager_extension.py
|
test_to_xml_will_generate_proper_xml_string
|
Khosiyat/anima
|
python
|
def test_to_xml_will_generate_proper_xml_string(self):
'testing if a proper xml compatible string will be generated with\n to_xml() method\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
result = sm.to_xml()
with open(path) as f:
expected = f.read()
self.maxDiff = None
self.assertEqual(expected, result)
|
def test_create_sequence_is_working_properly(self):
'testing if create_sequence is working properly\n '
seq = self.sm.create_sequence()
self.assertEqual(seq.type(), 'sequencer')
self.maxDiff = None
self.assertEqual(self.sm, seq.message.connections()[0])
| 2,378,834,401,552,188,000
|
testing if create_sequence is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_create_sequence_is_working_properly
|
Khosiyat/anima
|
python
|
def test_create_sequence_is_working_properly(self):
'\n '
seq = self.sm.create_sequence()
self.assertEqual(seq.type(), 'sequencer')
self.maxDiff = None
self.assertEqual(self.sm, seq.message.connections()[0])
|
def test_create_sequence_is_properly_setting_the_sequence_name(self):
'testing if create_sequence is working properly\n '
seq = self.sm.create_sequence('Test Sequence')
self.assertEqual('Test Sequence', seq.sequence_name.get())
| 7,593,421,248,791,318,000
|
testing if create_sequence is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_create_sequence_is_properly_setting_the_sequence_name
|
Khosiyat/anima
|
python
|
def test_create_sequence_is_properly_setting_the_sequence_name(self):
'\n '
seq = self.sm.create_sequence('Test Sequence')
self.assertEqual('Test Sequence', seq.sequence_name.get())
|
def test_to_edl_is_working_properly(self):
'testing if to_edl method is working properly\n '
import edl
seq1 = self.sm.create_sequence('sequence1')
seq1.create_shot('shot1')
seq1.create_shot('shot2')
seq1.create_shot('shot3')
l = self.sm.to_edl()
self.assertIsInstance(l, edl.List)
| -4,451,272,981,437,685,000
|
testing if to_edl method is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_to_edl_is_working_properly
|
Khosiyat/anima
|
python
|
def test_to_edl_is_working_properly(self):
'\n '
import edl
seq1 = self.sm.create_sequence('sequence1')
seq1.create_shot('shot1')
seq1.create_shot('shot2')
seq1.create_shot('shot3')
l = self.sm.to_edl()
self.assertIsInstance(l, edl.List)
|
def test_to_edl_will_generate_a_proper_edl_content(self):
'testing if to_edl will generate a proper edl content\n '
edl_path = os.path.abspath('./test_data/test_v001.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
l = sm.to_edl()
result = l.to_string()
with open(edl_path) as f:
expected_edl_content = f.read()
self.assertEqual(expected_edl_content, result)
| -4,220,463,395,195,804,000
|
testing if to_edl will generate a proper edl content
|
tests/previs/test_sequence_manager_extension.py
|
test_to_edl_will_generate_a_proper_edl_content
|
Khosiyat/anima
|
python
|
def test_to_edl_will_generate_a_proper_edl_content(self):
'\n '
edl_path = os.path.abspath('./test_data/test_v001.edl')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_version('v001')
sm = pymel.core.PyNode('sequenceManager1')
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(33)
shot1.sequenceStartFrame.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot1.track.set(1)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(34)
shot2.endFrame.set(64)
shot2.sequenceStartFrame.set(35)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(10)
shot2.track.set(1)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(65)
shot3.endFrame.set(110)
shot3.sequenceStartFrame.set(66)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(10)
shot3.track.set(1)
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
l = sm.to_edl()
result = l.to_string()
with open(edl_path) as f:
expected_edl_content = f.read()
self.assertEqual(expected_edl_content, result)
|
def test_generate_sequence_structure_returns_a_sequence_instance(self):
'testing if generate_sequence_structure() method will return a\n Sequence instance\n '
sm = pymel.core.PyNode('sequenceManager1')
seq1 = sm.create_sequence('sequence1')
shot1 = seq1.create_shot('shot1')
shot1.output.set('/tmp/shot1.mov')
shot2 = seq1.create_shot('shot2')
shot2.output.set('/tmp/shot2.mov')
result = sm.generate_sequence_structure()
self.assertIsInstance(result, Sequence)
| -4,498,311,867,630,089,000
|
testing if generate_sequence_structure() method will return a
Sequence instance
|
tests/previs/test_sequence_manager_extension.py
|
test_generate_sequence_structure_returns_a_sequence_instance
|
Khosiyat/anima
|
python
|
def test_generate_sequence_structure_returns_a_sequence_instance(self):
'testing if generate_sequence_structure() method will return a\n Sequence instance\n '
sm = pymel.core.PyNode('sequenceManager1')
seq1 = sm.create_sequence('sequence1')
shot1 = seq1.create_shot('shot1')
shot1.output.set('/tmp/shot1.mov')
shot2 = seq1.create_shot('shot2')
shot2.output.set('/tmp/shot2.mov')
result = sm.generate_sequence_structure()
self.assertIsInstance(result, Sequence)
|
def test_generate_sequence_structure_will_generate_sequences_and_shots_with_correct_number_of_tracks(self):
'testing if a proper sequence structure will be generated by using\n the generate_sequence_structure() method with correct number of tracks\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.from_xml(path)
seq1 = sm.sequences.get()[0]
shots = seq1.shots.get()
shot1 = shots[0]
shot2 = shots[1]
shot3 = shots[2]
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
seq = sm.generate_sequence_structure()
tracks = seq.media.video.tracks
self.assertEqual(len(tracks), 1)
track1 = tracks[0]
clips = track1.clips
self.assertEqual(len(clips), 3)
| -609,995,082,814,433,700
|
testing if a proper sequence structure will be generated by using
the generate_sequence_structure() method with correct number of tracks
|
tests/previs/test_sequence_manager_extension.py
|
test_generate_sequence_structure_will_generate_sequences_and_shots_with_correct_number_of_tracks
|
Khosiyat/anima
|
python
|
def test_generate_sequence_structure_will_generate_sequences_and_shots_with_correct_number_of_tracks(self):
'testing if a proper sequence structure will be generated by using\n the generate_sequence_structure() method with correct number of tracks\n '
path = os.path.abspath('./test_data/test_v001.xml')
sm = pymel.core.PyNode('sequenceManager1')
sm.from_xml(path)
seq1 = sm.sequences.get()[0]
shots = seq1.shots.get()
shot1 = shots[0]
shot2 = shots[1]
shot3 = shots[2]
self.assertEqual(shot1.track.get(), 1)
self.assertEqual(shot2.track.get(), 1)
self.assertEqual(shot3.track.get(), 1)
seq = sm.generate_sequence_structure()
tracks = seq.media.video.tracks
self.assertEqual(len(tracks), 1)
track1 = tracks[0]
clips = track1.clips
self.assertEqual(len(clips), 3)
|
def test_set_shot_name_template_is_working_properly(self):
'testing if set_shot_name_template() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
test_template = '<Sequence>_<Shot>_<Version>'
sm.set_shot_name_template(test_template)
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(sm.shot_name_template.get(), test_template)
| -5,700,847,774,720,538,000
|
testing if set_shot_name_template() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_set_shot_name_template_is_working_properly
|
Khosiyat/anima
|
python
|
def test_set_shot_name_template_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
test_template = '<Sequence>_<Shot>_<Version>'
sm.set_shot_name_template(test_template)
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(sm.shot_name_template.get(), test_template)
|
def test_get_shot_name_template_is_working_properly(self):
'testing if set_shot_name_template() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
test_template = '<Sequence>_<Shot>_<Version>'
sm.set_shot_name_template(test_template)
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(sm.get_shot_name_template(), test_template)
| 8,926,393,877,726,173,000
|
testing if set_shot_name_template() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_get_shot_name_template_is_working_properly
|
Khosiyat/anima
|
python
|
def test_get_shot_name_template_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
test_template = '<Sequence>_<Shot>_<Version>'
sm.set_shot_name_template(test_template)
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(sm.get_shot_name_template(), test_template)
|
def test_get_shot_name_template_will_create_shot_name_template_attribute_if_missing(self):
'testing if set_shot_name_template() will create the\n shot_name_template attribute if missing\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
result = sm.get_shot_name_template()
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(result, '<Sequence>_<Shot>_<Version>')
| 7,066,411,986,858,611,000
|
testing if set_shot_name_template() will create the
shot_name_template attribute if missing
|
tests/previs/test_sequence_manager_extension.py
|
test_get_shot_name_template_will_create_shot_name_template_attribute_if_missing
|
Khosiyat/anima
|
python
|
def test_get_shot_name_template_will_create_shot_name_template_attribute_if_missing(self):
'testing if set_shot_name_template() will create the\n shot_name_template attribute if missing\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('shot_name_template'))
result = sm.get_shot_name_template()
self.assertTrue(sm.hasAttr('shot_name_template'))
self.assertEqual(result, '<Sequence>_<Shot>_<Version>')
|
def test_set_version_is_working_properly(self):
'testing if set_version() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
test_version = 'v001'
sm.set_version(test_version)
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(sm.version.get(), test_version)
| -2,562,816,534,814,400,000
|
testing if set_version() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_set_version_is_working_properly
|
Khosiyat/anima
|
python
|
def test_set_version_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
test_version = 'v001'
sm.set_version(test_version)
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(sm.version.get(), test_version)
|
def test_get_version_is_working_properly(self):
'testing if set_version() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
test_version = 'v001'
sm.set_version(test_version)
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(sm.get_version(), test_version)
| -4,687,405,485,665,601,000
|
testing if set_version() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_get_version_is_working_properly
|
Khosiyat/anima
|
python
|
def test_get_version_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
test_version = 'v001'
sm.set_version(test_version)
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(sm.get_version(), test_version)
|
def test_get_version_will_create_attribute_if_missing(self):
'testing if get_version() will create the missing version attribute\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
result = sm.get_version()
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(result, '')
| -1,376,126,504,394,918,000
|
testing if get_version() will create the missing version attribute
|
tests/previs/test_sequence_manager_extension.py
|
test_get_version_will_create_attribute_if_missing
|
Khosiyat/anima
|
python
|
def test_get_version_will_create_attribute_if_missing(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('version'))
result = sm.get_version()
self.assertTrue(sm.hasAttr('version'))
self.assertEqual(result, )
|
def test_set_task_name_is_working_properly(self):
'testing if set_task_name() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
test_task_name = 'Animation'
sm.set_task_name(test_task_name)
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(sm.task_name.get(), test_task_name)
| -5,957,037,253,209,172,000
|
testing if set_task_name() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_set_task_name_is_working_properly
|
Khosiyat/anima
|
python
|
def test_set_task_name_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
test_task_name = 'Animation'
sm.set_task_name(test_task_name)
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(sm.task_name.get(), test_task_name)
|
def test_get_task_name_is_working_properly(self):
'testing if set_task_name() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
test_task_name = 'Animation'
sm.set_task_name(test_task_name)
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(sm.get_task_name(), test_task_name)
| 1,809,480,270,107,058,200
|
testing if set_task_name() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_get_task_name_is_working_properly
|
Khosiyat/anima
|
python
|
def test_get_task_name_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
test_task_name = 'Animation'
sm.set_task_name(test_task_name)
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(sm.get_task_name(), test_task_name)
|
def test_get_task_name_will_create_attribute_if_missing(self):
'testing if get_task_name() will create the missing task_name attribute\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
result = sm.get_task_name()
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(result, '')
| -4,364,813,692,820,742,700
|
testing if get_task_name() will create the missing task_name attribute
|
tests/previs/test_sequence_manager_extension.py
|
test_get_task_name_will_create_attribute_if_missing
|
Khosiyat/anima
|
python
|
def test_get_task_name_will_create_attribute_if_missing(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('task_name'))
result = sm.get_task_name()
self.assertTrue(sm.hasAttr('task_name'))
self.assertEqual(result, )
|
def test_set_take_name_is_working_properly(self):
'testing if set_take_name() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
test_take_name = 'Main'
sm.set_take_name(test_take_name)
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(sm.take_name.get(), test_take_name)
| -6,502,425,200,491,617,000
|
testing if set_take_name() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_set_take_name_is_working_properly
|
Khosiyat/anima
|
python
|
def test_set_take_name_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
test_take_name = 'Main'
sm.set_take_name(test_take_name)
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(sm.take_name.get(), test_take_name)
|
def test_get_take_name_is_working_properly(self):
'testing if set_take_name() is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
test_take_name = 'Main'
sm.set_take_name(test_take_name)
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(sm.get_take_name(), test_take_name)
| 4,979,500,875,014,622,000
|
testing if set_take_name() is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_get_take_name_is_working_properly
|
Khosiyat/anima
|
python
|
def test_get_take_name_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
test_take_name = 'Main'
sm.set_take_name(test_take_name)
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(sm.get_take_name(), test_take_name)
|
def test_get_take_name_will_create_attribute_if_missing(self):
'testing if get_take_name() will create the missing take_name attribute\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
result = sm.get_take_name()
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(result, '')
| -3,863,296,170,872,902,700
|
testing if get_take_name() will create the missing take_name attribute
|
tests/previs/test_sequence_manager_extension.py
|
test_get_take_name_will_create_attribute_if_missing
|
Khosiyat/anima
|
python
|
def test_get_take_name_will_create_attribute_if_missing(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
self.assertFalse(sm.hasAttr('take_name'))
result = sm.get_take_name()
self.assertTrue(sm.hasAttr('take_name'))
self.assertEqual(result, )
|
def test_generate_sequence_structure_is_working_properly(self):
'testing if generate_sequence_structure() method is working properly\n '
sm = pymel.core.PyNode('sequenceManager1')
from anima.env import mayaEnv
mayaEnv.Maya.set_fps(fps=24)
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(24)
shot1.sequenceStartFrame.set(0)
shot1.track.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(10)
shot2.endFrame.set(35)
shot2.sequenceStartFrame.set(25)
shot2.track.set(1)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(15)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(25)
shot3.endFrame.set(50)
shot3.sequenceStartFrame.set(45)
shot3.track.set(2)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(20)
seq = sm.generate_sequence_structure()
self.assertIsInstance(seq, Sequence)
rate = seq.rate
self.assertEqual('24', rate.timebase)
self.assertEqual(False, rate.ntsc)
self.assertEqual('00:00:00:00', seq.timecode)
self.assertEqual(False, seq.ntsc)
media = seq.media
self.assertIsInstance(media, Media)
video = media.video
self.assertIsInstance(video, Video)
self.assertIsNone(media.audio)
self.assertEqual(2, len(video.tracks))
track1 = video.tracks[0]
self.assertIsInstance(track1, Track)
self.assertEqual(len(track1.clips), 2)
self.assertEqual(track1.enabled, True)
track2 = video.tracks[1]
self.assertIsInstance(track2, Track)
self.assertEqual(len(track2.clips), 1)
self.assertEqual(track2.enabled, True)
clip1 = track1.clips[0]
self.assertIsInstance(clip1, Clip)
self.assertEqual('Video', clip1.type)
self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.id)
self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.name)
self.assertEqual(10, clip1.in_)
self.assertEqual(35, clip1.out)
self.assertEqual(0, clip1.start)
self.assertEqual(25, clip1.end)
clip2 = track1.clips[1]
self.assertIsInstance(clip2, Clip)
self.assertEqual('Video', clip2.type)
self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.id)
self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.name)
self.assertEqual(15, clip2.in_)
self.assertEqual(41, clip2.out)
self.assertEqual(25, clip2.start)
self.assertEqual(51, clip2.end)
clip3 = track2.clips[0]
self.assertIsInstance(clip3, Clip)
self.assertEqual('Video', clip3.type)
self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.id)
self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.name)
self.assertEqual(20, clip3.in_)
self.assertEqual(46, clip3.out)
self.assertEqual(45, clip3.start)
self.assertEqual(71, clip3.end)
file1 = clip1.file
self.assertIsInstance(file1, File)
self.assertEqual('SEQ001_HSNI_003_0010_v001', file1.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0010_v001.mov', file1.pathurl)
self.assertEqual(45, file1.duration)
file2 = clip2.file
self.assertIsInstance(file2, File)
self.assertEqual('SEQ001_HSNI_003_0020_v001', file2.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0020_v001.mov', file2.pathurl)
self.assertEqual(56, file2.duration)
file3 = clip3.file
self.assertIsInstance(file3, File)
self.assertEqual('SEQ001_HSNI_003_0030_v001', file3.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0030_v001.mov', file3.pathurl)
self.assertEqual(66, file3.duration)
| 4,421,209,912,940,247,600
|
testing if generate_sequence_structure() method is working properly
|
tests/previs/test_sequence_manager_extension.py
|
test_generate_sequence_structure_is_working_properly
|
Khosiyat/anima
|
python
|
def test_generate_sequence_structure_is_working_properly(self):
'\n '
sm = pymel.core.PyNode('sequenceManager1')
from anima.env import mayaEnv
mayaEnv.Maya.set_fps(fps=24)
sm.set_shot_name_template('<Sequence>_<Shot>_<Version>')
sm.set_version('v001')
seq1 = sm.create_sequence('SEQ001_HSNI_003')
shot1 = seq1.create_shot('0010')
shot1.startFrame.set(0)
shot1.endFrame.set(24)
shot1.sequenceStartFrame.set(0)
shot1.track.set(1)
shot1.output.set('/tmp/SEQ001_HSNI_003_0010_v001.mov')
shot1.handle.set(10)
shot2 = seq1.create_shot('0020')
shot2.startFrame.set(10)
shot2.endFrame.set(35)
shot2.sequenceStartFrame.set(25)
shot2.track.set(1)
shot2.output.set('/tmp/SEQ001_HSNI_003_0020_v001.mov')
shot2.handle.set(15)
shot3 = seq1.create_shot('0030')
shot3.startFrame.set(25)
shot3.endFrame.set(50)
shot3.sequenceStartFrame.set(45)
shot3.track.set(2)
shot3.output.set('/tmp/SEQ001_HSNI_003_0030_v001.mov')
shot3.handle.set(20)
seq = sm.generate_sequence_structure()
self.assertIsInstance(seq, Sequence)
rate = seq.rate
self.assertEqual('24', rate.timebase)
self.assertEqual(False, rate.ntsc)
self.assertEqual('00:00:00:00', seq.timecode)
self.assertEqual(False, seq.ntsc)
media = seq.media
self.assertIsInstance(media, Media)
video = media.video
self.assertIsInstance(video, Video)
self.assertIsNone(media.audio)
self.assertEqual(2, len(video.tracks))
track1 = video.tracks[0]
self.assertIsInstance(track1, Track)
self.assertEqual(len(track1.clips), 2)
self.assertEqual(track1.enabled, True)
track2 = video.tracks[1]
self.assertIsInstance(track2, Track)
self.assertEqual(len(track2.clips), 1)
self.assertEqual(track2.enabled, True)
clip1 = track1.clips[0]
self.assertIsInstance(clip1, Clip)
self.assertEqual('Video', clip1.type)
self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.id)
self.assertEqual('SEQ001_HSNI_003_0010_v001', clip1.name)
self.assertEqual(10, clip1.in_)
self.assertEqual(35, clip1.out)
self.assertEqual(0, clip1.start)
self.assertEqual(25, clip1.end)
clip2 = track1.clips[1]
self.assertIsInstance(clip2, Clip)
self.assertEqual('Video', clip2.type)
self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.id)
self.assertEqual('SEQ001_HSNI_003_0020_v001', clip2.name)
self.assertEqual(15, clip2.in_)
self.assertEqual(41, clip2.out)
self.assertEqual(25, clip2.start)
self.assertEqual(51, clip2.end)
clip3 = track2.clips[0]
self.assertIsInstance(clip3, Clip)
self.assertEqual('Video', clip3.type)
self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.id)
self.assertEqual('SEQ001_HSNI_003_0030_v001', clip3.name)
self.assertEqual(20, clip3.in_)
self.assertEqual(46, clip3.out)
self.assertEqual(45, clip3.start)
self.assertEqual(71, clip3.end)
file1 = clip1.file
self.assertIsInstance(file1, File)
self.assertEqual('SEQ001_HSNI_003_0010_v001', file1.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0010_v001.mov', file1.pathurl)
self.assertEqual(45, file1.duration)
file2 = clip2.file
self.assertIsInstance(file2, File)
self.assertEqual('SEQ001_HSNI_003_0020_v001', file2.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0020_v001.mov', file2.pathurl)
self.assertEqual(56, file2.duration)
file3 = clip3.file
self.assertIsInstance(file3, File)
self.assertEqual('SEQ001_HSNI_003_0030_v001', file3.name)
self.assertEqual('file://localhost/tmp/SEQ001_HSNI_003_0030_v001.mov', file3.pathurl)
self.assertEqual(66, file3.duration)
|
def to_k8s_yaml(self) -> List[Tuple[(str, List[Dict])]]:
'\n Return a list of dictionary configurations. One for each deployment in this Deployment\n .. # noqa: DAR201\n .. # noqa: DAR101\n '
if (self.name == 'gateway'):
return [('gateway', self.worker_deployments[0].get_gateway_yamls())]
else:
deployments = [self.head_deployment]
deployments.extend(self.worker_deployments)
return [(deployment.dns_name, deployment.get_runtime_yamls()) for deployment in deployments]
| -8,254,275,310,431,813,000
|
Return a list of dictionary configurations. One for each deployment in this Deployment
.. # noqa: DAR201
.. # noqa: DAR101
|
jina/orchestrate/deployments/config/k8s.py
|
to_k8s_yaml
|
ethan-jiang-1/jina
|
python
|
def to_k8s_yaml(self) -> List[Tuple[(str, List[Dict])]]:
'\n Return a list of dictionary configurations. One for each deployment in this Deployment\n .. # noqa: DAR201\n .. # noqa: DAR101\n '
if (self.name == 'gateway'):
return [('gateway', self.worker_deployments[0].get_gateway_yamls())]
else:
deployments = [self.head_deployment]
deployments.extend(self.worker_deployments)
return [(deployment.dns_name, deployment.get_runtime_yamls()) for deployment in deployments]
|
def __call__(self, ids):
'Return the mapping when evaluated.\n\n In this case, the ids received are actually the vocabulary `scheme`\n (top-level) and `subject` (nested). And since they are already\n human-readable, we keep them as-is.\n '
unique_ids = list(set(ids))
return {id_: id_ for id_ in unique_ids}
| 8,695,316,713,877,717,000
|
Return the mapping when evaluated.
In this case, the ids received are actually the vocabulary `scheme`
(top-level) and `subject` (nested). And since they are already
human-readable, we keep them as-is.
|
invenio_vocabularies/contrib/subjects/facets.py
|
__call__
|
alejandromumo/invenio-vocabularies
|
python
|
def __call__(self, ids):
'Return the mapping when evaluated.\n\n In this case, the ids received are actually the vocabulary `scheme`\n (top-level) and `subject` (nested). And since they are already\n human-readable, we keep them as-is.\n '
unique_ids = list(set(ids))
return {id_: id_ for id_ in unique_ids}
|
def dummy():
' Dummy function for comparison of the return values '
return
| 7,763,923,742,727,346,000
|
Dummy function for comparison of the return values
|
src/game_of_life/python_coderetreat_socramob/cr_socramob08/coord_test.py
|
dummy
|
hemmerling/codingdojo
|
python
|
def dummy():
' '
return
|
def is_user_context(context):
'Indicates if the request context is a normal user.'
if (not context):
return False
if context.is_admin:
return False
if ((not context.user_id) or (not context.project_id)):
return False
return True
| 6,483,598,451,008,784,000
|
Indicates if the request context is a normal user.
|
patron/context.py
|
is_user_context
|
casbin/openstack-patron
|
python
|
def is_user_context(context):
if (not context):
return False
if context.is_admin:
return False
if ((not context.user_id) or (not context.project_id)):
return False
return True
|
def require_admin_context(ctxt):
'Raise exception.AdminRequired() if context is an admin context.'
if (not ctxt.is_admin):
raise exception.AdminRequired()
| 8,881,687,383,398,372,000
|
Raise exception.AdminRequired() if context is an admin context.
|
patron/context.py
|
require_admin_context
|
casbin/openstack-patron
|
python
|
def require_admin_context(ctxt):
if (not ctxt.is_admin):
raise exception.AdminRequired()
|
def require_context(ctxt):
'Raise exception.Forbidden() if context is not a user or an\n admin context.\n '
if ((not ctxt.is_admin) and (not is_user_context(ctxt))):
raise exception.Forbidden()
| 6,181,499,204,192,342,000
|
Raise exception.Forbidden() if context is not a user or an
admin context.
|
patron/context.py
|
require_context
|
casbin/openstack-patron
|
python
|
def require_context(ctxt):
'Raise exception.Forbidden() if context is not a user or an\n admin context.\n '
if ((not ctxt.is_admin) and (not is_user_context(ctxt))):
raise exception.Forbidden()
|
def authorize_project_context(context, project_id):
'Ensures a request has permission to access the given project.'
if is_user_context(context):
if (not context.project_id):
raise exception.Forbidden()
elif (context.project_id != project_id):
raise exception.Forbidden()
| -6,026,524,350,522,053,000
|
Ensures a request has permission to access the given project.
|
patron/context.py
|
authorize_project_context
|
casbin/openstack-patron
|
python
|
def authorize_project_context(context, project_id):
if is_user_context(context):
if (not context.project_id):
raise exception.Forbidden()
elif (context.project_id != project_id):
raise exception.Forbidden()
|
def authorize_user_context(context, user_id):
'Ensures a request has permission to access the given user.'
if is_user_context(context):
if (not context.user_id):
raise exception.Forbidden()
elif (context.user_id != user_id):
raise exception.Forbidden()
| 4,605,583,626,984,261,000
|
Ensures a request has permission to access the given user.
|
patron/context.py
|
authorize_user_context
|
casbin/openstack-patron
|
python
|
def authorize_user_context(context, user_id):
if is_user_context(context):
if (not context.user_id):
raise exception.Forbidden()
elif (context.user_id != user_id):
raise exception.Forbidden()
|
def authorize_quota_class_context(context, class_name):
'Ensures a request has permission to access the given quota class.'
if is_user_context(context):
if (not context.quota_class):
raise exception.Forbidden()
elif (context.quota_class != class_name):
raise exception.Forbidden()
| -8,332,953,962,440,573,000
|
Ensures a request has permission to access the given quota class.
|
patron/context.py
|
authorize_quota_class_context
|
casbin/openstack-patron
|
python
|
def authorize_quota_class_context(context, class_name):
if is_user_context(context):
if (not context.quota_class):
raise exception.Forbidden()
elif (context.quota_class != class_name):
raise exception.Forbidden()
|
def __init__(self, user_id=None, project_id=None, is_admin=None, read_deleted='no', roles=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, user_name=None, project_name=None, service_catalog=None, instance_lock_checked=False, user_auth_plugin=None, **kwargs):
":param read_deleted: 'no' indicates deleted records are hidden,\n 'yes' indicates deleted records are visible,\n 'only' indicates that *only* deleted records are visible.\n\n :param overwrite: Set to False to ensure that the greenthread local\n copy of the index is not overwritten.\n\n :param user_auth_plugin: The auth plugin for the current request's\n authentication data.\n\n :param kwargs: Extra arguments that might be present, but we ignore\n because they possibly came in from older rpc messages.\n "
user = kwargs.pop('user', None)
tenant = kwargs.pop('tenant', None)
super(RequestContext, self).__init__(auth_token=auth_token, user=(user_id or user), tenant=(project_id or tenant), domain=kwargs.pop('domain', None), user_domain=kwargs.pop('user_domain', None), project_domain=kwargs.pop('project_domain', None), is_admin=is_admin, read_only=kwargs.pop('read_only', False), show_deleted=kwargs.pop('show_deleted', False), request_id=request_id, resource_uuid=kwargs.pop('resource_uuid', None), overwrite=overwrite)
kwargs.pop('user_identity', None)
if kwargs:
LOG.warning((_LW('Arguments dropped when creating context: %s') % str(kwargs)))
self.user_id = user_id
self.project_id = project_id
self.roles = (roles or [])
self.read_deleted = read_deleted
self.remote_address = remote_address
if (not timestamp):
timestamp = timeutils.utcnow()
if isinstance(timestamp, six.string_types):
timestamp = timeutils.parse_strtime(timestamp)
self.timestamp = timestamp
if service_catalog:
self.service_catalog = [s for s in service_catalog if (s.get('type') in ('volume', 'volumev2', 'key-manager'))]
else:
self.service_catalog = []
self.instance_lock_checked = instance_lock_checked
self.quota_class = quota_class
self.user_name = user_name
self.project_name = project_name
self.is_admin = is_admin
self.user_auth_plugin = user_auth_plugin
if (self.is_admin is None):
self.is_admin = policy.check_is_admin(self)
| -2,724,747,871,020,421,000
|
:param read_deleted: 'no' indicates deleted records are hidden,
'yes' indicates deleted records are visible,
'only' indicates that *only* deleted records are visible.
:param overwrite: Set to False to ensure that the greenthread local
copy of the index is not overwritten.
:param user_auth_plugin: The auth plugin for the current request's
authentication data.
:param kwargs: Extra arguments that might be present, but we ignore
because they possibly came in from older rpc messages.
|
patron/context.py
|
__init__
|
casbin/openstack-patron
|
python
|
def __init__(self, user_id=None, project_id=None, is_admin=None, read_deleted='no', roles=None, remote_address=None, timestamp=None, request_id=None, auth_token=None, overwrite=True, quota_class=None, user_name=None, project_name=None, service_catalog=None, instance_lock_checked=False, user_auth_plugin=None, **kwargs):
":param read_deleted: 'no' indicates deleted records are hidden,\n 'yes' indicates deleted records are visible,\n 'only' indicates that *only* deleted records are visible.\n\n :param overwrite: Set to False to ensure that the greenthread local\n copy of the index is not overwritten.\n\n :param user_auth_plugin: The auth plugin for the current request's\n authentication data.\n\n :param kwargs: Extra arguments that might be present, but we ignore\n because they possibly came in from older rpc messages.\n "
user = kwargs.pop('user', None)
tenant = kwargs.pop('tenant', None)
super(RequestContext, self).__init__(auth_token=auth_token, user=(user_id or user), tenant=(project_id or tenant), domain=kwargs.pop('domain', None), user_domain=kwargs.pop('user_domain', None), project_domain=kwargs.pop('project_domain', None), is_admin=is_admin, read_only=kwargs.pop('read_only', False), show_deleted=kwargs.pop('show_deleted', False), request_id=request_id, resource_uuid=kwargs.pop('resource_uuid', None), overwrite=overwrite)
kwargs.pop('user_identity', None)
if kwargs:
LOG.warning((_LW('Arguments dropped when creating context: %s') % str(kwargs)))
self.user_id = user_id
self.project_id = project_id
self.roles = (roles or [])
self.read_deleted = read_deleted
self.remote_address = remote_address
if (not timestamp):
timestamp = timeutils.utcnow()
if isinstance(timestamp, six.string_types):
timestamp = timeutils.parse_strtime(timestamp)
self.timestamp = timestamp
if service_catalog:
self.service_catalog = [s for s in service_catalog if (s.get('type') in ('volume', 'volumev2', 'key-manager'))]
else:
self.service_catalog = []
self.instance_lock_checked = instance_lock_checked
self.quota_class = quota_class
self.user_name = user_name
self.project_name = project_name
self.is_admin = is_admin
self.user_auth_plugin = user_auth_plugin
if (self.is_admin is None):
self.is_admin = policy.check_is_admin(self)
|
def elevated(self, read_deleted=None, overwrite=False):
'Return a version of this context with admin flag set.'
context = copy.deepcopy(self)
context.is_admin = True
if ('admin' not in context.roles):
context.roles.append('admin')
if (read_deleted is not None):
context.read_deleted = read_deleted
return context
| -4,897,044,628,749,857,000
|
Return a version of this context with admin flag set.
|
patron/context.py
|
elevated
|
casbin/openstack-patron
|
python
|
def elevated(self, read_deleted=None, overwrite=False):
context = copy.deepcopy(self)
context.is_admin = True
if ('admin' not in context.roles):
context.roles.append('admin')
if (read_deleted is not None):
context.read_deleted = read_deleted
return context
|
def withTiming(text='{func}() {time:.2f} ns'):
'Append timing information to a function\n\n Example:\n @withTiming()\n def function():\n pass\n\n '
def timings_decorator(func):
if (not TIMINGS):
return func
@wraps(func)
def func_wrapper(*args, **kwargs):
t0 = time.clock()
try:
return func(*args, **kwargs)
finally:
t1 = time.clock()
duration = ((t1 - t0) * (10 ** 6))
Stats.LastTiming = duration
log.debug(text.format(func=func.__name__, time=duration))
return func_wrapper
return timings_decorator
| -1,641,868,228,917,891,300
|
Append timing information to a function
Example:
@withTiming()
def function():
pass
|
cmdx.py
|
withTiming
|
fvbehr/cmdx
|
python
|
def withTiming(text='{func}() {time:.2f} ns'):
'Append timing information to a function\n\n Example:\n @withTiming()\n def function():\n pass\n\n '
def timings_decorator(func):
if (not TIMINGS):
return func
@wraps(func)
def func_wrapper(*args, **kwargs):
t0 = time.clock()
try:
return func(*args, **kwargs)
finally:
t1 = time.clock()
duration = ((t1 - t0) * (10 ** 6))
Stats.LastTiming = duration
log.debug(text.format(func=func.__name__, time=duration))
return func_wrapper
return timings_decorator
|
def protected(func):
'Prevent fatal crashes from illegal access to deleted nodes'
if ROGUE_MODE:
return func
@wraps(func)
def func_wrapper(*args, **kwargs):
if args[0]._destroyed:
raise ExistError('Cannot perform operation on deleted node')
return func(*args, **kwargs)
return func_wrapper
| -2,619,712,364,112,586,000
|
Prevent fatal crashes from illegal access to deleted nodes
|
cmdx.py
|
protected
|
fvbehr/cmdx
|
python
|
def protected(func):
if ROGUE_MODE:
return func
@wraps(func)
def func_wrapper(*args, **kwargs):
if args[0]._destroyed:
raise ExistError('Cannot perform operation on deleted node')
return func(*args, **kwargs)
return func_wrapper
|
def add_metaclass(metaclass):
'Add metaclass to Python 2 and 3 class\n\n Helper decorator, from six.py\n\n '
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if (slots is not None):
if isinstance(slots, str):
slots = [slots]
for slots_var in slots:
orig_vars.pop(slots_var)
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
if hasattr(cls, '__qualname__'):
orig_vars['__qualname__'] = cls.__qualname__
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper
| -3,188,808,974,660,015,600
|
Add metaclass to Python 2 and 3 class
Helper decorator, from six.py
|
cmdx.py
|
add_metaclass
|
fvbehr/cmdx
|
python
|
def add_metaclass(metaclass):
'Add metaclass to Python 2 and 3 class\n\n Helper decorator, from six.py\n\n '
def wrapper(cls):
orig_vars = cls.__dict__.copy()
slots = orig_vars.get('__slots__')
if (slots is not None):
if isinstance(slots, str):
slots = [slots]
for slots_var in slots:
orig_vars.pop(slots_var)
orig_vars.pop('__dict__', None)
orig_vars.pop('__weakref__', None)
if hasattr(cls, '__qualname__'):
orig_vars['__qualname__'] = cls.__qualname__
return metaclass(cls.__name__, cls.__bases__, orig_vars)
return wrapper
|
def UiUnit():
'Unlike other time units, this can be modified by the user at run-time'
return _Unit(om.MTime, om.MTime.uiUnit())
| 1,989,804,669,188,851,700
|
Unlike other time units, this can be modified by the user at run-time
|
cmdx.py
|
UiUnit
|
fvbehr/cmdx
|
python
|
def UiUnit():
return _Unit(om.MTime, om.MTime.uiUnit())
|
def twistSwingToQuaternion(ts):
'Convert twist/swing1/swing2 rotation in a Vector into a quaternion\n\n Arguments:\n ts (Vector): Twist, swing1 and swing2\n\n '
t = tan((ts.x * 0.25))
s1 = tan((ts.y * 0.25))
s2 = tan((ts.z * 0.25))
b = (2.0 / ((1.0 + (s1 * s1)) + (s2 * s2)))
c = (2.0 / (1.0 + (t * t)))
quat = Quaternion()
quat.w = ((b - 1.0) * (c - 1.0))
quat.x = (((- t) * (b - 1.0)) * c)
quat.y = ((- b) * (((c * t) * s1) + ((c - 1.0) * s2)))
quat.z = ((- b) * (((c * t) * s2) - ((c - 1.0) * s1)))
assert quat.isNormalised()
return quat
| -1,108,041,672,223,247,600
|
Convert twist/swing1/swing2 rotation in a Vector into a quaternion
Arguments:
ts (Vector): Twist, swing1 and swing2
|
cmdx.py
|
twistSwingToQuaternion
|
fvbehr/cmdx
|
python
|
def twistSwingToQuaternion(ts):
'Convert twist/swing1/swing2 rotation in a Vector into a quaternion\n\n Arguments:\n ts (Vector): Twist, swing1 and swing2\n\n '
t = tan((ts.x * 0.25))
s1 = tan((ts.y * 0.25))
s2 = tan((ts.z * 0.25))
b = (2.0 / ((1.0 + (s1 * s1)) + (s2 * s2)))
c = (2.0 / (1.0 + (t * t)))
quat = Quaternion()
quat.w = ((b - 1.0) * (c - 1.0))
quat.x = (((- t) * (b - 1.0)) * c)
quat.y = ((- b) * (((c * t) * s1) + ((c - 1.0) * s2)))
quat.z = ((- b) * (((c * t) * s2) - ((c - 1.0) * s1)))
assert quat.isNormalised()
return quat
|
def NurbsCurveData(points, degree=1, form=om1.MFnNurbsCurve.kOpen):
'Tuple of points to MObject suitable for nurbsCurve-typed data\n\n Arguments:\n points (tuple): (x, y, z) tuples per point\n degree (int, optional): Defaults to 1 for linear\n form (int, optional): Defaults to MFnNurbsCurve.kOpen,\n also available kClosed\n\n Example:\n Create a new nurbs curve like this.\n\n >>> data = NurbsCurveData(\n ... points=(\n ... (0, 0, 0),\n ... (0, 1, 0),\n ... (0, 2, 0),\n ... ))\n ...\n >>> parent = createNode("transform")\n >>> shape = createNode("nurbsCurve", parent=parent)\n >>> shape["cached"] = data\n\n '
degree = min(3, max(1, degree))
cvs = om1.MPointArray()
curveFn = om1.MFnNurbsCurve()
data = om1.MFnNurbsCurveData()
mobj = data.create()
for point in points:
cvs.append(om1.MPoint(*point))
curveFn.createWithEditPoints(cvs, degree, form, False, False, True, mobj)
return mobj
| 4,124,420,921,214,744,000
|
Tuple of points to MObject suitable for nurbsCurve-typed data
Arguments:
points (tuple): (x, y, z) tuples per point
degree (int, optional): Defaults to 1 for linear
form (int, optional): Defaults to MFnNurbsCurve.kOpen,
also available kClosed
Example:
Create a new nurbs curve like this.
>>> data = NurbsCurveData(
... points=(
... (0, 0, 0),
... (0, 1, 0),
... (0, 2, 0),
... ))
...
>>> parent = createNode("transform")
>>> shape = createNode("nurbsCurve", parent=parent)
>>> shape["cached"] = data
|
cmdx.py
|
NurbsCurveData
|
fvbehr/cmdx
|
python
|
def NurbsCurveData(points, degree=1, form=om1.MFnNurbsCurve.kOpen):
'Tuple of points to MObject suitable for nurbsCurve-typed data\n\n Arguments:\n points (tuple): (x, y, z) tuples per point\n degree (int, optional): Defaults to 1 for linear\n form (int, optional): Defaults to MFnNurbsCurve.kOpen,\n also available kClosed\n\n Example:\n Create a new nurbs curve like this.\n\n >>> data = NurbsCurveData(\n ... points=(\n ... (0, 0, 0),\n ... (0, 1, 0),\n ... (0, 2, 0),\n ... ))\n ...\n >>> parent = createNode("transform")\n >>> shape = createNode("nurbsCurve", parent=parent)\n >>> shape["cached"] = data\n\n '
degree = min(3, max(1, degree))
cvs = om1.MPointArray()
curveFn = om1.MFnNurbsCurve()
data = om1.MFnNurbsCurveData()
mobj = data.create()
for point in points:
cvs.append(om1.MPoint(*point))
curveFn.createWithEditPoints(cvs, degree, form, False, False, True, mobj)
return mobj
|
def _plug_to_default(plug):
'Find default value from plug, regardless of attribute type'
if plug.isArray:
raise TypeError('Array plugs are unsupported')
if plug.isCompound:
raise TypeError('Compound plugs are unsupported')
attr = plug.attribute()
type = attr.apiType()
if (type == om.MFn.kTypedAttribute):
return om.MFnTypedAttribute(attr).default
elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute, om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
return om.MFnUnitAttribute(attr).default
elif (type == om.MFn.kNumericAttribute):
return om.MFnNumericAttribute(attr).default
elif (type == om.MFn.kEnumAttribute):
return om.MFnEnumAttribute(attr).default
else:
raise TypeError(("Attribute type '%s' unsupported" % type))
| 984,843,986,271,279,900
|
Find default value from plug, regardless of attribute type
|
cmdx.py
|
_plug_to_default
|
fvbehr/cmdx
|
python
|
def _plug_to_default(plug):
if plug.isArray:
raise TypeError('Array plugs are unsupported')
if plug.isCompound:
raise TypeError('Compound plugs are unsupported')
attr = plug.attribute()
type = attr.apiType()
if (type == om.MFn.kTypedAttribute):
return om.MFnTypedAttribute(attr).default
elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute, om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
return om.MFnUnitAttribute(attr).default
elif (type == om.MFn.kNumericAttribute):
return om.MFnNumericAttribute(attr).default
elif (type == om.MFn.kEnumAttribute):
return om.MFnEnumAttribute(attr).default
else:
raise TypeError(("Attribute type '%s' unsupported" % type))
|
def _plug_to_python(plug, unit=None, context=None):
'Convert native `plug` to Python type\n\n Arguments:\n plug (om.MPlug): Native Maya plug\n unit (int, optional): Return value in this unit, e.g. Meters\n context (om.MDGContext, optional): Return value in this context\n\n '
assert (not plug.isNull), ("'%s' was null" % plug)
kwargs = dict()
if (context is not None):
kwargs['context'] = context
if (plug.isArray and plug.isCompound):
return _plug_to_python(plug.elementByLogicalIndex(0), unit, context)
elif plug.isArray:
return tuple((_plug_to_python(plug.elementByLogicalIndex(index), unit, context) for index in range(plug.evaluateNumElements())))
elif plug.isCompound:
return tuple((_plug_to_python(plug.child(index), unit, context) for index in range(plug.numChildren())))
attr = plug.attribute()
type = attr.apiType()
if (type == om.MFn.kTypedAttribute):
innerType = om.MFnTypedAttribute(attr).attrType()
if (innerType == om.MFnData.kAny):
return None
elif (innerType == om.MFnData.kMatrix):
if plug.isArray:
plug = plug.elementByLogicalIndex(0)
return tuple(om.MFnMatrixData(plug.asMObject(**kwargs)).matrix())
elif (innerType == om.MFnData.kString):
return plug.asString(**kwargs)
elif (innerType == om.MFnData.kNurbsCurve):
return om.MFnNurbsCurveData(plug.asMObject(**kwargs))
elif (innerType == om.MFnData.kComponentList):
return None
elif (innerType == om.MFnData.kInvalid):
return None
else:
log.debug(('Unsupported kTypedAttribute: %s' % innerType))
return None
elif (type == om.MFn.kMatrixAttribute):
return tuple(om.MFnMatrixData(plug.asMObject(**kwargs)).matrix())
elif (type == om.MFnData.kDoubleArray):
raise TypeError(('%s: kDoubleArray is not supported' % plug))
elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute)):
if (unit is None):
return plug.asMDistance(**kwargs).asUnits(Centimeters)
elif (unit == Millimeters):
return plug.asMDistance(**kwargs).asMillimeters()
elif (unit == Centimeters):
return plug.asMDistance(**kwargs).asCentimeters()
elif (unit == Meters):
return plug.asMDistance(**kwargs).asMeters()
elif (unit == Kilometers):
return plug.asMDistance(**kwargs).asKilometers()
elif (unit == Inches):
return plug.asMDistance(**kwargs).asInches()
elif (unit == Feet):
return plug.asMDistance(**kwargs).asFeet()
elif (unit == Miles):
return plug.asMDistance(**kwargs).asMiles()
elif (unit == Yards):
return plug.asMDistance(**kwargs).asYards()
else:
raise TypeError(("Unsupported unit '%d'" % unit))
elif (type in (om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
if (unit is None):
return plug.asMAngle(**kwargs).asUnits(Radians)
elif (unit == Degrees):
return plug.asMAngle(**kwargs).asDegrees()
elif (unit == Radians):
return plug.asMAngle(**kwargs).asRadians()
elif (unit == AngularSeconds):
return plug.asMAngle(**kwargs).asAngSeconds()
elif (unit == AngularMinutes):
return plug.asMAngle(**kwargs).asAngMinutes()
else:
raise TypeError(("Unsupported unit '%d'" % unit))
elif (type == om.MFn.kNumericAttribute):
innerType = om.MFnNumericAttribute(attr).numericType()
if (innerType == om.MFnNumericData.kBoolean):
return plug.asBool(**kwargs)
elif (innerType in (om.MFnNumericData.kShort, om.MFnNumericData.kInt, om.MFnNumericData.kLong, om.MFnNumericData.kByte)):
return plug.asInt(**kwargs)
elif (innerType in (om.MFnNumericData.kFloat, om.MFnNumericData.kDouble, om.MFnNumericData.kAddr)):
return plug.asDouble(**kwargs)
else:
raise TypeError(('Unsupported numeric type: %s' % innerType))
elif (type == om.MFn.kEnumAttribute):
return plug.asShort(**kwargs)
elif (type == om.MFn.kMessageAttribute):
return True
elif (type == om.MFn.kTimeAttribute):
if unit:
return plug.asMTime(**kwargs).asUnits(unit)
else:
return plug.asMTime(**kwargs).value
elif (type == om.MFn.kInvalid):
raise TypeError(('%s was invalid' % plug.name()))
else:
raise TypeError(("Unsupported type '%s'" % type))
| -3,045,147,447,084,764,000
|
Convert native `plug` to Python type
Arguments:
plug (om.MPlug): Native Maya plug
unit (int, optional): Return value in this unit, e.g. Meters
context (om.MDGContext, optional): Return value in this context
|
cmdx.py
|
_plug_to_python
|
fvbehr/cmdx
|
python
|
def _plug_to_python(plug, unit=None, context=None):
'Convert native `plug` to Python type\n\n Arguments:\n plug (om.MPlug): Native Maya plug\n unit (int, optional): Return value in this unit, e.g. Meters\n context (om.MDGContext, optional): Return value in this context\n\n '
assert (not plug.isNull), ("'%s' was null" % plug)
kwargs = dict()
if (context is not None):
kwargs['context'] = context
if (plug.isArray and plug.isCompound):
return _plug_to_python(plug.elementByLogicalIndex(0), unit, context)
elif plug.isArray:
return tuple((_plug_to_python(plug.elementByLogicalIndex(index), unit, context) for index in range(plug.evaluateNumElements())))
elif plug.isCompound:
return tuple((_plug_to_python(plug.child(index), unit, context) for index in range(plug.numChildren())))
attr = plug.attribute()
type = attr.apiType()
if (type == om.MFn.kTypedAttribute):
innerType = om.MFnTypedAttribute(attr).attrType()
if (innerType == om.MFnData.kAny):
return None
elif (innerType == om.MFnData.kMatrix):
if plug.isArray:
plug = plug.elementByLogicalIndex(0)
return tuple(om.MFnMatrixData(plug.asMObject(**kwargs)).matrix())
elif (innerType == om.MFnData.kString):
return plug.asString(**kwargs)
elif (innerType == om.MFnData.kNurbsCurve):
return om.MFnNurbsCurveData(plug.asMObject(**kwargs))
elif (innerType == om.MFnData.kComponentList):
return None
elif (innerType == om.MFnData.kInvalid):
return None
else:
log.debug(('Unsupported kTypedAttribute: %s' % innerType))
return None
elif (type == om.MFn.kMatrixAttribute):
return tuple(om.MFnMatrixData(plug.asMObject(**kwargs)).matrix())
elif (type == om.MFnData.kDoubleArray):
raise TypeError(('%s: kDoubleArray is not supported' % plug))
elif (type in (om.MFn.kDoubleLinearAttribute, om.MFn.kFloatLinearAttribute)):
if (unit is None):
return plug.asMDistance(**kwargs).asUnits(Centimeters)
elif (unit == Millimeters):
return plug.asMDistance(**kwargs).asMillimeters()
elif (unit == Centimeters):
return plug.asMDistance(**kwargs).asCentimeters()
elif (unit == Meters):
return plug.asMDistance(**kwargs).asMeters()
elif (unit == Kilometers):
return plug.asMDistance(**kwargs).asKilometers()
elif (unit == Inches):
return plug.asMDistance(**kwargs).asInches()
elif (unit == Feet):
return plug.asMDistance(**kwargs).asFeet()
elif (unit == Miles):
return plug.asMDistance(**kwargs).asMiles()
elif (unit == Yards):
return plug.asMDistance(**kwargs).asYards()
else:
raise TypeError(("Unsupported unit '%d'" % unit))
elif (type in (om.MFn.kDoubleAngleAttribute, om.MFn.kFloatAngleAttribute)):
if (unit is None):
return plug.asMAngle(**kwargs).asUnits(Radians)
elif (unit == Degrees):
return plug.asMAngle(**kwargs).asDegrees()
elif (unit == Radians):
return plug.asMAngle(**kwargs).asRadians()
elif (unit == AngularSeconds):
return plug.asMAngle(**kwargs).asAngSeconds()
elif (unit == AngularMinutes):
return plug.asMAngle(**kwargs).asAngMinutes()
else:
raise TypeError(("Unsupported unit '%d'" % unit))
elif (type == om.MFn.kNumericAttribute):
innerType = om.MFnNumericAttribute(attr).numericType()
if (innerType == om.MFnNumericData.kBoolean):
return plug.asBool(**kwargs)
elif (innerType in (om.MFnNumericData.kShort, om.MFnNumericData.kInt, om.MFnNumericData.kLong, om.MFnNumericData.kByte)):
return plug.asInt(**kwargs)
elif (innerType in (om.MFnNumericData.kFloat, om.MFnNumericData.kDouble, om.MFnNumericData.kAddr)):
return plug.asDouble(**kwargs)
else:
raise TypeError(('Unsupported numeric type: %s' % innerType))
elif (type == om.MFn.kEnumAttribute):
return plug.asShort(**kwargs)
elif (type == om.MFn.kMessageAttribute):
return True
elif (type == om.MFn.kTimeAttribute):
if unit:
return plug.asMTime(**kwargs).asUnits(unit)
else:
return plug.asMTime(**kwargs).value
elif (type == om.MFn.kInvalid):
raise TypeError(('%s was invalid' % plug.name()))
else:
raise TypeError(("Unsupported type '%s'" % type))
|
def _python_to_plug(value, plug):
'Pass value of `value` to `plug`\n\n Arguments:\n value (any): Instance of Python or Maya type\n plug (Plug): Target plug to which value is applied\n\n '
if isinstance(value, (tuple, list)):
if (plug.type() == 'kMatrixAttribute'):
assert (len(value) == 16), "Value didn't appear to be a valid matrix"
return _python_to_plug(Matrix4(value), plug)
for (index, value) in enumerate(value):
if isinstance(value, (tuple, list)):
raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
_python_to_plug(value, plug[index])
elif isinstance(value, om1.MObject):
node = _encode1(plug._node.path())
shapeFn = om1.MFnDagNode(node)
plug = shapeFn.findPlug(plug.name())
plug.setMObject(value)
elif isinstance(value, om.MEulerRotation):
for (index, value) in enumerate(value):
value = om.MAngle(value, om.MAngle.kRadians)
_python_to_plug(value, plug[index])
elif isinstance(value, om.MAngle):
plug._mplug.setMAngle(value)
elif isinstance(value, om.MDistance):
plug._mplug.setMDistance(value)
elif isinstance(value, om.MTime):
plug._mplug.setMTime(value)
elif isinstance(value, om.MQuaternion):
_python_to_plug(value.asEulerRotation(), plug)
elif isinstance(value, om.MVector):
for (index, value) in enumerate(value):
_python_to_plug(value, plug[index])
elif isinstance(value, om.MPoint):
for (index, value) in enumerate(value):
_python_to_plug(value, plug[index])
elif isinstance(value, om.MMatrix):
matrixData = om.MFnMatrixData()
matobj = matrixData.create(value)
plug._mplug.setMObject(matobj)
elif plug._mplug.isCompound:
count = plug._mplug.numChildren()
return _python_to_plug(([value] * count), plug)
elif isinstance(value, string_types):
plug._mplug.setString(value)
elif isinstance(value, int):
plug._mplug.setInt(value)
elif isinstance(value, float):
plug._mplug.setDouble(value)
elif isinstance(value, bool):
plug._mplug.setBool(value)
else:
raise TypeError(("Unsupported Python type '%s'" % value.__class__))
| 4,446,051,081,703,159,300
|
Pass value of `value` to `plug`
Arguments:
value (any): Instance of Python or Maya type
plug (Plug): Target plug to which value is applied
|
cmdx.py
|
_python_to_plug
|
fvbehr/cmdx
|
python
|
def _python_to_plug(value, plug):
'Pass value of `value` to `plug`\n\n Arguments:\n value (any): Instance of Python or Maya type\n plug (Plug): Target plug to which value is applied\n\n '
if isinstance(value, (tuple, list)):
if (plug.type() == 'kMatrixAttribute'):
assert (len(value) == 16), "Value didn't appear to be a valid matrix"
return _python_to_plug(Matrix4(value), plug)
for (index, value) in enumerate(value):
if isinstance(value, (tuple, list)):
raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
_python_to_plug(value, plug[index])
elif isinstance(value, om1.MObject):
node = _encode1(plug._node.path())
shapeFn = om1.MFnDagNode(node)
plug = shapeFn.findPlug(plug.name())
plug.setMObject(value)
elif isinstance(value, om.MEulerRotation):
for (index, value) in enumerate(value):
value = om.MAngle(value, om.MAngle.kRadians)
_python_to_plug(value, plug[index])
elif isinstance(value, om.MAngle):
plug._mplug.setMAngle(value)
elif isinstance(value, om.MDistance):
plug._mplug.setMDistance(value)
elif isinstance(value, om.MTime):
plug._mplug.setMTime(value)
elif isinstance(value, om.MQuaternion):
_python_to_plug(value.asEulerRotation(), plug)
elif isinstance(value, om.MVector):
for (index, value) in enumerate(value):
_python_to_plug(value, plug[index])
elif isinstance(value, om.MPoint):
for (index, value) in enumerate(value):
_python_to_plug(value, plug[index])
elif isinstance(value, om.MMatrix):
matrixData = om.MFnMatrixData()
matobj = matrixData.create(value)
plug._mplug.setMObject(matobj)
elif plug._mplug.isCompound:
count = plug._mplug.numChildren()
return _python_to_plug(([value] * count), plug)
elif isinstance(value, string_types):
plug._mplug.setString(value)
elif isinstance(value, int):
plug._mplug.setInt(value)
elif isinstance(value, float):
plug._mplug.setDouble(value)
elif isinstance(value, bool):
plug._mplug.setBool(value)
else:
raise TypeError(("Unsupported Python type '%s'" % value.__class__))
|
def _python_to_mod(value, plug, mod):
'Convert `value` into a suitable equivalent for om.MDGModifier\n\n Arguments:\n value (object): Value of any type to write into modifier\n plug (Plug): Plug within which to write value\n mod (om.MDGModifier): Modifier to use for writing it\n\n '
mplug = plug._mplug
if isinstance(value, (tuple, list)):
for (index, value) in enumerate(value):
if isinstance(value, (tuple, list)):
raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
_python_to_mod(value, plug[index], mod)
elif isinstance(value, om.MVector):
for (index, value) in enumerate(value):
_python_to_mod(value, plug[index], mod)
elif isinstance(value, string_types):
mod.newPlugValueString(mplug, value)
elif isinstance(value, int):
mod.newPlugValueInt(mplug, value)
elif isinstance(value, float):
mod.newPlugValueFloat(mplug, value)
elif isinstance(value, bool):
mod.newPlugValueBool(mplug, value)
elif isinstance(value, om.MAngle):
mod.newPlugValueMAngle(mplug, value)
elif isinstance(value, om.MDistance):
mod.newPlugValueMDistance(mplug, value)
elif isinstance(value, om.MTime):
mod.newPlugValueMTime(mplug, value)
elif isinstance(value, om.MEulerRotation):
for (index, value) in enumerate(value):
value = om.MAngle(value, om.MAngle.kRadians)
_python_to_mod(value, plug[index], mod)
else:
log.warning(('Unsupported plug type for modifier: %s' % type(value)))
return False
return True
| -9,122,478,816,224,801,000
|
Convert `value` into a suitable equivalent for om.MDGModifier
Arguments:
value (object): Value of any type to write into modifier
plug (Plug): Plug within which to write value
mod (om.MDGModifier): Modifier to use for writing it
|
cmdx.py
|
_python_to_mod
|
fvbehr/cmdx
|
python
|
def _python_to_mod(value, plug, mod):
'Convert `value` into a suitable equivalent for om.MDGModifier\n\n Arguments:\n value (object): Value of any type to write into modifier\n plug (Plug): Plug within which to write value\n mod (om.MDGModifier): Modifier to use for writing it\n\n '
mplug = plug._mplug
if isinstance(value, (tuple, list)):
for (index, value) in enumerate(value):
if isinstance(value, (tuple, list)):
raise TypeError(('Unsupported nested Python type: %s' % value.__class__))
_python_to_mod(value, plug[index], mod)
elif isinstance(value, om.MVector):
for (index, value) in enumerate(value):
_python_to_mod(value, plug[index], mod)
elif isinstance(value, string_types):
mod.newPlugValueString(mplug, value)
elif isinstance(value, int):
mod.newPlugValueInt(mplug, value)
elif isinstance(value, float):
mod.newPlugValueFloat(mplug, value)
elif isinstance(value, bool):
mod.newPlugValueBool(mplug, value)
elif isinstance(value, om.MAngle):
mod.newPlugValueMAngle(mplug, value)
elif isinstance(value, om.MDistance):
mod.newPlugValueMDistance(mplug, value)
elif isinstance(value, om.MTime):
mod.newPlugValueMTime(mplug, value)
elif isinstance(value, om.MEulerRotation):
for (index, value) in enumerate(value):
value = om.MAngle(value, om.MAngle.kRadians)
_python_to_mod(value, plug[index], mod)
else:
log.warning(('Unsupported plug type for modifier: %s' % type(value)))
return False
return True
|
def encode(path):
'Convert relative or absolute `path` to cmdx Node\n\n Fastest conversion from absolute path to Node\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n '
assert isinstance(path, string_types), ('%s was not string' % path)
selectionList = om.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
mobj = selectionList.getDependNode(0)
return Node(mobj)
| -8,308,368,486,272,812,000
|
Convert relative or absolute `path` to cmdx Node
Fastest conversion from absolute path to Node
Arguments:
path (str): Absolute or relative path to DAG or DG node
|
cmdx.py
|
encode
|
fvbehr/cmdx
|
python
|
def encode(path):
'Convert relative or absolute `path` to cmdx Node\n\n Fastest conversion from absolute path to Node\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n '
assert isinstance(path, string_types), ('%s was not string' % path)
selectionList = om.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
mobj = selectionList.getDependNode(0)
return Node(mobj)
|
def fromHash(code, default=None):
'Get existing node from MObjectHandle.hashCode()'
try:
return Singleton._instances[('%x' % code)]
except KeyError:
return default
| -779,055,603,039,526,500
|
Get existing node from MObjectHandle.hashCode()
|
cmdx.py
|
fromHash
|
fvbehr/cmdx
|
python
|
def fromHash(code, default=None):
try:
return Singleton._instances[('%x' % code)]
except KeyError:
return default
|
def fromHex(hex, default=None, safe=True):
'Get existing node from Node.hex'
node = Singleton._instances.get(hex, default)
if (safe and node and node.exists):
return node
else:
return node
| -8,415,511,792,610,757,000
|
Get existing node from Node.hex
|
cmdx.py
|
fromHex
|
fvbehr/cmdx
|
python
|
def fromHex(hex, default=None, safe=True):
node = Singleton._instances.get(hex, default)
if (safe and node and node.exists):
return node
else:
return node
|
def toHash(mobj):
'Cache the given `mobj` and return its hashCode\n\n This enables pre-caching of one or more nodes in situations where\n intend to access it later, at a more performance-critical moment.\n\n Ignores nodes that have already been cached.\n\n '
node = Node(mobj)
return node.hashCode
| 4,412,574,546,097,724,400
|
Cache the given `mobj` and return its hashCode
This enables pre-caching of one or more nodes in situations where
intend to access it later, at a more performance-critical moment.
Ignores nodes that have already been cached.
|
cmdx.py
|
toHash
|
fvbehr/cmdx
|
python
|
def toHash(mobj):
'Cache the given `mobj` and return its hashCode\n\n This enables pre-caching of one or more nodes in situations where\n intend to access it later, at a more performance-critical moment.\n\n Ignores nodes that have already been cached.\n\n '
node = Node(mobj)
return node.hashCode
|
def toHex(mobj):
'Cache the given `mobj` and return its hex value\n\n See :func:`toHash` for docstring.\n\n '
node = Node(mobj)
return node.hex
| -2,377,513,751,368,329,700
|
Cache the given `mobj` and return its hex value
See :func:`toHash` for docstring.
|
cmdx.py
|
toHex
|
fvbehr/cmdx
|
python
|
def toHex(mobj):
'Cache the given `mobj` and return its hex value\n\n See :func:`toHash` for docstring.\n\n '
node = Node(mobj)
return node.hex
|
def asHash(mobj):
'Return a given hashCode for `mobj`, without caching it\n\n This can be helpful in case you wish to synchronise `cmdx`\n with a third-party library or tool and wish to guarantee\n that an identical algorithm is used.\n\n '
handle = om.MObjectHandle(mobj)
return handle.hashCode()
| 623,203,837,139,447,900
|
Return a given hashCode for `mobj`, without caching it
This can be helpful in case you wish to synchronise `cmdx`
with a third-party library or tool and wish to guarantee
that an identical algorithm is used.
|
cmdx.py
|
asHash
|
fvbehr/cmdx
|
python
|
def asHash(mobj):
'Return a given hashCode for `mobj`, without caching it\n\n This can be helpful in case you wish to synchronise `cmdx`\n with a third-party library or tool and wish to guarantee\n that an identical algorithm is used.\n\n '
handle = om.MObjectHandle(mobj)
return handle.hashCode()
|
def asHex(mobj):
'Return a given hex string for `mobj`, without caching it\n\n See docstring for :func:`asHash` for details\n\n '
return ('%x' % asHash(mobj))
| -4,880,126,403,296,916,000
|
Return a given hex string for `mobj`, without caching it
See docstring for :func:`asHash` for details
|
cmdx.py
|
asHex
|
fvbehr/cmdx
|
python
|
def asHex(mobj):
'Return a given hex string for `mobj`, without caching it\n\n See docstring for :func:`asHash` for details\n\n '
return ('%x' % asHash(mobj))
|
def meters(cm):
"Centimeters (Maya's default unit) to Meters\n\n Example:\n >>> meters(100)\n 1.0\n\n "
return (cm * 0.01)
| -3,570,937,588,544,551,000
|
Centimeters (Maya's default unit) to Meters
Example:
>>> meters(100)
1.0
|
cmdx.py
|
meters
|
fvbehr/cmdx
|
python
|
def meters(cm):
"Centimeters (Maya's default unit) to Meters\n\n Example:\n >>> meters(100)\n 1.0\n\n "
return (cm * 0.01)
|
def clear():
'Remove all reused nodes'
Singleton._instances.clear()
| -312,182,393,654,529,150
|
Remove all reused nodes
|
cmdx.py
|
clear
|
fvbehr/cmdx
|
python
|
def clear():
Singleton._instances.clear()
|
def _encode1(path):
'Convert `path` to Maya API 1.0 MObject\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n Raises:\n ExistError on `path` not existing\n\n '
selectionList = om1.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
mobject = om1.MObject()
selectionList.getDependNode(0, mobject)
return mobject
| 962,091,573,452,979,100
|
Convert `path` to Maya API 1.0 MObject
Arguments:
path (str): Absolute or relative path to DAG or DG node
Raises:
ExistError on `path` not existing
|
cmdx.py
|
_encode1
|
fvbehr/cmdx
|
python
|
def _encode1(path):
'Convert `path` to Maya API 1.0 MObject\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n Raises:\n ExistError on `path` not existing\n\n '
selectionList = om1.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
mobject = om1.MObject()
selectionList.getDependNode(0, mobject)
return mobject
|
def _encodedagpath1(path):
'Convert `path` to Maya API 1.0 MObject\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n Raises:\n ExistError on `path` not existing\n\n '
selectionList = om1.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
dagpath = om1.MDagPath()
selectionList.getDagPath(0, dagpath)
return dagpath
| -2,508,639,482,950,188,500
|
Convert `path` to Maya API 1.0 MObject
Arguments:
path (str): Absolute or relative path to DAG or DG node
Raises:
ExistError on `path` not existing
|
cmdx.py
|
_encodedagpath1
|
fvbehr/cmdx
|
python
|
def _encodedagpath1(path):
'Convert `path` to Maya API 1.0 MObject\n\n Arguments:\n path (str): Absolute or relative path to DAG or DG node\n\n Raises:\n ExistError on `path` not existing\n\n '
selectionList = om1.MSelectionList()
try:
selectionList.add(path)
except RuntimeError:
raise ExistError(("'%s' does not exist" % path))
dagpath = om1.MDagPath()
selectionList.getDagPath(0, dagpath)
return dagpath
|
def decode(node):
'Convert cmdx Node to shortest unique path\n\n This is the same as `node.shortestPath()`\n To get an absolute path, use `node.path()`\n\n '
try:
return node.shortestPath()
except AttributeError:
return node.name(namespace=True)
| -4,636,056,238,598,363,000
|
Convert cmdx Node to shortest unique path
This is the same as `node.shortestPath()`
To get an absolute path, use `node.path()`
|
cmdx.py
|
decode
|
fvbehr/cmdx
|
python
|
def decode(node):
'Convert cmdx Node to shortest unique path\n\n This is the same as `node.shortestPath()`\n To get an absolute path, use `node.path()`\n\n '
try:
return node.shortestPath()
except AttributeError:
return node.name(namespace=True)
|
def createNode(type, name=None, parent=None):
'Create a new node\n\n This function forms the basic building block\n with which to create new nodes in Maya.\n\n .. note:: Missing arguments `shared` and `skipSelect`\n .. tip:: For additional performance, `type` may be given as an MTypeId\n\n Arguments:\n type (str): Type name of new node, e.g. "transform"\n name (str, optional): Sets the name of the newly-created node\n parent (Node, optional): Specifies the parent in the DAG under which\n the new node belongs\n\n Example:\n >>> node = createNode("transform") # Type as string\n >>> node = createNode(tTransform) # Type as ID\n\n '
try:
with DagModifier() as mod:
node = mod.createNode(type, name=name, parent=parent)
except TypeError:
with DGModifier() as mod:
node = mod.createNode(type, name=name)
return node
| 913,879,734,073,910,300
|
Create a new node
This function forms the basic building block
with which to create new nodes in Maya.
.. note:: Missing arguments `shared` and `skipSelect`
.. tip:: For additional performance, `type` may be given as an MTypeId
Arguments:
type (str): Type name of new node, e.g. "transform"
name (str, optional): Sets the name of the newly-created node
parent (Node, optional): Specifies the parent in the DAG under which
the new node belongs
Example:
>>> node = createNode("transform") # Type as string
>>> node = createNode(tTransform) # Type as ID
|
cmdx.py
|
createNode
|
fvbehr/cmdx
|
python
|
def createNode(type, name=None, parent=None):
'Create a new node\n\n This function forms the basic building block\n with which to create new nodes in Maya.\n\n .. note:: Missing arguments `shared` and `skipSelect`\n .. tip:: For additional performance, `type` may be given as an MTypeId\n\n Arguments:\n type (str): Type name of new node, e.g. "transform"\n name (str, optional): Sets the name of the newly-created node\n parent (Node, optional): Specifies the parent in the DAG under which\n the new node belongs\n\n Example:\n >>> node = createNode("transform") # Type as string\n >>> node = createNode(tTransform) # Type as ID\n\n '
try:
with DagModifier() as mod:
node = mod.createNode(type, name=name, parent=parent)
except TypeError:
with DGModifier() as mod:
node = mod.createNode(type, name=name)
return node
|
def getAttr(attr, type=None, time=None):
'Read `attr`\n\n Arguments:\n attr (Plug): Attribute as a cmdx.Plug\n type (str, optional): Unused\n time (float, optional): Time at which to evaluate the attribute\n\n Example:\n >>> node = createNode("transform")\n >>> getAttr(node + ".translateX")\n 0.0\n\n '
return attr.read(time=time)
| 1,755,435,229,108,206,600
|
Read `attr`
Arguments:
attr (Plug): Attribute as a cmdx.Plug
type (str, optional): Unused
time (float, optional): Time at which to evaluate the attribute
Example:
>>> node = createNode("transform")
>>> getAttr(node + ".translateX")
0.0
|
cmdx.py
|
getAttr
|
fvbehr/cmdx
|
python
|
def getAttr(attr, type=None, time=None):
'Read `attr`\n\n Arguments:\n attr (Plug): Attribute as a cmdx.Plug\n type (str, optional): Unused\n time (float, optional): Time at which to evaluate the attribute\n\n Example:\n >>> node = createNode("transform")\n >>> getAttr(node + ".translateX")\n 0.0\n\n '
return attr.read(time=time)
|
def setAttr(attr, value, type=None):
'Write `value` to `attr`\n\n Arguments:\n attr (Plug): Existing attribute to edit\n value (any): Value to write\n type (int, optional): Unused\n\n Example:\n >>> node = createNode("transform")\n >>> setAttr(node + ".translateX", 5.0)\n\n '
attr.write(value)
| 2,888,335,193,053,292,000
|
Write `value` to `attr`
Arguments:
attr (Plug): Existing attribute to edit
value (any): Value to write
type (int, optional): Unused
Example:
>>> node = createNode("transform")
>>> setAttr(node + ".translateX", 5.0)
|
cmdx.py
|
setAttr
|
fvbehr/cmdx
|
python
|
def setAttr(attr, value, type=None):
'Write `value` to `attr`\n\n Arguments:\n attr (Plug): Existing attribute to edit\n value (any): Value to write\n type (int, optional): Unused\n\n Example:\n >>> node = createNode("transform")\n >>> setAttr(node + ".translateX", 5.0)\n\n '
attr.write(value)
|
def addAttr(node, longName, attributeType, shortName=None, enumName=None, defaultValue=None):
'Add new attribute to `node`\n\n Arguments:\n node (Node): Add attribute to this node\n longName (str): Name of resulting attribute\n attributeType (str): Type of attribute, e.g. `string`\n shortName (str, optional): Alternate name of attribute\n enumName (str, optional): Options for an enum attribute\n defaultValue (any, optional): Default value of attribute\n\n Example:\n >>> node = createNode("transform")\n >>> addAttr(node, "myString", attributeType="string")\n >>> addAttr(node, "myDouble", attributeType=Double)\n\n '
at = attributeType
if (isinstance(at, type) and issubclass(at, _AbstractAttribute)):
Attribute = attributeType
else:
Attribute = {'double': Double, 'double3': Double3, 'string': String, 'long': Long, 'bool': Boolean, 'enume': Enum}[attributeType]
kwargs = {'default': defaultValue}
if enumName:
kwargs['fields'] = enumName.split(':')
attribute = Attribute(longName, **kwargs)
node.addAttr(attribute)
| -2,912,810,700,619,053,000
|
Add new attribute to `node`
Arguments:
node (Node): Add attribute to this node
longName (str): Name of resulting attribute
attributeType (str): Type of attribute, e.g. `string`
shortName (str, optional): Alternate name of attribute
enumName (str, optional): Options for an enum attribute
defaultValue (any, optional): Default value of attribute
Example:
>>> node = createNode("transform")
>>> addAttr(node, "myString", attributeType="string")
>>> addAttr(node, "myDouble", attributeType=Double)
|
cmdx.py
|
addAttr
|
fvbehr/cmdx
|
python
|
def addAttr(node, longName, attributeType, shortName=None, enumName=None, defaultValue=None):
'Add new attribute to `node`\n\n Arguments:\n node (Node): Add attribute to this node\n longName (str): Name of resulting attribute\n attributeType (str): Type of attribute, e.g. `string`\n shortName (str, optional): Alternate name of attribute\n enumName (str, optional): Options for an enum attribute\n defaultValue (any, optional): Default value of attribute\n\n Example:\n >>> node = createNode("transform")\n >>> addAttr(node, "myString", attributeType="string")\n >>> addAttr(node, "myDouble", attributeType=Double)\n\n '
at = attributeType
if (isinstance(at, type) and issubclass(at, _AbstractAttribute)):
Attribute = attributeType
else:
Attribute = {'double': Double, 'double3': Double3, 'string': String, 'long': Long, 'bool': Boolean, 'enume': Enum}[attributeType]
kwargs = {'default': defaultValue}
if enumName:
kwargs['fields'] = enumName.split(':')
attribute = Attribute(longName, **kwargs)
node.addAttr(attribute)
|
def listRelatives(node, type=None, children=False, allDescendents=False, parent=False, shapes=False):
'List relatives of `node`\n\n Arguments:\n node (DagNode): Node to enquire about\n type (int, optional): Only return nodes of this type\n children (bool, optional): Return children of `node`\n parent (bool, optional): Return parent of `node`\n shapes (bool, optional): Return only children that are shapes\n allDescendents (bool, optional): Return descendents of `node`\n fullPath (bool, optional): Unused; nodes are always exact\n path (bool, optional): Unused; nodes are always exact\n\n Example:\n >>> parent = createNode("transform")\n >>> child = createNode("transform", parent=parent)\n >>> listRelatives(child, parent=True) == [parent]\n True\n\n '
if (not isinstance(node, DagNode)):
return None
elif allDescendents:
return list(node.descendents(type=type))
elif shapes:
return list(node.shapes(type=type))
elif parent:
return [node.parent(type=type)]
elif children:
return list(node.children(type=type))
| 6,192,445,623,260,339,000
|
List relatives of `node`
Arguments:
node (DagNode): Node to enquire about
type (int, optional): Only return nodes of this type
children (bool, optional): Return children of `node`
parent (bool, optional): Return parent of `node`
shapes (bool, optional): Return only children that are shapes
allDescendents (bool, optional): Return descendents of `node`
fullPath (bool, optional): Unused; nodes are always exact
path (bool, optional): Unused; nodes are always exact
Example:
>>> parent = createNode("transform")
>>> child = createNode("transform", parent=parent)
>>> listRelatives(child, parent=True) == [parent]
True
|
cmdx.py
|
listRelatives
|
fvbehr/cmdx
|
python
|
def listRelatives(node, type=None, children=False, allDescendents=False, parent=False, shapes=False):
'List relatives of `node`\n\n Arguments:\n node (DagNode): Node to enquire about\n type (int, optional): Only return nodes of this type\n children (bool, optional): Return children of `node`\n parent (bool, optional): Return parent of `node`\n shapes (bool, optional): Return only children that are shapes\n allDescendents (bool, optional): Return descendents of `node`\n fullPath (bool, optional): Unused; nodes are always exact\n path (bool, optional): Unused; nodes are always exact\n\n Example:\n >>> parent = createNode("transform")\n >>> child = createNode("transform", parent=parent)\n >>> listRelatives(child, parent=True) == [parent]\n True\n\n '
if (not isinstance(node, DagNode)):
return None
elif allDescendents:
return list(node.descendents(type=type))
elif shapes:
return list(node.shapes(type=type))
elif parent:
return [node.parent(type=type)]
elif children:
return list(node.children(type=type))
|
def listConnections(attr):
'List connections of `attr`\n\n Arguments:\n attr (Plug or Node):\n\n Example:\n >>> node1 = createNode("transform")\n >>> node2 = createNode("mesh", parent=node1)\n >>> node1["v"] >> node2["v"]\n >>> listConnections(node1) == [node2]\n True\n >>> listConnections(node1 + ".v") == [node2]\n True\n >>> listConnections(node1["v"]) == [node2]\n True\n >>> listConnections(node2) == [node1]\n True\n\n '
return list((node for node in attr.connections()))
| -3,154,410,947,409,816,000
|
List connections of `attr`
Arguments:
attr (Plug or Node):
Example:
>>> node1 = createNode("transform")
>>> node2 = createNode("mesh", parent=node1)
>>> node1["v"] >> node2["v"]
>>> listConnections(node1) == [node2]
True
>>> listConnections(node1 + ".v") == [node2]
True
>>> listConnections(node1["v"]) == [node2]
True
>>> listConnections(node2) == [node1]
True
|
cmdx.py
|
listConnections
|
fvbehr/cmdx
|
python
|
def listConnections(attr):
'List connections of `attr`\n\n Arguments:\n attr (Plug or Node):\n\n Example:\n >>> node1 = createNode("transform")\n >>> node2 = createNode("mesh", parent=node1)\n >>> node1["v"] >> node2["v"]\n >>> listConnections(node1) == [node2]\n True\n >>> listConnections(node1 + ".v") == [node2]\n True\n >>> listConnections(node1["v"]) == [node2]\n True\n >>> listConnections(node2) == [node1]\n True\n\n '
return list((node for node in attr.connections()))
|
def connectAttr(src, dst):
'Connect `src` to `dst`\n\n Arguments:\n src (Plug): Source plug\n dst (Plug): Destination plug\n\n Example:\n >>> src = createNode("transform")\n >>> dst = createNode("transform")\n >>> connectAttr(src + ".rotateX", dst + ".scaleY")\n\n '
src.connect(dst)
| 8,954,620,462,276,712,000
|
Connect `src` to `dst`
Arguments:
src (Plug): Source plug
dst (Plug): Destination plug
Example:
>>> src = createNode("transform")
>>> dst = createNode("transform")
>>> connectAttr(src + ".rotateX", dst + ".scaleY")
|
cmdx.py
|
connectAttr
|
fvbehr/cmdx
|
python
|
def connectAttr(src, dst):
'Connect `src` to `dst`\n\n Arguments:\n src (Plug): Source plug\n dst (Plug): Destination plug\n\n Example:\n >>> src = createNode("transform")\n >>> dst = createNode("transform")\n >>> connectAttr(src + ".rotateX", dst + ".scaleY")\n\n '
src.connect(dst)
|
def curve(parent, points, degree=1, form=kOpen):
'Create a NURBS curve from a series of points\n\n Arguments:\n parent (DagNode): Parent to resulting shape node\n points (list): One tuples per point, with 3 floats each\n degree (int, optional): Degree of curve, 1 is linear\n form (int, optional): Whether to close the curve or not\n\n Example:\n >>> parent = createNode("transform")\n >>> shape = curve(parent, [\n ... (0, 0, 0),\n ... (0, 1, 0),\n ... (0, 2, 0),\n ... ])\n ...\n\n '
assert isinstance(parent, DagNode), 'parent must be of type cmdx.DagNode'
assert ((parent._modifier is None) or parent._modifier.isDone), "curve() currently doesn't work with a modifier"
degree = min(3, max(1, degree))
cvs = om1.MPointArray()
knots = om1.MDoubleArray()
curveFn = om1.MFnNurbsCurve()
knotcount = (((len(points) - degree) + (2 * degree)) - 1)
for point in points:
cvs.append(om1.MPoint(*point))
for index in range(knotcount):
knots.append(index)
mobj = curveFn.create(cvs, knots, degree, form, False, True, _encode1(parent.path()))
mod = om1.MDagModifier()
mod.renameNode(mobj, (parent.name(namespace=True) + 'Shape'))
mod.doIt()
def undo():
mod.deleteNode(mobj)
mod.doIt()
def redo():
mod.undoIt()
commit(undo, redo)
shapeFn = om1.MFnDagNode(mobj)
return encode(shapeFn.fullPathName())
| 2,621,312,259,576,523,300
|
Create a NURBS curve from a series of points
Arguments:
parent (DagNode): Parent to resulting shape node
points (list): One tuples per point, with 3 floats each
degree (int, optional): Degree of curve, 1 is linear
form (int, optional): Whether to close the curve or not
Example:
>>> parent = createNode("transform")
>>> shape = curve(parent, [
... (0, 0, 0),
... (0, 1, 0),
... (0, 2, 0),
... ])
...
|
cmdx.py
|
curve
|
fvbehr/cmdx
|
python
|
def curve(parent, points, degree=1, form=kOpen):
'Create a NURBS curve from a series of points\n\n Arguments:\n parent (DagNode): Parent to resulting shape node\n points (list): One tuples per point, with 3 floats each\n degree (int, optional): Degree of curve, 1 is linear\n form (int, optional): Whether to close the curve or not\n\n Example:\n >>> parent = createNode("transform")\n >>> shape = curve(parent, [\n ... (0, 0, 0),\n ... (0, 1, 0),\n ... (0, 2, 0),\n ... ])\n ...\n\n '
assert isinstance(parent, DagNode), 'parent must be of type cmdx.DagNode'
assert ((parent._modifier is None) or parent._modifier.isDone), "curve() currently doesn't work with a modifier"
degree = min(3, max(1, degree))
cvs = om1.MPointArray()
knots = om1.MDoubleArray()
curveFn = om1.MFnNurbsCurve()
knotcount = (((len(points) - degree) + (2 * degree)) - 1)
for point in points:
cvs.append(om1.MPoint(*point))
for index in range(knotcount):
knots.append(index)
mobj = curveFn.create(cvs, knots, degree, form, False, True, _encode1(parent.path()))
mod = om1.MDagModifier()
mod.renameNode(mobj, (parent.name(namespace=True) + 'Shape'))
mod.doIt()
def undo():
mod.deleteNode(mobj)
mod.doIt()
def redo():
mod.undoIt()
commit(undo, redo)
shapeFn = om1.MFnDagNode(mobj)
return encode(shapeFn.fullPathName())
|
def lookAt(origin, center, up=None):
'Build a (left-handed) look-at matrix\n\n See glm::glc::matrix_transform::lookAt for reference\n\n + Z (up)\n /\n /\n (origin) o------ + X (center)\n + Y\n\n Arguments:\n origin (Vector): Starting position\n center (Vector): Point towards this\n up (Vector, optional): Up facing this way, defaults to Y-up\n\n Example:\n >>> mat = lookAt(\n ... (0, 0, 0), # Relative the origin..\n ... (1, 0, 0), # X-axis points towards global X\n ... (0, 1, 0) # Z-axis points towards global Y\n ... )\n >>> tm = Tm(mat)\n >>> int(degrees(tm.rotation().x))\n -90\n\n '
if isinstance(origin, (tuple, list)):
origin = Vector(origin)
if isinstance(center, (tuple, list)):
center = Vector(center)
if ((up is not None) and isinstance(up, (tuple, list))):
up = Vector(up)
up = (up or Vector(0, 1, 0))
x = (center - origin).normalize()
y = ((center - origin) ^ (center - up)).normalize()
z = (x ^ y)
return MatrixType((x[0], x[1], x[2], 0, y[0], y[1], y[2], 0, z[0], z[1], z[2], 0, 0, 0, 0, 0))
| 6,781,457,938,299,411,000
|
Build a (left-handed) look-at matrix
See glm::glc::matrix_transform::lookAt for reference
+ Z (up)
/
/
(origin) o------ + X (center)
+ Y
Arguments:
origin (Vector): Starting position
center (Vector): Point towards this
up (Vector, optional): Up facing this way, defaults to Y-up
Example:
>>> mat = lookAt(
... (0, 0, 0), # Relative the origin..
... (1, 0, 0), # X-axis points towards global X
... (0, 1, 0) # Z-axis points towards global Y
... )
>>> tm = Tm(mat)
>>> int(degrees(tm.rotation().x))
-90
|
cmdx.py
|
lookAt
|
fvbehr/cmdx
|
python
|
def lookAt(origin, center, up=None):
'Build a (left-handed) look-at matrix\n\n See glm::glc::matrix_transform::lookAt for reference\n\n + Z (up)\n /\n /\n (origin) o------ + X (center)\n + Y\n\n Arguments:\n origin (Vector): Starting position\n center (Vector): Point towards this\n up (Vector, optional): Up facing this way, defaults to Y-up\n\n Example:\n >>> mat = lookAt(\n ... (0, 0, 0), # Relative the origin..\n ... (1, 0, 0), # X-axis points towards global X\n ... (0, 1, 0) # Z-axis points towards global Y\n ... )\n >>> tm = Tm(mat)\n >>> int(degrees(tm.rotation().x))\n -90\n\n '
if isinstance(origin, (tuple, list)):
origin = Vector(origin)
if isinstance(center, (tuple, list)):
center = Vector(center)
if ((up is not None) and isinstance(up, (tuple, list))):
up = Vector(up)
up = (up or Vector(0, 1, 0))
x = (center - origin).normalize()
y = ((center - origin) ^ (center - up)).normalize()
z = (x ^ y)
return MatrixType((x[0], x[1], x[2], 0, y[0], y[1], y[2], 0, z[0], z[1], z[2], 0, 0, 0, 0, 0))
|
def first(iterator, default=None):
'Return first member of an `iterator`\n\n Example:\n >>> def it():\n ... yield 1\n ... yield 2\n ... yield 3\n ...\n >>> first(it())\n 1\n\n '
return next(iterator, default)
| 6,883,098,760,134,999,000
|
Return first member of an `iterator`
Example:
>>> def it():
... yield 1
... yield 2
... yield 3
...
>>> first(it())
1
|
cmdx.py
|
first
|
fvbehr/cmdx
|
python
|
def first(iterator, default=None):
'Return first member of an `iterator`\n\n Example:\n >>> def it():\n ... yield 1\n ... yield 2\n ... yield 3\n ...\n >>> first(it())\n 1\n\n '
return next(iterator, default)
|
def last(iterator, default=None):
'Return last member of an `iterator`\n\n Example:\n >>> def it():\n ... yield 1\n ... yield 2\n ... yield 3\n ...\n >>> last(it())\n 3\n\n '
last = default
for member in iterator:
last = member
return last
| -4,751,365,905,604,169,000
|
Return last member of an `iterator`
Example:
>>> def it():
... yield 1
... yield 2
... yield 3
...
>>> last(it())
3
|
cmdx.py
|
last
|
fvbehr/cmdx
|
python
|
def last(iterator, default=None):
'Return last member of an `iterator`\n\n Example:\n >>> def it():\n ... yield 1\n ... yield 2\n ... yield 3\n ...\n >>> last(it())\n 3\n\n '
last = default
for member in iterator:
last = member
return last
|
def commit(undo, redo=(lambda : None)):
'Commit `undo` and `redo` to history\n\n Arguments:\n undo (func): Call this function on next undo\n redo (func, optional): Like `undo`, for for redo\n\n '
if (not ENABLE_UNDO):
return
if (not hasattr(cmds, command)):
install()
try:
assert (shared.redo is None)
assert (shared.undo is None)
except AssertionError:
log.debug(('%s has a problem with undo' % __name__))
shared.undo = ('%x' % id(undo))
shared.redo = ('%x' % id(redo))
shared.undos[shared.undo] = undo
shared.redos[shared.redo] = redo
getattr(cmds, command)()
| 686,232,892,509,046,300
|
Commit `undo` and `redo` to history
Arguments:
undo (func): Call this function on next undo
redo (func, optional): Like `undo`, for for redo
|
cmdx.py
|
commit
|
fvbehr/cmdx
|
python
|
def commit(undo, redo=(lambda : None)):
'Commit `undo` and `redo` to history\n\n Arguments:\n undo (func): Call this function on next undo\n redo (func, optional): Like `undo`, for for redo\n\n '
if (not ENABLE_UNDO):
return
if (not hasattr(cmds, command)):
install()
try:
assert (shared.redo is None)
assert (shared.undo is None)
except AssertionError:
log.debug(('%s has a problem with undo' % __name__))
shared.undo = ('%x' % id(undo))
shared.redo = ('%x' % id(redo))
shared.undos[shared.undo] = undo
shared.redos[shared.redo] = redo
getattr(cmds, command)()
|
def install():
'Load this shared as a plug-in\n\n Call this prior to using the shared\n\n '
if ENABLE_UNDO:
cmds.loadPlugin(__file__, quiet=True)
self.installed = True
| -5,349,846,116,969,325,000
|
Load this shared as a plug-in
Call this prior to using the shared
|
cmdx.py
|
install
|
fvbehr/cmdx
|
python
|
def install():
'Load this shared as a plug-in\n\n Call this prior to using the shared\n\n '
if ENABLE_UNDO:
cmds.loadPlugin(__file__, quiet=True)
self.installed = True
|
def findPlugin(name):
'Find the original class of a plug-in by `name`'
try:
return InstalledPlugins[name]
except KeyError:
raise ExistError(("'%s' is not a recognised plug-in" % name))
| -2,457,719,582,756,939,300
|
Find the original class of a plug-in by `name`
|
cmdx.py
|
findPlugin
|
fvbehr/cmdx
|
python
|
def findPlugin(name):
try:
return InstalledPlugins[name]
except KeyError:
raise ExistError(("'%s' is not a recognised plug-in" % name))
|
def __eq__(self, other):
'MObject supports this operator explicitly'
try:
return (self._mobject == other._mobject)
except AttributeError:
return (str(self) == str(other))
| 1,662,863,173,826,148,000
|
MObject supports this operator explicitly
|
cmdx.py
|
__eq__
|
fvbehr/cmdx
|
python
|
def __eq__(self, other):
try:
return (self._mobject == other._mobject)
except AttributeError:
return (str(self) == str(other))
|
def __add__(self, other):
'Support legacy + \'.attr\' behavior\n\n Example:\n >>> node = createNode("transform")\n >>> getAttr(node + ".tx")\n 0.0\n >>> delete(node)\n\n '
return self[other.strip('.')]
| -4,542,163,359,849,990,700
|
Support legacy + '.attr' behavior
Example:
>>> node = createNode("transform")
>>> getAttr(node + ".tx")
0.0
>>> delete(node)
|
cmdx.py
|
__add__
|
fvbehr/cmdx
|
python
|
def __add__(self, other):
'Support legacy + \'.attr\' behavior\n\n Example:\n >>> node = createNode("transform")\n >>> getAttr(node + ".tx")\n 0.0\n >>> delete(node)\n\n '
return self[other.strip('.')]
|
def __contains__(self, other):
'Does the attribute `other` exist?'
return self.hasAttr(other)
| 3,437,677,476,302,128,600
|
Does the attribute `other` exist?
|
cmdx.py
|
__contains__
|
fvbehr/cmdx
|
python
|
def __contains__(self, other):
return self.hasAttr(other)
|
def __getitem__(self, key):
'Get plug from self\n\n Arguments:\n key (str, tuple): String lookup of attribute,\n optionally pass tuple to include unit.\n\n Example:\n >>> node = createNode("transform")\n >>> node["translate"] = (1, 1, 1)\n >>> node["translate", Meters]\n (0.01, 0.01, 0.01)\n\n '
unit = None
cached = False
if isinstance(key, (list, tuple)):
(key, items) = (key[0], key[1:])
for item in items:
if isinstance(item, _Unit):
unit = item
elif isinstance(item, _Cached):
cached = True
if cached:
try:
return CachedPlug(self._state['values'][(key, unit)])
except KeyError:
pass
try:
plug = self.findPlug(key)
except RuntimeError:
raise ExistError(('%s.%s' % (self.path(), key)))
return Plug(self, plug, unit=unit, key=key, modifier=self._modifier)
| -2,924,461,867,035,181,000
|
Get plug from self
Arguments:
key (str, tuple): String lookup of attribute,
optionally pass tuple to include unit.
Example:
>>> node = createNode("transform")
>>> node["translate"] = (1, 1, 1)
>>> node["translate", Meters]
(0.01, 0.01, 0.01)
|
cmdx.py
|
__getitem__
|
fvbehr/cmdx
|
python
|
def __getitem__(self, key):
'Get plug from self\n\n Arguments:\n key (str, tuple): String lookup of attribute,\n optionally pass tuple to include unit.\n\n Example:\n >>> node = createNode("transform")\n >>> node["translate"] = (1, 1, 1)\n >>> node["translate", Meters]\n (0.01, 0.01, 0.01)\n\n '
unit = None
cached = False
if isinstance(key, (list, tuple)):
(key, items) = (key[0], key[1:])
for item in items:
if isinstance(item, _Unit):
unit = item
elif isinstance(item, _Cached):
cached = True
if cached:
try:
return CachedPlug(self._state['values'][(key, unit)])
except KeyError:
pass
try:
plug = self.findPlug(key)
except RuntimeError:
raise ExistError(('%s.%s' % (self.path(), key)))
return Plug(self, plug, unit=unit, key=key, modifier=self._modifier)
|
def __setitem__(self, key, value):
'Support item assignment of new attributes or values\n\n Example:\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("transform", name="myNode")\n >>> node["myAttr"] = Double(default=1.0)\n >>> node["myAttr"] == 1.0\n True\n >>> node["rotateX", Degrees] = 1.0\n >>> node["rotateX"] = Degrees(1)\n >>> node["rotateX", Degrees]\n 1.0\n >>> node["myDist"] = Distance()\n >>> node["myDist"] = node["translateX"]\n >>> node["myDist", Centimeters] = node["translateX", Meters]\n >>> round(node["rotateX", Radians], 3)\n 0.017\n >>> node["myDist"] = Distance()\n Traceback (most recent call last):\n ...\n ExistError: myDist\n >>> node["notExist"] = 5\n Traceback (most recent call last):\n ...\n ExistError: |myNode.notExist\n >>> delete(node)\n\n '
if isinstance(value, Plug):
value = value.read()
unit = None
if isinstance(key, (list, tuple)):
(key, unit) = key
if isinstance(value, (list, tuple)):
value = list((unit(v) for v in value))
else:
value = unit(value)
elif isinstance(value, (tuple, list)):
if isinstance(value[0], type):
if issubclass(value[0], _AbstractAttribute):
(Attribute, kwargs) = value
attr = Attribute(key, **kwargs)
try:
return self.addAttr(attr.create())
except RuntimeError:
raise ExistError(key)
try:
plug = self.findPlug(key)
except RuntimeError:
raise ExistError(('%s.%s' % (self.path(), key)))
plug = Plug(self, plug, unit=unit)
if (not getattr(self._modifier, 'isDone', True)):
if _python_to_mod(value, plug, self._modifier._modifier):
return
else:
log.warning(('Could not write %s via modifier, writing directly..' % plug))
plug.write(value)
| -7,451,303,800,496,541,000
|
Support item assignment of new attributes or values
Example:
>>> _ = cmds.file(new=True, force=True)
>>> node = createNode("transform", name="myNode")
>>> node["myAttr"] = Double(default=1.0)
>>> node["myAttr"] == 1.0
True
>>> node["rotateX", Degrees] = 1.0
>>> node["rotateX"] = Degrees(1)
>>> node["rotateX", Degrees]
1.0
>>> node["myDist"] = Distance()
>>> node["myDist"] = node["translateX"]
>>> node["myDist", Centimeters] = node["translateX", Meters]
>>> round(node["rotateX", Radians], 3)
0.017
>>> node["myDist"] = Distance()
Traceback (most recent call last):
...
ExistError: myDist
>>> node["notExist"] = 5
Traceback (most recent call last):
...
ExistError: |myNode.notExist
>>> delete(node)
|
cmdx.py
|
__setitem__
|
fvbehr/cmdx
|
python
|
def __setitem__(self, key, value):
'Support item assignment of new attributes or values\n\n Example:\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("transform", name="myNode")\n >>> node["myAttr"] = Double(default=1.0)\n >>> node["myAttr"] == 1.0\n True\n >>> node["rotateX", Degrees] = 1.0\n >>> node["rotateX"] = Degrees(1)\n >>> node["rotateX", Degrees]\n 1.0\n >>> node["myDist"] = Distance()\n >>> node["myDist"] = node["translateX"]\n >>> node["myDist", Centimeters] = node["translateX", Meters]\n >>> round(node["rotateX", Radians], 3)\n 0.017\n >>> node["myDist"] = Distance()\n Traceback (most recent call last):\n ...\n ExistError: myDist\n >>> node["notExist"] = 5\n Traceback (most recent call last):\n ...\n ExistError: |myNode.notExist\n >>> delete(node)\n\n '
if isinstance(value, Plug):
value = value.read()
unit = None
if isinstance(key, (list, tuple)):
(key, unit) = key
if isinstance(value, (list, tuple)):
value = list((unit(v) for v in value))
else:
value = unit(value)
elif isinstance(value, (tuple, list)):
if isinstance(value[0], type):
if issubclass(value[0], _AbstractAttribute):
(Attribute, kwargs) = value
attr = Attribute(key, **kwargs)
try:
return self.addAttr(attr.create())
except RuntimeError:
raise ExistError(key)
try:
plug = self.findPlug(key)
except RuntimeError:
raise ExistError(('%s.%s' % (self.path(), key)))
plug = Plug(self, plug, unit=unit)
if (not getattr(self._modifier, 'isDone', True)):
if _python_to_mod(value, plug, self._modifier._modifier):
return
else:
log.warning(('Could not write %s via modifier, writing directly..' % plug))
plug.write(value)
|
@withTiming()
def __init__(self, mobject, exists=True, modifier=None):
'Initialise Node\n\n Private members:\n mobject (om.MObject): Wrap this MObject\n fn (om.MFnDependencyNode): The corresponding function set\n modifier (om.MDagModifier, optional): Operations are\n deferred to this modifier.\n destroyed (bool): Has this node been destroyed by Maya?\n state (dict): Optional state for performance\n\n '
self._mobject = mobject
self._fn = self._Fn(mobject)
self._modifier = modifier
self._destroyed = False
self._removed = False
self._hashCode = None
self._state = {'plugs': dict(), 'values': dict(), 'callbacks': list()}
self.onDestroyed = list()
self.onRemoved = list()
Stats.NodeInitCount += 1
self._state['callbacks'] += [(om.MNodeMessage.addNodeDestroyedCallback(mobject, self._onDestroyed, None) if (not ROGUE_MODE) else 0), om.MNodeMessage.addNodeAboutToDeleteCallback(mobject, self._onRemoved, None)]
| 8,592,241,082,817,294,000
|
Initialise Node
Private members:
mobject (om.MObject): Wrap this MObject
fn (om.MFnDependencyNode): The corresponding function set
modifier (om.MDagModifier, optional): Operations are
deferred to this modifier.
destroyed (bool): Has this node been destroyed by Maya?
state (dict): Optional state for performance
|
cmdx.py
|
__init__
|
fvbehr/cmdx
|
python
|
@withTiming()
def __init__(self, mobject, exists=True, modifier=None):
'Initialise Node\n\n Private members:\n mobject (om.MObject): Wrap this MObject\n fn (om.MFnDependencyNode): The corresponding function set\n modifier (om.MDagModifier, optional): Operations are\n deferred to this modifier.\n destroyed (bool): Has this node been destroyed by Maya?\n state (dict): Optional state for performance\n\n '
self._mobject = mobject
self._fn = self._Fn(mobject)
self._modifier = modifier
self._destroyed = False
self._removed = False
self._hashCode = None
self._state = {'plugs': dict(), 'values': dict(), 'callbacks': list()}
self.onDestroyed = list()
self.onRemoved = list()
Stats.NodeInitCount += 1
self._state['callbacks'] += [(om.MNodeMessage.addNodeDestroyedCallback(mobject, self._onDestroyed, None) if (not ROGUE_MODE) else 0), om.MNodeMessage.addNodeAboutToDeleteCallback(mobject, self._onRemoved, None)]
|
def plugin(self):
'Return the user-defined class of the plug-in behind this node'
return type(self._fn.userNode())
| -8,343,381,332,814,641,000
|
Return the user-defined class of the plug-in behind this node
|
cmdx.py
|
plugin
|
fvbehr/cmdx
|
python
|
def plugin(self):
return type(self._fn.userNode())
|
def instance(self):
'Return the current plug-in instance of this node'
return self._fn.userNode()
| 6,989,978,509,210,736,000
|
Return the current plug-in instance of this node
|
cmdx.py
|
instance
|
fvbehr/cmdx
|
python
|
def instance(self):
return self._fn.userNode()
|
def object(self):
'Return MObject of this node'
return self._mobject
| -2,894,038,405,073,490,000
|
Return MObject of this node
|
cmdx.py
|
object
|
fvbehr/cmdx
|
python
|
def object(self):
return self._mobject
|
def isAlive(self):
'The node exists somewhere in memory'
return (not self._destroyed)
| 3,206,443,701,243,128,300
|
The node exists somewhere in memory
|
cmdx.py
|
isAlive
|
fvbehr/cmdx
|
python
|
def isAlive(self):
return (not self._destroyed)
|
@property
def data(self):
'Special handling for data stored in the instance\n\n Normally, the initialisation of data could happen in the __init__,\n but for some reason the postConstructor of a custom plug-in calls\n __init__ twice for every unique hex, which causes any data added\n there to be wiped out once the postConstructor is done.\n\n '
return _data[self.hex]
| -2,381,850,114,063,403,500
|
Special handling for data stored in the instance
Normally, the initialisation of data could happen in the __init__,
but for some reason the postConstructor of a custom plug-in calls
__init__ twice for every unique hex, which causes any data added
there to be wiped out once the postConstructor is done.
|
cmdx.py
|
data
|
fvbehr/cmdx
|
python
|
@property
def data(self):
'Special handling for data stored in the instance\n\n Normally, the initialisation of data could happen in the __init__,\n but for some reason the postConstructor of a custom plug-in calls\n __init__ twice for every unique hex, which causes any data added\n there to be wiped out once the postConstructor is done.\n\n '
return _data[self.hex]
|
@property
def exists(self):
'The node exists in both memory *and* scene\n\n Example:\n >>> node = createNode("joint")\n >>> node.exists\n True\n >>> cmds.delete(str(node))\n >>> node.exists\n False\n >>> node.destroyed\n False\n >>> _ = cmds.file(new=True, force=True)\n >>> node.exists\n False\n >>> node.destroyed\n True\n\n '
return (not self._removed)
| 8,187,415,923,217,228,000
|
The node exists in both memory *and* scene
Example:
>>> node = createNode("joint")
>>> node.exists
True
>>> cmds.delete(str(node))
>>> node.exists
False
>>> node.destroyed
False
>>> _ = cmds.file(new=True, force=True)
>>> node.exists
False
>>> node.destroyed
True
|
cmdx.py
|
exists
|
fvbehr/cmdx
|
python
|
@property
def exists(self):
'The node exists in both memory *and* scene\n\n Example:\n >>> node = createNode("joint")\n >>> node.exists\n True\n >>> cmds.delete(str(node))\n >>> node.exists\n False\n >>> node.destroyed\n False\n >>> _ = cmds.file(new=True, force=True)\n >>> node.exists\n False\n >>> node.destroyed\n True\n\n '
return (not self._removed)
|
@property
def hashCode(self):
'Return MObjectHandle.hashCode of this node\n\n This a guaranteed-unique integer (long in Python 2)\n similar to the UUID of Maya 2016\n\n '
return self._hashCode
| 6,138,801,481,474,258,000
|
Return MObjectHandle.hashCode of this node
This a guaranteed-unique integer (long in Python 2)
similar to the UUID of Maya 2016
|
cmdx.py
|
hashCode
|
fvbehr/cmdx
|
python
|
@property
def hashCode(self):
'Return MObjectHandle.hashCode of this node\n\n This a guaranteed-unique integer (long in Python 2)\n similar to the UUID of Maya 2016\n\n '
return self._hashCode
|
@property
def hexStr(self):
'Return unique hashCode as hexadecimal string\n\n Example:\n >>> node = createNode("transform")\n >>> node.hexStr == format(node.hashCode, "x")\n True\n\n '
return self._hexStr
| 8,393,172,980,965,556,000
|
Return unique hashCode as hexadecimal string
Example:
>>> node = createNode("transform")
>>> node.hexStr == format(node.hashCode, "x")
True
|
cmdx.py
|
hexStr
|
fvbehr/cmdx
|
python
|
@property
def hexStr(self):
'Return unique hashCode as hexadecimal string\n\n Example:\n >>> node = createNode("transform")\n >>> node.hexStr == format(node.hashCode, "x")\n True\n\n '
return self._hexStr
|
@property
def typeId(self):
'Return the native maya.api.MTypeId of this node\n\n Example:\n >>> node = createNode("transform")\n >>> node.typeId == tTransform\n True\n\n '
return self._fn.typeId
| -2,107,388,808,234,822,000
|
Return the native maya.api.MTypeId of this node
Example:
>>> node = createNode("transform")
>>> node.typeId == tTransform
True
|
cmdx.py
|
typeId
|
fvbehr/cmdx
|
python
|
@property
def typeId(self):
'Return the native maya.api.MTypeId of this node\n\n Example:\n >>> node = createNode("transform")\n >>> node.typeId == tTransform\n True\n\n '
return self._fn.typeId
|
def isA(self, type):
'Evaluate whether self is of `type`\n\n Arguments:\n type (int): MFn function set constant\n\n Example:\n >>> node = createNode("transform")\n >>> node.isA(kTransform)\n True\n >>> node.isA(kShape)\n False\n\n '
return self._mobject.hasFn(type)
| -4,339,258,898,542,097,000
|
Evaluate whether self is of `type`
Arguments:
type (int): MFn function set constant
Example:
>>> node = createNode("transform")
>>> node.isA(kTransform)
True
>>> node.isA(kShape)
False
|
cmdx.py
|
isA
|
fvbehr/cmdx
|
python
|
def isA(self, type):
'Evaluate whether self is of `type`\n\n Arguments:\n type (int): MFn function set constant\n\n Example:\n >>> node = createNode("transform")\n >>> node.isA(kTransform)\n True\n >>> node.isA(kShape)\n False\n\n '
return self._mobject.hasFn(type)
|
@property
def storable(self):
'Whether or not to save this node with the file'
return None
| 59,265,570,661,141,010
|
Whether or not to save this node with the file
|
cmdx.py
|
storable
|
fvbehr/cmdx
|
python
|
@property
def storable(self):
return None
|
@withTiming('findPlug() reuse {time:.4f} ns')
def findPlug(self, name, cached=False):
'Cache previously found plugs, for performance\n\n Cost: 4.9 microseconds/call\n\n Part of the time taken in querying an attribute is the\n act of finding a plug given its name as a string.\n\n This causes a 25% reduction in time taken for repeated\n attribute queries. Though keep in mind that state is stored\n in the `cmdx` object which currently does not survive rediscovery.\n That is, if a node is created and later discovered through a call\n to `encode`, then the original and discovered nodes carry one\n state each.\n\n Additional challenges include storing the same plug for both\n long and short name of said attribute, which is currently not\n the case.\n\n Arguments:\n name (str): Name of plug to find\n cached (bool, optional): Return cached plug, or\n throw an exception. Default to False, which\n means it will run Maya\'s findPlug() and cache\n the result.\n safe (bool, optional): Always find the plug through\n Maya\'s API, defaults to False. This will not perform\n any caching and is intended for use during debugging\n to spot whether caching is causing trouble.\n\n Example:\n >>> node = createNode("transform")\n >>> node.findPlug("translateX", cached=True)\n Traceback (most recent call last):\n ...\n KeyError: "\'translateX\' not cached"\n >>> plug1 = node.findPlug("translateX")\n >>> isinstance(plug1, om.MPlug)\n True\n >>> plug1 is node.findPlug("translateX")\n True\n >>> plug1 is node.findPlug("translateX", cached=True)\n True\n\n '
try:
existing = self._state['plugs'][name]
Stats.PlugReuseCount += 1
return existing
except KeyError:
if cached:
raise KeyError(("'%s' not cached" % name))
plug = self._fn.findPlug(name, False)
self._state['plugs'][name] = plug
return plug
| -5,004,697,658,754,552,000
|
Cache previously found plugs, for performance
Cost: 4.9 microseconds/call
Part of the time taken in querying an attribute is the
act of finding a plug given its name as a string.
This causes a 25% reduction in time taken for repeated
attribute queries. Though keep in mind that state is stored
in the `cmdx` object which currently does not survive rediscovery.
That is, if a node is created and later discovered through a call
to `encode`, then the original and discovered nodes carry one
state each.
Additional challenges include storing the same plug for both
long and short name of said attribute, which is currently not
the case.
Arguments:
name (str): Name of plug to find
cached (bool, optional): Return cached plug, or
throw an exception. Default to False, which
means it will run Maya's findPlug() and cache
the result.
safe (bool, optional): Always find the plug through
Maya's API, defaults to False. This will not perform
any caching and is intended for use during debugging
to spot whether caching is causing trouble.
Example:
>>> node = createNode("transform")
>>> node.findPlug("translateX", cached=True)
Traceback (most recent call last):
...
KeyError: "'translateX' not cached"
>>> plug1 = node.findPlug("translateX")
>>> isinstance(plug1, om.MPlug)
True
>>> plug1 is node.findPlug("translateX")
True
>>> plug1 is node.findPlug("translateX", cached=True)
True
|
cmdx.py
|
findPlug
|
fvbehr/cmdx
|
python
|
@withTiming('findPlug() reuse {time:.4f} ns')
def findPlug(self, name, cached=False):
'Cache previously found plugs, for performance\n\n Cost: 4.9 microseconds/call\n\n Part of the time taken in querying an attribute is the\n act of finding a plug given its name as a string.\n\n This causes a 25% reduction in time taken for repeated\n attribute queries. Though keep in mind that state is stored\n in the `cmdx` object which currently does not survive rediscovery.\n That is, if a node is created and later discovered through a call\n to `encode`, then the original and discovered nodes carry one\n state each.\n\n Additional challenges include storing the same plug for both\n long and short name of said attribute, which is currently not\n the case.\n\n Arguments:\n name (str): Name of plug to find\n cached (bool, optional): Return cached plug, or\n throw an exception. Default to False, which\n means it will run Maya\'s findPlug() and cache\n the result.\n safe (bool, optional): Always find the plug through\n Maya\'s API, defaults to False. This will not perform\n any caching and is intended for use during debugging\n to spot whether caching is causing trouble.\n\n Example:\n >>> node = createNode("transform")\n >>> node.findPlug("translateX", cached=True)\n Traceback (most recent call last):\n ...\n KeyError: "\'translateX\' not cached"\n >>> plug1 = node.findPlug("translateX")\n >>> isinstance(plug1, om.MPlug)\n True\n >>> plug1 is node.findPlug("translateX")\n True\n >>> plug1 is node.findPlug("translateX", cached=True)\n True\n\n '
try:
existing = self._state['plugs'][name]
Stats.PlugReuseCount += 1
return existing
except KeyError:
if cached:
raise KeyError(("'%s' not cached" % name))
plug = self._fn.findPlug(name, False)
self._state['plugs'][name] = plug
return plug
|
def update(self, attrs):
'Apply a series of attributes all at once\n\n This operates similar to a Python dictionary.\n\n Arguments:\n attrs (dict): Key/value pairs of name and attribute\n\n Examples:\n >>> node = createNode("transform")\n >>> node.update({"tx": 5.0, ("ry", Degrees): 30.0})\n >>> node["tx"]\n 5.0\n\n '
for (key, value) in attrs.items():
self[key] = value
| -4,940,603,168,361,517,000
|
Apply a series of attributes all at once
This operates similar to a Python dictionary.
Arguments:
attrs (dict): Key/value pairs of name and attribute
Examples:
>>> node = createNode("transform")
>>> node.update({"tx": 5.0, ("ry", Degrees): 30.0})
>>> node["tx"]
5.0
|
cmdx.py
|
update
|
fvbehr/cmdx
|
python
|
def update(self, attrs):
'Apply a series of attributes all at once\n\n This operates similar to a Python dictionary.\n\n Arguments:\n attrs (dict): Key/value pairs of name and attribute\n\n Examples:\n >>> node = createNode("transform")\n >>> node.update({"tx": 5.0, ("ry", Degrees): 30.0})\n >>> node["tx"]\n 5.0\n\n '
for (key, value) in attrs.items():
self[key] = value
|
def clear(self):
'Clear transient state\n\n A node may cache previously queried values for performance\n at the expense of memory. This method erases any cached\n values, freeing up memory at the expense of performance.\n\n Example:\n >>> node = createNode("transform")\n >>> node["translateX"] = 5\n >>> node["translateX"]\n 5.0\n >>> # Plug was reused\n >>> node["translateX"]\n 5.0\n >>> # Value was reused\n >>> node.clear()\n >>> node["translateX"]\n 5.0\n >>> # Plug and value was recomputed\n\n '
self._state['plugs'].clear()
self._state['values'].clear()
| 4,240,554,032,611,138,000
|
Clear transient state
A node may cache previously queried values for performance
at the expense of memory. This method erases any cached
values, freeing up memory at the expense of performance.
Example:
>>> node = createNode("transform")
>>> node["translateX"] = 5
>>> node["translateX"]
5.0
>>> # Plug was reused
>>> node["translateX"]
5.0
>>> # Value was reused
>>> node.clear()
>>> node["translateX"]
5.0
>>> # Plug and value was recomputed
|
cmdx.py
|
clear
|
fvbehr/cmdx
|
python
|
def clear(self):
'Clear transient state\n\n A node may cache previously queried values for performance\n at the expense of memory. This method erases any cached\n values, freeing up memory at the expense of performance.\n\n Example:\n >>> node = createNode("transform")\n >>> node["translateX"] = 5\n >>> node["translateX"]\n 5.0\n >>> # Plug was reused\n >>> node["translateX"]\n 5.0\n >>> # Value was reused\n >>> node.clear()\n >>> node["translateX"]\n 5.0\n >>> # Plug and value was recomputed\n\n '
self._state['plugs'].clear()
self._state['values'].clear()
|
@protected
def name(self, namespace=False):
'Return the name of this node\n\n Arguments:\n namespace (bool, optional): Return with namespace,\n defaults to False\n\n Example:\n >>> node = createNode("transform", name="myName")\n >>> node.name()\n u\'myName\'\n\n '
if namespace:
return self._fn.name()
else:
return self._fn.name().rsplit(':', 1)[(- 1)]
| 4,953,245,960,046,820,000
|
Return the name of this node
Arguments:
namespace (bool, optional): Return with namespace,
defaults to False
Example:
>>> node = createNode("transform", name="myName")
>>> node.name()
u'myName'
|
cmdx.py
|
name
|
fvbehr/cmdx
|
python
|
@protected
def name(self, namespace=False):
'Return the name of this node\n\n Arguments:\n namespace (bool, optional): Return with namespace,\n defaults to False\n\n Example:\n >>> node = createNode("transform", name="myName")\n >>> node.name()\n u\'myName\'\n\n '
if namespace:
return self._fn.name()
else:
return self._fn.name().rsplit(':', 1)[(- 1)]
|
def namespace(self):
'Get namespace of node\n\n Example:\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("transform", name="myNode")\n >>> node.namespace()\n u\'\'\n >>> _ = cmds.namespace(add=":A")\n >>> _ = cmds.namespace(add=":A:B")\n >>> node = createNode("transform", name=":A:B:myNode")\n >>> node.namespace()\n u\'A:B\'\n\n '
name = self._fn.name()
if (':' in name):
return name.rsplit(':', 1)[0]
return type(name)()
| 2,306,088,550,495,356,000
|
Get namespace of node
Example:
>>> _ = cmds.file(new=True, force=True)
>>> node = createNode("transform", name="myNode")
>>> node.namespace()
u''
>>> _ = cmds.namespace(add=":A")
>>> _ = cmds.namespace(add=":A:B")
>>> node = createNode("transform", name=":A:B:myNode")
>>> node.namespace()
u'A:B'
|
cmdx.py
|
namespace
|
fvbehr/cmdx
|
python
|
def namespace(self):
'Get namespace of node\n\n Example:\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("transform", name="myNode")\n >>> node.namespace()\n u\'\'\n >>> _ = cmds.namespace(add=":A")\n >>> _ = cmds.namespace(add=":A:B")\n >>> node = createNode("transform", name=":A:B:myNode")\n >>> node.namespace()\n u\'A:B\'\n\n '
name = self._fn.name()
if (':' in name):
return name.rsplit(':', 1)[0]
return type(name)()
|
def pop(self, key):
'Delete an attribute\n\n Arguments:\n key (str): Name of attribute to delete\n\n Example:\n >>> node = createNode("transform")\n >>> node["myAttr"] = Double()\n >>> node.pop("myAttr")\n >>> node.hasAttr("myAttr")\n False\n\n '
del self[key]
| 321,921,154,133,839,940
|
Delete an attribute
Arguments:
key (str): Name of attribute to delete
Example:
>>> node = createNode("transform")
>>> node["myAttr"] = Double()
>>> node.pop("myAttr")
>>> node.hasAttr("myAttr")
False
|
cmdx.py
|
pop
|
fvbehr/cmdx
|
python
|
def pop(self, key):
'Delete an attribute\n\n Arguments:\n key (str): Name of attribute to delete\n\n Example:\n >>> node = createNode("transform")\n >>> node["myAttr"] = Double()\n >>> node.pop("myAttr")\n >>> node.hasAttr("myAttr")\n False\n\n '
del self[key]
|
def dump(self, ignore_error=True):
'Return dictionary of all attributes\n\n Example:\n >>> import json\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("choice")\n >>> dump = node.dump()\n >>> isinstance(dump, dict)\n True\n >>> dump["choice1.caching"]\n False\n\n '
attrs = {}
count = self._fn.attributeCount()
for index in range(count):
obj = self._fn.attribute(index)
plug = self._fn.findPlug(obj, False)
try:
value = Plug(self, plug).read()
except (RuntimeError, TypeError):
value = None
if (not ignore_error):
raise
attrs[plug.name()] = value
return attrs
| 2,472,120,626,968,427,500
|
Return dictionary of all attributes
Example:
>>> import json
>>> _ = cmds.file(new=True, force=True)
>>> node = createNode("choice")
>>> dump = node.dump()
>>> isinstance(dump, dict)
True
>>> dump["choice1.caching"]
False
|
cmdx.py
|
dump
|
fvbehr/cmdx
|
python
|
def dump(self, ignore_error=True):
'Return dictionary of all attributes\n\n Example:\n >>> import json\n >>> _ = cmds.file(new=True, force=True)\n >>> node = createNode("choice")\n >>> dump = node.dump()\n >>> isinstance(dump, dict)\n True\n >>> dump["choice1.caching"]\n False\n\n '
attrs = {}
count = self._fn.attributeCount()
for index in range(count):
obj = self._fn.attribute(index)
plug = self._fn.findPlug(obj, False)
try:
value = Plug(self, plug).read()
except (RuntimeError, TypeError):
value = None
if (not ignore_error):
raise
attrs[plug.name()] = value
return attrs
|
def dumps(self, indent=4, sortKeys=True):
'Return a JSON compatible dictionary of all attributes'
return json.dumps(self.dump(), indent=indent, sort_keys=sortKeys)
| 3,366,320,842,954,178,000
|
Return a JSON compatible dictionary of all attributes
|
cmdx.py
|
dumps
|
fvbehr/cmdx
|
python
|
def dumps(self, indent=4, sortKeys=True):
return json.dumps(self.dump(), indent=indent, sort_keys=sortKeys)
|
def type(self):
'Return type name\n\n Example:\n >>> node = createNode("choice")\n >>> node.type()\n u\'choice\'\n\n '
return self._fn.typeName
| -1,410,811,883,108,725,800
|
Return type name
Example:
>>> node = createNode("choice")
>>> node.type()
u'choice'
|
cmdx.py
|
type
|
fvbehr/cmdx
|
python
|
def type(self):
'Return type name\n\n Example:\n >>> node = createNode("choice")\n >>> node.type()\n u\'choice\'\n\n '
return self._fn.typeName
|
def addAttr(self, attr):
'Add a new dynamic attribute to node\n\n Arguments:\n attr (Plug): Add this attribute\n\n Example:\n >>> node = createNode("transform")\n >>> attr = Double("myAttr", default=5.0)\n >>> node.addAttr(attr)\n >>> node["myAttr"] == 5.0\n True\n\n '
if isinstance(attr, _AbstractAttribute):
attr = attr.create()
self._fn.addAttribute(attr)
| 6,901,022,088,270,368,000
|
Add a new dynamic attribute to node
Arguments:
attr (Plug): Add this attribute
Example:
>>> node = createNode("transform")
>>> attr = Double("myAttr", default=5.0)
>>> node.addAttr(attr)
>>> node["myAttr"] == 5.0
True
|
cmdx.py
|
addAttr
|
fvbehr/cmdx
|
python
|
def addAttr(self, attr):
'Add a new dynamic attribute to node\n\n Arguments:\n attr (Plug): Add this attribute\n\n Example:\n >>> node = createNode("transform")\n >>> attr = Double("myAttr", default=5.0)\n >>> node.addAttr(attr)\n >>> node["myAttr"] == 5.0\n True\n\n '
if isinstance(attr, _AbstractAttribute):
attr = attr.create()
self._fn.addAttribute(attr)
|
def hasAttr(self, attr):
'Return whether or not `attr` exists\n\n Arguments:\n attr (str): Name of attribute to check\n\n Example:\n >>> node = createNode("transform")\n >>> node.hasAttr("mysteryAttribute")\n False\n >>> node.hasAttr("translateX")\n True\n >>> node["myAttr"] = Double() # Dynamic attribute\n >>> node.hasAttr("myAttr")\n True\n\n '
return self._fn.hasAttribute(attr)
| 4,437,251,695,110,137,000
|
Return whether or not `attr` exists
Arguments:
attr (str): Name of attribute to check
Example:
>>> node = createNode("transform")
>>> node.hasAttr("mysteryAttribute")
False
>>> node.hasAttr("translateX")
True
>>> node["myAttr"] = Double() # Dynamic attribute
>>> node.hasAttr("myAttr")
True
|
cmdx.py
|
hasAttr
|
fvbehr/cmdx
|
python
|
def hasAttr(self, attr):
'Return whether or not `attr` exists\n\n Arguments:\n attr (str): Name of attribute to check\n\n Example:\n >>> node = createNode("transform")\n >>> node.hasAttr("mysteryAttribute")\n False\n >>> node.hasAttr("translateX")\n True\n >>> node["myAttr"] = Double() # Dynamic attribute\n >>> node.hasAttr("myAttr")\n True\n\n '
return self._fn.hasAttribute(attr)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.