summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--README.rst6
-rw-r--r--data/leap_client.pro19
-rw-r--r--data/ts/en_US.ts39
-rw-r--r--docs/api/leap.base.rst98
-rw-r--r--docs/api/leap.base.tests.rst43
-rw-r--r--docs/api/leap.baseapp.rst75
-rw-r--r--docs/api/leap.certs.rst11
-rw-r--r--docs/api/leap.crypto.rst26
-rw-r--r--docs/api/leap.crypto.tests.rst11
-rw-r--r--docs/api/leap.eip.rst74
-rw-r--r--docs/api/leap.eip.tests.rst43
-rw-r--r--docs/api/leap.gui.firstrun.rst91
-rw-r--r--docs/api/leap.gui.rst75
-rw-r--r--docs/api/leap.gui.tests.rst59
-rw-r--r--docs/api/leap.rst41
-rw-r--r--docs/api/leap.testing.rst43
-rw-r--r--docs/api/leap.util.rst66
-rw-r--r--docs/api/leap.util.tests.rst19
-rw-r--r--docs/api/modules.rst7
-rw-r--r--docs/dev/internationalization.rst23
-rw-r--r--docs/index.rst8
-rw-r--r--src/leap/base/exceptions.py34
-rw-r--r--src/leap/base/pluggableconfig.py18
-rw-r--r--src/leap/base/specs.py6
-rw-r--r--src/leap/base/tests/test_providers.py10
-rw-r--r--src/leap/util/tests/test_translations.py22
-rw-r--r--src/leap/util/translations.py83
28 files changed, 1021 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 5bdf9c36..a8859725 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+SHELL := /bin/zsh
# ################################
# Makefile for compiling resources
# files.
@@ -62,5 +63,8 @@ deb:
@git tag -a debian/$(DEBVER) -m "..."
@debuild -us -uc -i.git
+apidocs:
+ @sphinx-apidoc -o docs/api src/leap
+
clean :
$(RM) $(COMPILED_UI) $(COMPILED_RESOURCES) $(COMPILED_UI:.py=.pyc) $(COMPILED_RESOURCES:.py=.pyc)
diff --git a/README.rst b/README.rst
index 01e1c151..9ef3f99b 100644
--- a/README.rst
+++ b/README.rst
@@ -15,12 +15,12 @@ You can read the documentation online at `http://leap-client.readthedocs.org <ht
Quick Start
==============
-At the current development stage we still do not have any versioned release. Instead, you might want to have a look at the `testers guide<http://leap-client.readthedocs.org/en/latest/testers/howto.html>`_ for a quick howto on fetching and testing latest development code.
+At the current development stage we still do not have any versioned release. Instead, you might want to have a look at the `testers guide <http://leap-client.readthedocs.org/en/latest/testers/howto.html>`_ for a quick howto on fetching and testing latest development code.
Dependencies
------------------
-Leap client depends on these libraries:
+LEAP Client depends on these libraries:
* ``python 2.6`` or ``2.7``
* ``qt4 libraries``
@@ -73,7 +73,7 @@ After a successful installation, there should be a launcher called ``leap-client
Hacking
=======
-See the `hackers guide<http://leap-client.readthedocs.org/en/latest/dev/environment.html>`_
+See the `hackers guide <http://leap-client.readthedocs.org/en/latest/dev/environment.html>`_.
The LEAP client git repository is available at::
diff --git a/data/leap_client.pro b/data/leap_client.pro
index 4c559029..3f76d6af 100644
--- a/data/leap_client.pro
+++ b/data/leap_client.pro
@@ -2,15 +2,16 @@
# is not there a f*** way of expanding this? other to template with python I mean...
-SOURCES += ../src/leap/gui/firstrun/intro.py
-SOURCES += ../src/leap/gui/firstrun/last.py
-SOURCES += ../src/leap/gui/firstrun/login.py
-SOURCES += ../src/leap/gui/firstrun/providerinfo.py
-SOURCES += ../src/leap/gui/firstrun/providerselect.py
-SOURCES += ../src/leap/gui/firstrun/providersetup.py
-SOURCES += ../src/leap/gui/firstrun/register.py
-SOURCES += ../src/leap/gui/firstrun/regvalidation.py
-SOURCES += ../src/leap/gui/firstrun/wizard.py
+SOURCES += ../src/leap/base/exceptions.py
+SOURCES += ../src/leap/gui/firstrun/intro.py
+SOURCES += ../src/leap/gui/firstrun/last.py
+SOURCES += ../src/leap/gui/firstrun/login.py
+SOURCES += ../src/leap/gui/firstrun/providerinfo.py
+SOURCES += ../src/leap/gui/firstrun/providerselect.py
+SOURCES += ../src/leap/gui/firstrun/providersetup.py
+SOURCES += ../src/leap/gui/firstrun/register.py
+SOURCES += ../src/leap/gui/firstrun/regvalidation.py
+SOURCES += ../src/leap/gui/firstrun/wizard.py
# where to generate ts files -- tx will pick from here
diff --git a/data/ts/en_US.ts b/data/ts/en_US.ts
index f6aadc5c..a802dd75 100644
--- a/data/ts/en_US.ts
+++ b/data/ts/en_US.ts
@@ -1,6 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
+ <name>Errors</name>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="57"/>
+ <source>Interface not found</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="64"/>
+ <source>Looks like your computer is not connected to the internet</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="72"/>
+ <source>Looks like there are problems with your internet connection</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="80"/>
+ <source>It looks like there is no internet connection.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="88"/>
+ <source>Domain cannot be found</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../src/leap/base/exceptions.py" line="95"/>
+ <source>The Encrypted Connection was lost. Shutting down...</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>IntroPage</name>
<message>
<location filename="../src/leap/gui/firstrun/intro.py" line="14"/>
@@ -216,4 +249,10 @@
<translation type="unfinished"></translation>
</message>
</context>
+<context>
+ <name>TestyClass</name>
+</context>
+<context>
+ <name>this is a cat</name>
+</context>
</TS>
diff --git a/docs/api/leap.base.rst b/docs/api/leap.base.rst
new file mode 100644
index 00000000..778836c4
--- /dev/null
+++ b/docs/api/leap.base.rst
@@ -0,0 +1,98 @@
+base Package
+============
+
+:mod:`auth` Module
+------------------
+
+.. automodule:: leap.base.auth
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`authentication` Module
+----------------------------
+
+.. automodule:: leap.base.authentication
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`checks` Module
+--------------------
+
+.. automodule:: leap.base.checks
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`config` Module
+--------------------
+
+.. automodule:: leap.base.config
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`connection` Module
+------------------------
+
+.. automodule:: leap.base.connection
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`constants` Module
+-----------------------
+
+.. automodule:: leap.base.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`exceptions` Module
+------------------------
+
+.. automodule:: leap.base.exceptions
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`network` Module
+---------------------
+
+.. automodule:: leap.base.network
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`pluggableconfig` Module
+-----------------------------
+
+.. automodule:: leap.base.pluggableconfig
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`providers` Module
+-----------------------
+
+.. automodule:: leap.base.providers
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`specs` Module
+-------------------
+
+.. automodule:: leap.base.specs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.base.tests
+
diff --git a/docs/api/leap.base.tests.rst b/docs/api/leap.base.tests.rst
new file mode 100644
index 00000000..7af035b0
--- /dev/null
+++ b/docs/api/leap.base.tests.rst
@@ -0,0 +1,43 @@
+tests Package
+=============
+
+:mod:`test_auth` Module
+-----------------------
+
+.. automodule:: leap.base.tests.test_auth
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_checks` Module
+-------------------------
+
+.. automodule:: leap.base.tests.test_checks
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_config` Module
+-------------------------
+
+.. automodule:: leap.base.tests.test_config
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_providers` Module
+----------------------------
+
+.. automodule:: leap.base.tests.test_providers
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_validation` Module
+-----------------------------
+
+.. automodule:: leap.base.tests.test_validation
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.baseapp.rst b/docs/api/leap.baseapp.rst
new file mode 100644
index 00000000..f24b4976
--- /dev/null
+++ b/docs/api/leap.baseapp.rst
@@ -0,0 +1,75 @@
+baseapp Package
+===============
+
+:mod:`constants` Module
+-----------------------
+
+.. automodule:: leap.baseapp.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`dialogs` Module
+---------------------
+
+.. automodule:: leap.baseapp.dialogs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`eip` Module
+-----------------
+
+.. automodule:: leap.baseapp.eip
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`leap_app` Module
+----------------------
+
+.. automodule:: leap.baseapp.leap_app
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`log` Module
+-----------------
+
+.. automodule:: leap.baseapp.log
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`mainwindow` Module
+------------------------
+
+.. automodule:: leap.baseapp.mainwindow
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`network` Module
+---------------------
+
+.. automodule:: leap.baseapp.network
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`permcheck` Module
+-----------------------
+
+.. automodule:: leap.baseapp.permcheck
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`systray` Module
+---------------------
+
+.. automodule:: leap.baseapp.systray
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.certs.rst b/docs/api/leap.certs.rst
new file mode 100644
index 00000000..e9cc2524
--- /dev/null
+++ b/docs/api/leap.certs.rst
@@ -0,0 +1,11 @@
+certs Package
+=============
+
+:mod:`certs` Package
+--------------------
+
+.. automodule:: leap.certs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.crypto.rst b/docs/api/leap.crypto.rst
new file mode 100644
index 00000000..a04e2e1d
--- /dev/null
+++ b/docs/api/leap.crypto.rst
@@ -0,0 +1,26 @@
+crypto Package
+==============
+
+:mod:`certs` Module
+-------------------
+
+.. automodule:: leap.crypto.certs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`leapkeyring` Module
+-------------------------
+
+.. automodule:: leap.crypto.leapkeyring
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.crypto.tests
+
diff --git a/docs/api/leap.crypto.tests.rst b/docs/api/leap.crypto.tests.rst
new file mode 100644
index 00000000..54ffa62f
--- /dev/null
+++ b/docs/api/leap.crypto.tests.rst
@@ -0,0 +1,11 @@
+tests Package
+=============
+
+:mod:`test_certs` Module
+------------------------
+
+.. automodule:: leap.crypto.tests.test_certs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.eip.rst b/docs/api/leap.eip.rst
new file mode 100644
index 00000000..e418461b
--- /dev/null
+++ b/docs/api/leap.eip.rst
@@ -0,0 +1,74 @@
+eip Package
+===========
+
+:mod:`checks` Module
+--------------------
+
+.. automodule:: leap.eip.checks
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`config` Module
+--------------------
+
+.. automodule:: leap.eip.config
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`constants` Module
+-----------------------
+
+.. automodule:: leap.eip.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`eipconnection` Module
+---------------------------
+
+.. automodule:: leap.eip.eipconnection
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`exceptions` Module
+------------------------
+
+.. automodule:: leap.eip.exceptions
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`openvpnconnection` Module
+-------------------------------
+
+.. automodule:: leap.eip.openvpnconnection
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`specs` Module
+-------------------
+
+.. automodule:: leap.eip.specs
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`udstelnet` Module
+-----------------------
+
+.. automodule:: leap.eip.udstelnet
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.eip.tests
+
diff --git a/docs/api/leap.eip.tests.rst b/docs/api/leap.eip.tests.rst
new file mode 100644
index 00000000..932a074f
--- /dev/null
+++ b/docs/api/leap.eip.tests.rst
@@ -0,0 +1,43 @@
+tests Package
+=============
+
+:mod:`data` Module
+------------------
+
+.. automodule:: leap.eip.tests.data
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_checks` Module
+-------------------------
+
+.. automodule:: leap.eip.tests.test_checks
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_config` Module
+-------------------------
+
+.. automodule:: leap.eip.tests.test_config
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_eipconnection` Module
+--------------------------------
+
+.. automodule:: leap.eip.tests.test_eipconnection
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_openvpnconnection` Module
+------------------------------------
+
+.. automodule:: leap.eip.tests.test_openvpnconnection
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.gui.firstrun.rst b/docs/api/leap.gui.firstrun.rst
new file mode 100644
index 00000000..36470c33
--- /dev/null
+++ b/docs/api/leap.gui.firstrun.rst
@@ -0,0 +1,91 @@
+firstrun Package
+================
+
+:mod:`firstrun` Package
+-----------------------
+
+.. automodule:: leap.gui.firstrun
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`intro` Module
+-------------------
+
+.. automodule:: leap.gui.firstrun.intro
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`last` Module
+------------------
+
+.. automodule:: leap.gui.firstrun.last
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`login` Module
+-------------------
+
+.. automodule:: leap.gui.firstrun.login
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`mixins` Module
+--------------------
+
+.. automodule:: leap.gui.firstrun.mixins
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`providerinfo` Module
+--------------------------
+
+.. automodule:: leap.gui.firstrun.providerinfo
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`providerselect` Module
+----------------------------
+
+.. automodule:: leap.gui.firstrun.providerselect
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`providersetup` Module
+---------------------------
+
+.. automodule:: leap.gui.firstrun.providersetup
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`register` Module
+----------------------
+
+.. automodule:: leap.gui.firstrun.register
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`regvalidation` Module
+---------------------------
+
+.. automodule:: leap.gui.firstrun.regvalidation
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`wizard` Module
+--------------------
+
+.. automodule:: leap.gui.firstrun.wizard
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.gui.rst b/docs/api/leap.gui.rst
new file mode 100644
index 00000000..a35a7856
--- /dev/null
+++ b/docs/api/leap.gui.rst
@@ -0,0 +1,75 @@
+gui Package
+===========
+
+:mod:`gui` Package
+------------------
+
+.. automodule:: leap.gui
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`constants` Module
+-----------------------
+
+.. automodule:: leap.gui.constants
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`locale_rc` Module
+-----------------------
+
+.. automodule:: leap.gui.locale_rc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`mainwindow_rc` Module
+---------------------------
+
+.. automodule:: leap.gui.mainwindow_rc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`progress` Module
+----------------------
+
+.. automodule:: leap.gui.progress
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`styles` Module
+--------------------
+
+.. automodule:: leap.gui.styles
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`threads` Module
+---------------------
+
+.. automodule:: leap.gui.threads
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`utils` Module
+-------------------
+
+.. automodule:: leap.gui.utils
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.gui.firstrun
+ leap.gui.tests
+
diff --git a/docs/api/leap.gui.tests.rst b/docs/api/leap.gui.tests.rst
new file mode 100644
index 00000000..60b0a6ca
--- /dev/null
+++ b/docs/api/leap.gui.tests.rst
@@ -0,0 +1,59 @@
+tests Package
+=============
+
+:mod:`test_firstrun_login` Module
+---------------------------------
+
+.. automodule:: leap.gui.tests.test_firstrun_login
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_firstrun_providerselect` Module
+------------------------------------------
+
+.. automodule:: leap.gui.tests.test_firstrun_providerselect
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_firstrun_register` Module
+------------------------------------
+
+.. automodule:: leap.gui.tests.test_firstrun_register
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_firstrun_wizard` Module
+----------------------------------
+
+.. automodule:: leap.gui.tests.test_firstrun_wizard
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_mainwindow_rc` Module
+--------------------------------
+
+.. automodule:: leap.gui.tests.test_mainwindow_rc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_progress` Module
+---------------------------
+
+.. automodule:: leap.gui.tests.test_progress
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_threads` Module
+--------------------------
+
+.. automodule:: leap.gui.tests.test_threads
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.rst b/docs/api/leap.rst
new file mode 100644
index 00000000..ce715c5d
--- /dev/null
+++ b/docs/api/leap.rst
@@ -0,0 +1,41 @@
+leap Package
+============
+
+:mod:`leap` Package
+-------------------
+
+.. automodule:: leap.__init__
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`_version` Module
+----------------------
+
+.. automodule:: leap._version
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`app` Module
+-----------------
+
+.. automodule:: leap.app
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.base
+ leap.baseapp
+ leap.certs
+ leap.crypto
+ leap.eip
+ leap.gui
+ leap.testing
+ leap.util
+
diff --git a/docs/api/leap.testing.rst b/docs/api/leap.testing.rst
new file mode 100644
index 00000000..dfad1b0c
--- /dev/null
+++ b/docs/api/leap.testing.rst
@@ -0,0 +1,43 @@
+testing Package
+===============
+
+:mod:`basetest` Module
+----------------------
+
+.. automodule:: leap.testing.basetest
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`https_server` Module
+--------------------------
+
+.. automodule:: leap.testing.https_server
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`pyqt` Module
+------------------
+
+.. automodule:: leap.testing.pyqt
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`qunittest` Module
+-----------------------
+
+.. automodule:: leap.testing.qunittest
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_basetest` Module
+---------------------------
+
+.. automodule:: leap.testing.test_basetest
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/leap.util.rst b/docs/api/leap.util.rst
new file mode 100644
index 00000000..dbb69ebe
--- /dev/null
+++ b/docs/api/leap.util.rst
@@ -0,0 +1,66 @@
+util Package
+============
+
+:mod:`coroutines` Module
+------------------------
+
+.. automodule:: leap.util.coroutines
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`dicts` Module
+-------------------
+
+.. automodule:: leap.util.dicts
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`fileutil` Module
+----------------------
+
+.. automodule:: leap.util.fileutil
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`leap_argparse` Module
+---------------------------
+
+.. automodule:: leap.util.leap_argparse
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`misc` Module
+------------------
+
+.. automodule:: leap.util.misc
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`translations` Module
+--------------------------
+
+.. automodule:: leap.util.translations
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`web` Module
+-----------------
+
+.. automodule:: leap.util.web
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+Subpackages
+-----------
+
+.. toctree::
+
+ leap.util.tests
+
diff --git a/docs/api/leap.util.tests.rst b/docs/api/leap.util.tests.rst
new file mode 100644
index 00000000..eb6654c4
--- /dev/null
+++ b/docs/api/leap.util.tests.rst
@@ -0,0 +1,19 @@
+tests Package
+=============
+
+:mod:`test_fileutil` Module
+---------------------------
+
+.. automodule:: leap.util.tests.test_fileutil
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+:mod:`test_leap_argparse` Module
+--------------------------------
+
+.. automodule:: leap.util.tests.test_leap_argparse
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
diff --git a/docs/api/modules.rst b/docs/api/modules.rst
new file mode 100644
index 00000000..d49776ae
--- /dev/null
+++ b/docs/api/modules.rst
@@ -0,0 +1,7 @@
+leap
+====
+
+.. toctree::
+ :maxdepth: 4
+
+ leap
diff --git a/docs/dev/internationalization.rst b/docs/dev/internationalization.rst
index e6b89dea..1a9af0be 100644
--- a/docs/dev/internationalization.rst
+++ b/docs/dev/internationalization.rst
@@ -38,21 +38,30 @@ tl;dr;::
self.tr('your string')
-for any string that you want to be translated.
+for any string that you want to be translated, as long as the instance derives from ``QObject``.
+
+If you have to translate something that it is not a ``QObject``, use the magic leap ``translate`` method:
+
+
+.. code-block:: python
+
+ from leap.util.translations import translate
+
+ class Foo(object):
+ bar = translate(<Context>, <string>, <comment>)
+
.. Note about this: there seems to be some problems with the .tr method
- on QObjects. Investigate this.
- I still believe we can use a generic _ method which is smart enough to
- fallback to QObject.tr methods or lookup our own tr implementation (for our
- multilungual objects, like in exceptions or provider labels that came from json objects).
+ so the translate method could actually be the preferred thing in all the cases.
+ Still missing what to do for language labels (json-based).
--kali
For i18n maintainers
^^^^^^^^^^^^^^^^^^^^
-You need ``pylupdate4`` for these steps. To get it, in debian::
+You need ``pylupdate4`` and ``lrelease`` for these steps. To get it, in debian::
- $ apt-get install python-qt4-utils
+ $ apt-get install pyqt4-dev-tools qt4-linguist-tools
If you do not already have it, install the ``transifex-client`` from the cheese shop::
diff --git a/docs/index.rst b/docs/index.rst
index 017fa32c..a57e030f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -78,10 +78,14 @@ API Documentation
If you are looking for a reference to specific classes or functions, you are likely to find it here
+.. I should investigate a bit more how to skip some things, and how to give nice format
+ to the docstrings.
+ Maybe we should not have sphinx-apidocs building everything, but a minimal index of our own.
+
.. note::
- when it's finished, that's it :)
+ when it's a bit more polished, that's it :)
.. toctree::
:maxdepth: 2
- api
+ api/leap
diff --git a/src/leap/base/exceptions.py b/src/leap/base/exceptions.py
index 227da953..c5e56b76 100644
--- a/src/leap/base/exceptions.py
+++ b/src/leap/base/exceptions.py
@@ -14,6 +14,7 @@ Exception attributes and their meaning/uses
* usermessage: the message that will be passed to user in ErrorDialogs
in Qt-land.
"""
+from leap.util.translations import translate
class LeapException(Exception):
@@ -22,6 +23,7 @@ class LeapException(Exception):
sets some parameters that we will check
during error checking routines
"""
+
critical = False
failfirst = False
warning = False
@@ -46,32 +48,50 @@ class ImproperlyConfigured(Exception):
pass
-class NoDefaultInterfaceFoundError(LeapException):
- message = "no default interface found"
- usermessage = "Looks like your computer is not connected to the internet"
+# NOTE: "Errors" (context) has to be a explicit string!
class InterfaceNotFoundError(LeapException):
# XXX should take iface arg on init maybe?
message = "interface not found"
+ usermessage = translate(
+ "Errors",
+ "Interface not found")
+
+
+class NoDefaultInterfaceFoundError(LeapException):
+ message = "no default interface found"
+ usermessage = translate(
+ "Errors",
+ "Looks like your computer "
+ "is not connected to the internet")
class NoConnectionToGateway(CriticalError):
message = "no connection to gateway"
- usermessage = "Looks like there are problems with your internet connection"
+ usermessage = translate(
+ "Errors",
+ "Looks like there are problems "
+ "with your internet connection")
class NoInternetConnection(CriticalError):
message = "No Internet connection found"
- usermessage = "It looks like there is no internet connection."
+ usermessage = translate(
+ "Errors",
+ "It looks like there is no internet connection.")
# and now we try to connect to our web to troubleshoot LOL :P
class CannotResolveDomainError(LeapException):
message = "Cannot resolve domain"
- usermessage = "Domain cannot be found"
+ usermessage = translate(
+ "Errors",
+ "Domain cannot be found")
class TunnelNotDefaultRouteError(CriticalError):
message = "Tunnel connection dissapeared. VPN down?"
- usermessage = "The Encrypted Connection was lost. Shutting down..."
+ usermessage = translate(
+ "Errors",
+ "The Encrypted Connection was lost. Shutting down...")
diff --git a/src/leap/base/pluggableconfig.py b/src/leap/base/pluggableconfig.py
index 0ca985ea..3517db6b 100644
--- a/src/leap/base/pluggableconfig.py
+++ b/src/leap/base/pluggableconfig.py
@@ -10,6 +10,8 @@ import urlparse
import jsonschema
+from leap.util.translations import LEAPTranslatable
+
logger = logging.getLogger(__name__)
@@ -118,7 +120,6 @@ adaptors['json'] = JSONAdaptor()
# to proper python types.
# TODO:
-# - multilingual object.
# - HTTPS uri
@@ -132,6 +133,20 @@ class DateType(object):
return time.strftime(self.fmt, data)
+class TranslatableType(object):
+ """
+ a type that casts to LEAPTranslatable objects.
+ Used for labels we get from providers and stuff.
+ """
+
+ def to_python(self, data):
+ return LEAPTranslatable(data)
+
+ # needed? we already have an extended dict...
+ #def get_prep_value(self, data):
+ #return dict(data)
+
+
class URIType(object):
def to_python(self, data):
@@ -164,6 +179,7 @@ types = {
'date': DateType(),
'uri': URIType(),
'https-uri': HTTPSURIType(),
+ 'translatable': TranslatableType(),
}
diff --git a/src/leap/base/specs.py b/src/leap/base/specs.py
index 962aa07d..f57d7e9c 100644
--- a/src/leap/base/specs.py
+++ b/src/leap/base/specs.py
@@ -22,12 +22,16 @@ leap_provider_spec = {
#'required': True,
},
'name': {
- 'type': dict, # XXX multilingual object?
+ #'type': LEAPTranslatable,
+ 'type': dict,
+ 'format': 'translatable',
'default': {u'en': u'Test Provider'}
#'required': True
},
'description': {
+ #'type': LEAPTranslatable,
'type': dict,
+ 'format': 'translatable',
'default': {u'en': u'Test provider'}
},
'enrollment_policy': {
diff --git a/src/leap/base/tests/test_providers.py b/src/leap/base/tests/test_providers.py
index 9c11f270..f257f54d 100644
--- a/src/leap/base/tests/test_providers.py
+++ b/src/leap/base/tests/test_providers.py
@@ -15,10 +15,12 @@ from leap.base import providers
EXPECTED_DEFAULT_CONFIG = {
u"api_version": u"0.1.0",
- u"description": {u'en': u"Test provider"},
+ #u"description": "LEAPTranslatable<{u'en': u'Test provider'}>",
+ u"description": {u'en': u'Test provider'},
u"default_language": u"en",
#u"display_name": {u'en': u"Test Provider"},
u"domain": u"testprovider.example.org",
+ #u'name': "LEAPTranslatable<{u'en': u'Test Provider'}>",
u'name': {u'en': u'Test Provider'},
u"enrollment_policy": u"open",
#u"serial": 1,
@@ -66,6 +68,7 @@ class TestLeapProviderDefinition(BaseLeapTest):
self.definition.save(to=self.testfile, force=True)
deserialized = json.load(open(self.testfile, 'rb'))
self.maxDiff = None
+ #import ipdb;ipdb.set_trace()
self.assertEqual(deserialized, EXPECTED_DEFAULT_CONFIG)
def test_provider_dump_to_slug(self):
@@ -84,8 +87,9 @@ class TestLeapProviderDefinition(BaseLeapTest):
with open(self.testfile, 'w') as wf:
wf.write(json.dumps(EXPECTED_DEFAULT_CONFIG))
self.definition.load(fromfile=self.testfile)
- self.assertDictEqual(self.config,
- EXPECTED_DEFAULT_CONFIG)
+ #self.assertDictEqual(self.config,
+ #EXPECTED_DEFAULT_CONFIG)
+ self.assertItemsEqual(self.config, EXPECTED_DEFAULT_CONFIG)
def test_provider_validation(self):
self.definition.validate(self.config)
diff --git a/src/leap/util/tests/test_translations.py b/src/leap/util/tests/test_translations.py
new file mode 100644
index 00000000..794daeba
--- /dev/null
+++ b/src/leap/util/tests/test_translations.py
@@ -0,0 +1,22 @@
+import unittest
+
+from leap.util import translations
+
+
+class TrasnlationsTestCase(unittest.TestCase):
+ """
+ tests for translation functions and classes
+ """
+
+ def setUp(self):
+ self.trClass = translations.LEAPTranslatable
+
+ def test_trasnlatable(self):
+ tr = self.trClass({"en": "house", "es": "casa"})
+ eq = self.assertEqual
+ eq(tr.tr(to="es"), "casa")
+ eq(tr.tr(to="en"), "house")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/src/leap/util/translations.py b/src/leap/util/translations.py
new file mode 100644
index 00000000..14b8c020
--- /dev/null
+++ b/src/leap/util/translations.py
@@ -0,0 +1,83 @@
+import inspect
+import logging
+
+from PyQt4.QtCore import QCoreApplication
+from PyQt4.QtCore import QLocale
+
+logger = logging.getLogger(__name__)
+
+"""
+here I could not do all that I wanted.
+the context is not getting passed to the xml file.
+Looks like pylupdate4 is somehow a hack that does not
+parse too well the python ast.
+I guess we could generate the xml for ourselves as a last recourse.
+"""
+
+# XXX BIG NOTE:
+# RESIST the temptation to get the translate function
+# more compact, or have the Context argument passed as a variable
+# It HAS to be explicit due to how the pylupdate parser
+# works.
+
+
+qtTranslate = QCoreApplication.translate
+
+
+def translate(*args, **kwargs):
+ """
+ our magic function.
+ translate(Context, text, comment)
+ """
+ #print 'translating...'
+ klsname = None
+ try:
+ # get class value from instance
+ # using live object inspection
+ prev_frame = inspect.stack()[1][0]
+ self = inspect.getargvalues(prev_frame).locals.get('self')
+ if self:
+ # XXX will this work with QObject wrapper??
+ if isinstance(LEAPTranslatable, self) and hasattr(self, 'tr'):
+ print "we got a self in base class"
+ return self.tr(*args)
+
+ # Trying to get the class name
+ # but this is useless, the parser
+ # has already got the context.
+ klsname = self.__class__.__name__
+ #print 'KLSNAME -- ', klsname
+ except:
+ logger.error('error getting stack frame')
+ #print 'error getting stack frame'
+
+ if klsname:
+ nargs = (klsname,) + args
+ return qtTranslate(*nargs)
+
+ else:
+ nargs = ('default', ) + args
+ return qtTranslate(*nargs)
+
+
+class LEAPTranslatable(dict):
+ """
+ An extended dict that implements a .tr method
+ so it can be translated on the fly by our
+ magic translate method
+ """
+
+ try:
+ locale = str(QLocale.system().name()).split('_')[0]
+ except:
+ logger.warning("could not get system locale!")
+ print "could not get system locale!"
+ locale = "en"
+
+ def tr(self, to=None):
+ if not to:
+ to = self.locale
+ _tr = self.get(to, None)
+ if not _tr:
+ _tr = self.get("en", None)
+ return _tr