コード例 #1
0
ファイル: E_Type_Wrapper.py プロジェクト: xiaochang91/tapyr
 def descendents (self) :
     def _gen (self) :
         for c in self.children :
             yield c
             for d in c.descendents :
                 yield d
     return tuple (uniq (_gen (self)))
コード例 #2
0
 def base_dirs (self) :
     result  = self.__super.base_dirs
     opt_map = self.cmd._opt_map
     cdo     = opt_map.get (self._config_dirs_name)
     if cdo and cdo.base_dirs :
         result = cdo.base_dirs + result
     return tuple (uniq (result))
コード例 #3
0
ファイル: Command.py プロジェクト: nasir733/airbnb-clone
 def base_dirs(self):
     result = self.__super.base_dirs
     opt_map = self.cmd._opt_map
     cdo = opt_map.get(self._config_dirs_name)
     if cdo and cdo.base_dirs:
         result = cdo.base_dirs + result
     return tuple(uniq(result))
コード例 #4
0
ファイル: Completer.py プロジェクト: JPilarr/tapyr
 def elems(self):
     if self.embedder:
         elems = ichain((self.elem, ), self.embedder.entity_p_buddy_elems)
         result = tuple(uniq(elems))
     else:
         result = self.entity_p_buddy_elems
     return result
コード例 #5
0
ファイル: Completer.py プロジェクト: Tapyr/tapyr
 def elems (self) :
     if self.embedder :
         elems  = ichain ((self.elem, ), self.embedder.entity_p_buddy_elems)
         result = tuple  (uniq (elems))
     else :
         result = self.entity_p_buddy_elems
     return result
コード例 #6
0
ファイル: E_Type_Wrapper.py プロジェクト: JPilarr/tapyr
    def descendents(self):
        def _gen(self):
            for c in self.children:
                yield c
                yield from c.descendents

        return tuple(uniq(_gen(self)))
コード例 #7
0
ファイル: Completer.py プロジェクト: Tapyr/tapyr
 def embedded_elems (self) :
     def _gen (self) :
         for e in self.elem.elements :
             c = e.completer
             if c is not None :
                 yield c.embedded_elems
         yield (self.elem, )
     return tuple (uniq (ichain (* _gen (self))))
コード例 #8
0
ファイル: Attr.py プロジェクト: Tapyr/tapyr
 def q_able_names (self) :
     result = self.attr.q_able_names
     if self is not self.eff :
         result = uniq (itertools.chain (result, self.eff.q_able_names))
     prefix = self.prefix
     if prefix :
         result = (".".join ((prefix, name)) for name in result)
     return tuple (sorted (result))
コード例 #9
0
ファイル: Attr.py プロジェクト: JPilarr/tapyr
 def q_able_names(self):
     result = self.attr.q_able_names
     if self is not self.eff:
         result = uniq(itertools.chain(result, self.eff.q_able_names))
     prefix = self.prefix
     if prefix:
         result = (".".join((prefix, name)) for name in result)
     return tuple(sorted(result))
コード例 #10
0
ファイル: M_Link.py プロジェクト: Tapyr/tapyr
 def _m_create_role_children (cls) :
     for role in uniq (cls._role_children_to_add) :
         role = getattr (cls._Attributes, role)
         children = sorted \
             ( pyk.itervalues (role.E_Type.children_np)
             , key = TFL.Getter.i_rank
             )
         for c in children :
             cls._m_create_role_child ((role.name, c))
コード例 #11
0
ファイル: M_Link.py プロジェクト: xiaochang91/tapyr
 def _m_create_role_children(cls):
     for role in uniq(cls._role_children_to_add):
         role = getattr(cls._Attributes, role)
         children = sorted \
             ( pyk.itervalues (role.E_Type.children_np)
             , key = TFL.Getter.i_rank
             )
         for c in children:
             cls._m_create_role_child((role.name, c))
コード例 #12
0
ファイル: Completer.py プロジェクト: JPilarr/tapyr
    def embedded_elems(self):
        def _gen(self):
            for e in self.elem.elements:
                c = e.completer
                if c is not None:
                    yield c.embedded_elems
            yield (self.elem, )

        return tuple(uniq(ichain(*_gen(self))))
コード例 #13
0
ファイル: E_Type_Wrapper.py プロジェクト: xiaochang91/tapyr
 def ancestors (self) :
     def _gen (self) :
         p = self.parent
         if p :
             if p.sa_table is not None :
                 yield p
             for a in p.ancestors :
                 yield a
     return tuple (uniq (_gen (self)))
コード例 #14
0
ファイル: Completer.py プロジェクト: Tapyr/tapyr
 def entity_p_buddy_elems (self) :
     result = self.own_elems
     if self.entity_p :
         def _gen (self) :
             yield self.own_elems
             for e in self.anchor.elements :
                 c = e.completer
                 if c is not None and c.entity_p :
                     yield c.embedded_elems
         result = tuple (uniq (ichain (* _gen (self))))
     return result
