From 540b7c311b3993b449c8bd1f94ee396486d6619e Mon Sep 17 00:00:00 2001 From: Stefan Krulj Date: Fri, 12 Oct 2012 17:52:48 +0200 Subject: [PATCH] project stucture cleanup, modules auto-import --- main.py | 29 ++++++++++++------- choose.py => modules/active/choose.py | 0 cowsay.py => modules/active/cowsay.py | 0 get_quote.py => modules/active/get_quote.py | 0 kraken.py => modules/active/kraken.py | 0 .../active/last_active.py | 0 logger.py => modules/active/logger.py | 0 pen.py => modules/active/pen.py | 0 tantrum.py => modules/active/tantrum.py | 0 tell.py => modules/active/tell.py | 0 brathuhn.py => sys/brathuhn.py | 0 config.py => sys/config.py | 0 jingle_ft.py => sys/jingle_ft.py | 0 quote.py => sys/quote.py | 0 s5b.py => sys/s5b.py | 0 stream_ft.py => sys/stream_ft.py | 0 util.py => sys/util.py | 0 17 files changed, 18 insertions(+), 11 deletions(-) rename choose.py => modules/active/choose.py (100%) rename cowsay.py => modules/active/cowsay.py (100%) rename get_quote.py => modules/active/get_quote.py (100%) rename kraken.py => modules/active/kraken.py (100%) rename last_active.py => modules/active/last_active.py (100%) rename logger.py => modules/active/logger.py (100%) rename pen.py => modules/active/pen.py (100%) rename tantrum.py => modules/active/tantrum.py (100%) rename tell.py => modules/active/tell.py (100%) rename brathuhn.py => sys/brathuhn.py (100%) rename config.py => sys/config.py (100%) rename jingle_ft.py => sys/jingle_ft.py (100%) mode change 100755 => 100644 rename quote.py => sys/quote.py (100%) rename s5b.py => sys/s5b.py (100%) rename stream_ft.py => sys/stream_ft.py (100%) rename util.py => sys/util.py (100%) diff --git a/main.py b/main.py index e18cef8..1df1d4c 100755 --- a/main.py +++ b/main.py @@ -1,20 +1,27 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import brathuhn, os +import sys, os -import stream_ft,xmpp +cwd = os.getcwd() +sys.path.append(os.path.join(cwd,"sys")) +sys.path.append(os.path.join(cwd,"modules","active")) -import kraken -import get_quote -import logger -import cowsay -import choose -import tantrum -import tell -import last_active -import pen +import brathuhn +modules = [] +files = os.listdir( os.path.join(cwd,"modules","active") ) + +for f in files: + if f.endswith(".py"): + mod = f[:-3] + elif f.endswith(".pyc"): + mod = f[:-4] + if not mod in modules: + modules.append(mod) + +for mod in modules: + __import__(mod) brathuhn.connect_and_join() brathuhn.loop() diff --git a/choose.py b/modules/active/choose.py similarity index 100% rename from choose.py rename to modules/active/choose.py diff --git a/cowsay.py b/modules/active/cowsay.py similarity index 100% rename from cowsay.py rename to modules/active/cowsay.py diff --git a/get_quote.py b/modules/active/get_quote.py similarity index 100% rename from get_quote.py rename to modules/active/get_quote.py diff --git a/kraken.py b/modules/active/kraken.py similarity index 100% rename from kraken.py rename to modules/active/kraken.py diff --git a/last_active.py b/modules/active/last_active.py similarity index 100% rename from last_active.py rename to modules/active/last_active.py diff --git a/logger.py b/modules/active/logger.py similarity index 100% rename from logger.py rename to modules/active/logger.py diff --git a/pen.py b/modules/active/pen.py similarity index 100% rename from pen.py rename to modules/active/pen.py diff --git a/tantrum.py b/modules/active/tantrum.py similarity index 100% rename from tantrum.py rename to modules/active/tantrum.py diff --git a/tell.py b/modules/active/tell.py similarity index 100% rename from tell.py rename to modules/active/tell.py diff --git a/brathuhn.py b/sys/brathuhn.py similarity index 100% rename from brathuhn.py rename to sys/brathuhn.py diff --git a/config.py b/sys/config.py similarity index 100% rename from config.py rename to sys/config.py diff --git a/jingle_ft.py b/sys/jingle_ft.py old mode 100755 new mode 100644 similarity index 100% rename from jingle_ft.py rename to sys/jingle_ft.py diff --git a/quote.py b/sys/quote.py similarity index 100% rename from quote.py rename to sys/quote.py diff --git a/s5b.py b/sys/s5b.py similarity index 100% rename from s5b.py rename to sys/s5b.py diff --git a/stream_ft.py b/sys/stream_ft.py similarity index 100% rename from stream_ft.py rename to sys/stream_ft.py diff --git a/util.py b/sys/util.py similarity index 100% rename from util.py rename to sys/util.py