Skip to content

Commit

Permalink
fix(util): do not degenerate during activity_split
Browse files Browse the repository at this point in the history
First step, next one will actually be keeping that data ...
  • Loading branch information
Byron committed Mar 10, 2015
1 parent 1e332dd commit 7816cc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/mako/lib/lib.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion src/mako/lib/schema.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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):
Expand All @@ -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())

Expand Down Expand Up @@ -564,7 +564,7 @@ def build_activity_mappings(activities, res = None, fqan = None):
# 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:
Expand All @@ -578,7 +578,7 @@ def build_activity_mappings(activities, res = None, fqan = None):
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)

Expand Down

0 comments on commit 7816cc8

Please sign in to comment.