From 7e243936f226f6e26d2b551765b62cddc866776b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 11 Mar 2015 21:21:11 +0100 Subject: [PATCH] fix(traits): finally, we pick up all types HashMap types were missing previously, but now it seems to be picked up quite nicely. Would this mean we do the type-setup correctly, everywhere ? --- gen/youtube3/src/lib.rs | 20 +++++++++++++++++++- src/mako/lib/util.py | 20 +++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index 354dffe352f..4193672655b 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -5035,7 +5035,7 @@ impl ResponseResult for PageInfo {} /// /// This type is not used in any activity, and only used as *part* of another schema. /// -#[derive(Default, Clone)] +#[derive(Default, Clone, RustcEncodable, RustcDecodable)] pub struct ChannelContentDetailsRelatedPlaylists { /// The ID of the playlist that contains the channel"s uploaded videos. Use the videos.insert method to upload new videos and the videos.delete method to delete previously uploaded videos. pub uploads: Option, @@ -5051,7 +5051,25 @@ pub struct ChannelContentDetailsRelatedPlaylists { impl NestedType for ChannelContentDetailsRelatedPlaylists {} impl Part for ChannelContentDetailsRelatedPlaylists {} +impl RequestValue for ChannelContentDetailsRelatedPlaylists {} +impl ResponseResult for ChannelContentDetailsRelatedPlaylists {} +impl cmn::Resource for ChannelContentDetailsRelatedPlaylists {} +impl ChannelContentDetailsRelatedPlaylists { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.uploads.is_some() { r = r + "uploads,"; } + if self.watch_history.is_some() { r = r + "watchHistory,"; } + if self.likes.is_some() { r = r + "likes,"; } + if self.favorites.is_some() { r = r + "favorites,"; } + if self.watch_later.is_some() { r = r + "watchLater,"; } + r.pop(); + r + } +} // ################### diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 0ea2a9c0539..b4e92cfec6e 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -367,7 +367,7 @@ def schema_markers(s, c): used_by.extend(oid.used_by) used_by.extend(oid.parents) # end gather usages - + for sid in ids: activities = c.sta_map.get(sid, dict()) if len(activities) == 0: @@ -616,12 +616,23 @@ def link_used(s, rs): if rs.id not in l: l.append(rs.id) + def append_unique(l, s): + if s not in l: + l.append(s) + return l + all_schemas = deepcopy(schemas) def recurse_properties(prefix, rs, s, parent_ids): assure_list(s, USED_BY) assure_list(s, PARENT).extend(parent_ids) link_used(s, rs) + if is_nested_type_property(s) and 'id' not in s: + s.id = prefix + all_schemas[s.id] = s + rs = s + # end this is already a perfectly valid type + properties = s.get('properties', {rs.id: s}) for pn, p in properties.iteritems(): link_used(p, rs) @@ -634,13 +645,12 @@ def recurse_properties(prefix, rs, s, parent_ids): if 'items' in p: ns.update((k, deepcopy(v)) for k, v in p.items.iteritems()) - recurse_properties(prefix + canonical_type_name(pn), ns, ns, parent_ids + [rs.id]) + recurse_properties(nested_type_name(prefix, pn), ns, ns, append_unique(parent_ids, rs.id)) elif _is_map_prop(p): - # TODO: does this code run ? Why is there a plain prefix - recurse_properties(prefix + canonical_type_name(pn), rs, p.additionalProperties, parent_ids + []) + recurse_properties(nested_type_name(prefix, pn), rs, p.additionalProperties, append_unique(parent_ids, rs.id)) elif 'items' in p: # it's an array - recurse_properties(prefix + canonical_type_name(pn), rs, p.items, parent_ids + []) + recurse_properties(nested_type_name(prefix, pn), rs, p.items, append_unique(parent_ids, rs.id)) # end handle prop itself # end for each property # end utility