diff options
author | Eduardo Silva <edsiper@gmail.com> | 2007-11-13 14:09:13 (GMT) |
---|---|---|
committer | Eduardo Silva <edsiper@gmail.com> | 2007-11-13 14:09:13 (GMT) |
commit | 5c1178f4b6c8ad947f312e9d094ef6ef92bce85e (patch) | |
tree | 2450696081baa4a20a8b7103a2f56b9f755d5844 | |
parent | 16671eae2dba3c4950a7303e18b4d0c93c54b5b2 (diff) |
Move initial classes to core.py
-rw-r--r-- | purk/__init__.py | 105 |
1 files changed, 1 insertions, 104 deletions
diff --git a/purk/__init__.py b/purk/__init__.py index b398dfb..5d20240 100644 --- a/purk/__init__.py +++ b/purk/__init__.py @@ -1,104 +1 @@ -import os -import sys -import traceback -import events -import windows - -urkpath = os.path.abspath(os.path.dirname(__file__)) - -if os.path.abspath(os.curdir) != os.path.join(urkpath): - sys.path[0] = os.path.join(urkpath) - -sys.path = [ - os.path.join(urkpath, "scripts"), - ] + sys.path - -script_path = urkpath+"/scripts" - -from ui import * - -# Here I'm trying to handle the original URL IRC Client, urk don't use -# normal classes . Let's try to get an Urk Widget: -class Trigger(object): - def __init__(self): - self._mods = [] - self.events = events - self._load_scripts() - - def _load_scripts(self): - script_path = urkpath + "/scripts" - try: - suffix = os.extsep+"py" - for script in os.listdir(script_path): - if script.endswith(suffix): - try: - mod = self.events.load(script) - self._mods.append(mod) - except: - traceback.print_exc() - print "Failed loading script %s." % script - except OSError: - pass - - def get_modules(self): - return self._mods - -class Core(object): - def __init__(self): - self.window = None - self.trigger = Trigger() - self.events = self.trigger.events - self.manager = widgets.UrkUITabs(self) - self.channels = [] - - mods = self.trigger.get_modules() - for m in mods: - m.core = self - m.manager = self.manager - - if not self.window: - self.window = windows.new(windows.StatusWindow, irc.Network(self), "status", self) - self.window.activate() - - register_idle(self.trigger_start) - #gtk.gdk.threads_enter() - - def run_command(self, command): - offset = 0 - if command[0] == '/': - offset = 1 - - self.events.run(command[offset:], self.manager.get_active(), self.window.network) - - def trigger_start(self): - self.events.trigger("Start") - - def _add_script(self, module): - return - -class Client(object): - def __init__(self): - self.core = Core() - self.widget = self.core.manager - print self.widget - self.widget.show_all() - - def run_command(self, command): - self.core.run_command(command) - - def join_server(self, network_name, port=6667): - command = 'server '+ network_name + ' ' + str(port) - self.run_command(command) - - def get_widget(self): - return self.widget - - def show(self): - self.widget.show_all() - - def add_channel(self, channel): - print "Add channel: ", channel - self.core.channels.append(channel) - - def clear_channels(self): - self.core.channels = [] +from core import *
\ No newline at end of file |