コード例 #15
0
ファイル: Completer.py プロジェクト: Tapyr/tapyr
 def own_elems (self) :
     def _gen (self) :
         ep = self.elem.parent
         yield (self.elem, )
         for n in self.attr.completer.names :
             elem = ep.get (n)
             if elem is not None :
                 if elem.completer is not None :
                     yield elem.completer.embedded_elems
                 else :
                     yield (elem, )
     return tuple (uniq (ichain (* _gen (self))))
コード例 #16
0
ファイル: Completer.py プロジェクト: JPilarr/tapyr
    def entity_p_buddy_elems(self):
        result = self.own_elems
        if self.entity_p:

            def _gen(self):
                yield self.own_elems
                for e in self.anchor.elements:
                    c = e.completer
                    if c is not None and c.entity_p:
                        yield c.embedded_elems

            result = tuple(uniq(ichain(*_gen(self))))
        return result
コード例 #17
0
ファイル: Completer.py プロジェクト: JPilarr/tapyr
    def own_elems(self):
        def _gen(self):
            ep = self.elem.parent
            yield (self.elem, )
            for n in self.attr.completer.names:
                elem = ep.get(n)
                if elem is not None:
                    if elem.completer is not None:
                        yield elem.completer.embedded_elems
                    else:
                        yield (elem, )

        return tuple(uniq(ichain(*_gen(self))))
コード例 #18
0
ファイル: deploy.py プロジェクト: xiaochang91/tapyr
 def dynamic_defaults (self, defaults) :
     def _gen_template_dirs (self, defaults) :
         yield self.app_dir
         tpds = defaults.get ("template_package_dirs", ["_JNJ"])
         for tpd in tpds :
             mod = import_module (tpd)
             yield sos.path.dirname (mod.__file__)
     result   = self.__super.dynamic_defaults (defaults)
     combined = dict (defaults, ** result)
     tdirs    = list (combined.get ("template_dirs", ()))
     tdirs.extend  (_gen_template_dirs (self, combined))
     result ["template_dirs"] = tuple (uniq (tdirs))
     return result
コード例 #19
0
 def _m_combine_lists(cls, bases, dict):
     for name in cls._lists_to_combine:
         setattr \
             ( cls, name
             , list
                 ( uniq
                     ( itertools.chain
                         ( * (   getattr (c, name, [])
                             for c in reversed ((cls, ) + bases)
                             )
                         )
                     )
                 )
             )
コード例 #20
0
ファイル: M_Auto_Combine_Lists.py プロジェクト: Tapyr/tapyr
 def _m_combine_lists (cls, bases, dict) :
     for name in cls._lists_to_combine :
         setattr \
             ( cls, name
             , list
                 ( uniq
                     ( itertools.chain
                         ( * (   getattr (c, name, [])
                             for c in reversed ((cls, ) + bases)
                             )
                         )
                     )
                 )
             )
コード例 #21
0
ファイル: Environment.py プロジェクト: xiaochang91/tapyr
def HTML \
        ( version          = "html/5.jnj"
        , load_path        = ()
        , loader           = None
        , globals          = {}
        , encoding         = "utf-8"
        , i18n             = False
        , Media_Parameters = None
        , GTW              = None
        , prefixes         = {}
        , ** kw
        ) :
    jnj_loader = FileSystemLoader (sos.path.dirname (__file__), "utf-8")
    loaders    = []
    if loader :
        loaders.append (loader)
    if load_path :
        loaders.append (FileSystemLoader (load_path, encoding))
    loaders.append (jnj_loader)
    if prefixes :
        sk = lambda x : (- len (x [1]), x [1])
        for prefix, lp in sorted (pyk.iteritems (prefixes), key = sk) :
            loaders.append \
                ( PrefixLoader
                   ({prefix : FileSystemLoader (lp, encoding)}, delimiter='::')
                )
    loaders.append (PrefixLoader (dict (STD = jnj_loader), delimiter='::'))
    loader     = ChoiceLoader (loaders)
    extensions = (kw.pop ("extensions", []) + Default_Extensions)
    if i18n :
        extensions.append ("jinja2.ext.i18n")
    result = Environment  \
        ( extensions = uniq (extensions), loader = loader, ** kw)
    if GTW is None :
        GTW = JNJ.GTW (result)
    result.globals.update \
        ( globals
        , GTW          = GTW
        , html_version = version
        )
    result.Media_Parameters = Media_Parameters
    result.encoding         = encoding
    result.static_handler   = None
    if i18n :
        result.install_gettext_translations (TFL.I18N)
    return result
