Esempio n. 1
0
 def create_top (self, cmd, ** kw) :
     RST            = GTW.RST
     TOP            = RST.TOP
     result         = TOP.Root \
         ( language = "de"
         , ** kw
         )
     result.add_entries \
         ( TOP.MOM.Admin.Site
             ( name            = "Admin"
             , short_title     = "Admin"
             , pid             = "Admin"
             , title           = u"Verwaltung der Homepage"
             , head_line       = u"Administration der Homepage"
             , auth_required   = True
             , entries         = self._nav_admin_groups ()
             )
         , TOP.Auth
             ( name            = _ ("Auth")
             , pid             = "Auth"
             , short_title     = _ ("Authorization and Account handling")
             , hidden          = True
             )
         , TOP.L10N
             ( name            = _ ("L10N")
             , short_title     =
                 _ ("Choice of language used for localization")
             , country_map     = dict (de = "AT")
             )
         )
     return result
Esempio n. 2
0
class A_Date(_A_Date_):
    """Date value."""

    example = "2010-10-10"
    completer = MOM.Attr.Completer_Spec(4)
    typ = _("Date")
    P_Type = datetime.date
    Q_Ckd_Type = MOM.Attr.Querier.Date
    Q_Name = "DATE"
    syntax = _("yyyy-mm-dd")
    ui_length = 12
    input_formats  = \
        ( "%Y-%m-%d", "%Y/%m/%d", "%Y%m%d", "%Y %m %d"
        , "%d/%m/%Y", "%d.%m.%Y", "%d-%m-%Y"
        )
    _tuple_len = 3

    class _Doc_Map_(_A_Date_._Doc_Map_):

        input_formats = """
            The possible strftime-formats used to convert raw values to cooked
            values.
        """

    # end class _Doc_Map_

    def as_rest_cargo_ckd(self, obj, *args, **kw):
        value = self.kind.get_value(obj)
        if value is not None:
            return pyk.text_type(value.strftime("%Y-%m-%d"))

    # end def as_rest_cargo_ckd

    @TFL.Meta.Class_and_Instance_Method
    def cooked(soc, value):
        if isinstance(value, datetime.datetime):
            value = value.date()
        elif isinstance(value, pyk.string_types):
            try:
                value = soc._from_string(value)
            except ValueError:
                msg = "Date expected, got %r" % (value, )
                raise MOM.Error.Attribute_Syntax(None, soc, value, msg)
        elif not isinstance(value, datetime.date):
            raise TypeError("Date expected, got %r" % (value, ))
        return value

    # end def cooked

    @classmethod
    def now(cls):
        return datetime.datetime.now().date()

    # end def now

    @TFL.Meta.Class_and_Instance_Method
    def value_range_delta(self, obj):
        from _CAL.Delta import Date_Delta
        return Date_Delta(1)
Esempio n. 3
0
        class desc(A_String):
            """Short description of the %(ui_name.lower ())s"""

            kind = Attr.Optional
            example = _("Office")
            max_length = 20
            ui_name = _("Description")

            completer = Attr.Completer_Spec(1)
Esempio n. 4
0
class A_Sex(_A_Named_Object_):
    """Sex of a person."""

    example = "F"
    typ = "Sex"
    P_Type = pyk.text_type
    Table     = \
        { "F"  : _("Female")
        , "M"  : _("Male")
        }
Esempio n. 5
0
 def recover (cls, request, value, ttl_s = None) :
     """Recover a signed token from `value`"""
     root   = request.root
     result = cls.__new__ (cls)
     result.request = request
     result.x_value = value
     parts  = value.split (cls.val_sep, 2)
     if len (parts) != 3 :
         if value :
             fmt = _ ("Malformed %s value '%s'")
         else :
             fmt = _ ("Missing %s%s")
         result._invalid = _T (fmt) % (cls.__name__, value)
         return result
     (result.cargo, result.timestamp, result.x_signature) = parts
     enc = result.encoding
     try:
         result.data = data = base64.b64decode (result.cargo).decode (enc)
     except Exception as exc :
         result._invalid = str (exc)
         return result
     if not root.HTTP.safe_str_cmp (result.x_signature, result.signature) :
         result._invalid = msg = \
             _T ("Invalid %s signature for '%s'") % (cls.__name__, data)
         logging.warning (msg)
     try :
         timestamp = base64.b64decode (result.timestamp).decode (enc)
     except Exception as exc :
         result._invalid = repr (exc)
     else :
         try :
             then = result.time = int (timestamp)
         except Exception as exc :
             result._invalid = repr (exc)
     if result :
         now = request.current_time
         ttl = ttl_s if ttl_s is not None else request.resource.session_ttl_s
         if then < (now - ttl) :
             result._invalid = msg = \
                 ( _T ("Expired %s '%s' older then %s seconds")
                 % (cls.__name__, data, ttl)
                 )
             logging.warning (msg)
         elif then > now + 180 :
             ### don't accept tokens with a timestamp more than 2 minutes in
             ### the future
             result._invalid = msg = \
                 ( _T ("Time-travelling %s '%s' [%s seconds ahead]")
                 % (cls.__name__, data, then - now)
                 )
             logging.warning (msg)
     return result
