@@ -100,66 +100,14 @@ def print_response(response):
100100 'such as <code>playlists.delete()</code>, but it is also ' +
101101 'true for some other methods, such as <code>videos.rate()</code>.' )
102102
103- # Build a resource based on a list of properties given as key-value pairs.
104- # Leave properties with empty values out of the inserted resource.
105- def build_resource (properties ):
106- resource = {}
107- for p in properties :
108- # Given a key like "snippet.title", split into "snippet" and "title", where
109- # "snippet" will be an object and "title" will be a property in that object.
110- prop_array = p .split ('.' )
111- ref = resource
112- for pa in range (0 , len (prop_array )):
113- is_array = False
114- key = prop_array [pa ]
115-
116- # For properties that have array values, convert a name like
117- # "snippet.tags[]" to snippet.tags, and set a flag to handle
118- # the value as an array.
119- if key [- 2 :] == '[]' :
120- key = key [0 :len (key )- 2 :]
121- is_array = True
122-
123- if pa == (len (prop_array ) - 1 ):
124- # Leave properties without values out of inserted resource.
125- if properties [p ]:
126- if is_array :
127- ref [key ] = properties [p ].split (',' )
128- else :
129- ref [key ] = properties [p ]
130- elif key not in ref :
131- # For example, the property is "snippet.title", but the resource does
132- # not yet have a "snippet" object. Create the snippet object here.
133- # Setting "ref = ref[key]" means that in the next time through the
134- # "for pa in range ..." loop, we will be setting a property in the
135- # resource's "snippet" object.
136- ref [key ] = {}
137- ref = ref [key ]
138- else :
139- # For example, the property is "snippet.description", and the resource
140- # already has a "snippet" object.
141- ref = ref [key ]
142- return resource
143-
144- # Remove keyword arguments that are not set
145- def remove_empty_kwargs (** kwargs ):
146- good_kwargs = {}
147- if kwargs is not None :
148- for key , value in kwargs .iteritems ():
149- if value :
150- good_kwargs [key ] = value
151- return good_kwargs
152-
153103def channels_list_by_username (client , ** kwargs ):
154- kwargs = remove_empty_kwargs (** kwargs ) # See full sample for function
155104 response = client .channels ().list (
156105 ** kwargs
157106 ).execute ()
158107
159108 return print_response (response )
160109
161110
162-
163111if __name__ == '__main__' :
164112 # When running locally, disable OAuthlib's HTTPs verification. When
165113 # running in production *do not* leave this option enabled.
0 commit comments