def wsdl_call(self, method, *args, **kwargs): "Pre and post process SOAP call, input and output parameters using WSDL" soap_uri = soap_namespaces[self.__soap_ns] operation = self.get_operation(method) # get i/o type declarations: input = operation['input'] output = operation['output'] header = operation.get('header') if 'action' in operation: self.action = operation['action'] # construct header and parameters if header: self.__call_headers = sort_dict(header, self.__headers) if input and args: # convert positional parameters to named parameters: d = [(k, arg) for k, arg in zip(input.values()[0].keys(), args)] kwargs.update(dict(d)) if input and kwargs: params = sort_dict(input.values()[0], kwargs).items() if self.__soap_server == "axis": # use the operation name method = method else: # use the message (element) name method = input.keys()[0] #elif not input: #TODO: no message! (see wsmtxca.dummy) else: params = kwargs and kwargs.items() # call remote procedure response = self.call(method, *params) # parse results: resp = response('Body', ns=soap_uri).children().unmarshall(output) return resp and resp.values()[0] # pass Response tag children
def wsdl_call(self, method, *args, **kwargs): "Pre and post process SOAP call, input and output parameters using WSDL" soap_uri = soap_namespaces[self.__soap_ns] operation = self.get_operation(method) # get i/o type declarations: input = operation["input"] output = operation["output"] header = operation.get("header") if "action" in operation: self.action = operation["action"] # construct header and parameters if header: self.__call_headers = sort_dict(header, self.__headers) if input and args: # convert positional parameters to named parameters: d = [(k, arg) for k, arg in zip(input.values()[0].keys(), args)] kwargs.update(dict(d)) if input and kwargs: params = sort_dict(input.values()[0], kwargs).items() if self.__soap_server == "axis": # use the operation name method = method else: # use the message (element) name method = input.keys()[0] # elif not input: # TODO: no message! (see wsmtxca.dummy) else: params = kwargs and kwargs.items() # call remote procedure response = self.call(method, *params) # parse results: resp = response("Body", ns=soap_uri).children().unmarshall(output) return resp and resp.values()[0] # pass Response tag children
def get_nucleotide_counts(dna_sequence): nucleotide_counts = {"A": 0, "G": 0, "T": 0, "C": 0} my_seq = Seq(dna_sequence) for key in list(nucleotide_counts.keys()): nucleotide_counts[key] = my_seq.count(key) return sort_dict(nucleotide_counts)
if __name__ == '__main__': streamer_list = ['a', 'b', 'c'] user_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'] users = {} # Generate streamer followers/followees for user in user_list: new_user = User(user, pick_random(user, user_list), pick_random(user, user_list)) users[user] = new_user # Determine follower weight for user in users: users[user].follow_weight = (len(user_list) - len(users[user].followers)) / len(user_list) users[user].describe() # Calculate connections for user in streamer_list: users[user].find_connections(users) users[user].score_connections(users) print('----------------------') user = users['b'] print(user.connections) print(user.counts) print(sort_dict(user.scores, True))