Esempio n. 6
0
 def recover(cls, request, value, ttl_s=None):
     """Recover a signed token from `value`"""
     root = request.root
     result = cls.__new__(cls)
     result.request = request
     result.x_value = value
     parts = value.split(cls.val_sep, 2)
     if len(parts) != 3:
         if value:
             fmt = _("Malformed %s value '%s'")
         else:
             fmt = _("Missing %s%s")
         result._invalid = _T(fmt) % (cls.__name__, value)
         return result
     (result.cargo, result.timestamp, result.x_signature) = parts
     enc = result.encoding
     try:
         result.data = data = base64.b64decode(result.cargo).decode(enc)
     except Exception as exc:
         result._invalid = str(exc)
         return result
     if not root.HTTP.safe_str_cmp(result.x_signature, result.signature):
         result._invalid = msg = \
             _T ("Invalid %s signature for '%s'") % (cls.__name__, data)
         logging.warning(msg)
     try:
         timestamp = base64.b64decode(result.timestamp).decode(enc)
     except Exception as exc:
         result._invalid = repr(exc)
     else:
         try:
             then = result.time = int(timestamp)
         except Exception as exc:
             result._invalid = repr(exc)
     if result:
         now = request.current_time
         ttl = ttl_s if ttl_s is not None else request.resource.session_ttl_s
         if then < (now - ttl):
             result._invalid = msg = \
                 ( _T ("Expired %s '%s' older then %s seconds")
                 % (cls.__name__, data, ttl)
                 )
             logging.warning(msg)
         elif then > now + 180:
             ### don't accept tokens with a timestamp more than 2 minutes in
             ### the future
             result._invalid = msg = \
                 ( _T ("Time-travelling %s '%s' [%s seconds ahead]")
                 % (cls.__name__, data, then - now)
                 )
             logging.warning(msg)
     return result
Esempio n. 7
0
        class title (A_String) :
            """Academic title"""

            kind           = Attr.Primary_Optional
            ignore_case    = True
            example        = "Dr."
            max_length     = 20
            rank           = 2
            ui_name        = _("Academic title")
            ui_name_short  = _("Title")

            completer      = Attr.Completer_Spec  (0)
            polisher       = \
                Attr.Polisher.capitalize_if_lower_case_compress_spaces
Esempio n. 8
0
class A_Int_Range (_A_Range_) :
    """Integer range."""

    C_Type         = A_Int
    P_Type         = TFL.Int_Range
    example        = "[1, 5]"
    typ            = _ ("Int_Range")

    class _Attributes (_A_Range_._Attributes) :

        _Ancestor = _A_Range_._Attributes

        class btype (_Ancestor.btype) :

            default            = "[]"

        # end class btype

        class lower (_Ancestor.lower, A_Int) :

            pass

        # end class lower

        class upper (_Ancestor.upper, A_Int) :

            pass
Esempio n. 9
0
 def _test(self):
     """This is a method doc string"""
     print(_T(ckw.title or "Baz"))
     print(_T("Foo"))
     foo = _("Markup %d")
     print(_T(foo) % 42)
     print(_Tn("Singular", "Plural", 4))
Esempio n. 10
0
class A_Date_Range(_A_Range_):
    """Date range."""

    C_Type = A_Date
    P_Type = CAL.Date_Range
    example = "[2016-07-05, 2016-07-20]"
    typ = _("Date_Range")

    class _Attributes(_A_Range_._Attributes):

        _Ancestor = _A_Range_._Attributes

        class btype(_Ancestor.btype):

            default = "[]"

        # end class btype

        class lower(_Ancestor.lower, A_Date):

            ui_name = _("start")

        # end class lower

        class upper(_Ancestor.upper, A_Date):

            ui_name = _("finish")
