code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
for handler in _handlers: handler.comicDownloaded(comic, filename, text=text)
def comicDownloaded(self, comic, filename, text=None)
Emit comic downloaded events for handlers.
5.095356
3.803852
1.339525
for handler in _handlers: handler.comicPageLink(comic, url, prevUrl)
def comicPageLink(self, comic, url, prevUrl)
Emit an event to inform the handler about links between comic pages. Should be overridden in subclass.
5.387521
4.195662
1.28407
"Pack a series of arguments into a value Redis command" result = [] result.append("*") result.append(str(len(args))) result.append(DELIMITER) for arg in args: result.append("$") result.append(str(len(arg))) result.append(DELIMITER) result.append(arg) resul...
def encode(*args)
Pack a series of arguments into a value Redis command
3.750191
2.58083
1.453095
if not namespace: namespace = self.NAMESPACE req_name = name+'Request' resp_name = name+'Response' req = pythonzimbra.request_xml.RequestXml() resp = pythonzimbra.response_xml.ResponseXml() if self._session.is_logged_in(): req.set_auth_t...
def request(self, name, content={}, namespace=None)
Do a SOAP request and returns the result. Simple wrapper arround pythonzimbra functions :param name: ex: 'Auth' for performing an 'AuthRequest' :param content: a dict formatted pythonzimbra-style for request :param namespace: (optional), the namespace, if different from the ...
3.521888
3.458228
1.018408
resp = self.request(name, content) # We stop on the first non-attribute (attributes are unicode/str) # If it's a list, we only return the first one. for i in resp.values(): if type(i) == list: return i[0] elif type(i) == dict: ...
def request_single(self, name, content={})
Simple wrapper arround request to extract a single response :returns: the first tag in the response body
5.634871
5.992559
0.940311
domain_name = zobjects.Account(name=login).get_domain() preauth_key = parent_zc.get_domain(domain_name)['zimbraPreAuthKey'] rc = self.REST_PREAUTH( self._server_host, parent_zc._server_port, preauth_key=preauth_key) authToken = rc.get_preauth_token(login) ...
def get_logged_in_by(self, login, parent_zc, duration=0)
Use another client to get logged in via preauth mechanism by an already logged in admin. It required the domain of the admin user to have preAuthKey The preauth key cannot be created by API, do it with zmprov : zmprov gdpak <domain>
7.001611
6.479783
1.080532
# a duration of zero is interpretted literaly by the API... selector = zobjects.Account(name=login).to_selector() delegate_args = {'account': selector} if duration: delegate_args['duration': duration] resp = admin_zc.request('DelegateAuth', delegate_args) ...
def delegated_login(self, login, admin_zc, duration=0)
Use another client to get logged in via delegated_auth mechanism by an already logged in admin. :param admin_zc: An already logged-in admin client :type admin_zc: ZimbraAdminClient :param login: the user login (or email) you want to log as
8.036424
9.537064
0.842652
params = {} if grantee_type: if 'grantee' not in params.keys(): params['grantee'] = {} params['grantee'].update({'type': grantee_type}) if grantee_id: if 'grantee' not in params.keys(): params['grantee'] = {} ...
def get_share_info(self, grantee_type=None, grantee_id=None, grantee_name=None, owner=None, owner_type='name')
:returns: list of dict representing shares informations
2.147166
2.114115
1.015633
s = zobjects.Signature(name=name) s.set_content(content, contenttype) resp = self.request('CreateSignature', {'signature': s.to_creator()}) return zobjects.Signature.from_dict(resp['signature'])
def create_signature(self, name, content, contenttype="text/html")
:param: name verbose name of the signature :param: content content of the signature, in html or plain-text :param: contenttype can be "text/html" (default) or "text/plain" :returns: a zobjects.Signature object
5.701128
4.894812
1.164729
signatures = self.request_list('GetSignatures') return [zobjects.Signature.from_dict(i) for i in signatures]
def get_signatures(self)
Get all signatures for the current user :returns: a list of zobjects.Signature
11.606866
7.613791
1.524453
resp = self.request_list('GetSignatures') # GetSignature does not allow to filter the results, so we do it by # hand... if resp and (len(resp) > 0): for sig_dict in resp: sig = zobjects.Signature.from_dict(sig_dict) if hasattr(signatu...
def get_signature(self, signature)
Retrieve one signature, discriminated by name or id. Note that signature name is not case sensitive. :param: a zobjects.Signature describing the signature like "Signature(name='my-sig')" :returns: a zobjects.Signature object, filled with the signature if no sig...
4.649
3.94328
1.178968
# if no content is specified, just use a selector (id/name) dic = signature.to_creator(for_modify=True) self.request('ModifySignature', {'signature': dic})
def modify_signature(self, signature)
Modify an existing signature Can modify the content, contenttype and name. An unset attribute will not delete the attribute but leave it untouched. :param: signature a zobject.Signature object, with modified content/contentype/name, the id should be present and ...
25.699062
21.96167
1.170178
pref_list = self.request('GetPrefs')['pref'] out = {} for pref in pref_list: out[pref['name']] = utils.auto_type(pref['_content']) return out
def get_preferences(self)
Gets all the preferences of the current user :returns: a dict presenting the preferences by name, values are typed to str/bool/int/float regarding their content.
7.660363
7.882161
0.971861
resp = self.request_single('GetPrefs', {'pref': {'name': pref_name}}) return utils.auto_type(resp['_content'])
def get_preference(self, pref_name)
Gets a single named preference :returns: the value, typed to str/bool/int/float regarding its content.
13.310015
12.709838
1.047221
params = { 'name': name, 'a': attrs } resp = self.request('CreateIdentity', {'identity': params}) return zobjects.Identity.from_dict(resp['identity'])
def create_identity(self, name, attrs=[])
Create an Identity :param: name identity name :param: attrs list of dict of attributes (zimsoap format) :returns: a zobjects.Identity object
5.364693
4.652143
1.153166
resp = self.request('GetIdentities') if 'identity' in resp: identities = resp['identity'] if type(identities) != list: identities = [identities] if identity or attrs: wanted_identities = [] for u_identity in ...
def get_identities(self, identity=None, attrs=None)
Get identities matching name and attrs of the user, as a list :param: zobjects.Identity or identity name (string) :param: attrs dict of attributes to return only identities matching :returns: list of zobjects.Identity
2.520367
2.389257
1.054875
if isinstance(identity, zobjects.Identity): self.request('ModifyIdentity', {'identity': identity._full_data}) return self.get_identities(identity=identity.name)[0] else: attrs = [] for attr, value in kwargs.items(): attrs.append({...
def modify_identity(self, identity, **kwargs)
Modify some attributes of an identity or its name. :param: identity a zobjects.Identity with `id` set (mandatory). Also set items you want to modify/set and/or the `name` attribute to rename the identity. Can also take the name in string and then attributes to modif...
3.723984
3.09631
1.202717
if isinstance(identity, zobjects.Identity): self.request( 'DeleteIdentity', {'identity': identity.to_selector()}) else: self.request('DeleteIdentity', {'identity': {'name': identity}})
def delete_identity(self, identity)
Delete an identity from its name or id :param: a zobjects.Identity object with name or id defined or a string of the identity's name
6.154145
4.35518
1.413063
try: return zobj.id except AttributeError: try: return fetch_func(zobj).id except AttributeError: raise ValueError('Unqualified Resource')
def _get_or_fetch_id(self, zobj, fetch_func)
Returns the ID of a Zobject wether it's already known or not If zobj.id is not known (frequent if zobj is a selector), fetches first the object and then returns its ID. :type zobj: a zobject subclass :type fetch_func: the function to fetch the zobj from server if its id ...
5.383122
5.845417
0.920913
selector = cal_resource.to_selector() resp = self.request_single('GetCalendarResource', {'calresource': selector}) return zobjects.CalendarResource.from_dict(resp)
def get_calendar_resource(self, cal_resource)
Fetches an calendar resource with all its attributes. :param account: a CalendarResource, with either id or name attribute set. :returns: a CalendarResource object, filled.
8.821976
9.523033
0.926383
args = { 'name': name, 'a': [{'n': k, '_content': v} for k, v in attrs.items()] } if password: args['password'] = password resp = self.request_single('CreateCalendarResource', args) return zobjects.CalendarResource.from_dict(resp)
def create_calendar_resource(self, name, password=None, attrs={})
:param: attrs a dict of attributes, must specify the displayName and zimbraCalResType
4.422123
3.824728
1.156193
attrs = [{'n': k, '_content': v} for k, v in attrs.items()] self.request('ModifyCalendarResource', { 'id': self._get_or_fetch_id( calres, self.get_calendar_resource), 'a': attrs })
def modify_calendar_resource(self, calres, attrs)
:param calres: a zobjects.CalendarResource :param attrs: a dictionary of attributes to set ({key:value,...})
5.723836
6.492294
0.881635
resp = self.request('RenameCalendarResource', { 'id': self._get_or_fetch_id(r_description, self.get_calendar_resource), 'newName': new_r_name }) return zobjects.CalendarResource.from_dict(resp['calresource'])
def rename_calendar_resource(self, r_description, new_r_name)
:param r_description : a CalendarResource specifying either : - id: the ressource ID - r_description: the name of the ressource :param new_r_name: new name of the list :return: a zobjects.CalendarResource
5.133021
4.377984
1.172462
resp = self.request_single('GetMailboxStats') ret = {} for k, v in resp.items(): ret[k] = int(v) return ret
def get_mailbox_stats(self)
Get global stats about mailboxes Parses <stats numMboxes="6" totalSize="141077"/> :returns: dict with stats
4.775377
4.97627
0.95963
selector = domain.to_selector() cos_list = self.request_list('CountAccount', {'domain': selector}) ret = [] for i in cos_list: count = int(i['_content']) ret.append((zobjects.ClassOfService.from_dict(i), count)) return list(ret)
def count_account(self, domain)
Count the number of accounts for a given domain, sorted by cos :returns: a list of pairs <ClassOfService object>,count
10.002193
7.706672
1.297862
selector = zobjects.Mailbox(id=account_id).to_selector() resp = self.request_single('GetMailbox', {'mbox': selector}) return zobjects.Mailbox.from_dict(resp)
def get_account_mailbox(self, account_id)
Returns a Mailbox corresponding to an account. Usefull to get the size (attribute 's'), and the mailbox ID, returns nothing appart from that.
8.82737
8.263121
1.068285
resp = self.request( 'GetAccountInfo', {'account': account.to_selector()}) return zobjects.COS.from_dict(resp['cos'])
def get_account_cos(self, account)
Fetch the cos for a given account Quite different from the original request which returns COS + various URL + COS + zimbraMailHost... But all other informations are accessible through get_account. :type account: zobjects.Account :rtype: zobjects.COS
11.178549
6.761755
1.653202
args = {'name': name} resp = self.request_single('CreateDomain', args) return zobjects.Domain.from_dict(resp)
def create_domain(self, name)
:param name: A string, NOT a zObject :return: a zobjects.Domain
9.211156
5.810049
1.585384
attrs = [{'n': k, '_content': v} for k, v in attrs.items()] self.request('ModifyDomain', { 'id': self._get_or_fetch_id(domain, self.get_domain), 'a': attrs })
def modify_domain(self, domain, attrs)
:type domain: a zobjects.Domain :param attrs: attributes to modify :type attrs dict
5.643227
7.945611
0.710232
self.request('AddDistributionListAlias', { 'id': self._get_or_fetch_id( distribution_list, self.get_distribution_list ), 'alias': alias, })
def add_distribution_list_alias(self, distribution_list, alias)
:param distribution_list: a distribution list object to be used as a selector :param alias: email alias address :returns: None (the API itself returns nothing)
5.918545
6.007786
0.985146
self.request('RemoveDistributionListAlias', { 'id': self._get_or_fetch_id( distribution_list, self.get_distribution_list ), 'alias': alias, })
def remove_distribution_list_alias(self, distribution_list, alias)
:param distribution_list: an distribution list object to be used as a selector :param alias: email alias address :returns: None (the API itself returns nothing)
5.385342
5.307411
1.014683
selector = dl_description.to_selector() resp = self.request_single('GetDistributionList', {'dl': selector}) dl = zobjects.DistributionList.from_dict(resp) return dl
def get_distribution_list(self, dl_description)
:param: dl_description : a DistributionList specifying either : - id: the account_id - name: the name of the list :returns: the DistributionList
8.628439
8.292565
1.040503
attrs = [{'n': k, '_content': v} for k, v in attrs.items()] self.request('ModifyDistributionList', { 'id': self._get_or_fetch_id(dl_description, self.get_distribution_list), 'a': attrs })
def modify_distribution_list(self, dl_description, attrs)
:param dl_description : a DistributionList specifying either : - id: the dl_list_id - dl_description: the name of the list :param attrs : a dictionary of attributes to set ({key:value,...})
5.639508
6.432073
0.876779
resp = self.request('RenameDistributionList', { 'id': self._get_or_fetch_id(dl_description, self.get_distribution_list), 'newName': new_dl_name }) return zobjects.DistributionList.from_dict(resp['dl'])
def rename_distribution_list(self, dl_description, new_dl_name)
:param dl_description : a DistributionList specifying either : - id: the dl_list_id - dl_description: the name of the list :param new_dl_name: new name of the list :return: a zobjects.DistributionList
5.573011
4.261783
1.307671
members = [{'_content': v} for v in members] resp = self.request_single('AddDistributionListMember', { 'id': self._get_or_fetch_id(distribution_list, self.get_distribution_list), 'dlm': members }) return resp
def add_distribution_list_member(self, distribution_list, members)
Adds members to the distribution list :type distribution_list: zobjects.DistributionList :param members: list of email addresses you want to add :type members: list of str
6.281444
8.231838
0.763067
selector = account.to_selector() resp = self.request_single('GetAccount', {'account': selector}) return zobjects.Account.from_dict(resp)
def get_account(self, account)
Fetches an account with all its attributes. :param account: an account object, with either id or name attribute set :returns: a zobjects.Account object, filled.
9.191965
6.604244
1.391827
self.request('RenameAccount', { 'id': self._get_or_fetch_id(account, self.get_account), 'newName': new_name })
def rename_account(self, account, new_name)
Rename an account. :param account: a zobjects.Account :param new_name: a string of new account name
6.124716
6.72139
0.911228
attrs = [{'n': k, '_content': v} for k, v in attrs.items()] self.request('ModifyAccount', { 'id': self._get_or_fetch_id(account, self.get_account), 'a': attrs })
def modify_account(self, account, attrs)
:param account: a zobjects.Account :param attrs : a dictionary of attributes to set ({key:value,...})
5.895812
7.358223
0.801255
attrs = [{'n': k, '_content': v} for k, v in attrs.items()] params = {'name': email, 'a': attrs} if password: params['password'] = password resp = self.request_single('CreateAccount', params) return zobjects.Account.from_dict(resp)
def create_account(self, email, password=None, attrs={})
:param email: Full email with domain eg: login@domain.com :param password: Password for local auth :param attrs: a dictionary of attributes to set ({key:value,...}) :returns: the created zobjects.Account
5.775572
6.089684
0.948419
self.request('DeleteAccount', { 'id': self._get_or_fetch_id(account, self.get_account), })
def delete_account(self, account)
:param account: an account object to be used as a selector
9.201213
7.940526
1.158766
self.request('AddAccountAlias', { 'id': self._get_or_fetch_id(account, self.get_account), 'alias': alias, })
def add_account_alias(self, account, alias)
:param account: an account object to be used as a selector :param alias: email alias address :returns: None (the API itself returns nothing)
6.200219
5.792701
1.07035
self.request('RemoveAccountAlias', { 'id': self._get_or_fetch_id(account, self.get_account), 'alias': alias, })
def remove_account_alias(self, account, alias)
:param account: an account object to be used as a selector :param alias: email alias address :returns: None (the API itself returns nothing)
5.88097
5.592071
1.051662
domain = account.get_domain() try: preauth_key = self.get_domain(domain)['zimbraPreAuthKey'] except KeyError: raise DomainHasNoPreAuthKey(domain) timestamp = int(time.time())*1000 expires = duration*1000 return utils.build_preauth_str(prea...
def mk_auth_token(self, account, admin=False, duration=0)
Builds an authentification token, using preauth mechanism. See http://wiki.zimbra.com/wiki/Preauth :param duration: in seconds defaults to 0, which means "use account default" :param account: an account object to be used as a selector :returns: the auth string
4.831676
4.482395
1.077923
warnings.warn("delegate_auth() on parent client is deprecated," " use delegated_login() on child client instead", DeprecationWarning) selector = account.to_selector() resp = self.request('DelegateAuth', {'account': selector}) lifetime...
def delegate_auth(self, account)
Uses the DelegateAuthRequest to provide a ZimbraAccountClient already logged with the provided account. It's the mechanism used with the "view email" button in admin console.
6.16007
5.854687
1.05216
if account is None: account = self.get_account(zobjects.Account(name=account_name)) selector = account.to_selector() resp = self.request('DelegateAuth', {'account': selector}) authToken = resp['authToken'] lifetime = int(resp['lifetime']) return au...
def get_account_authToken(self, account=None, account_name='')
Use the DelegateAuthRequest to provide a token and his lifetime for the provided account. If account is provided we use it, else we retreive the account from the provided account_name.
5.962038
4.376063
1.36242
search_response = self.request('SearchDirectory', kwargs) result = {} items = { "account": zobjects.Account.from_dict, "domain": zobjects.Domain.from_dict, "dl": zobjects.DistributionList.from_dict, "cos": zobjects.COS.from_dict, ...
def search_directory(self, **kwargs)
SearchAccount is deprecated, using SearchDirectory :param query: Query string - should be an LDAP-style filter string (RFC 2254) :param limit: The maximum number of accounts to return (0 is default and means all) :param offset: The starting offset (0, 25, etc) :param dom...
2.799824
2.542381
1.101261
if isinstance(l, (text_type, int)): return l if not isinstance(l, list): raise TypeError(l, ' should be a list of integers, \ not {0}'.format(type(l))) str_ids = ','.join(str(i) for i in l) return str_ids
def _return_comma_list(self, l)
get a list and return a string with comma separated list values Examples ['to', 'ta'] will return 'to,ta'.
4.257824
4.511081
0.943859
aces = [] if rights: for right in rights: ace = self.request( 'GetPermission', {'ace': { 'right': {'_content': right}}}) if 'ace' in ace.keys() and isinstance(ace, list): ...
def get_permissions(self, rights=[])
:param rights: list of rights. Possible values : 'sendAs', 'sendOnBehalfOf' :return: dict with key ace with a list of rights
2.687459
2.298972
1.168983
task = zobjects.Task() task_creator = task.to_creator(subject, desc) resp = self.request('CreateTask', task_creator) task_id = resp['calItemId'] return task_id
def create_task(self, subject, desc)
Create a task :param subject: the task's subject :param desc: the task's content in plain-text :returns: the task's id
6.693654
8.172236
0.819072
task = self.request_single('GetTask', {'id': task_id}) if task: return zobjects.Task.from_dict(task) else: return None
def get_task(self, task_id)
Retrieve one task, discriminated by id. :param: task_id: the task id :returns: a zobjects.Task object ; if no task is matching, returns None.
5.331057
4.505917
1.183124
cn = {} if folder_id: cn['l'] = str(folder_id) if tags: tags = self._return_comma_list(tags) cn['tn'] = tags if members: cn['m'] = members attrs = [{'n': k, '_content': v} for k, v in attrs.items()] cn['a'] = attrs...
def create_contact(self, attrs, members=None, folder_id=None, tags=None)
Create a contact Does not include VCARD nor group membership yet XML example : <cn l="7> ## ContactSpec <a n="lastName">MARTIN</a> <a n="firstName">Pierre</a> <a n="email">pmartin@example.com</a> </cn> Which would be in zimsoap : attrs = { 'l...
4.498519
4.028277
1.116735
params = {} if ids: ids = self._return_comma_list(ids) params['cn'] = {'id': ids} for key, value in kwargs.items(): if key in ['a', 'ma']: params[key] = {'n': value} else: params[key] = value conta...
def get_contacts(self, ids=None, **kwargs)
Get all contacts for the current user :param l: string of a folder id :param ids: An coma separated list of contact's ID to look for :returns: a list of zobjects.Contact
4.485426
4.684678
0.957467
cn = {} if tags: tags = self._return_comma_list(tags) cn['tn'] = tags if members: cn['m'] = members if attrs: attrs = [{'n': k, '_content': v} for k, v in attrs.items()] cn['a'] = attrs cn['id'] = contact_id ...
def modify_contact(self, contact_id, attrs=None, members=None, tags=None)
:param contact_id: zimbra id of the targetd contact :param attrs : a dictionary of attributes to set ({key:value,...}) :param members: list of dict representing contacts and operation (+|-|reset) :param tags: comma-separated list of tag names :returns: the modified zobj...
4.706669
4.216978
1.116124
str_ids = self._return_comma_list(ids) self.request('ContactAction', {'action': {'op': 'delete', 'id': str_ids}})
def delete_contacts(self, ids)
Delete selected contacts for the current user :param ids: list of ids
9.903287
12.861804
0.769977
cn = {} cn['m'] = members if folder_id: cn['l'] = str(folder_id) if tags: cn['tn'] = tags attrs = [{'n': k, '_content': v} for k, v in attrs.items()] attrs.append({'n': 'type', '_content': 'group'}) cn['a'] = attrs resp =...
def create_group(self, attrs, members, folder_id=None, tags=None)
Create a contact group XML example : <cn l="7> ## ContactSpec <a n="lastName">MARTIN</a> <a n="firstName">Pierre</a> <a n="email">pmartin@example.com</a> </cn> Which would be in zimsoap : attrs = { 'lastname': 'MARTIN', ...
4.697866
4.054863
1.158576
if folder_ids: f_ids = folder_ids elif paths: f_ids = [] for path in paths: folder = self.get_folder(path=path) f_ids.append(folder[f_type]['id']) comma_ids = self._return_comma_list(f_ids) params = {'action':...
def delete_folders(self, paths=None, folder_ids=None, f_type='folder')
:param folder_ids: list of ids :param path: list of folder's paths
3.3494
3.453411
0.969882
self.delete_folders(paths=paths, folder_ids=folder_ids, f_type='link')
def delete_mountpoints(self, paths=None, folder_ids=None)
:param folder_ids: list of ids :param path: list of folder's paths
7.468207
7.659978
0.974965
f_ids = self._return_comma_list(folder_ids) params = {'action': { 'id': f_ids, 'op': 'grant', 'grant': {'perm': perm, 'gt': gt} }} if perm == 'none': params['action']['op'] = '!grant' params['action']['zid'] = zid ...
def modify_folder_grant( self, folder_ids, perm, zid=None, grantee_name=None, gt='usr', flags=None )
:param folder_ids: list of ids :param perm: permission to grant to the user on folder(s) :param zid: id of user to grant rights :param grantee_name: email address of user to grant rights :param flags: folder's flags
3.794955
3.979078
0.953727
f_ids = self._return_comma_list(folder_ids) params = {'action': { 'id': f_ids, 'op': 'update', }} if color: params['action']['color'] = color if flags: params['action']['f'] = flags if parent_folder: p...
def modify_folders( self, folder_ids, color=None, flags=None, parent_folder=None, name=None, num_days=None, rgb=None, tags=None, view=None )
:param folder_ids: list of ids :param color: color numeric; range 0-127; defaults to 0 if not present; client can display only 0-7 :param flags: flags :param parent_folder: id of new location folder :param name: new name for the folder :param tags: list of tag names ...
2.90761
2.993327
0.971364
str_ids = self._return_comma_list(ids) self.request('ConvAction', {'action': {'op': 'delete', 'id': str_ids }})
def delete_conversations(self, ids)
Delete selected conversations :params ids: list of ids
11.837898
12.489702
0.947813
str_ids = self._return_comma_list(ids) self.request('ConvAction', {'action': {'op': 'move', 'id': str_ids, 'l': str(folder)}})
def move_conversations(self, ids, folder)
Move selected conversations to an other folder :params ids: list of ids :params folder: folder id
8.247035
8.90707
0.925898
content = {'m': kwargs} content['m']['l'] = str(folder) content['m']['content'] = {'_content': msg_content} return self.request('AddMsg', content)
def add_message(self, msg_content, folder, **kwargs)
Inject a message :params string msg_content: The entire message's content. :params string folder: Folder pathname (starts with '/') or folder ID
6.736036
10.37427
0.649302
str_ids = self._return_comma_list(ids) params = {'action': { 'id': str_ids, 'op': 'move', 'l': folder_id }} self.request('MsgAction', params)
def move_messages(self, ids, folder_id)
Move selected messages to an other folder :param msg_ids: list of message's ids to move :param folder_id: folder's id where to move messages
6.424005
7.925781
0.81052
str_ids = self._return_comma_list(ids) params = {'action': { 'id': str_ids, 'op': 'update', 'f': flag }} self.request('MsgAction', params)
def update_messages_flag(self, ids, flag)
List of flags : u -> unread f -> flagged a -> has attachment s -> sent by me r -> replied w -> forwarded d -> draft x -> deleted n -> notification sent by default a message priority is "normal" otherwise: ! ...
7.519495
8.004196
0.939444
str_ids = self._return_comma_list(ids) return self.request('MsgAction', {'action': {'op': 'delete', 'id': str_ids}})
def delete_messages(self, ids)
Delete selected messages for the current user :param ids: list of ids
9.728087
12.303947
0.790648
content = kwargs content['query'] = {'_content': query} return self.request('Search', content)
def search(self, query, **kwargs)
Search object in account :returns: a dic where value c contains the list of results (if there is any). Example : { 'more': '0', 'offset': '0', 'sortBy': 'dateDesc', 'c': [ { 'id': '-261', 'm': {'id':...
14.367384
13.35487
1.075816
folder = self.create_folder(dest_folder) for type_source, source_config in data_source.items(): data_source[type_source]['l'] = folder['id'] return self.request('CreateDataSource', data_source)
def create_data_source(self, data_source, dest_folder)
Create data source from a dict data_source example = { 'pop3': { 'leaveOnServer': "(0|1)", 'id': 'data-source-id', 'name': 'data-source-name', 'isEnabled': '(0|1)', 'importOnly': '(0|1)', 'host': 'data-source-server', 'port': 'd...
6.087724
5.234932
1.162904
source_type = [k for k in data_source.keys()][0] complete_source = self.get_data_sources( source_id=data_source[source_type]['id']) folder_id = complete_source[source_type][0]['l'] self.delete_folders(folder_ids=[folder_id]) return self.request('DeleteDataSou...
def delete_data_source(self, data_source)
Delete data source with it's name or ID. data_source = { 'imap': {'name': 'data-source-name'}} or data_source = { 'pop3': {'id': 'data-source-id'}}
4.760143
4.125085
1.15395
filters['condition'] = condition new_rule = { 'name': name, 'active': active, 'filterTests': filters, 'filterActions': actions } new_rules = [zobjects.FilterRule.from_dict(new_rule)] prev_rules = self.get_filter_rules(w...
def add_filter_rule( self, name, condition, filters, actions, active=1, way='in')
:param: name filter name :param: condition allof or anyof :param: filters dict of filters :param: actions dict of actions :param: way string discribing if filter is for 'in' or 'out' messages :returns: list of user's zobjects.FilterRule
3.585797
3.438984
1.042691
if isinstance(_filter, zobjects.FilterRule): _filter = _filter.name for f in self.get_filter_rules(way=way): if f.name == _filter: return f return None
def get_filter_rule(self, _filter, way='in')
Return the filter rule :param: _filter a zobjects.FilterRule or the filter name :param: way string discribing if filter is for 'in' or 'out' messages :returns: a zobjects.FilterRule
3.80988
2.980865
1.278112
try: if way == 'in': filters = self.request( 'GetFilterRules')['filterRules']['filterRule'] elif way == 'out': filters = self.request( 'GetOutgoingFilterRules')['filterRules']['filterRule'] # Zi...
def get_filter_rules(self, way='in')
:param: way string discribing if filter is for 'in' or 'out' messages :returns: list of zobjects.FilterRule
3.476361
3.00925
1.155225
if isinstance(_filter, zobjects.FilterRule): _filter = _filter.name content = { 'filterRules': { 'filterRule': {'name': _filter} }, 'query': {'_content': query} } if way == 'in': ids = self.request(...
def apply_filter_rule(self, _filter, query='in:inbox', way='in')
:param: _filter _filter a zobjects.FilterRule or the filter name :param: query on what will the filter be applied :param: way string discribing if filter is for 'in' or 'out' messages :returns: list of impacted message's ids
4.59444
3.801709
1.20852
updated_rules = [] rules = self.get_filter_rules(way=way) if isinstance(_filter, zobjects.FilterRule): _filter = _filter.name if rules: for rule in rules: if not rule.name == _filter: updated_rules.append(rule) ...
def delete_filter_rule(self, _filter, way='in')
delete a filter rule :param: _filter a zobjects.FilterRule or the filter name :param: way string discribing if filter is for 'in' or 'out' messages :returns: a list of zobjects.FilterRule
3.423636
3.03193
1.129193
self.end_date = (datetime.datetime.now() + datetime.timedelta(0, lifetime))
def set_end_date(self, lifetime)
Computes and store an absolute end_date session according to the lifetime of the session
3.898842
3.771948
1.033642
if namespace is None: namespace = self.client.NAMESPACE data = self.client.request( 'Auth', { 'account': zobjects.Account(name=username).to_selector(), 'password': {'_content': password} }, namespace) ...
def login(self, username, password, namespace=None)
Performs the login against zimbra (sends AuthRequest, receives AuthResponse). :param namespace: if specified, the namespace used for authetication (if the client namespace is not suitable for authentication).
6.30841
5.667421
1.113101
response = self.request(E.searchExtensionRequest( E.limit(limit), E.offset(offset), E.withDescription(int(kw.get('with_description', 0))), E.withPrice(int(kw.get('with_price', 0))), E.withUsageCount(int(kw.get('with_usage_count', 0))), ...
def search_extension(self, limit=100, offset=0, **kw)
Search the list of available extensions.
3.21113
3.229791
0.994222
response = self.request(E.retrieveExtensionRequest( E.name(name), E.withDescription(int(kw.get('with_description', 0))), E.withPrice(int(kw.get('with_price', 0))), E.withUsageCount(int(kw.get('with_usage_count', 0))), )) return response....
def retrieve_extension(self, name, **kw)
Retrieve details on a single extension.
3.75262
3.38155
1.109734
c = vm.pop() b = vm.pop() a = vm.pop() vm.push(b) vm.push(c) vm.push(a)
def rot(vm)
Rotate topmost three items once to the left. ( a b c -- b c a )
2.210532
1.741351
1.269435
if instructions is None: instructions = default_instructions if isinstance(instruction, str): return instructions[instruction] elif hasattr(instruction, "__call__"): rev = dict(((v,k) for (k,v) in instructions.items())) return rev[instruction] else: raise er...
def lookup(instruction, instructions = None)
Looks up instruction, which can either be a function or a string. If it's a string, returns the corresponding method. If it's a function, returns the corresponding name.
3.71499
3.747011
0.991454
response = self.request(E.retrieveResellerRequest()) return Reseller(response.data)
def retrieve(self)
Retrieve contact information on ourselves.
27.842169
19.759224
1.409072
(scheme, netloc, path, query, fragment) = urlparse.urlsplit(url) query_dict = urlparse.parse_qs(query) query_dict.pop(key, None) query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True) return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
def remove_query_param(url, key)
Given a URL and a key/val pair, remove an item in the query parameters of the URL, and return the new URL.
1.707815
1.742593
0.980042
names = [ ("Creators/%s" % name).lower(), ("DrunkDuck/%s" % name).lower(), ("GoComics/%s" % name).lower(), ("KeenSpot/%s" % name).lower(), ("ComicGenesis/%s" % name).lower(), ("SmackJeeves/%s" % name).lower(), ] for scraperclass in get_scraperclasses(): ...
def has_comic(name)
Check if comic name already exists.
4.53349
4.487396
1.010272
min_comics, filename = args with codecs.open(filename, 'a', 'utf-8') as fp: for name, shortname in sorted(load_result(json_file).items()): if name in exclude_comics: continue if has_comic(name): prefix = u'#' else: ...
def print_results(args)
Print all comics that have at least the given number of minimum comic strips.
6.262622
5.741478
1.090768
servercontent = requests.post( '{}/services/auth/login'.format( url), headers={}, verify=False, data={ 'username': user, 'password': password }) get_session_key = parseString( servercontent.text).getElementsByTagName( ...
def get_session_key( user, password, url='https://localhost:8089', verify=False, ssl_options=None)
get_session_key This will get a user session key and throw for any errors :param user: username :param password: password :param url: splunk auth url :param verify: verify cert :param ssl_options: ssl options dictionary
3.442053
3.440557
1.000435
''' Request api, return json. \b DOES: Call a api on your devices. token: device_token method: GET or POST endpoint: device_path, such as: /v1/node/GroveTempHumProD0/temperature wio call <device_token> <request_method> <device_path> \b EXAMPLE: w...
def cli(wio, method, endpoint, token,)
Request api, return json. \b DOES: Call a api on your devices. token: device_token method: GET or POST endpoint: device_path, such as: /v1/node/GroveTempHumProD0/temperature wio call <device_token> <request_method> <device_path> \b EXAMPLE: wio call 98dd...
3.669741
1.963528
1.868953
def is_whitelisted(remote_ip, whitelist): # Convert the ip into a long int version of the ip address user_ip = ipaddr.IPv4Address(remote_ip) # Loop through the ranges in the whitelist and check if any([user_ip in ipaddr.IPv4Network(entry) for entry in whitelist]): ...
def whitelisted(argument=None)
Decorates a method requiring that the requesting IP address is whitelisted. Requires a whitelist value as a list in the Application.settings dictionary. IP addresses can be an individual IP address or a subnet. Examples: ['10.0.0.0/8','192.168.1.0/24', '1.2.3.4/32'] :param list argument: L...
3.25963
3.034253
1.074278
try: x = self.df[xcol].values.reshape(-1, 1) y = self.df[ycol] lm = linear_model.LinearRegression() lm.fit(x, y) predictions = lm.predict(x) self.df[name] = predictions except Exception as e: self.err(e, "Can no...
def lreg(self, xcol, ycol, name="Regression")
Add a column to the main dataframe populted with the model's linear regression for a column
2.47285
2.453367
1.007941
try: v = (np.std(self.df[col]) / np.mean(self.df[col])) * 100 return v except Exception as e: self.err(e, "Can not calculate coefficient of variance")
def cvar_(self, col)
Returns the coefficient of variance of a column in percentage
4.49877
3.793532
1.185905
data = cls.getPage(cls.url) url1 = cls.fetchUrl(cls.url, data, cls.prevSearch) data = cls.getPage(url1) url2 = cls.fetchUrl(url1, data, cls.nextSearch) return cls.prevUrlModifier(url2)
def starter(cls)
Get bounced start URL.
5.219373
4.330708
1.205201
mo = compile(r"index(\d+)\.html").search(url) num = int(mo.group(1)) - 1 prefix = url.rsplit('/', 1)[0] return "%s/index%d.html" % (prefix, num)
def getPrevUrl(self, url, data)
Decrease index.html number.
3.637593
3.107229
1.170687
''' Update article.languages ''' if instance.article.languages: languages = instance.article.languages.split(',') else: languages = [] if instance.language not in languages: languages.append(instance.language) instance.article.languages = ','.join(languages) i...
def pre_save_title(instance, **kwargs)
Update article.languages
3.872884
3.070924
1.261146
''' Update article.languages ''' if instance.article.languages: languages = instance.article.languages.split(',') else: languages = [] if instance.language in languages: languages.remove(instance.language) instance.article.languages = ','.join(languages) insta...
def pre_delete_title(instance, **kwargs)
Update article.languages
3.743328
3.090502
1.211237
def digest_auth_decorator(func): def func_replacement(self, *args, **kwargs): # 'self' here is the RequestHandler object, which is inheriting # from DigestAuthMixin to get 'get_authenticated_user' if self.get_authenticated_user(auth_func, realm): retu...
def digest_auth(realm, auth_func)
A decorator used to protect methods with HTTP Digest authentication.
4.261796
4.240625
1.004993
username = self.params["username"] if algorithm == 'MD5' or not algorithm: return "%s:%s:%s" % (username, self.realm, auth_pass) elif algorithm == 'MD5-Sess': return self.apply_checksum('%s:%s:%s:%s:%s' % \ (username, ...
def A1(self, algorithm, auth_pass)
If 'algorithm' is "MD5" or unset, A1 is: A1 = unq(username-value) ":" unq(realm-value) ":" passwd if 'algorithm' is 'MD5-Sess', A1 is: A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) ":" unq(nonce-value) ":" unq(cnonce-value)
4.050735
2.942168
1.376786
if self.params['qop'] == 'auth' or not self.params['qop']: return self.request.method + ":" + self.request.uri elif self.params['qop'] == 'auth-int': #print "UNSUPPORTED 'qop' METHOD\n" return ":".join([self.request.method, self.r...
def A2(self)
If the "qop" directive's value is "auth" or is unspecified, then A2 is: A2 = Method ":" digest-uri-value Else, A2 = Method ":" digest-uri-value ":" H(entity-body)
5.447119
4.099072
1.328866
if in_utc: return datetime.datetime.utcnow().strftime( format) else: return datetime.datetime.now().strftime( format)
def rnow( format='%Y-%m-%d %H:%M:%S', in_utc=False)
rnow Get right now as a string formatted datetime :param format: string output format for datetime :param in_utc: bool timezone in utc or local time
2.259128
2.63892
0.856081
global palette, color_num if i is not None: color_num = i if color_num == len(palette) - 1: color_num = 0 res = palette[color_num] color_num += 1 return res
def color_(self, i=None)
Get a color from the palette
3.034086
2.66115
1.140141
global palette color = palette[self.color_index] if len(palette) - 1 == self.color_index: self.color_index = 0 else: self.color_index += 1 self.color(color)
def scolor(self)
Set a unique color from a serie
3.042825
2.914347
1.044084
''' Login with your Wio account. \b DOES: Login and save an access token for interacting with your account on the Wio. \b USE: wio login ''' mserver = wio.config.get("mserver", None) if mserver: click.echo(click.style('> ', fg='green') + "Current server is: ...
def cli(wio)
Login with your Wio account. \b DOES: Login and save an access token for interacting with your account on the Wio. \b USE: wio login
3.412787
3.03361
1.124992
debug = SPLUNK_DEBUG for i in log.root.handlers: handler_class_name = i.__class__.__name__.lower() if debug: print(( ' - wait_for_exit handler={}').format( handler_class_name)) if ('splunkpublisher' == handler_class_name ...
def wait_for_exit( log, debug=False)
wait_for_exit Sleep to allow the thread to pick up final messages before exiting and stopping the Splunk HTTP publisher. You can decrease this delay (in seconds) by reducing the splunk_sleep_interval or by exporting the env var: export SPLUNK_SLEEP_INTERVAL=0.5 If you set the timer to 0 then ...
3.537156
3.367983
1.05023