From 7816cc81455c1c7a48e84289e176baf25e8480e2 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 10 Mar 2015 16:10:19 +0100 Subject: [PATCH] fix(util): do not degenerate during activity_split First step, next one will actually be keeping that data ... --- src/mako/lib/lib.mako | 2 +- src/mako/lib/schema.mako | 2 +- src/mako/lib/util.py | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index 7a45f3ef65..57ce078280 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -72,7 +72,7 @@ Or specifically ... ```ignore % for an, a in c.sta_map[fr.id].iteritems(): -<% resource, activity = activity_split(an) %>\ +<% category, resource, activity = activity_split(an) %>\ let r = hub.${mangle_ident(resource)}().${mangle_ident(activity)}(...).${api.terms.action}() % endfor ``` diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index b58ef76684..fd76e38e10 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -66,7 +66,7 @@ ${s.get('description', 'There is no detailed description.')} This type is used in activities, which are methods you may call on this type or where this type is involved in. The list links the activity name, along with information about where it is used (one of ${put_and(enclose_in('*', IO_TYPES))}). -${''.join("* [%s](struct.%s.html) (%s)\n" % (activity_split(a)[1], mb_type(*activity_split(a)[:2]), iot and '|'.join(iot) or 'none') +${''.join("* [%s](struct.%s.html) (%s)\n" % (activity_split(a)[2], mb_type(*activity_split(a)[1:3]), iot and '|'.join(iot) or 'none') for a, iot in c.sta_map[s.id].iteritems())} % else: diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index a8fa5a5b0e..e37d0af132 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -350,7 +350,7 @@ def schema_markers(s, c): else: # it should have at least one activity that matches it's type to qualify for the Resource trait for fqan, iot in activities.iteritems(): - if activity_name_to_type_name(activity_split(fqan)[0]).lower() == s.id.lower(): + if activity_name_to_type_name(activity_split(fqan)[1]).lower() == s.id.lower(): res.add('Resource') if IO_RESPONSE in iot: res.add('ResponseResult') @@ -370,10 +370,10 @@ def schema_markers(s, c): # ------------------------- ## @name Activity Utilities # @{ -# return (name, method) +# return (category, name, method) def activity_split(fqan): t = fqan.split('.') - return t[1], '.'.join(t[2:]) + return t[0], t[1], '.'.join(t[2:]) # Shorthand to get a type from parameters of activities def activity_rust_type(p, allow_optionals=True): @@ -387,7 +387,7 @@ def to_fqan(name, resource, method): def activity_name_to_type_name(an): return canonical_type_name(an)[:-1] -# yields (resource, activity, activity_data) +# yields (category, resource, activity, activity_data) def iter_acitivities(c): return ((activity_split(an) + [a]) for an, a in c.fqan_map.iteritems()) @@ -564,7 +564,7 @@ def new_context(resources): # delete: has no response or request # getrating: response is a 'SomethingResult', which is still related to activities name # the latter is used to deduce the resource name - an, _ = activity_split(m.id) + category, an, _ = activity_split(m.id) tn = activity_name_to_type_name(an) info = res.setdefault(tn, dict()) if m.id not in info: @@ -578,7 +578,7 @@ def new_context(resources): sta_map, fqan_map = build_activity_mappings(resources) rta_map = dict() for an in fqan_map: - resource, activity = activity_split(an) + category, resource, activity = activity_split(an) rta_map.setdefault(resource, list()).append(activity) return Context(sta_map, fqan_map, rta_map)