[Zope3-checkins] CVS: Products3/pypgsqlda/pgtypes - _geometry.py:1.1.2.2
Christian Theune
ct@gocept.com
Sun, 13 Apr 2003 19:08:07 -0400
Update of /cvs-repository/Products3/pypgsqlda/pgtypes
In directory cvs.zope.org:/tmp/cvs-serv22826/pgtypes
Modified Files:
Tag: tiran-pypgsql_types-branch
_geometry.py
Log Message:
- removed LF
- added some blank comments to remember filling them out to be compatible
with z3 style guide
- whitespace normalization
-
=== Products3/pypgsqlda/pgtypes/_geometry.py 1.1.2.1 => 1.1.2.2 ===
--- Products3/pypgsqlda/pgtypes/_geometry.py:1.1.2.1 Mon Apr 7 12:18:50 2003
+++ Products3/pypgsqlda/pgtypes/_geometry.py Sun Apr 13 19:08:06 2003
@@ -1,22 +1,22 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Geometric object implementation
-
-$Id$
-"""
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Geometric object implementation
-from zope.proxy.context import ContextMethod
+$Id$
+"""
+
+from zope.proxy.context import ContextMethod
from interface import geometric
import re
from math import pi
@@ -39,59 +39,56 @@
groupPointList = re.compile(r"(\([\d.]+,[\d.]+\))")
def isOpenPath(data):
- return openPath.match(unicode(data))
+ return not not openPath.match(unicode(data))
def isClosedPath(data):
- return closedPath.match(unicode(data))
+ return not not closedPath.match(unicode(data))
class GeometricError(Exception):
- """XXX
+ """ XXX
"""
pass
class GeometricInfinite(object):
+ """ XXX
"""
- """
+
def __str__(self):
return u"INF"
-
__str__ = ContextMethod(__str__)
def __call__(self):
return self.__str__
-
__call__ = ContextMethod(__call__)
def __repr__(self):
return self.__str__()
-
__repr__ = ContextMethod(__repr__)
class Geometric2d(object):
+ """ XXX
+ """
__implements__ = geometric.IGeometric2d
def __init__(self):
self._data = None
- return NotImplemented
+ return NotImplemented # XXX ?
isClosed = property(lambda: False, None, None)
- isOpen = property(lambda: False, None, None)
+ isOpen = property(lambda: False, None, None)
length = property(lambda: 0, None, None)
def __str__(self):
return unicode(self._data)
-
__str__ = ContextMethod(__str__)
def __call__(self):
return self.__str__
-
__call__ = ContextMethod(__call__)
def __repr__(self):
return self.__str__()
-
__repr__ = ContextMethod(__repr__)
def __iter__(self):
@@ -106,50 +103,57 @@
return 0
class Shape2d(Geometric2d):
+ """ XXX
+ """
+
__implements__ = geometric.IShape2d, Geometric2d.__implements__
area = property(lambda: 0, None, None, None)
-
-class Point2d(Geometric2d):
- """Simple geometric point
- """
-
+class Point2d(Geometric2d):
+ """Simple geometric point
+ """
+
__implements__ = geometric.IPoint2d, Geometric2d.__implements__
- def __init__(self, data):
+ def __init__(self, data):
self._data = data
- self._x = None
- self._y = None
+ self._x = None
+ self._y = None
self._iter = 0
def _convert(self):
+ """ XXX
"""
- """
- if self._x and self._y: return # already converted data
- point = groupPoint.match(unicode(self._data)).groups()
+ if self._x and self._y:
+ return # already converted data
+ point = groupPoint.match(unicode(self._data)).groups() # XXX No match returns "None"
if len(point) != 2:
raise GeometricError, u"'%s' has wrong size" % data
self.x = point[0]
self.y = point[1]
-
+
def _getX(self):
- self._convert()
- return self._x
-
- def _setX(self, value):
- self._x = float(value)
-
- x = property(_getX, _setX, None, 'x coordinate as float')
-
+ """ XXX
+ """
+ self._convert()
+ return self._x
+
+ def _setX(self, value):
+ """ XXX
+ """
+ self._x = float(value)
+
+ x = property(_getX, _setX, None, 'x coordinate as float')
+
def _getY(self):
- self._convert()
- return self._y
-
- def _setY(self, value):
- self._y = float(value)
-
- y = property(_getY, _setY, None, 'y coordinate as float')
+ self._convert()
+ return self._y
+
+ def _setY(self, value):
+ self._y = float(value)
+
+ y = property(_getY, _setY, None, 'y coordinate as float')
def next(self):
"""next() support for iterator"""
@@ -160,18 +164,22 @@
raise StopIteration
def __len__(self):
- return 1
+ return 1
class Box2d(Shape2d):
+ """ XXX
+ """
+
__implements__ = geometric.IBox2d, Shape2d.__implements__
def __init__(self, data):
- self._data = data
+ self._data = data
self._points = []
- self._iter = 0
+ self._iter = 0
def _convert(self):
- if self._points: return
+ if self._points:
+ return
box = groupPointList.findall(unicode(data))
if len(box) != 2:
raise GeometricError, u"'%s' has wrong size" % data
@@ -223,16 +231,22 @@
raise StopIteration
class Circle2d(Shape2d):
+ """ XXX
+ """
+
__implements__ = geometric.ICircle2d, Shape2d.__implements__
def __init__(self, data):
- self._data = data
+ self._data = data
self._center = None
self._radius = None
def _convert(self):
- if self._center and self._radius: return
- circle = groupCircle.match(unicode(data)).groups()
+ """ XXX
+ """
+ if self._center and self._radius:
+ return
+ circle = groupCircle.match(unicode(data)).groups() # XXX match may return None
if len(circle) != 2:
raise GeometricError, u"'%s' has wrong size" % data
self._center = Point2d(circle[0])
@@ -280,8 +294,10 @@
else:
raise StopIteration
-
class OpenPath(Geometric2d):
+ """ XXX
+ """
+
__implements__ = geometric.IBox2d, Geometric2d.__implements__
def __init__(self, data):
@@ -290,9 +306,13 @@
self._points = None
class ClosedPath(Geometric2d):
+ """ XXX
+ """
+
__implements__ = geometric.IBox2d, Geometric2d.__implements__
def __init__(self, data):
self._data = data
self._iter = 0
self._points = None
+