@@ -100,66 +100,14 @@ def print_response(response):
100
100
'such as <code>playlists.delete()</code>, but it is also ' +
101
101
'true for some other methods, such as <code>videos.rate()</code>.' )
102
102
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
-
153
103
def channels_list_by_username (client , ** kwargs ):
154
- kwargs = remove_empty_kwargs (** kwargs ) # See full sample for function
155
104
response = client .channels ().list (
156
105
** kwargs
157
106
).execute ()
158
107
159
108
return print_response (response )
160
109
161
110
162
-
163
111
if __name__ == '__main__' :
164
112
# When running locally, disable OAuthlib's HTTPs verification. When
165
113
# running in production *do not* leave this option enabled.
0 commit comments