Esempio n. 11
0
class A_TX_Power(_A_Unit_, _A_Float_):
    """Transmit Power specified in multiples of W or dBW, dBm,
       converted to dBm.
    """

    typ = _("TX Power")
    needs_raw_value = True
    _default_unit = "dBm"
    _unit_dict      = dict \
        ( mW        = 1
        ,  W        = 1.E3
        , kW        = 1.E6
        , MW        = 1.E9
        , dBm       = 1
        , dBmW      = 1 # alias for dBm, see http://en.wikipedia.org/wiki/DBm
        , dBW       = 1
        )

    def _from_string(self, s, obj, glob, locl):
        v = self.__super._from_string(s, obj, glob, locl)
        pat = self._unit_pattern
        unit = ""
        if pat.search(s):
            unit = pat.unit
        if unit.startswith('dB'):
            if unit == 'dBW':
                v += 30
        else:
            v = log(v) / log(10) * 10.
        return v
        class standard(A_Id_Entity):
            """Wireless standard used by the wireless interface."""

            kind = Attr.Necessary
            P_Type = CNDB.OMP.Wireless_Standard
            ui_allow_new = False
            ui_name = _("Wi-Fi Standard")
Esempio n. 13
0
 def _test (self) :
     """This is a method doc string"""
     print (_T (ckw.title or "Baz"))
     print (_T ("Foo"))
     foo = _("Markup %d")
     print (_T(foo) % 42)
     print (_Tn ("Singular", "Plural", 4))
Esempio n. 14
0
class A_Time_Range(_A_Range_):
    """Time range."""

    C_Type = A_Time_X
    P_Type = CAL.Time_Range
    example = "[08:30, 10:00)"
    typ = _("Time_Range")

    class _Attributes(_A_Range_._Attributes):

        _Ancestor = _A_Range_._Attributes

        class btype(_Ancestor.btype):

            default = "[)"

        # end class btype

        class lower(_Ancestor.lower, A_Time_X):

            ui_name = _("start")

        # end class lower

        class upper(_Ancestor.upper, A_Time_X):

            ui_name = _("finish")
Esempio n. 15
0
class Range_Contains(_Range_):
    """Range-Attribute query filter for contains."""

    desc          = _ \
        ("Select entities where the attribute contains the specified value")
    op_fct = _("CONTAINS")
    op_nam = "contains"
Esempio n. 16
0
class Delete(_Action_):

    action = "remove"
    css_class = ""
    description = _("Delete %(tn)s %(obj)s")
    href = None
    icon = "trash-o"
Esempio n. 17
0
class Range_Overlaps(_Range_):
    """Range-Attribute query filter for overlaps."""

    desc          = _ \
        ("Select entities where the attribute overlaps the specified range ")
    op_fct = _("OVERLAPS")
    op_nam = "overlaps"
        class left(_Ancestor.left):
            """The wireless standard for this channel"""

            role_name = 'standard'
            role_type = CNDB.OMP.Wireless_Standard
            ui_allow_new = False
            ui_name = _("Wi-Fi Standard")
Esempio n. 19
0
class Change(_Action_):

    action = "change"
    css_class = ""
    description = _("Change %(tn)s %(obj)s")
    href = None
    icon = "pencil"
Esempio n. 20
0
class A_IM_Protocol(A_Enum):
    """Instant messaging protocol"""

    example = "XMPP"
    typ = "im_protocol"

    C_Type = A_String
    max_length = 16

    Table      = dict \
        ( ICQ         = _("First internet-wide instant messaging service")
        , IRC         = _("Internet relay chat")
        , XMPP        = _
            ( "Extensible messaging and presence protocol; used by Jabber "
              "and Google Talk"
            )
        )
Esempio n. 21
0
class Starts_With(_String_):
    """Attribute query for starts-with."""

    desc          = _ \
        ( "Select entities where the attribute value starts "
          "with the specified value"
        )
    op_fct = _("STARTSWITH")
Esempio n. 22
0
class Ends_With(_String_):
    """Attribute query for ends-with."""

    desc          = _ \
        ( "Select entities where the attribute value ends "
          "with the specified value"
        )
    op_fct = _("ENDSWITH")
Esempio n. 23
0
        class role(A_String):
            """Role of crew member."""

            kind = Attr.Optional
            example = _("trimmer")
            max_length = 32

            completer = Attr.Completer_Spec(1)
Esempio n. 24
0
        class desc(A_String):
            """Description of %(ui_name.lower ())s."""

            kind = Attr.Optional
            max_length = 160
            ui_name = _("Description")

            completer = Attr.Completer_Spec(1)
