def fractional(points, fi, LatLon=None, **LatLon_kwds): '''Return the point at a given I{fractional} index. @arg points: The points (C{LatLon}[], L{Numpy2LatLon}[], L{Tuple2LatLon}[] or C{other}[]). @arg fi: The fractional index (C{float} or C{int}). @kwarg LatLon: Optional class to return the I{intermediate}, I{fractional} point (C{LatLon}) or C{None}. @kwarg LatLon_kwds: Optional B{C{LatLon}} keyword arguments, ignored of B{C{LatLon=None}}. @return: A B{C{LatLon}} or if B{C{LatLon}} is C{None}, a L{LatLon2Tuple}C{(lat, lon)} for B{C{points[fi]}} if I{fractional} index B{C{fi}} is C{int}, otherwise the intermediate point between B{C{points[int(fi)]}} and B{C{points[int(fi) + 1]}} for C{float} I{fractional} index B{C{fi}}. @raise IndexError: Fractional index B{C{fi}} invalid or B{C{points}} not subscriptable. ''' try: if not (isscalar(fi) and 0 <= fi < len(points)): raise IndexError p = _fractional(points, fi) except (IndexError, TypeError): raise _IndexError(fractional.__name__, fi) if LatLon and isinstance(p, LatLon2Tuple): p = LatLon(*p, **LatLon_kwds) return p
def __getattr__(self, name): try: return tuple.__getitem__(self, self._Names_.index(name)) except IndexError: raise _IndexError(_dot_(self.classname, '<name>'), name) except ValueError: return tuple.__getattribute__(self, name)
def __getattr__(self, name): '''Get the value of an attribute or item by B{C{name}}. ''' try: return tuple.__getitem__(self, self._Names_.index(name)) except IndexError: raise _IndexError(_DOT_(self.classname, Fmt.ANGLE(_name_)), name) except ValueError: return tuple.__getattribute__(self, name)