[maemo-commits] [maemo-commits] r8558 - in projects/haf/trunk/python-xml: . xml/xpath
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Dec 1 23:11:01 EET 2006
- Previous message: [maemo-commits] r8557 - projects/haf/trunk/python-xml/xml/utils
- Next message: [maemo-commits] r8559 - projects/haf/trunk/python/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: osantana
Date: 2006-12-01 23:10:54 +0200 (Fri, 01 Dec 2006)
New Revision: 8558
Modified:
projects/haf/trunk/python-xml/setup.py
projects/haf/trunk/python-xml/xml/xpath/BuiltInExtFunctions.py
projects/haf/trunk/python-xml/xml/xpath/Conversions.py
projects/haf/trunk/python-xml/xml/xpath/CoreFunctions.py
projects/haf/trunk/python-xml/xml/xpath/ParsedExpr.py
Log:
reverting the last commit
Modified: projects/haf/trunk/python-xml/setup.py
===================================================================
--- projects/haf/trunk/python-xml/setup.py 2006-12-01 21:06:33 UTC (rev 8557)
+++ projects/haf/trunk/python-xml/setup.py 2006-12-01 21:10:54 UTC (rev 8558)
@@ -147,11 +147,11 @@
))
# Build boolean
-#ext_modules.append(
-# Extension(xml('.utils.boolean'),
-# extra_link_args=LDFLAGS,
-# sources=['extensions/boolean.c'],
-# ))
+ext_modules.append(
+ Extension(xml('.utils.boolean'),
+ extra_link_args=LDFLAGS,
+ sources=['extensions/boolean.c'],
+ ))
# On Windows, install the documentation into a directory xmldoc, along
Modified: projects/haf/trunk/python-xml/xml/xpath/BuiltInExtFunctions.py
===================================================================
--- projects/haf/trunk/python-xml/xml/xpath/BuiltInExtFunctions.py 2006-12-01 21:06:33 UTC (rev 8557)
+++ projects/haf/trunk/python-xml/xml/xpath/BuiltInExtFunctions.py 2006-12-01 21:10:54 UTC (rev 8558)
@@ -14,6 +14,7 @@
import sys, re, string, urllib
from xml.dom import Node, EMPTY_NAMESPACE
from xml.dom.Text import Text
+from xml.utils import boolean
from xml.xpath import CoreFunctions, Conversions, FT_EXT_NAMESPACE, FT_OLD_EXT_NAMESPACE
def Version(context):
@@ -40,7 +41,7 @@
if not arg:
arg = context.node
arg = Conversions.StringValue(arg)
- bool = re.match(pattern, arg) and True or False
+ bool = re.match(pattern, arg) and boolean.true or boolean.false
return bool
Modified: projects/haf/trunk/python-xml/xml/xpath/Conversions.py
===================================================================
--- projects/haf/trunk/python-xml/xml/xpath/Conversions.py 2006-12-01 21:06:33 UTC (rev 8557)
+++ projects/haf/trunk/python-xml/xml/xpath/Conversions.py 2006-12-01 21:10:54 UTC (rev 8558)
@@ -19,6 +19,7 @@
from xml.xpath import NaN, Inf
from xml.xpath import Util
from xml.xpath import NAMESPACE_NODE
+from xml.utils import boolean
import types
try:
@@ -90,7 +91,7 @@
"""Get the number value of any object"""
if type(object) in [type(1), type(2.3), type(4L)]:
return 1, object
- elif isinstance(object, bool):
+ elif boolean.IsBooleanType(object):
return 1, int(object)
#FIXME: This can probably be optimized
object = StringValue(object)
@@ -106,7 +107,7 @@
return 1, object
-CoreBooleanValue = lambda obj: (1, bool(StringValue(obj)))
+CoreBooleanValue = lambda obj: (1, boolean.BooleanValue(obj, StringValue))
g_stringConversions = [CoreStringValue]
g_numberConversions = [CoreNumberValue]
@@ -152,7 +153,7 @@
types.IntType : str,
types.LongType : lambda l: repr(l)[:-1],
types.FloatType : lambda f: f is NaN and 'NaN' or '%g' % f,
- bool : str,
+ boolean.BooleanType : str,
types.InstanceType : _strInstance,
types.ListType : lambda x: x and _strConversions.get(type(x[0]), _strUnknown)(x[0]) or '',
}
Modified: projects/haf/trunk/python-xml/xml/xpath/CoreFunctions.py
===================================================================
--- projects/haf/trunk/python-xml/xml/xpath/CoreFunctions.py 2006-12-01 21:06:33 UTC (rev 8557)
+++ projects/haf/trunk/python-xml/xml/xpath/CoreFunctions.py 2006-12-01 21:10:54 UTC (rev 8558)
@@ -20,6 +20,7 @@
from xml.xpath import Util, Conversions
from xml.xpath import NAMESPACE_NODE
from xml.xpath import CompiletimeException, RuntimeException
+from xml.utils import boolean
from xml.FtCore import get_translator
@@ -153,7 +154,7 @@
"""Function: <string> starts-with(<string>, <string>)"""
outer = Conversions.StringValue(outer)
inner = Conversions.StringValue(inner)
- return outer[:len(inner)] == inner and True or False
+ return outer[:len(inner)] == inner and boolean.true or boolean.false
def Contains(context, outer, inner):
@@ -161,9 +162,9 @@
outer = Conversions.StringValue(outer)
inner = Conversions.StringValue(inner)
if len(inner) == 1:
- return inner in outer and True or False
+ return inner in outer and boolean.true or boolean.false
else:
- return string.find(outer, inner) != -1 and True or False
+ return string.find(outer, inner) != -1 and boolean.true or boolean.false
def SubstringBefore(context, outer, inner):
@@ -244,17 +245,17 @@
def Not(context, object):
"""Function: <boolean> not(<boolean>)"""
- return (not Conversions.BooleanValue(object) and True) or False
+ return (not Conversions.BooleanValue(object) and boolean.true) or boolean.false
-def True_(context):
+def True(context):
"""Function: <boolean> true()"""
- return True
+ return boolean.true
-def False_(context):
+def False(context):
"""Function: <boolean> false()"""
- return False
+ return boolean.false
def Lang(context, lang):
@@ -270,9 +271,9 @@
if index != -1:
value = value[:index]
value = string.upper(value)
- return value == lang and True or False
+ return value == lang and boolean.true or boolean.false
node = node.nodeType == Node.ATTRIBUTE_NODE and node.ownerElement or node.parentNode
- return False
+ return boolean.false
### Number Functions ###
@@ -351,8 +352,8 @@
(EMPTY_NAMESPACE, 'translate'): Translate,
(EMPTY_NAMESPACE, 'boolean'): _Boolean,
(EMPTY_NAMESPACE, 'not'): Not,
- (EMPTY_NAMESPACE, 'true'): True_,
- (EMPTY_NAMESPACE, 'false'): False_,
+ (EMPTY_NAMESPACE, 'true'): True,
+ (EMPTY_NAMESPACE, 'false'): False,
(EMPTY_NAMESPACE, 'lang'): Lang,
(EMPTY_NAMESPACE, 'number'): Number,
(EMPTY_NAMESPACE, 'sum'): Sum,
Modified: projects/haf/trunk/python-xml/xml/xpath/ParsedExpr.py
===================================================================
--- projects/haf/trunk/python-xml/xml/xpath/ParsedExpr.py 2006-12-01 21:06:33 UTC (rev 8557)
+++ projects/haf/trunk/python-xml/xml/xpath/ParsedExpr.py 2006-12-01 21:10:54 UTC (rev 8558)
@@ -22,6 +22,7 @@
from xml.xpath import Util
from xml.xpath import ParsedStep
from xml.xpath import ParsedAxisSpecifier
+from xml.utils import boolean
import Set
class NodeSet(UserList.UserList):
@@ -436,11 +437,11 @@
def evaluate(self, context):
if self._op == '=':
- true = True
- false = False
+ true = boolean.true
+ false = boolean.false
else:
- true = False
- false = True
+ true = boolean.false
+ false = boolean.true
lrt = self._left.evaluate(context)
rrt = self._right.evaluate(context)
@@ -464,7 +465,7 @@
val = lrt
if type(val) in NumberTypes:
func = Conversions.NumberValue
- elif isinstance(val,bool):
+ elif boolean.IsBooleanType(val):
func = Conversions.BooleanValue
elif type(val) == types.StringType:
func = Conversions.StringValue
@@ -477,7 +478,7 @@
return true
return false
- if isinstance(lrt, bool) or isinstance(rrt, bool):
+ if boolean.IsBooleanType(lrt) or boolean.IsBooleanType(rrt):
rt = Conversions.BooleanValue(lrt) == Conversions.BooleanValue(rrt)
elif lType in NumberTypes or rType in NumberTypes:
rt = Conversions.NumberValue(lrt) == Conversions.NumberValue(rrt)
@@ -542,7 +543,7 @@
rt = (lrt > rrt)
elif self._op == 3:
rt = (lrt >= rrt)
- return rt and True or False
+ return rt and boolean.true or boolean.false
def pprint(self, indent=''):
print indent + str(self)
- Previous message: [maemo-commits] r8557 - projects/haf/trunk/python-xml/xml/utils
- Next message: [maemo-commits] r8559 - projects/haf/trunk/python/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