Esempio n. 25
0
 def _auto_doc(cls, attrs, kw):
     """Auto-compute docstring for predicate over `attrs`."""
     return  \
         ( _ ("The attribute values for %s must be %s for each object")
         % ( portable_repr (attrs) if len (attrs) > 1
               else portable_repr (attrs [0])
           , cls.Kind_Cls.typ
           )
         )
Esempio n. 26
0
File: Type.py Progetto: Tapyr/tapyr
 def _auto_doc (cls, attrs, kw) :
     """Auto-compute docstring for predicate over `attrs`."""
     return  \
         ( _ ("The attribute values for %s must be %s for each object")
         % ( portable_repr (attrs) if len (attrs) > 1
               else portable_repr (attrs [0])
           , cls.Kind_Cls.typ
           )
         )
Esempio n. 27
0
class Create(_Action_):

    description = _("Create a new %(tn)s")
    icon = "plus-circle"
    template_macro = "action_button_create"

    @Once_Property
    @getattr_safe
    def href(self):
        return self.resource.href_create()
Esempio n. 28
0
        class desc(A_String):
            """Short description of the link"""

            kind = Attr.Optional
            Kind_Mixins = (Attr.Computed_Set_Mixin, )
            max_length = 20
            ui_name = _("Description")

            completer = Attr.Completer_Spec(1)

            def computed(self, obj):
                return getattr(obj.right, self.name, "")
Esempio n. 29
0
 def _checkers(self, e_type, kind):
     for c in self.__super._checkers(e_type, kind):
         yield c
     if self.not_in_future:
         name = self.name
         p_name = "%s__not_in_future" % name
         check  = MOM.Pred.Condition.__class__ \
             ( p_name, (MOM.Pred.Condition, )
             , dict
                 ( assertion  = "%s <= now" % (name, )
                 , attributes = (name, )
                 , bindings   = dict
                     ( now    = "Q.%s.NOW" % (self.Q_Name, )
                     )
                 , kind       = MOM.Pred.Object
                 , name       = p_name
                 , __doc__    = _ ("Value must not be in the future")
                 )
             )
         yield check
     if self.not_in_past:
         name = self.name
         p_name = "%s__not_in_past" % name
         check  = MOM.Pred.Condition.__class__ \
             ( p_name, (MOM.Pred.Condition, )
             , dict
                 ( assertion  = "%s >= now" % (name, )
                 , attributes = (name, )
                 , bindings   = dict
                     ( now    = "Q.%s.NOW" % (self.Q_Name, )
                     )
                 , guard      = "not playback_p"
                 , guard_attr = ("playback_p", )
                 , kind       = MOM.Pred.Object_Init
                 , name       = p_name
                 , __doc__    =
                     _ ("Value must be in the future, not the past")
                 )
             )
         yield check
Esempio n. 30
0
 def _checkers (self, e_type, kind) :
     for c in self.__super._checkers (e_type, kind) :
         yield c
     if self.not_in_future :
         name   = self.name
         p_name = "%s__not_in_future" % name
         check  = MOM.Pred.Condition.__class__ \
             ( p_name, (MOM.Pred.Condition, )
             , dict
                 ( assertion  = "%s <= now" % (name, )
                 , attributes = (name, )
                 , bindings   = dict
                     ( now    = "Q.%s.NOW" % (self.Q_Name, )
                     )
                 , kind       = MOM.Pred.Object
                 , name       = p_name
                 , __doc__    = _ ("Value must not be in the future")
                 )
             )
         yield check
     if self.not_in_past :
         name   = self.name
         p_name = "%s__not_in_past" % name
         check  = MOM.Pred.Condition.__class__ \
             ( p_name, (MOM.Pred.Condition, )
             , dict
                 ( assertion  = "%s >= now" % (name, )
                 , attributes = (name, )
                 , bindings   = dict
                     ( now    = "Q.%s.NOW" % (self.Q_Name, )
                     )
                 , guard      = "not playback_p"
                 , guard_attr = ("playback_p", )
                 , kind       = MOM.Pred.Object_Init
                 , name       = p_name
                 , __doc__    =
                     _ ("Value must be in the future, not the past")
                 )
             )
         yield check
Esempio n. 31
0
 def __init__ \
         (self, e_type, needed, missing, epk, kw, kind = _("required")) :
     kw  = dict   (kw)
     raw = kw.pop ("raw", False)
     self.__super.__init__ (e_type, raw)
     self.attributes = missing
     self.epk        = epk
     self.e_type     = e_type
     self.kind       = kind
     self.kw         = kw
     self.missing    = missing
     self.needed     = needed
     self.val_disp   = kw
     self.args       = (self.head, self.description)
