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
25 from decimal import Decimal
27 from sequence import Sequence
28 from nodes import Node
29 from nodes_misc import nodeToXpath
31 def printSequence( sequence , fullTree = False , displayLocation = False ) :
33 if not isinstance( sequence , Sequence ) :
34 print 'Not a sequence' , `sequence`
38 for i , item in enumerate( sequence ) :
40 if isinstance( item , Node ) :
43 print nodeToXpath( item )
45 print '' , # Needed to insert a space before the asDebug() output !
47 item.asDebug( maxDepth = 2 , maxChildren = 0 , file = sys.stdout )
49 item.asDebug( file = sys.stdout )
50 elif isinstance( item , basestring ) :
51 print i , 'STRING' , item
52 elif isinstance( item , bool ) :
53 print i , 'BOOLEAN' , item
54 elif isinstance( item , ( int , long ) ) :
55 print i , 'INTEGER' , item
56 elif isinstance( item , Decimal ) :
57 print i , 'DECIMAL' , item
58 elif isinstance( item , float ) :
59 print i , 'FLOAT|DOUBLE' , item
61 print i , '*UNKNOWN*' , `item`