Using a wrapper layer is not the way to go [...]
It is quite popular for those who wish to avoid learning C.
The person who adds this to FG will need to know C, and therefore the wrapper layer is moot.
Hooray wrote in Sat Jan 02, 2016 12:35 am:Using a wrapper layer is not the way to go [...]
It is quite popular for those who wish to avoid learning C.
I suggested the use of a wrapper, like Boost.Python, not because people may not know C, but because it takes away from the low-level details of dealing with the low-level nature of C,
wrappers add layers of code... layers of code add to processing time and, more importantly, code bloat for no real good reason...
[edward@localhost python]$ fgfs --aircraft=py-ogel
Enabling ATI viewport hack
Starting automatic scenery download/synchronization. Using built-in SVN support. Directory: '/flightgear/home/.fgfs/TerraSync'.
No path in sim/sound/path
Loading local weather routines...
Animated jetways ... initialized
********************************************************************************
This is the py-ogel, test.py external python script.
#######################################
# Check out the property tree module. #
#######################################
Importing prop_tree.
prop_tree.__dict__ = ['Node', 'Props', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'extract_alias', 'extract_path', 'extract_type', 'extract_value', 'is_alias', 'is_node']
prop_tree.Props.__dict__ = ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
prop_tree.Node.__dict__ = ['__abs__', '__add__', '__and__', '__bool__', '__class__', '__delattr__', '__delitem__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imod__', '__imul__', '__init__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__itruediv__', '__ixor__', '__le__', '__len__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__xor__', '_path']
############################
# Testing some properties. #
############################
props.sim: <prop_tree.Node object at 0x1071ab90, value=None, type='none', path='/sim'>
x: ogel-jsbsim-2.0
extract_path(x): /sim/aero
x: ogel-jsbsim-2.0
y: True
extract_path(x): /sim/aero
extract_path(y): /systems/electrical/serviceable
repr(x): <prop_tree.Node object at 0x10512a30, value='ogel-jsbsim-2.0', type='string', path='/sim/aero'>
repr(y): <prop_tree.Node object at 0x10517f30, value=True, type='bool', path='/systems/electrical/serviceable'>
########################################
# Testing deletion of an aliased node. #
########################################
#############################
# Testing property setting. #
#############################
z: <prop_tree.Node object at 0x1071ab90, value=0.3, type='double', path='/environment/moonlight'>
z: <prop_tree.Node object at 0x1071ab90, value=0.3, type='double', path='/environment/moonlight'>
z: <prop_tree.Node object at 0x10512a30, value=20.0, type='double', path='/environment/moonlight[0]'>
<prop_tree.Node object at 0x10517730, value=True, type='bool', path='/systems/electrical/serviceable'>
<prop_tree.Node object at 0x10517730, value=False, type='bool', path='/systems/electrical/serviceable'>
<prop_tree.Node object at 0x10517730, value=True, type='bool', path='/systems/electrical/serviceable'>
<prop_tree.Node object at 0x1071ab90, value='test string', type='string', path='/environment/aaa'>
<prop_tree.Node object at 0x1071ab90, value=100, type='int', path='/environment/testint'>
##########################
# Testing concatenation. #
##########################
Set 0: ['a', 'b', 'ab']
True result: ab
Property tree result: <prop_tree.Node object at 0x106f4430, value='ab', type='string', path='/py-testing[0]/c'>
The results match.
Set 1: [1, 2, 3]
True result: 3
Property tree result: <prop_tree.Node object at 0x106f4430, value=3, type='int', path='/py-testing[1]/c'>
The results match.
Set 2: [1.0, 2.0, 3.0]
True result: 3.0
Property tree result: <prop_tree.Node object at 0x106f3c30, value=3.0, type='double', path='/py-testing[2]/c'>
The results match.
#####################################
# Testing property setting failure. #
#####################################
Skipping the AttributeError.
#############################
# Testing maths operations. #
#############################
Type - bool:
[snip]
float(z) = 1.0 (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[53]'>)
Type - int:
<node> + 1 = 21 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[54]'>)
[snip]
float(z) = -3.0 (From <prop_tree.Node object at 0x106f4c30, value=-3, type='int', path='/test-inplace[111]'>)
Type - float:
<node> + 1.0 = 21.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[112]'>)
1.0 + <node> = 21.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[114]'>)
<node> - 1.0 = 19.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[116]'>)
1.0 - <node> = -19.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[118]'>)
<node> * 2.0 = 40.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[120]'>)
2.0 * <node> = 40.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[122]'>)
<node> / 3.0 = 6.666666666666667 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[124]'>)
3.0 / <node> = 0.15 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[126]'>)
<node> ** 2.0 = 25.0 (From <prop_tree.Node object at 0x106f4c30, value=5.0, type='double', path='/test-inplace[128]'>)
2.0 ** <node> = 32.0 (From <prop_tree.Node object at 0x106f4c30, value=5.0, type='double', path='/test-inplace[130]'>)
<node> % 9.0 = 6.0 (From <prop_tree.Node object at 0x106f4c30, value=24.0, type='double', path='/test-inplace[132]'>)
2.0 % <node> = 2.0 (From <prop_tree.Node object at 0x106f4c30, value=5.0, type='double', path='/test-inplace[134]'>)
<node> // 3.0 = 6.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[136]'>)
333.0 // <node> = 55.0 (From <prop_tree.Node object at 0x106f4c30, value=6.0, type='double', path='/test-inplace[138]'>)
divmod(2.0, <node>) = (-2.0, 1.0) (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[140]'>)
divmod(<node>, 2.0) = (-1.0, -1.0) (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[142]'>)
neg(z) = 3.0 (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[144]'>)
pos(z) = -3.0 (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[145]'>)
abs(z) = 3.0 (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[146]'>)
~(z) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[147]'>)
<node> << 3.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[148]'>)
3.0 << <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[149]'>)
<node> >> 3.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[150]'>)
3.0 >> <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[151]'>)
<node> & 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[152]'>)
0.0 & <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[153]'>)
<node> ^ 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[154]'>)
0.0 ^ <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[155]'>)
<node> | 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[156]'>)
0.0 | <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[157]'>)
int(z) = -3 (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[158]'>)
float(z) = -3.0 (From <prop_tree.Node object at 0x106f4c30, value=-3.0, type='double', path='/test-inplace[159]'>)
Type - str:
<node> + '1' = 201 (From <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[160]'>)
'1' + <node> = 120 (From <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[162]'>)
<node> - '1' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[164]'>)
'1' - <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[165]'>)
<node> * '2' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[166]'>)
'2' * <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[167]'>)
<node> / '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[168]'>)
'3' / <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[169]'>)
<node> ** '2' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='5', type='string', path='/test-inplace[170]'>)
'2' ** <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='5', type='string', path='/test-inplace[171]'>)
<node> % '9' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='24', type='string', path='/test-inplace[172]'>)
'2' % <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='5', type='string', path='/test-inplace[173]'>)
<node> // '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[174]'>)
'3' // <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='6', type='string', path='/test-inplace[175]'>)
divmod('2', <node>) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[176]'>)
divmod(<node>, '2') : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[177]'>)
neg(z) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[178]'>)
pos(z) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[179]'>)
abs(z) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[180]'>)
~(z) : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[181]'>)
<node> << '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[182]'>)
'3' << <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[183]'>)
<node> >> '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[184]'>)
'3' >> <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[185]'>)
<node> & '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[186]'>)
'0' & <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[187]'>)
<node> ^ '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[188]'>)
'0' ^ <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[189]'>)
<node> | '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[190]'>)
'0' | <node> : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[191]'>)
int(z) = -3 (From <prop_tree.Node object at 0x106f4c30, value='-3', type='string', path='/test-inplace[192]'>)
int(z) : The <class 'ValueError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='-3.0', type='string', path='/test-inplace[193]'>)
float(z) = -3.0 (From <prop_tree.Node object at 0x106f4c30, value='-3.0', type='string', path='/test-inplace[194]'>)
int(z) : The <class 'ValueError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='abcd', type='string', path='/test-inplace[195]'>)
float(z) : The <class 'ValueError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='abcd', type='string', path='/test-inplace[196]'>)
#####################################
# Testing invalid maths operations. #
#####################################
<prop_tree.Node object at 0x106f4c30, value='X', type='string', path='/invalid-math/type[0]'>
Correct TypeError for <str> + 1
Correct TypeError for 1 + <str>
Correct TypeError for <str> - 1
Correct TypeError for 1 - <str>
Correct TypeError for <str> * 1
Correct TypeError for 1 * <str>
Correct TypeError for <str> / 1
Correct TypeError for 1 / <str>
###############################################################
# Testing the non-existant path '/abc' for an AttributeError. #
###############################################################
AttributeError for props.abc correctly raised.
##########################################
# Testing path '-' and '_' translations. #
##########################################
<prop_tree.Node object at 0x106f3c30, value=-9999.0, type='double', path='/position/altitude-ft'>
<prop_tree.Node object at 0x106f3c30, value='underscore test', type='string', path='/underscore/a-b_c-d_e'>
###################################
# Testing the length of an array. #
###################################
<prop_tree.Node object at 0x106f3c30, value=None, type='none', path='/py-testing'>
The props.py_testing length: 3 (should be 3).
Element 0: <prop_tree.Node object at 0x106f3c30, value=None, type='none', path='/py-testing[0]'>
Element 1: <prop_tree.Node object at 0x106f4c30, value=None, type='none', path='/py-testing[1]'>
Element 2: <prop_tree.Node object at 0x106f4c30, value=None, type='none', path='/py-testing[2]'>
<prop_tree.Node object at 0x106f3c30, value=True, type='bool', path='/systems/electrical/serviceable'>
The props.systems.electrical.serviceable length: 1 (should be 1).
Element 0: <prop_tree.Node object at 0x106f3c30, value=True, type='bool', path='/systems/electrical/serviceable[0]'>
########################################################
# Testing setattr() and hasattr() on the props object. #
########################################################
<prop_tree.Node object at 0x106f3c30, value=True, type='bool', path='/setattr-test'>
###############################
# Equality condition testing. #
###############################
Equality testing of 'True':
Testing if "props.test_bool_equality == True": Test passed.
Testing if "props.test_bool_equality != False": Test passed.
Equality testing of '10':
Testing if "props.test_int_equality == 10": Test passed.
Testing if "props.test_int_equality != True": Test passed.
Testing if "props.test_int_equality <= 10": Test passed.
Testing if "props.test_int_equality <= 21": Test passed.
Testing if "props.test_int_equality >= 10": Test passed.
Testing if "props.test_int_equality >= 1": Test passed.
Testing if "props.test_int_equality < 20000": Test passed.
Testing if "props.test_int_equality > -2000": Test passed.
Equality testing of '10.0':
Testing if "props.test_double_equality == 10.0": Test passed.
Testing if "props.test_double_equality != True": Test passed.
Testing if "props.test_double_equality <= 10.0": Test passed.
Testing if "props.test_double_equality <= 21.0": Test passed.
Testing if "props.test_double_equality >= 10.0": Test passed.
Testing if "props.test_double_equality >= 1.0": Test passed.
Testing if "props.test_double_equality < 20000.0": Test passed.
Testing if "props.test_double_equality > -2000.0": Test passed.
Equality testing of 'hello':
Testing if "props.test_string_equality == hello": Test passed.
Testing if "props.test_string_equality != Hello": Test passed.
Segfault checking:
Equality testing of 'hello':
Testing if "props.test_string_equality_segfault == hello": Test passed.
Testing if "props.test_string_equality_segfault != Hello": Test passed.
Testing if "props.test_string_equality_segfault <= 10.0": Test failed - TypeError.
Testing if "props.test_string_equality_segfault <= 21.0": Test failed - TypeError.
Testing if "props.test_string_equality_segfault >= 10.0": Test failed - TypeError.
Testing if "props.test_string_equality_segfault >= 1.0": Test failed - TypeError.
Testing if "props.test_string_equality_segfault < 20000.0": Test failed - TypeError.
Testing if "props.test_string_equality_segfault > -2000.0": Test failed - TypeError.
NameError caught - no segfault.
######################################
# Testing the string representation. #
######################################
The string representation of props.test_string_repr is 'Hello!': Test passed.
The string representation of props.test_string_repr[1] is '200': Test passed.
The string representation of props.test_string_repr[2] is 'True': Test passed.
####################
# Subnode testing. #
####################
Normal subnode.
Setting: a = props.test_subnode
a.c: <prop_tree.Node object at 0x106f4430, value='subnode', type='string', path='/test-subnode/c'>
Setting: b = props.test_subnode.c; b += '_test'
Setting: c = a.c
a: <prop_tree.Node object at 0x106f3c30, value=None, type='none', path='/test-subnode'>
b: <prop_tree.Node object at 0x106f4c30, value='subnode_test', type='string', path='/test-subnode/c'>
c: <prop_tree.Node object at 0x10517730, value='subnode_test', type='string', path='/test-subnode/c'>
Array-type subnode.
Setting: a = props.test_subnode[1]
a.c: <prop_tree.Node object at 0x106f3c30, value='subnode', type='string', path='/test-subnode[1]/c'>
Setting: b = props.test_subnode[1].c; b += '_test'
Setting: c = a.c
a: <prop_tree.Node object at 0x1049dca0, value=None, type='none', path='/test-subnode[1]'>
b: <prop_tree.Node object at 0x106f3c30, value='subnode_test', type='string', path='/test-subnode[1]/c'>
c: <prop_tree.Node object at 0x106f4430, value='subnode_test', type='string', path='/test-subnode[1]/c'>
#####################################
# Testing inplace maths operations. #
#####################################
Type - bool:
<node> + False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[197]'>)
<node> - False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[198]'>)
<node> * False = False (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[199]'>)
<node> / False : The <class 'ZeroDivisionError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[200]'>)
<node> / True = False (From <prop_tree.Node object at 0x106f4c30, value=False, type='bool', path='/test-inplace[201]'>)
<node> ** False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[202]'>)
<node> % False : The <class 'ZeroDivisionError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[203]'>)
<node> % True = False (From <prop_tree.Node object at 0x106f4c30, value=False, type='bool', path='/test-inplace[204]'>)
<node> // False : The <class 'ZeroDivisionError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[205]'>)
<node> // True = False (From <prop_tree.Node object at 0x106f4c30, value=False, type='bool', path='/test-inplace[206]'>)
<node> << False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[207]'>)
<node> >> False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[208]'>)
<node> & False = False (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[209]'>)
<node> ^ False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[210]'>)
<node> | False = True (From <prop_tree.Node object at 0x106f4c30, value=True, type='bool', path='/test-inplace[211]'>)
Type - int:
<node> + 1 = 21 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[212]'>)
<node> - 1 = 19 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[213]'>)
<node> * 2 = 40 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[214]'>)
<node> / 3 = 6 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[215]'>)
<node> ** 2 = 25 (From <prop_tree.Node object at 0x106f4c30, value=5, type='int', path='/test-inplace[216]'>)
<node> % 9 = 6 (From <prop_tree.Node object at 0x106f4c30, value=24, type='int', path='/test-inplace[217]'>)
<node> // 3 = 6 (From <prop_tree.Node object at 0x106f4c30, value=20, type='int', path='/test-inplace[218]'>)
<node> << 3 = 104 (From <prop_tree.Node object at 0x106f4c30, value=13, type='int', path='/test-inplace[219]'>)
<node> >> 3 = 1 (From <prop_tree.Node object at 0x106f4c30, value=13, type='int', path='/test-inplace[220]'>)
<node> & 0 = 0 (From <prop_tree.Node object at 0x106f4c30, value=1, type='int', path='/test-inplace[221]'>)
<node> ^ 0 = 1 (From <prop_tree.Node object at 0x106f4c30, value=1, type='int', path='/test-inplace[222]'>)
<node> | 0 = 1 (From <prop_tree.Node object at 0x106f4c30, value=1, type='int', path='/test-inplace[223]'>)
Type - float:
<node> + 1.0 = 21.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[224]'>)
<node> - 1.0 = 19.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[225]'>)
<node> * 2.0 = 40.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[226]'>)
<node> / 3.0 = 6.666666666666667 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[227]'>)
<node> ** 2.0 = 25.0 (From <prop_tree.Node object at 0x106f4c30, value=5.0, type='double', path='/test-inplace[228]'>)
<node> % 9.0 = 6.0 (From <prop_tree.Node object at 0x106f4c30, value=24.0, type='double', path='/test-inplace[229]'>)
<node> // 3.0 = 6.0 (From <prop_tree.Node object at 0x106f4c30, value=20.0, type='double', path='/test-inplace[230]'>)
<node> << 3.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[231]'>)
<node> >> 3.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=13.0, type='double', path='/test-inplace[232]'>)
<node> & 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[233]'>)
<node> ^ 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[234]'>)
<node> | 0.0 : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value=1.0, type='double', path='/test-inplace[235]'>)
Type - str:
<node> + '1' = 201 (From <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[236]'>)
<node> - '1' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[237]'>)
<node> * '2' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[238]'>)
<node> / '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[239]'>)
<node> ** '2' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='5', type='string', path='/test-inplace[240]'>)
<node> % '9' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='24', type='string', path='/test-inplace[241]'>)
<node> // '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='20', type='string', path='/test-inplace[242]'>)
<node> << '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[243]'>)
<node> >> '3' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='13', type='string', path='/test-inplace[244]'>)
<node> & '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[245]'>)
<node> ^ '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[246]'>)
<node> | '0' : The <class 'TypeError'> error was raised as expected. (From node: <prop_tree.Node object at 0x106f4c30, value='1', type='string', path='/test-inplace[247]'>)
###################
# Boolean checks. #
###################
Truth check for the bool type object <prop_tree.Node object at 0x10517730, value=True, type='bool', path='/test-bool-check[0]'>: Test passed.
Falsity check for the bool type object <prop_tree.Node object at 0x10517730, value=False, type='bool', path='/test-bool-check[0]'>: Test passed.
Truth check for the int type object <prop_tree.Node object at 0x10517730, value=1, type='int', path='/test-bool-check[1]'>: Test passed.
Falsity check for the int type object <prop_tree.Node object at 0x10517730, value=0, type='int', path='/test-bool-check[1]'>: Test passed.
Truth check for the double type object <prop_tree.Node object at 0x10517730, value=1.0, type='double', path='/test-bool-check[2]'>: Test passed.
Falsity check for the double type object <prop_tree.Node object at 0x10517730, value=0.0, type='double', path='/test-bool-check[2]'>: Test passed.
Truth check for the string type object <prop_tree.Node object at 0x10517730, value='Hello', type='string', path='/test-bool-check[3]'>: Test passed.
Falsity check for the string type object <prop_tree.Node object at 0x10517730, value='', type='string', path='/test-bool-check[3]'>: Test passed.
#####################
# Testing indexing. #
#####################
The values match, '/test-indexing' == '/test-indexing'.
The values match, '/test-indexing[10]' == '/test-indexing[10]'.
The values match, <prop_tree.Node object at 0x106f4c30, value=10, type='int', path='/test-indexing[2]'> == 10.
The values match, <prop_tree.Node object at 0x106f4c30, value=4, type='int', path='/test-indexing[10]'> == 4.
The values match, <prop_tree.Node object at 0x106f4c30, value='Hello!', type='string', path='/test-indexing[2]/a[2]'> == 'Hello!'.
The values match, <prop_tree.Node object at 0x106f4c30, value='Hello', type='string', path='/test-indexing[10]/a[2]'> == 'Hello'.
The values match, <prop_tree.Node object at 0x10517730, value='X', type='string', path='/test-indexing2'> == 'X'.
The values match, <prop_tree.Node object at 0x1071ab90, value='Y', type='string', path='/test-indexing2[1]'> == 'Y'.
The values match, <prop_tree.Node object at 0x106f4c30, value='Z', type='string', path='/test-indexing2[2]'> == 'Z'.
################################
# Testing prop_tree functions. #
################################
Checking <prop_tree.Node object at 0x10512a30, value='Random string', type='string', path='/test-node-functions[2]'>.
extract_alias(obj) = None
extract_path(obj) = '/test-node-functions[2]'
extract_type(obj) = 'string'
extract_value(obj) = 'Random string'
is_alias(obj) = False
is_node(obj) = True
Checking <prop_tree.Node object at 0x10512a30, alias='/test-node-functions[2]', value='Random string', type='string', path='/test-node-functions[3]'>.
extract_alias(obj) = '/test-node-functions[2]'
extract_path(obj) = '/test-node-functions[3]'
extract_type(obj) = 'string'
extract_value(obj) = 'Random string'
is_alias(obj) = True
is_node(obj) = True
Checking 2.
is_node(obj) = False
Checking 'Hello'.
is_node(obj) = False
Checking <class 'object'>.
is_node(obj) = False
Checking <prop_tree.Props object at 0x7f539d7a9070>.
is_node(obj) = False
View the function docs:
extract_path.__doc__ =
"""
Return the string representation of the property tree path.
@return: The property tree path.
@rtype: str
"""
extract_type.__doc__ =
"""
Return the property tree type corresponding to the value.
@return: The type of value that the property tree path refers to, as defined in the property tree rather than a Python type.
@rtype: str
"""
extract_value.__doc__ =
"""
Return the property tree value.
@return: The property tree value.
@rtype: object
"""
is_node.__doc__ =
"""
Return the property tree value.
@return: The property tree value.
@rtype: object
"""
################################
# Testing Node hidden objects. #
################################
props.test_node_hidden.__doc__: 'A Python property tree node.'
props.test_node_hidden._path: '/'
extract_path(props.test_node_hidden): '/test-node-hidden'
###########################################################
# Testing a new copy of Props and Node (segfault checks). #
###########################################################
A new Node: <prop_tree.Node object at 0x1049dca0, value=True, type='bool', path='/test-new-node'>
A new Props object: <prop_tree.Props object at 0x7f539d7a9080>
The new Props object test_new_node Node: <prop_tree.Node object at 0x10512a30, value=True, type='bool', path='/test-new-node'>
#######################
# Test Node aliasing. #
#######################
Source value: 'Hop'
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x10512a30, value='Hop', type='string', path='/test-alias[0]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value='test', type='string', path='/test-alias-new[0]/iter[0]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[0]', value='Hop', type='string', path='/test-alias-new[0]/iter[0]'>
Source value: ''
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value='', type='string', path='/test-alias[1]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[1]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[1]', value='', type='string', path='/test-alias-new[0]/iter[1]'>
Source value: True
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=True, type='bool', path='/test-alias[2]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[2]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[2]', value=True, type='bool', path='/test-alias-new[0]/iter[2]'>
Source value: False
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias[3]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[3]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[3]', value=False, type='bool', path='/test-alias-new[0]/iter[3]'>
Source value: 1
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=1, type='int', path='/test-alias[4]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[4]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[4]', value=1, type='int', path='/test-alias-new[0]/iter[4]'>
Source value: 0
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=0, type='int', path='/test-alias[5]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[5]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[5]', value=0, type='int', path='/test-alias-new[0]/iter[5]'>
Source value: 1.0
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=1.0, type='double', path='/test-alias[6]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[6]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[6]', value=1.0, type='double', path='/test-alias-new[0]/iter[6]'>
Source value: 0.0
Pre-target value: 'test'
Source node: <prop_tree.Node object at 0x1049f4b0, value=0.0, type='double', path='/test-alias[7]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value='test', type='string', path='/test-alias-new[0]/iter[7]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[7]', value=0.0, type='double', path='/test-alias-new[0]/iter[7]'>
Source value: 'Hop'
Pre-target value: False
Source node: <prop_tree.Node object at 0x10512a30, value='Hop', type='string', path='/test-alias[0]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value=False, type='bool', path='/test-alias-new[1]/iter[0]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[0]', value='Hop', type='string', path='/test-alias-new[1]/iter[0]'>
Source value: ''
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value='', type='string', path='/test-alias[1]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[1]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[1]', value='', type='string', path='/test-alias-new[1]/iter[1]'>
Source value: True
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=True, type='bool', path='/test-alias[2]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[2]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[2]', value=True, type='bool', path='/test-alias-new[1]/iter[2]'>
Source value: False
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias[3]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[3]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[3]', value=False, type='bool', path='/test-alias-new[1]/iter[3]'>
Source value: 1
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=1, type='int', path='/test-alias[4]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[4]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[4]', value=1, type='int', path='/test-alias-new[1]/iter[4]'>
Source value: 0
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=0, type='int', path='/test-alias[5]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[5]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[5]', value=0, type='int', path='/test-alias-new[1]/iter[5]'>
Source value: 1.0
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=1.0, type='double', path='/test-alias[6]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[6]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[6]', value=1.0, type='double', path='/test-alias-new[1]/iter[6]'>
Source value: 0.0
Pre-target value: False
Source node: <prop_tree.Node object at 0x1049f4b0, value=0.0, type='double', path='/test-alias[7]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias-new[1]/iter[7]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[7]', value=0.0, type='double', path='/test-alias-new[1]/iter[7]'>
Source value: 'Hop'
Pre-target value: -5
Source node: <prop_tree.Node object at 0x10512a30, value='Hop', type='string', path='/test-alias[0]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value=-5, type='int', path='/test-alias-new[2]/iter[0]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[0]', value='Hop', type='string', path='/test-alias-new[2]/iter[0]'>
Source value: ''
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value='', type='string', path='/test-alias[1]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[1]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[1]', value='', type='string', path='/test-alias-new[2]/iter[1]'>
Source value: True
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=True, type='bool', path='/test-alias[2]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[2]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[2]', value=True, type='bool', path='/test-alias-new[2]/iter[2]'>
Source value: False
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias[3]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[3]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[3]', value=False, type='bool', path='/test-alias-new[2]/iter[3]'>
Source value: 1
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=1, type='int', path='/test-alias[4]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[4]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[4]', value=1, type='int', path='/test-alias-new[2]/iter[4]'>
Source value: 0
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=0, type='int', path='/test-alias[5]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[5]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[5]', value=0, type='int', path='/test-alias-new[2]/iter[5]'>
Source value: 1.0
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=1.0, type='double', path='/test-alias[6]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[6]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[6]', value=1.0, type='double', path='/test-alias-new[2]/iter[6]'>
Source value: 0.0
Pre-target value: -5
Source node: <prop_tree.Node object at 0x1049f4b0, value=0.0, type='double', path='/test-alias[7]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=-5, type='int', path='/test-alias-new[2]/iter[7]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[7]', value=0.0, type='double', path='/test-alias-new[2]/iter[7]'>
Source value: 'Hop'
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x10512a30, value='Hop', type='string', path='/test-alias[0]'>
Pre-target node: <prop_tree.Node object at 0x10512a30, value=20.0, type='double', path='/test-alias-new[3]/iter[0]'>
Updated target node: <prop_tree.Node object at 0x10512a30, alias='/test-alias[0]', value='Hop', type='string', path='/test-alias-new[3]/iter[0]'>
Source value: ''
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value='', type='string', path='/test-alias[1]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[1]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[1]', value='', type='string', path='/test-alias-new[3]/iter[1]'>
Source value: True
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=True, type='bool', path='/test-alias[2]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[2]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[2]', value=True, type='bool', path='/test-alias-new[3]/iter[2]'>
Source value: False
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=False, type='bool', path='/test-alias[3]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[3]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[3]', value=False, type='bool', path='/test-alias-new[3]/iter[3]'>
Source value: 1
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=1, type='int', path='/test-alias[4]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[4]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[4]', value=1, type='int', path='/test-alias-new[3]/iter[4]'>
Source value: 0
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=0, type='int', path='/test-alias[5]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[5]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[5]', value=0, type='int', path='/test-alias-new[3]/iter[5]'>
Source value: 1.0
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=1.0, type='double', path='/test-alias[6]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[6]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[6]', value=1.0, type='double', path='/test-alias-new[3]/iter[6]'>
Source value: 0.0
Pre-target value: 20.0
Source node: <prop_tree.Node object at 0x1049f4b0, value=0.0, type='double', path='/test-alias[7]'>
Pre-target node: <prop_tree.Node object at 0x1049f4b0, value=20.0, type='double', path='/test-alias-new[3]/iter[7]'>
Updated target node: <prop_tree.Node object at 0x1049f4b0, alias='/test-alias[7]', value=0.0, type='double', path='/test-alias-new[3]/iter[7]'>
********************************************************************************
Here is an AttributeError, for luck:
Traceback (most recent call last):
File "/flightgear/hangar/py-ogel/test.py", line 1019, in <module>
print(props.does_not_exist)
AttributeError: The property tree node '/does-not-exist' does not exist.
********************************************************************************
This is the py-ogel, XML inline python script.
a: 11
********************************************************************************
# check required dependencies
find_package(Boost REQUIRED)
# check required dependencies
set(Python_ADDITIONAL_VERSIONS 3.4)
Enabling ATI viewport hack
Starting automatic scenery download/synchronization. Using built-in SVN support. Directory: '/home/user-name/.fgfs/TerraSync'.
No path in sim/sound/path
canvas::Text: Missing 'ttf' font reader
canvas::Text: Failed to open font file /home/user-name/fgfs2/install/flightgear/fgdata/Fonts/LiberationFonts/LiberationSans-Bold.ttf
I wand spam
Sorry, qdot doesn't appear to be trimmable
Trim Results:
Altitude AGL: 4.1 wdot: 3.22e+01 Tolerance: 1e-03 Failed
Pitch Angle: -0.12 qdot: 1.01e-09 Tolerance: 1e-04 Passed
Roll Angle: -0.31 pdot: -6.67e-08 Tolerance: 1e-04 Passed
Trim Statistics:
Total Iterations: 2
Sub-iterations:
wdot: 5 average: 2.5 successful: 1 stability: 2
qdot: 0 average: 0 successful: 0 stability: 2
pdot: 6 average: 3 successful: 2 stability: 2
Run Count: 66
...
<python>
....
<eggs>
<script>
import hello
hello.spam()
</script>
</eggs>
</python>
diff --git a/src/Python/PythonSys.cxx b/src/Python/PythonSys.cxx
index 4b654af..2f49ec1 100644
--- a/src/Python/PythonSys.cxx
+++ b/src/Python/PythonSys.cxx
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include <Python.h>
#include <simgear/props/props.hxx>
@@ -81,6 +82,12 @@ void FGPythonSys::init()
PyRun_SimpleString("builtins.props = prop_tree.Props()");
PyRun_SimpleString("del prop_tree");
PyRun_SimpleString("del builtins");
+ //add FGhome/Python
+ PyRun_SimpleString("import sys");
+ char FGpythonPath[512] = "";
+ snprintf(FGpythonPath, 512,"sys.path.append('%s/Python')",globals->get_fg_root().c_str());
+ PyRun_SimpleString(FGpythonPath);
+ PyRun_SimpleString("del sys");
}
// Load all the scripts out of the property tree.
def spam():
print("I wand spam")
Users browsing this forum: No registered users and 7 guests