Esempio n. 32
0
File: Error.py Progetto: Tapyr/tapyr
 def __init__ \
         (self, e_type, needed, missing, epk, kw, kind = _("required")) :
     kw  = dict   (kw)
     raw = kw.pop ("raw", False)
     self.__super.__init__ (e_type, raw)
     self.attributes = missing
     self.epk        = epk
     self.e_type     = e_type
     self.kind       = kind
     self.kw         = kw
     self.missing    = missing
     self.needed     = needed
     self.val_disp   = kw
     self.args       = (self.head, self.description)
Esempio n. 33
0
        class sn(A_Numeric_String):
            """Subscriber number (without country code, network destination code, extension)"""

            kind = Attr.Primary_Optional
            max_length = 14
            min_length = 3
            check = ("value != '0'", )
            example = "234567"
            rank = 3
            ui_name = _("Subscriber number")
            ui_rank = -3

            completer = Attr.Completer_Spec(1, Attr.Selector.primary)
            polisher = PAP.E164.Polisher.SN()
Esempio n. 34
0
class A_DNS_Time(_A_Unit_, _A_Int_):
    """ Allow specification of DNS times in other units than seconds """

    typ = _("DNS Time")
    needs_raw_value = True
    min_value = 0
    max_value = 2147483647
    _unit_dict      = dict \
        ( seconds   = 1
        , minutes   = 60
        , hours     = 60 * 60
        , days      = 60 * 60 * 24
        , weeks     = 60 * 60 * 24 * 7
        )
Esempio n. 35
0
class A_Time_Delta(A_Attr_Type):
    """Time delta value."""

    example = "1 h"
    completer = MOM.Attr.Completer_Spec(0)
    typ = _("Time-Delta")
    P_Type = datetime.timedelta
    Pickler = Pickler_As_String
    syntax         = _ \
        ( "hh:mm:ss, the seconds `ss` are optional\n"
          "One can also use values like::\n"
          "    30m"
          "    20 minutes"
          "    1.5h10.25m7.125s"
          "    1.5 hours 10.25 minutes 7.125 seconds"
          "    1.5 hours, 10.25 minutes, 7.125 seconds"
        )

    @TFL.Meta.Class_and_Instance_Method
    def cooked(soc, value):
        if value is not None:
            msg = "%s expected, got %r" % (soc.typ, value)
            if isinstance(value, pyk.string_types):
                try:
                    value = CAL.Time_Delta.from_string(value)._body
                except ValueError:
                    raise MOM.Error.Attribute_Syntax(None, soc, value, msg)
            elif not isinstance(value, (datetime.timedelta)):
                raise TypeError(msg)
            return value

    # end def cooked

    @TFL.Meta.Class_and_Instance_Method
    def as_string(soc, value):
        result = ""
        if value is not None:
            result = str(value)
            if result.endswith(":00"):
                result = result[:-3]
        return result

    # end def as_string

    @TFL.Meta.Class_and_Instance_Method
    def _from_string(soc, s, obj=None):
        s = s.strip()
        if s:
            return soc.cooked(s)
Esempio n. 36
0
File: Field.py Progetto: Tapyr/tapyr
 def _description (self) :
     return _ ("Number of %s belonging to %s")
Esempio n. 37
0
    def iso_7064_mod11_10 (cls, vin) :
        result = 0
        for i in vin :
            result = (((result or 10) * 2) % 11 + int (i)) % 10
        return result == 1
    # end def iso_7064_mod11_10

    @classmethod
    def mod11 (cls, vin) :
        return not (vin % 11)
    # end def mod11

# end class _Country_Rule_

### EU
_Country_Rule_ ( "AT", _ ("Austria"),         r"U\d{8}")
_Country_Rule_ ( "BE", _ ("Belgium"),         r"[01]\d{9}")
_Country_Rule_ ( "BG", _ ("Bulgaria"),        r"\d{9,10}")
_Country_Rule_ ( "CZ", _ ("Czech Republic "), r"\d{8,10}")
_Country_Rule_ ( "DE", _ ("Germany"),         r"\d{9}")
_Country_Rule_ ( "DK", _ ("Denmark"),         r"\d{8}")
_Country_Rule_ ( "EE", _ ("Estland"),         r"\d{9}")
_Country_Rule_ ( "EL", _ ("Greece"),          r"\d{9}")
_Country_Rule_ ( "ES", _ ("Spain"),           r"[A-Z0-9]\d{7}[A-Z0-9]")
_Country_Rule_ ( "FI", _ ("Finland"),         r"\d{8}")
_Country_Rule_ ( "FR", _ ("France"),          r"\d{2}\d{9}"
               , checker = _Country_Rule_.fr_checker
               )