コード例 #22
0
 def _effective_prop_kind_mixins(self, name, kind, prop_type, e_type):
     result = self.__super._effective_prop_kind_mixins \
         (name, kind, prop_type, e_type)
     if prop_type.needs_raw_value and not kind.electric:
         result += (MOM.Attr._Raw_Value_Mixin_, )
     if prop_type.auto_up_depends:
         MI = \
             ( MOM.Attr._Auto_Update_Lazy_Mixin_
             if   (MOM.Attr.Computed_Set_Mixin in result)
             else MOM.Attr._Auto_Update_Mixin_
             )
         result += (MI, )
     if isinstance(e_type, MOM.Meta.M_E_Type_An):
         result = (MOM.Attr._Nested_Mixin_, ) + result
     if MOM.Attr.Computed_Mixin in result:
         result = tuple(r for r in result if r != MOM.Attr.Sticky_Mixin)
     result = prop_type.Kind_Mixins_X + result
     return tuple(uniq(result))
コード例 #23
0
ファイル: M_Auto_Update_Combined.py プロジェクト: Tapyr/tapyr
 def _m_update_combine (cls, bases, dct) :
     def _gen (cls, bases, name) :
         undef = update_combined_many.Undef
         for c in reversed ((cls, ) + bases) :
             yield getattr (c, name, undef)
     for name in cls._attrs_to_update_combine :
         try :
             v = update_combined_many (* _gen (cls, bases, name))
         except Exception as exc :
             print \
                 ( "*** Exception when trying to update/combined", name
                 , "for class", cls
                 )
             raise
         setattr (cls, name, v)
     for name in cls._attrs_uniq_to_update_combine :
         v = update_combined_many (* _gen (cls, bases, name))
         setattr (cls, name, v.__class__ (uniq (v)))
コード例 #24
0
ファイル: Spec.py プロジェクト: Tapyr/tapyr
 def _effective_prop_kind_mixins (self, name, kind, prop_type, e_type) :
     result = self.__super._effective_prop_kind_mixins \
         (name, kind, prop_type, e_type)
     if prop_type.needs_raw_value and not kind.electric :
         result += (MOM.Attr._Raw_Value_Mixin_, )
     if prop_type.auto_up_depends :
         MI = \
             ( MOM.Attr._Auto_Update_Lazy_Mixin_
             if   (MOM.Attr.Computed_Set_Mixin in result)
             else MOM.Attr._Auto_Update_Mixin_
             )
         result += (MI, )
     if isinstance (e_type, MOM.Meta.M_E_Type_An) :
         result = (MOM.Attr._Nested_Mixin_, ) + result
     if MOM.Attr.Computed_Mixin in result :
         result = tuple (r for r in result if r != MOM.Attr.Sticky_Mixin)
     result = prop_type.Kind_Mixins_X + result
     return tuple (uniq (result))
コード例 #25
0
ファイル: Selector.py プロジェクト: Tapyr/tapyr
 def names (self) :
     def _gen (self) :
         selector = self.selector
         skip_pat = self.name_skip_pat
         trigger  = self.trigger
         try :
             f = selector [trigger]
         except KeyError :
             logging.warning \
                 ( "Unknown trigger attribute %s for %r"
                 % (trigger, selector)
                 )
         else :
             yield f.name
         for f in selector.atoms :
             n = f.name
             if not skip_pat.match (n) :
                 yield n
     return tuple (uniq (_gen (self)))
コード例 #26
0
ファイル: Ticker.py プロジェクト: JPilarr/tapyr
 def __init__ \
         ( self, base
         , deltas           = None
         , log_round_amount = None
         , scale            = 0
         , ** kwds
         ) :
     self.base   = base
     self.deltas = \
         ( None if deltas is None else sorted
             (uniq (itertools.chain (deltas, ([] if scale else [1, base]))))
         )
     self.lra    = log_round_amount
     self.scale  = scale
     self._kwds  = kwds
     self.pop_to_self     (kwds, "base_deltas")
     self.__dict__.update (kwds)
     if base == 10 :
         self.log = log10
コード例 #27
0
ファイル: Ticker.py プロジェクト: Tapyr/tapyr
 def __init__ \
         ( self, base
         , deltas           = None
         , log_round_amount = None
         , scale            = 0
         , ** kwds
         ) :
     self.base   = base
     self.deltas = \
         ( None if deltas is None else sorted
             (uniq (itertools.chain (deltas, ([] if scale else [1, base]))))
         )
     self.lra    = log_round_amount
     self.scale  = scale
     self._kwds  = kwds
     self.pop_to_self     (kwds, "base_deltas")
     self.__dict__.update (kwds)
     if base == 10 :
         self.log = log10
