コード例 #1
0
 def __getattr__(self, name):
     try:
         return self[name]
     except KeyError:
         if name == _name_:
             return _NamedDict.name.fget(self)
     raise _AttributeError(item=self._dot_(name), txt=_doesn_t_exist_)
コード例 #2
0
ファイル: simplify.py プロジェクト: rbpdqdat/PyGeodesy
    def vwr(self, attr):
        '''Return the Visvalingam-Whyatt results, optionally
           including the triangular area (in meters) as
           attribute attr to each simplified point.
        '''
        pts, r = self.pts, self.r

        # double check the minimal triangular area
        assert min(t2.h2 for t2 in r) > self.s2 > 0

        if attr:  # return the trangular area (actually
            # the sqrt of double the triangular area)
            # converted back from degrees to meter
            if isNumpy2(pts):
                raise _AttributeError(attr=attr)
            m = radians(_1_0) * self.radius
            r[0].h2 = r[-1].h2 = 0  # zap sentinels
            for t2 in r:  # convert back to meter
                setattr(pts[t2.ix], attr, sqrt(t2.h2) * m)

        # double check for duplicates
        n = len(r)
        r = dict((t2.ix, True) for t2 in r)
        assert len(r) == n
        return self.points(r)
コード例 #3
0
ファイル: basics.py プロジェクト: rbpdqdat/PyGeodesy
 def _immutable(inst, value):
     '''Throws an C{AttributeError}, always.
     '''
     from pygeodesy.named import classname
     s = _DOT_(repr(inst), self.name)
     s = _EQUALSPACED_(s, repr(value))
     t = _SPACE_(_immutable_, classname(self))
     raise _AttributeError(s, txt=t)
コード例 #4
0
ファイル: named.py プロジェクト: rbpdqdat/PyGeodesy
 def __getattr__(self, name):
     '''Get the value of an attribute or enum by B{C{name}}.
     '''
     try:
         return self[name]
     except KeyError:
         if name == _name_:
             return _NamedDict.name.fget(self)
     raise _AttributeError(item=self._DOT_(name), txt=_doesn_t_exist_)
コード例 #5
0
ファイル: streprs.py プロジェクト: rbpdqdat/PyGeodesy
def _boolkwds(inst, **name_value_pairs):  # in .frechet, .hausdorff, .heights
    '''(INTERNAL) Set applicable C{bool} properties/attributes.
    '''
    for n, v in name_value_pairs.items():
        b = getattr(inst, n, None)
        if b is None:  # invalid bool attr
            t = _SPACE_(_EQUAL_(n, repr(v)), 'for',
                        inst.__class__.__name__)  # XXX .classname
            raise _AttributeError(t, txt=_not_('applicable'))
        if v in (False, True) and v != b:
            setattr(inst, NN(_UNDER_, n), v)
コード例 #6
0
ファイル: streprs.py プロジェクト: rbpdqdat/PyGeodesy
 def _getattr(o, a):
     if hasattr(o, a):
         return getattr(o, a)
     raise _AttributeError(Fmt.DOT(a), o)
コード例 #7
0
ファイル: basics.py プロジェクト: baris-ekici/PyGeodesy
 def _getattr(o, a):
     if hasattr(o, a):
         return getattr(o, a)
     raise _AttributeError('.%s' % (a, ), o)
コード例 #8
0
ファイル: basics.py プロジェクト: baris-ekici/PyGeodesy
 def immutable(inst, value):
     '''Throws an C{AttributeError}, always.
     '''
     t = immutable.__name__, inst, method.__name__, value
     raise _AttributeError('%s property: %r.%s = %r' % t)
コード例 #9
0
ファイル: lazily.py プロジェクト: rbpdqdat/PyGeodesy
 def __getattr__(self, attr):
     try:
         return self[attr]
     except KeyError:  # PYCHOK no cover
         from pygeodesy.errors import _AttributeError
         raise _AttributeError(self._DOT_(attr), txt=_doesn_t_exist_)