GijsTimmers / kotnetcli

An easy automated way to log in on Kotnet.
GNU General Public License v3.0
5 stars 4 forks source link

We should probably restructure the importing system #77

Closed GijsTimmers closed 8 years ago

GijsTimmers commented 9 years ago

Current situation:

from communicator.fabriek import LoginCommunicatorFabriek, LogoutCommunicatorFabriek
(...)
from tools import cursor
(...)
from tools import log

There have been some problems packaging the application: some modules can't be found, etc.

We've seen this problem before. For example, the communicators in the communicator/ directory have to import cursor.hide() from the tools/ directory. The current situation works, but is far from unified, and still gives problems every now and then.

I'd like to propose to import the importable classes to __init__.py instead. If we do so, the directory name __init__.py resides in becomes a package to easily import stuff from, like an API. Another advantage is that we can explicitly say what should be imported and what not.

[gijs@xiphos kotnetcli]$ tree -I "compilation|doc|app|app-development"
.
├── browser.py
├── browser.pyc
├── communicator
│   ├── bubblec.py
│   ├── bubblec.pyc
│   ├── coloramac.py
│   ├── coloramac.pyc
│   ├── cursesc.py
│   ├── cursesc.pyc
│   ├── dialogc.py
│   ├── dialogc.pyc
│   ├── fabriek.py
│   ├── fabriek.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── plaintextc.py
│   ├── plaintextc.pyc
│   ├── quietc.py
│   ├── quietc.pyc
│   ├── README.md
│   ├── summaryc.py
│   └── summaryc.pyc
├── credentials.py
├── credentials.pyc
├── __init__.py
├── kotnetcli-android.py
├── kotnetcli.py
├── kotnetcli_test.py
├── kotnetcli-win-easy.py
├── logoutformuliertemplate.html
├── testsuite.py
├── tools
│   ├── cursor.py
│   ├── cursor.pyc
│   ├── errorcodes.py
│   ├── errorcodes.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── log.py
│   ├── log.pyc
│   ├── pinger.py
│   ├── pinger.pyc
│   └── windowscredentialsforgetter.py
├── worker.py
└── worker.pyc

IIUC, that would give us code like:

from tools import cursor_hide
from communicator import LoginCommunicatorFabriek, LogoutCommunicatorFabriek

which is a lot cleaner IMO.

GijsTimmers commented 9 years ago

I'll probably create a new branch to make the necessary changes before merging them into dev: restructured_init

jovanbulck commented 9 years ago

I agree this would be a lot cleaner and more readable :+1:

GijsTimmers commented 9 years ago

:-)

GijsTimmers commented 8 years ago

Fixed. 5e3123cead2dc020f1fec4840a2f98b4e0d0411e