コード例 #28
0
    def _m_update_combine(cls, bases, dct):
        def _gen(cls, bases, name):
            undef = update_combined_many.Undef
            for c in reversed((cls, ) + bases):
                yield getattr(c, name, undef)

        for name in cls._attrs_to_update_combine:
            try:
                v = update_combined_many(*_gen(cls, bases, name))
            except Exception as exc:
                print \
                    ( "*** Exception when trying to update/combined", name
                    , "for class", cls
                    )
                raise
            setattr(cls, name, v)
        for name in cls._attrs_uniq_to_update_combine:
            v = update_combined_many(*_gen(cls, bases, name))
            setattr(cls, name, v.__class__(uniq(v)))
コード例 #29
0
ファイル: Selector.py プロジェクト: xiaochang91/tapyr
    def names(self):
        def _gen(self):
            selector = self.selector
            skip_pat = self.name_skip_pat
            trigger = self.trigger
            try:
                f = selector[trigger]
            except KeyError:
                logging.warning \
                    ( "Unknown trigger attribute %s for %r"
                    % (trigger, selector)
                    )
            else:
                yield f.name
            for f in selector.atoms:
                n = f.name
                if not skip_pat.match(n):
                    yield n

        return tuple(uniq(_gen(self)))
コード例 #30
0
ファイル: Error.py プロジェクト: Tapyr/tapyr
 def finish (self) :
     if self._wrapped_errors is None :
         ### keep only those error instances that are lowest-rank for
         ### each and every of their `attributes`
         raw_errors = self._raw_errors
         arm = defaultdict_rank ()
         for e in raw_errors :
             try :
                 attrs = e.attributes
             except AttributeError :
                 pass
             else :
                 for a in attrs :
                     arm [a] = min (e.rank, arm [a])
                 e.__keep = all ((arm [a] == e.rank) for a in attrs)
         errors = dusplit (raw_errors, Q.__keep) [-1]
         ### wrap the filtered error instances
         entity = self.entity
         wrapped_errors = self._wrapped_errors = sorted \
             ( (Wrapper (entity, error) for error in uniq (errors))
             , key = Q.po_index
             )
         for i, w in enumerate (wrapped_errors) :
             w.index = i
コード例 #31
0
ファイル: Error.py プロジェクト: JPilarr/tapyr
 def finish(self):
     if self._wrapped_errors is None:
         ### keep only those error instances that are lowest-rank for
         ### each and every of their `attributes`
         raw_errors = self._raw_errors
         arm = defaultdict_rank()
         for e in raw_errors:
             try:
                 attrs = e.attributes
             except AttributeError:
                 pass
             else:
                 for a in attrs:
                     arm[a] = min(e.rank, arm[a])
                 e.__keep = all((arm[a] == e.rank) for a in attrs)
         errors = dusplit(raw_errors, Q.__keep)[-1]
         ### wrap the filtered error instances
         entity = self.entity
         wrapped_errors = self._wrapped_errors = sorted \
             ( (Wrapper (entity, error) for error in uniq (errors))
             , key = Q.po_index
             )
         for i, w in enumerate(wrapped_errors):
             w.index = i
コード例 #32
0
 def names (self) :
     return tuple (uniq ((self.name, ) + self.polisher.buddies))
コード例 #33
0
ファイル: Def_Map.py プロジェクト: Tapyr/tapyr
 def _of_bases (self, cls) :
     result = TFL.defaultdict (list)
     for b in reversed (cls.__bases__) :
         for k, cs in pyk.iteritems (self.of_class (b)) :
             result [k] = list (uniq (ichain (result [k], cs)))
     return result
コード例 #34
0
ファイル: To_Html.py プロジェクト: Tapyr/tapyr
 def add_replacers (self, * replacers) :
     self.replacers = list \
         (uniq (itertools.chain (self.replacers, replacers)))
コード例 #35
0
ファイル: Selector.py プロジェクト: Tapyr/tapyr
 def attrs (self) :
     return tuple (uniq (itertools.chain (* (s.attrs for s in self.sels))))
コード例 #36
0
ファイル: Selector.py プロジェクト: xiaochang91/tapyr
 def attrs(self):
     return tuple(uniq(itertools.chain(*(s.attrs for s in self.sels))))
コード例 #37
0
ファイル: Def_Map.py プロジェクト: xiaochang91/tapyr
 def _of_bases(self, cls):
     result = TFL.defaultdict(list)
     for b in reversed(cls.__bases__):
         for k, cs in pyk.iteritems(self.of_class(b)):
             result[k] = list(uniq(ichain(result[k], cs)))
     return result
コード例 #38
0
ファイル: To_Html.py プロジェクト: xiaochang91/tapyr
 def add_replacers(self, *replacers):
     self.replacers = list \
         (uniq (itertools.chain (self.replacers, replacers)))