4 # Copyright (C) 2002 Jörg Lehmann <joergl@users.sourceforge.net>
5 # Copyright (C) 2002 André Wobst <wobsta@users.sourceforge.net>
7 # This file is part of PyX (http://pyx.sourceforge.net/).
9 # PyX is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # PyX is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with PyX; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 class _nodefault
: pass
28 "arg is string-like (cf. python cookbook 3.2)"
44 if type(arg
+ 0.0) is type(arg
):
51 """arg is sequence-like (e.g. has a len)
52 a string is *not* considered to be a sequence"""
53 if _isstring(arg
): return None
59 def _ensuresequence(arg
):
60 """return arg or (arg,) depending on the result of _issequence,
61 None is converted to ()"""
62 if _isstring(arg
): return (arg
,)
63 if arg
is None: return ()
64 if _issequence(arg
): return arg
68 def _getitemno(arg
, n
):
76 def _issequenceofsequences(arg
):
77 """check if arg has a sequence or None as it's first entry"""
78 return _issequence(arg
) and len(arg
) and (_issequence(arg
[0]) or arg
[0] is None)
81 def _getsequenceno(arg
, n
):
82 """get sequence number n if arg is a sequence of sequences,
83 otherwise it gets just arg"""
84 if _issequenceofsequences(arg
):