4 # Copyright (C) 2005 Frédéric Jolliton <frederic@jolliton.com>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 from sequence import Sequence
27 from nodes import Node
28 from nodes_misc import nodeToXpath
30 def printSequence( sequence , fullTree = False , displayLocation = False ) :
32 if not isinstance( sequence , Sequence ) :
33 print 'Not a sequence' , `sequence`
37 for i , item in enumerate( sequence ) :
39 if isinstance( item , Node ) :
42 print nodeToXpath( item )
44 print '' , # Needed to insert a space before the asDebug() output !
46 item.asDebug( maxDepth = 2 , maxChildren = 0 , file = sys.stdout )
48 item.asDebug( file = sys.stdout )
49 elif isinstance( item , basestring ) :
50 print i , 'STRING' , item
51 elif isinstance( item , bool ) :
52 print i , 'BOOLEAN' , item
53 elif isinstance( item , ( int , long ) ) :
54 print i , 'INTEGER' , item
55 elif isinstance( item , Decimal ) :
56 print i , 'DECIMAL' , item
57 elif isinstance( item , float ) :
58 print i , 'FLOAT|DOUBLE' , item
60 print i , '*UNKNOWN*' , `item`