johnbachman / py-fcm

Automatically exported from code.google.com/p/py-fcm
0 stars 1 forks source link

data tree allows you to 'visit' nonexistant nodes #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
In [1]: import fcm

In [2]: x = fcm.loadFCS('3FITC_4PE_004.fcs')

In [3]: print x.tree.pprint()
root

In [4]: x.visit('ba')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)

/home/jolly/Projects/fcm/sample_data/<ipython console> in <module>()

/usr/local/lib/python2.7/site-packages/fcm/core/fcmdata.pyc in visit(self, name)
    129     def visit(self, name):
    130         """Switch current view of the data"""
--> 131         self.tree.visit(name)
    132 
    133     def current_node(self):

/usr/local/lib/python2.7/site-packages/fcm/core/tree.pyc in visit(self, name)
    143         '''visit a node in the tree'''
    144         if isinstance(name, str):
--> 145             self.current = self.nodes[name]
    146         else: # in this case we assume we're a node type.
    147             self.current = name

KeyError: 'ba'

In [5]: x.visit(2)

we need to check beyond if it's a string, and only accept nodes or strings

What is the expected output? What do you see instead?

should throw some kind of error if the node we try and move to doesn't exist.

Please use labels and text to provide additional information.

Original issue reported on code.google.com by Jacob.Frelinger@gmail.com on 30 Jun 2011 at 2:19

GoogleCodeExporter commented 9 years ago
fixed in rev 1d317523b573

Original comment by Jacob.Frelinger@gmail.com on 30 Jun 2011 at 3:00