From 2dae2703fb8c2ae7e721ce83020c0dd10ff9ca33 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 3 May 2013 02:59:22 +0900 Subject: updated documentation * documentation reviewed after rewrite, ready for 0.2.1 * updated docstrings format to fit sphinx autodoc --- src/leap/config/leapsettings.py | 69 ++++++++++++++++++++------------------- src/leap/config/providerconfig.py | 27 ++++++++------- 2 files changed, 51 insertions(+), 45 deletions(-) (limited to 'src/leap/config') diff --git a/src/leap/config/leapsettings.py b/src/leap/config/leapsettings.py index df9c9f11..59a0a16d 100644 --- a/src/leap/config/leapsettings.py +++ b/src/leap/config/leapsettings.py @@ -34,10 +34,10 @@ def to_bool(val): Returns the boolean value corresponding to val. Will return False in case val is not a string or something that behaves like one. - @param val: value to cast - @type val: either bool already or str + :param val: value to cast + :type val: either bool already or str - @rtype: bool + :rtype: bool """ if isinstance(val, bool): return val @@ -70,9 +70,9 @@ class LeapSettings(object): """ Constructor - @param standalone: parameter used to define the location of + :param standalone: parameter used to define the location of the config - @type standalone: bool + :type standalone: bool """ settings_path = os.path.join(get_platform_prefixer() @@ -86,7 +86,7 @@ class LeapSettings(object): """ Returns the saved geometry or None if it wasn't saved - @rtype: bytearray or None + :rtype: bytearray or None """ return self._settings.value(self.GEOMETRY_KEY, None) @@ -94,8 +94,8 @@ class LeapSettings(object): """ Saves the geometry to the settings - @param geometry: bytearray representing the geometry - @type geometry: bytearray + :param geometry: bytearray representing the geometry + :type geometry: bytearray """ leap_assert(geometry, "We need a geometry") self._settings.setValue(self.GEOMETRY_KEY, geometry) @@ -104,7 +104,7 @@ class LeapSettings(object): """ Returns the window state or None if it wasn't saved - @rtype: bytearray or None + :rtype: bytearray or None """ return self._settings.value(self.WINDOWSTATE_KEY, None) @@ -112,8 +112,8 @@ class LeapSettings(object): """ Saves the window state to the settings - @param windowstate: bytearray representing the window state - @type windowstate: bytearray + :param windowstate: bytearray representing the window state + :type windowstate: bytearray """ leap_assert(windowstate, "We need a window state") self._settings.setValue(self.WINDOWSTATE_KEY, windowstate) @@ -122,10 +122,10 @@ class LeapSettings(object): """ Returns a list of enabled services for the given provider - @param provider: provider domain - @type provider: str + :param provider: provider domain + :type provider: str - @rtype: list of str + :rtype: list of str """ leap_assert(len(provider) > 0, "We need a nonempty provider") @@ -140,10 +140,11 @@ class LeapSettings(object): """ Saves the list of enabled services for the given provider - @param provider: provider domain - @type provider: str - @param services: list of services to save - @type services: list of str + :param provider: provider domain + :type provider: str + + :param services: list of services to save + :type services: list of str """ leap_assert(len(provider) > 0, "We need a nonempty provider") @@ -156,7 +157,7 @@ class LeapSettings(object): """ Returns the configured user to remember, None if there isn't one - @rtype: str or None + :rtype: str or None """ return self._settings.value(self.USER_KEY, None) @@ -164,8 +165,8 @@ class LeapSettings(object): """ Saves the user to remember - @param user: user name to remember - @type user: str + :param user: user name to remember + :type user: str """ leap_assert(len(user) > 0, "We cannot save an empty user") self._settings.setValue(self.USER_KEY, user) @@ -174,7 +175,7 @@ class LeapSettings(object): """ Returns the value of the remember selection. - @rtype: bool + :rtype: bool """ return to_bool(self._settings.value(self.REMEMBER_KEY, False)) @@ -182,9 +183,9 @@ class LeapSettings(object): """ Sets wheter the app should remember username and password - @param remember: True if the app should remember username and + :param remember: True if the app should remember username and password, False otherwise - @rtype: bool + :rtype: bool """ leap_assert_type(remember, bool) self._settings.setValue(self.REMEMBER_KEY, remember) @@ -193,7 +194,7 @@ class LeapSettings(object): """ Returns True if the app should automatically login, False otherwise - @rtype: bool + :rtype: bool """ return to_bool(self._settings.value(self.AUTOLOGIN_KEY, False)) @@ -201,8 +202,8 @@ class LeapSettings(object): """ Sets whether the app should automatically login - @param autologin: True if the app should autologin, False otherwise - @type autologin: bool + :param autologin: True if the app should autologin, False otherwise + :type autologin: bool """ leap_assert_type(autologin, bool) self._settings.setValue(self.AUTOLOGIN_KEY, autologin) @@ -211,19 +212,21 @@ class LeapSettings(object): # just one for now def get_properprovider(self): """ - Returns True if there is a properly configured provider + Returns True if there is a properly configured provider. + + .. note:: this assumes only one provider for now. - @rtype: bool + :rtype: bool """ return to_bool(self._settings.value(self.PROPERPROVIDER_KEY, False)) def set_properprovider(self, properprovider): """ - Sets wether the app should automatically login + Sets whether the app should automatically login. - @param properprovider: True if the provider is properly - configured, False otherwise - @type properprovider: bool + :param properprovider: True if the provider is properly configured, + False otherwise. + :type properprovider: bool """ leap_assert_type(properprovider, bool) self._settings.setValue(self.PROPERPROVIDER_KEY, properprovider) diff --git a/src/leap/config/providerconfig.py b/src/leap/config/providerconfig.py index 5aa0cc6e..8f75d4fe 100644 --- a/src/leap/config/providerconfig.py +++ b/src/leap/config/providerconfig.py @@ -68,7 +68,7 @@ class ProviderConfig(BaseConfig): """ Returns the enrollment policy - @rtype: string + :rtype: string """ return self._safe_get_value("enrollment_policy") @@ -82,27 +82,28 @@ class ProviderConfig(BaseConfig): def get_services(self): """ Returns a list with the services supported by the - current provider + current provider. - @rtype: list + :rtype: list """ return self._safe_get_value("services") def get_services_string(self): """ - Returns a string with the services supported by the current provider, - ready to be shown to the user + Returns a string with the services supported by the current + provider, ready to be shown to the user. """ return ", ".join(self.get_services()) def get_ca_cert_path(self, about_to_download=False): """ - Returns the path to the certificate for the current provider + Returns the path to the certificate for the current provider. - @param about_to_download: defines wether we want the path to - download the cert or not. This helps avoid checking if the - cert exists because we are about to write it. - @type about_to_download: bool + :param about_to_download: defines wether we want the path to + download the cert or not. This helps avoid + checking if the cert exists because we + are about to write it. + :type about_to_download: bool """ cert_path = os.path.join(self.get_path_prefix(), @@ -122,8 +123,10 @@ class ProviderConfig(BaseConfig): def provides_eip(self): """ - Returns True if this particular provider has the EIP - service. False otherwise + Returns True if this particular provider has the EIP service, + False otherwise. + + :rtype: bool """ return "openvpn" in self.get_services() -- cgit v1.2.3