add provider db documentation url

default case for unwrapping
try fixing python linting
This commit is contained in:
Simon Laux
2019-12-20 15:17:07 +01:00
parent 7da5fe2726
commit 5479877f65
3 changed files with 9 additions and 6 deletions

View File

@@ -3663,22 +3663,24 @@ int dc_contact_is_verified (dc_contact_t* contact);
/** /**
* Get the provider json object for the given domain. * Get the provider json object for the given domain.
* For more documentation see https://docs.rs/deltachat-provider-database/
* *
* @memberof dc_provider_t * @memberof dc_provider_t
* @param domain The domain to get provider info for. * @param domain The domain to get provider info for.
* @return a provider json object as string. If no provider info is found, an empty string will be returned. * @return a provider json object as string. If no provider info is found, an empty string will be returned.
*/ */
char* dc_provider_json_from_domain (const char* domain); char* dc_provider_json_from_domain (const char* domain);
/** /**
* Get the provider json object for the given email address. * Get the provider json object for the given email address.
* For more documentation see https://docs.rs/deltachat-provider-database/
* *
* The provider is extracted from the email address and it's information is returned. * The provider is extracted from the email address and it's information is returned.
* *
* @memberof dc_provider_t * @memberof dc_provider_t
* @param email The user's email address to extract the provider info form. * @param email The user's email address to extract the provider info form.
* @return a provider json object as string. If no provider info is found, an empty string will be returned. * @return a provider json object as string. If no provider info is found, an empty string will be returned.
*/ */
char* dc_provider_json_from_email (const char* email); char* dc_provider_json_from_email (const char* email);

View File

@@ -11,7 +11,7 @@ pub unsafe extern "C" fn dc_provider_json_from_domain(
) -> *mut libc::c_char { ) -> *mut libc::c_char {
let domain = to_string_lossy(domain); let domain = to_string_lossy(domain);
match deltachat_provider_database::get_provider_info(&domain) { match deltachat_provider_database::get_provider_info(&domain) {
Some(provider) => serde_json::to_string(provider).unwrap().strdup(), Some(provider) => serde_json::to_string(provider).unwrap_or("".to_owned()).strdup(),
None => "".strdup(), None => "".strdup(),
} }
} }
@@ -23,7 +23,7 @@ pub unsafe extern "C" fn dc_provider_json_from_email(
let email = to_string_lossy(email); let email = to_string_lossy(email);
let domain = deltachat_provider_database::get_domain_from_email(&email); let domain = deltachat_provider_database::get_domain_from_email(&email);
match deltachat_provider_database::get_provider_info(domain) { match deltachat_provider_database::get_provider_info(domain) {
Some(provider) => serde_json::to_string(provider).unwrap().strdup(), Some(provider) => serde_json::to_string(provider).unwrap_or("".to_owned()).strdup(),
None => "".strdup(), None => "".strdup(),
} }
} }

View File

@@ -1,9 +1,10 @@
"""Provider info class.""" """Provider info class."""
from .capi import ffi, lib from .capi import lib
from .cutil import as_dc_charpointer, from_dc_charpointer from .cutil import as_dc_charpointer, from_dc_charpointer
import json import json
class ProviderNotFoundError(Exception): class ProviderNotFoundError(Exception):
"""The provider information was not found.""" """The provider information was not found."""
@@ -55,7 +56,7 @@ class Provider(object):
def status(self): def status(self):
"""The status of the provider information. """The status of the provider information.
This is This is
:attr:`"OK"`, :attr:`"OK"`,
:attr:`"PREPARATION"` or :attr:`"PREPARATION"` or
:attr:`"BROKEN"`. :attr:`"BROKEN"`.