_Country_Rule_ ( "GB", _ ("United Kingdom"),  r"\d{9}(?:\d{3})?")
_Country_Rule_ ( "HR", _ ("Croatia"),         r"\d{11}"
               , checker = _Country_Rule_.iso_7064_mod11_10
Esempio n. 38
0
File: _Test.py Progetto: Tapyr/tapyr
#    Test file which will be parsed.
#
# Revision Dates
#    15-Apr-2010 (MG) Creation
#    10-Oct-2016 (CT) Make Python-3 compatible
#    ««revision-date»»···
# --

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from _TFL.I18N import _, _T, _Tn, Translations, Config
import os

_("Just markup")
print(_T("Markup and translation"))
print(_Tn("Singular", "Plural", 2))

path = os.path.join(os.path.dirname(__file__), "-I18N", "de.mo")
Config.current = Translations(open(path), "messages")

print("_T tests")
print(_T("Just markup"))
print(_T("Markup and translation"))
print(_T("Singular"))
print(_T("Plural"))
print("_Tn tests")
print(_Tn("Singular", "Plural", 0))
print(_Tn("Singular", "Plural", 1))
print(_Tn("Singular", "Plural", 2))
Esempio n. 39
0
File: Roles.py Progetto: Tapyr/tapyr
    return [node], []
# end def _added_role

register_local_role ("added", _added_role)

def _deleted_role (role, rawtext, text, lineno, inliner, options={}, content=[]) :
    cssc = "deleted" if len (rawtext) > 60 else "deleted-inline"
    node = nodes.inline (rawtext, text, classes = [cssc], ** options)
    return [node], []
# end def _deleted_role

register_local_role ("deleted", _deleted_role)

### http://de.wikipedia.org/wiki/Anf%C3%BChrungszeichen#Kodierung
_quot_map = dict \
    ( qd  = (_("\u201C"), _("\u201D")) # ("&ldquo;",  "&rdquo;")
    , qf  = (_("\u2039"), _("\u203A")) # ("&lsaquo;", "&rsaquo;")
    , qg  = (_("«"),      _("»"))      # ("&laquo;",  "&raquo;")
    , qs  = (_("\u2018"), _("\u2019")) # ("&lsquo;",  "&rsquo;")
    )

def _quoted_role \
        (role, rawtext, text, lineno, inliner, options={}, content=[]) :
    ql, qr = _quot_map.get (role) or _quot_map ["qd"]
    text   = "%s%s%s" % (_T (ql), text, _T (qr))
    node   = nodes.inline (rawtext, text, ** options)
    return [node], []
# end def _quoted_role

register_local_role ("q",  _quoted_role)
register_local_role ("qd", _quoted_role)
Esempio n. 40
0
File: Command.py Progetto: FFM/FFG
 def create_top (self, cmd, ** kw) :
     import _GTW._RST._TOP.import_TOP
     import rst_top
     RST = GTW.RST
     TOP = RST.TOP
     auth_r \
         = TOP.MOM.Admin.E_Type._auth_required \
         = TOP.MOM.Admin.Group._auth_required \
         = cmd.auth_required
     result = rst_top.create (cmd, ** kw)
     result.add_entries \
         ( RST_addons.Dashboard
             ( auth_required   = auth_r
             , pid             = "DB"
             )
         , TOP.Page_ReST
             ( name            = "about"
             , short_title     = "Über Funkfeuer"
             , title           = "Über Funkfeuer"
             , page_template_name = "html/dashboard/about.jnj"
             )
         , TOP.Dir
             ( name            = "My-Funkfeuer"
             , short_title     = "My Funkfeuer"
             , auth_required   = auth_r
             , permission      = RST_addons.Login_has_Person
             , entries         =
                 [ RST_addons.User_Node
                     ( name            = "node"
                     )
                 , RST_addons.User_Net_Device
                     ( name            = "device"
                     , short_title     = _T ("Device")
                     )
                 , RST_addons.User_Net_Interface
                     ( name            = "interface"
                     , short_title     = _T ("Interface")
                     )
                 , RST_addons.User_Net_Interface_in_IP_Network
                     ( name            = "interface_in_ip_network"
                     , short_title     = _T ("Interface in Network")
                     , hidden          = True
                     )
                 , RST_addons.User_Wired_Interface
                     ( name            = "wired-interface"
                     , short_title     = _T ("Wired_Interface")
                     )
                 , RST_addons.User_Wireless_Interface
                     ( name            = "wireless-interface"
                     , short_title     = _T ("Wireless_Interface")
                     )
                 , RST_addons.User_Antenna
                     ( name            = "antenna"
                     , short_title     = _T ("Antenna")
                     )
                 , RST_addons.User_Person
                     ( name            = "person"
                     , hidden          = True
                     )
                 , RST_addons.User_Person_has_Address
                     ( name            = "has_address"
                     , hidden          = True
                     )
                 , RST_addons.User_Person_has_Account
                     ( name            = "has_account"
                     , hidden          = True
                     )
                 , RST_addons.User_Person_has_Email
                     ( name            = "has_email"
                     , hidden          = True
                     )
                 , RST_addons.User_Person_has_IM_Handle
                     ( name            = "has_im_handle"
                     , hidden          = True
                     )
                 , RST_addons.User_Person_has_Phone
                     ( name            = "has_phone"
                     , hidden          = True
                     )
                 ]
             )
         , TOP.MOM.Doc.App_Type
             ( name            = "Doc"
             , short_title     = _ ("Model doc")
             , title           = _ ("Documentation for FFG object model")
             )
         , TOP.Alias \
             ( name            = "/Doc/FFG"
             , target          = "/Doc/CNDB"
             , hidden          = True
             )
         , TOP.MOM.Admin.Site
             ( name            = "Admin"
             , short_title     = "Admin"
             , pid             = "Admin"
             , title           = _ ("Administration of FFG node database")
             , head_line       = _ ("Administration of FFG node database")
             , auth_required   = auth_r
             , entries         =
                 [ self.nav_admin_group
                     ( "FFG"
                     , _ ("Administration of node database")
                     , "CNDB"
                     , permission = RST.In_Group ("FFG-admin")
                         if auth_r else None
                     )
                 , self.nav_admin_group
                     ( "PAP"
                     , _ ("Administration of persons/addresses...")
                     , "GTW.OMP.PAP"
                     , permission = RST.In_Group ("FFG-admin")
                         if auth_r else None
                     )
                 , self.nav_admin_group
                     ( _ ("Users")
                     , _ ("Administration of user accounts and groups")
                     , "GTW.OMP.Auth"
                     , permission = RST.Is_Superuser ()
                     )
                 ]
             )
         , GTW.RST.MOM.Scope
             ( name            = "api"
             , auth_required   = auth_r
             , exclude_robots  = True
             , json_indent     = 2
             , pid             = "RESTful"
             )
         , TOP.Page_ReST
             ( name               = "impressum"
             , short_title        = "Impressum"
             , title              = "Impressum"
             , page_template_name = "html/dashboard/static.jnj"
             , src_contents       = impressum_contents
             )
         , GTW.RST.MOM.Doc.App_Type
             ( name            = "api-doc"
             , hidden          = True
             )
         , TOP.Auth
             ( name            = _ ("Auth")
             , pid             = "Auth"
             , short_title     = _ (u"Authorization and Account handling")
             , hidden          = True
             )
         , TOP.L10N
             ( name            = _ ("L10N")
             , short_title     =
               _ (u"Choice of language used for localization")
             , country_map     = dict (de = "AT")
             )
         , TOP.Robot_Excluder ()
         )
     if cmd.debug :
         result.add_entries \
             ( TOP.Console
                 ( name            = "Console"
                 , short_title     = _ ("Console")
                 , title           = _ ("Interactive Python interpreter")
                 , permission      = RST.Is_Superuser ()
                 )
             , RST.Raiser
                 ( name            = "RAISE"
                 , hidden          = True
                 )
             )
     if result.DEBUG :
         scope = result.__dict__.get ("scope", "*not yet created*")
         print ("RST.TOP root created,", scope)
     return result
Esempio n. 41
0
"""

from   __future__  import absolute_import
from   __future__  import division
from   __future__  import print_function
from   __future__  import unicode_literals

from   _CAL                       import CAL
from   _TFL                       import TFL

from   _TFL.I18N                  import _

import _TFL.G8R

Month_Abbrs = TFL.G8R \
    ( [ _("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun")
      , _("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")
      ]
    )

Month_Names = TFL.G8R \
    ( [ _("January"), _("February"), _("March")
      , _("April"),   _("May"),      _("June")
      , _("July"),    _("August"),   _("September")
      , _("October"), _("November"), _("December")
      ]
    )

Months = TFL.G8R (Month_Abbrs.words, Month_Names.words)

Recurrence_Units = TFL.G8R \
Esempio n. 42
0
 def __repr__ (self) :
     return pyk.reprify (_ ("Infinity"))
Esempio n. 43
0
 def create_top (self, cmd, ** kw) :
     import _GTW._RST._TOP.import_TOP
     import rst_top
     RST = GTW.RST
     TOP = RST.TOP
     auth_r \
         = TOP.MOM.Admin.E_Type._auth_required \
         = TOP.MOM.Admin.Group._auth_required \
         = cmd.auth_required
     result = rst_top.create (cmd, ** kw)
     result.add_entries \
         ( TOP.Dir
             ( name            = "My-Funkfeuer"
             , short_title     = "My Funkfeuer"
             , auth_required   = auth_r
             , permission      = RST_addons.Login_has_Person
             , entries         =
                 [ RST_addons.User_Node
                     ( name            = "node"
                     )
                 , RST_addons.User_Net_Device
                     ( name            = "device"
                     , short_title     = _T ("Device")
                     )
                 , RST_addons.User_Wired_Interface
                     ( name            = "wired-interface"
                     , short_title     = _T ("Wired IF")
                     )
                 , RST_addons.User_Wireless_Interface
                     ( name            = "wireless-interface"
                     , short_title     = _T ("Wireless IF")
                      )
                 ]
             )
         , TOP.Page_ReST
             ( name            = "Funkfeuer"
             , short_title     = "Funkfeuer?"
             , title           = "Was ist Funkfeuer?"
             , src_contents    = landing_page
             )
         , TOP.MOM.Doc.App_Type
             ( name            = "Doc"
             , short_title     = _ ("Model doc")
             , title           = _ ("Documentation for FFM object model")
             )
         , TOP.MOM.Admin.Site
             ( name            = "Admin"
             , short_title     = "Admin"
             , pid             = "Admin"
             , title           = _ ("Administration of FFM node database")
             , head_line       = _ ("Administration of FFM node database")
             , auth_required   = auth_r
             , entries         =
                 [ self.nav_admin_group
                     ( "FFM"
                     , _ ("Administration of node database")
                     , "FFM"
                     , permission = RST.In_Group ("FFM-admin")
                         if auth_r else None
                     )
                 , self.nav_admin_group
                     ( "PAP"
                     , _ ("Administration of persons/addresses...")
                     , "GTW.OMP.PAP"
                     , permission = RST.In_Group ("FFM-admin")
                         if auth_r else None
                     )
                 , self.nav_admin_group
                     ( _ ("Users")
                     , _ ("Administration of user accounts and groups")
                     , "GTW.OMP.Auth"
                     , permission = RST.Is_Superuser ()
                     )
                 ]
             )
         , GTW.RST.MOM.Scope
             ( name            = "api"
             , auth_required   = auth_r
             , exclude_robots  = True
             , json_indent     = 2
             )
         , TOP.Auth
             ( name            = _ ("Auth")
             , pid             = "Auth"
             , short_title     = _ (u"Authorization and Account handling")
             , hidden          = True
             )
         , TOP.L10N
             ( name            = _ ("L10N")
             , short_title     =
               _ (u"Choice of language used for localization")
             , country_map     = dict (de = "AT")
             )
         , TOP.Robot_Excluder ()
         )
     if cmd.debug :
         result.add_entries \
             ( TOP.Console
                 ( name            = "Console"
                 , short_title     = _ ("Console")
                 , title           = _ ("Interactive Python interpreter")
                 , permission      = RST.Is_Superuser ()
                 )
             , RST.Raiser
                 ( name            = "RAISE"
                 , hidden          = True
                 )
             )
     if result.DEBUG :
         scope = result.__dict__.get ("scope", "*not yet created*")
         print ("RST.TOP root created, Scope", scope)
     return result
Esempio n. 44
0
File: HTML.py Progetto: Tapyr/tapyr
from   _TFL.pyk                 import pyk
from   _TFL.Regexp              import *
from   _TFL._Meta.Once_Property import Once_Property

import _TFL._Meta.Object
import _TFL.Caller

from   random                   import randrange

_obfuscator_format = """\
<a class="nospam" title="%(need)s">%(text)s</a>\
<b class="nospam" title="%(js_args)s"></b>\
"""

scheme_map = dict \
    ( mailto = _("email address")
    , tel    = _("phone number")
    )

def obfuscated (text) :
    """Return `text` as (slightly) obfuscated Javascript array."""
    result = ",".join \
        ( "%s%+d" % (s, c - s)
        for (c, s) in ((ord (c), randrange (1, 256)) for c in text)
        )
    return result
# end def obfuscated

def _obfuscator (scheme = "mailto") :
    def _rep (match) :
        return _obfuscator_format % dict \