From c7b2e180e6cfb4aec22f8ab3e0aebc6773032216 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Fri, 27 Jan 2012 11:19:49 +0100 Subject: 'invest' python module is now 'mate-invest' to solve conflicts with gnome --- invest-applet/invest/Makefile.am | 6 ++-- invest-applet/invest/about.py | 6 ++-- invest-applet/invest/applet.py | 24 +++++++-------- invest-applet/invest/chart.py | 14 ++++----- invest-applet/invest/invest-applet.py | 28 ++++++++--------- invest-applet/invest/invest-chart | 15 --------- invest-applet/invest/mate-invest-chart | 15 +++++++++ invest-applet/invest/networkmanager.py | 10 +++--- invest-applet/invest/preferences.py | 38 +++++++++++------------ invest-applet/invest/quotes.py | 56 +++++++++++++++++----------------- invest-applet/invest/test.py | 4 +-- invest-applet/invest/widgets.py | 8 ++--- 12 files changed, 112 insertions(+), 112 deletions(-) delete mode 100755 invest-applet/invest/invest-chart create mode 100755 invest-applet/invest/mate-invest-chart diff --git a/invest-applet/invest/Makefile.am b/invest-applet/invest/Makefile.am index 286b974c..aa0a4945 100644 --- a/invest-applet/invest/Makefile.am +++ b/invest-applet/invest/Makefile.am @@ -1,11 +1,11 @@ invest-applet: invest-applet.py sed -e "s|\@PYTHONDIR\@|$(pythondir)/|" $< > $@ -bin_SCRIPTS = invest-chart +bin_SCRIPTS = mate-invest-chart libexec_SCRIPTS = invest-applet -investdir = $(pythondir)/invest +investdir = $(pythondir)/mate-invest invest_PYTHON = \ __init__.py \ about.py \ @@ -33,7 +33,7 @@ DISTCLEANFILES = \ EXTRA_DIST = \ defs.py.in \ invest-applet.py \ - invest-chart \ + mate-invest-chart \ test.py #TESTS = test.py diff --git a/invest-applet/invest/about.py b/invest-applet/invest/about.py index e2829e86..82e7d486 100644 --- a/invest-applet/invest/about.py +++ b/invest-applet/invest/about.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- from os.path import join from gettext import gettext as _ -from invest.defs import VERSION -import invest +from mate-invest.defs import VERSION +import mate-invest import gtk, gtk.gdk invest_logo = None try: - invest_logo = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest_neutral.svg"), 96, 96) + invest_logo = gtk.gdk.pixbuf_new_from_file_at_size(join(mate-invest.ART_DATA_DIR, "invest_neutral.svg"), 96, 96) except Exception, msg: pass diff --git a/invest-applet/invest/applet.py b/invest-applet/invest/applet.py index c1689586..3bbffef2 100644 --- a/invest-applet/invest/applet.py +++ b/invest-applet/invest/applet.py @@ -5,11 +5,11 @@ gobject.threads_init() from gettext import gettext as _ import mateconf -import invest, invest.about, invest.chart, invest.preferences, invest.defs -from invest.quotes import QuoteUpdater -from invest.widgets import * +import mate-invest, mate-invest.about, mate-invest.chart, mate-invest.preferences, mate-invest.defs +from mate-invest.quotes import QuoteUpdater +from mate-invest.widgets import * -gtk.window_set_default_icon_from_file(join(invest.ART_DATA_DIR, "invest_neutral.svg")) +gtk.window_set_default_icon_from_file(join(mate-invest.ART_DATA_DIR, "invest_neutral.svg")) class InvestApplet: def __init__(self, applet): @@ -45,9 +45,9 @@ class InvestApplet: def button_clicked(self, widget,event): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: # Three cases... - if len (invest.STOCKS) == 0: + if len (mate-invest.STOCKS) == 0: # a) We aren't configured yet - invest.preferences.show_preferences(self, _("You have not entered any stock information yet")) + mate-invest.preferences.show_preferences(self, _("You have not entered any stock information yet")) self.reload_ilw() elif not self.quotes_updater.quotes_valid: # b) We can't get the data (e.g. offline) @@ -61,13 +61,13 @@ class InvestApplet: self.ilw.toggle_show() def on_about(self, component, verb): - invest.about.show_about() + mate-invest.about.show_about() def on_help(self, component, verb): - invest.help.show_help() + mate-invest.help.show_help() def on_preferences(self, component, verb): - invest.preferences.show_preferences(self) + mate-invest.preferences.show_preferences(self) self.reload_ilw() def on_refresh(self, component, verb): @@ -75,11 +75,11 @@ class InvestApplet: def set_applet_icon(self, change): if change == 1: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_up.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate-invest.ART_DATA_DIR, "invest-22_up.png"), -1,-1) elif change == 0: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_neutral.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate-invest.ART_DATA_DIR, "invest-22_neutral.png"), -1,-1) else: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest-22_down.png"), -1,-1) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate-invest.ART_DATA_DIR, "invest-22_down.png"), -1,-1) self.applet_icon.set_from_pixbuf(pixbuf) def set_applet_tooltip(self, text): diff --git a/invest-applet/invest/chart.py b/invest-applet/invest/chart.py index c6caff74..480e3bff 100644 --- a/invest-applet/invest/chart.py +++ b/invest-applet/invest/chart.py @@ -3,9 +3,9 @@ import gtk, gtk.gdk import gobject import os -import invest +import mate-invest from gettext import gettext as _ -from invest import * +from mate-invest import * import sys from os.path import join import urllib @@ -48,9 +48,9 @@ class ImageRetriever(Thread, _IdleObject): def run(self): self.image = gtk.Image() - try: sock = urllib.urlopen(self.image_url, proxies = invest.PROXY) + try: sock = urllib.urlopen(self.image_url, proxies = mate-invest.PROXY) except Exception, msg: - invest.debug("Error while opening %s: %s" % (self.image_url, msg)) + mate-invest.debug("Error while opening %s: %s" % (self.image_url, msg)) else: loader = gtk.gdk.PixbufLoader() loader.connect("closed", lambda loader: self.image.set_from_pixbuf(loader.get_pixbuf())) @@ -107,10 +107,10 @@ class FinancialChart: win.set_title(_("Financial Chart")) try: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(invest.ART_DATA_DIR, "invest_neutral.svg"), 96,96) + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(join(mate-invest.ART_DATA_DIR, "invest_neutral.svg"), 96,96) self.ui.get_object("plot").set_from_pixbuf(pixbuf) except Exception, msg: - invest.debug("Could not load 'invest-neutral.svg' file: %s" % msg) + mate-invest.debug("Could not load 'invest-neutral.svg' file: %s" % msg) pass # Defaut comboboxes values @@ -249,7 +249,7 @@ class FinancialChart: def show_chart(tickers): ui = gtk.Builder(); - ui.add_from_file(os.path.join(invest.BUILDER_DATA_DIR, "financialchart.ui")) + ui.add_from_file(os.path.join(mate-invest.BUILDER_DATA_DIR, "financialchart.ui")) chart = FinancialChart(ui) ui.get_object("s").set_text(' '.join(tickers)) chart.on_refresh_chart() diff --git a/invest-applet/invest/invest-applet.py b/invest-applet/invest/invest-applet.py index 884bcba8..81900c23 100755 --- a/invest-applet/invest/invest-applet.py +++ b/invest-applet/invest/invest-applet.py @@ -19,20 +19,20 @@ else: sys.path.insert(0, abspath("@PYTHONDIR@")) # Now the path is set, import our applet -import invest, invest.applet, invest.defs, invest.help +import mate-invest, mate-invest.applet, mate-invest.defs, mate-invest.help # Prepare i18n import gettext, locale -gettext.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -gettext.textdomain(invest.defs.GETTEXT_PACKAGE) -locale.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -locale.textdomain(invest.defs.GETTEXT_PACKAGE) +gettext.bindtextdomain(mate-invest.defs.GETTEXT_PACKAGE, mate-invest.defs.MATELOCALEDIR) +gettext.textdomain(mate-invest.defs.GETTEXT_PACKAGE) +locale.bindtextdomain(mate-invest.defs.GETTEXT_PACKAGE, mate-invest.defs.MATELOCALEDIR) +locale.textdomain(mate-invest.defs.GETTEXT_PACKAGE) from gettext import gettext as _ def applet_factory(applet, iid): - invest.debug('Starting invest instance: %s %s'% ( applet, iid )) - invest.applet.InvestApplet(applet) + mate-invest.debug('Starting invest instance: %s %s'% ( applet, iid )) + mate-invest.applet.InvestApplet(applet) return True # Return a standalone window that holds the applet @@ -77,12 +77,12 @@ if __name__ == "__main__": if o in ("-h", "--help"): usage() elif o in ("-d", "--debug"): - invest.DEBUGGING = True - invest.debug("Debugging enabled") - # these messages cannot be turned by invest.DEBUGGING at their originating location, + mate-invest.DEBUGGING = True + mate-invest.debug("Debugging enabled") + # these messages cannot be turned by mate-invest.DEBUGGING at their originating location, # because that variable was set here to be True - invest.debug("Data Dir: %s" % invest.SHARED_DATA_DIR) - invest.debug("Detected PROXY: %s" % invest.PROXY) + mate-invest.debug("Data Dir: %s" % mate-invest.SHARED_DATA_DIR) + mate-invest.debug("Detected PROXY: %s" % mate-invest.PROXY) elif o in ("-w", "--window"): standalone = True @@ -93,6 +93,6 @@ if __name__ == "__main__": mateapplet.matecomponent_factory( "OAFIID:Invest_Applet_Factory", mateapplet.Applet.__gtype__, - invest.defs.PACKAGE, - invest.defs.VERSION, + mate-invest.defs.PACKAGE, + mate-invest.defs.VERSION, applet_factory) diff --git a/invest-applet/invest/invest-chart b/invest-applet/invest/invest-chart deleted file mode 100755 index 37df77cb..00000000 --- a/invest-applet/invest/invest-chart +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import sys, invest.chart, gtk - -# Prepare i18n -import gettext, locale -gettext.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -gettext.textdomain(invest.defs.GETTEXT_PACKAGE) -locale.bindtextdomain(invest.defs.GETTEXT_PACKAGE, invest.defs.MATELOCALEDIR) -locale.textdomain(invest.defs.GETTEXT_PACKAGE) - -if __name__ == "__main__": - win = invest.chart.show_chart(sys.argv[1:]) - win.connect("destroy", lambda x: gtk.main_quit()) - gtk.main() diff --git a/invest-applet/invest/mate-invest-chart b/invest-applet/invest/mate-invest-chart new file mode 100755 index 00000000..097f4c78 --- /dev/null +++ b/invest-applet/invest/mate-invest-chart @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import sys, mate-invest.chart, gtk + +# Prepare i18n +import gettext, locale +gettext.bindtextdomain(mate-invest.defs.GETTEXT_PACKAGE, mate-invest.defs.MATELOCALEDIR) +gettext.textdomain(invest.defs.GETTEXT_PACKAGE) +locale.bindtextdomain(mate-invest.defs.GETTEXT_PACKAGE, mate-invest.defs.MATELOCALEDIR) +locale.textdomain(mate-invest.defs.GETTEXT_PACKAGE) + +if __name__ == "__main__": + win = mate-invest.chart.show_chart(sys.argv[1:]) + win.connect("destroy", lambda x: gtk.main_quit()) + gtk.main() diff --git a/invest-applet/invest/networkmanager.py b/invest-applet/invest/networkmanager.py index 415e9ce4..a784d807 100644 --- a/invest-applet/invest/networkmanager.py +++ b/invest-applet/invest/networkmanager.py @@ -1,4 +1,4 @@ -import invest +import mate-invest from dbus.mainloop.glib import DBusGMainLoop import dbus @@ -19,7 +19,7 @@ class NetworkManager: loop = DBusGMainLoop() # get the NetworkManager object from D-Bus - invest.debug("Connecting to Network Manager via D-Bus") + mate-invest.debug("Connecting to Network Manager via D-Bus") bus = dbus.SystemBus(mainloop=loop) nmobj = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') nm = dbus.Interface(nmobj, 'org.freedesktop.NetworkManager') @@ -32,9 +32,9 @@ class NetworkManager: # get the current status of the network manager self.state = nm.state() - invest.debug("Current Network Manager status is %d" % self.state) + mate-invest.debug("Current Network Manager status is %d" % self.state) except Exception, msg: - invest.error("Could not connect to the Network Manager: %s" % msg ) + mate-invest.error("Could not connect to the Network Manager: %s" % msg ) def online(self): return self.state == STATE_UNKNOWN or self.state == STATE_CONNECTED @@ -47,7 +47,7 @@ class NetworkManager: if isinstance(signal, dict): state = signal.get('State') if state != None: - invest.debug("Network Manager change state %d => %d" % (self.state, state) ); + mate-invest.debug("Network Manager change state %d => %d" % (self.state, state) ); self.state = state # notify about state change diff --git a/invest-applet/invest/preferences.py b/invest-applet/invest/preferences.py index 3c48ee42..14bc6f90 100644 --- a/invest-applet/invest/preferences.py +++ b/invest-applet/invest/preferences.py @@ -2,14 +2,14 @@ from gettext import gettext as _ import locale from os.path import join import gtk, gobject, mateconf -import invest +import mate-invest import currencies import cPickle class PrefsDialog: def __init__(self, applet): self.ui = gtk.Builder() - self.ui.add_from_file(join(invest.BUILDER_DATA_DIR, "prefs-dialog.ui")) + self.ui.add_from_file(join(mate-invest.BUILDER_DATA_DIR, "prefs-dialog.ui")) self.dialog = self.ui.get_object("preferences") self.treeview = self.ui.get_object("stocks") @@ -44,8 +44,8 @@ class PrefsDialog: completion.set_match_func(self.match_func, 0) completion.connect("match-selected", self.on_completion_selection, 1) - if invest.CONFIG.has_key("currency"): - code = invest.CONFIG["currency"]; + if mate-invest.CONFIG.has_key("currency"): + code = mate-invest.CONFIG["currency"]; if self.currencies.has_key(code): self.currency_code = code; currency = self.format_currency(self.currencies[self.currency_code], self.currency_code) @@ -56,7 +56,7 @@ class PrefsDialog: if self.currency_code != None: self.add_exchange_column() - stock_items = invest.STOCKS.items () + stock_items = mate-invest.STOCKS.items () stock_items.sort () for key, data in stock_items: label = data["label"] @@ -80,7 +80,7 @@ class PrefsDialog: value = locale.atof(new_text) self.model[path][col] = value except Exception, msg: - invest.error('Exception while processing cell change: %s' % msg) + mate-invest.error('Exception while processing cell change: %s' % msg) pass def format(self, fmt, value): @@ -138,16 +138,16 @@ class PrefsDialog: pass self.dialog.destroy() - invest.STOCKS = {} + mate-invest.STOCKS = {} def save_symbol(model, path, iter): #if int(model[iter][1]) == 0 or float(model[iter][2]) < 0.0001: # return - if not model[iter][0] in invest.STOCKS: - invest.STOCKS[model[iter][0]] = { 'label': model[iter][1], 'purchases': [] } + if not model[iter][0] in mate-invest.STOCKS: + mate-invest.STOCKS[model[iter][0]] = { 'label': model[iter][1], 'purchases': [] } - invest.STOCKS[model[iter][0]]["purchases"].append({ + mate-invest.STOCKS[model[iter][0]]["purchases"].append({ "amount": float(model[iter][2]), "bought": float(model[iter][3]), "comission": float(model[iter][4]), @@ -155,19 +155,19 @@ class PrefsDialog: }) self.model.foreach(save_symbol) try: - cPickle.dump(invest.STOCKS, file(invest.STOCKS_FILE, 'w')) - invest.debug('Stocks written to file') + cPickle.dump(mate-invest.STOCKS, file(mate-invest.STOCKS_FILE, 'w')) + mate-invest.debug('Stocks written to file') except Exception, msg: - invest.error('Could not save stocks file: %s' % msg) + mate-invest.error('Could not save stocks file: %s' % msg) - invest.CONFIG = {} + mate-invest.CONFIG = {} if self.currency_code != None and len(self.currency_code) == 3: - invest.CONFIG['currency'] = self.currency_code + mate-invest.CONFIG['currency'] = self.currency_code try: - cPickle.dump(invest.CONFIG, file(invest.CONFIG_FILE, 'w')) - invest.debug('Configuration written to file') + cPickle.dump(invest.CONFIG, file(mate-invest.CONFIG_FILE, 'w')) + mate-invest.debug('Configuration written to file') except Exception, msg: - invest.debug('Could not save configuration file: %s' % msg) + mate-invest.debug('Could not save configuration file: %s' % msg) def sync_ui(self): pass @@ -183,7 +183,7 @@ class PrefsDialog: model.remove(model.get_iter(path)) def on_help(self, w): - invest.help.show_help_section("invest-applet-usage") + mate-invest.help.show_help_section("invest-applet-usage") def on_tree_keypress(self, w, event): if event.keyval == 65535: diff --git a/invest-applet/invest/quotes.py b/invest-applet/invest/quotes.py index e8f6145b..42317470 100644 --- a/invest-applet/invest/quotes.py +++ b/invest-applet/invest/quotes.py @@ -7,7 +7,7 @@ from urllib import urlopen import datetime from threading import Thread -import invest, invest.about, invest.chart +import mate-invest, mate-invest.about, mate-invest.chart import currencies CHUNK_SIZE = 512*1024 # 512 kB @@ -55,11 +55,11 @@ class QuotesRetriever(Thread, _IdleObject): def run(self): quotes_url = QUOTES_URL % {"s": self.tickers} try: - quotes_file = urlopen(quotes_url, proxies = invest.PROXY) + quotes_file = urlopen(quotes_url, proxies = mate-invest.PROXY) self.data = quotes_file.readlines () quotes_file.close () except Exception, msg: - invest.debug("Error while retrieving quotes data (url = %s): %s" % (quotes_url, msg)) + mate-invest.debug("Error while retrieving quotes data (url = %s): %s" % (quotes_url, msg)) else: self.retrieved = True self.emit("completed") @@ -80,37 +80,37 @@ class QuoteUpdater(gtk.ListStore): self.refresh() # tell the network manager to notify me when network status changes - invest.nm.set_statechange_callback(self.nm_state_changed) + mate-invest.nm.set_statechange_callback(self.nm_state_changed) def set_update_interval(self, interval): if self.timeout_id != None: - invest.debug("Canceling refresh timer") + mate-invest.debug("Canceling refresh timer") gobject.source_remove(self.timeout_id) self.timeout_id = None if interval > 0: - invest.debug("Setting refresh timer to %s:%02d.%03d" % ( interval / 60000, interval % 60000 / 1000, interval % 1000) ) + mate-invest.debug("Setting refresh timer to %s:%02d.%03d" % ( interval / 60000, interval % 60000 / 1000, interval % 1000) ) self.timeout_id = gobject.timeout_add(interval, self.refresh) def nm_state_changed(self): # when nm is online but we do not have an update timer, create it and refresh - if invest.nm.online(): + if mate-invest.nm.online(): if self.timeout_id == None: self.set_update_interval(AUTOREFRESH_TIMEOUT) self.refresh() def refresh(self): - invest.debug("Refreshing") + mate-invest.debug("Refreshing") # when nm tells me I am offline, stop the update interval - if invest.nm.offline(): - invest.debug("We are offline, stopping update timer") + if mate-invest.nm.offline(): + mate-invest.debug("We are offline, stopping update timer") self.set_update_interval(0) return False - if len(invest.STOCKS) == 0: + if len(mate-invest.STOCKS) == 0: return True - tickers = '+'.join(invest.STOCKS.keys()) + tickers = '+'.join(mate-invest.STOCKS.keys()) quotes_retriever = QuotesRetriever(tickers) quotes_retriever.connect("completed", self.on_retriever_completed) quotes_retriever.start() @@ -141,7 +141,7 @@ class QuoteUpdater(gtk.ListStore): def on_currency_retriever_completed(self, retriever): if retriever.retrieved == False: - invest.error("Failed to retrieve currency rates!") + mate-invest.error("Failed to retrieve currency rates!") else: self.convert_currencies(self.parse_yahoo_csv(csv.reader(retriever.data))) self.update_tooltip() @@ -239,7 +239,7 @@ class QuoteUpdater(gtk.ListStore): pb = None # get the label of this stock for later reuse - label = invest.STOCKS[ticker]["label"] + label = mate-invest.STOCKS[ticker]["label"] if len(label) == 0: if len(val["label"]) != 0: label = val["label"] @@ -260,7 +260,7 @@ class QuoteUpdater(gtk.ListStore): # sometimes, funny currencies are returned (special characters), only consider known currencies if len(val["currency"]) > 0 and val["currency"] not in currencies.Currencies.currencies: - invest.debug("Currency '%s' is not known, dropping" % val["currency"]) + mate-invest.debug("Currency '%s' is not known, dropping" % val["currency"]) val["currency"] = "" # if this is a currency not yet seen and different from the target currency, memorize it @@ -269,7 +269,7 @@ class QuoteUpdater(gtk.ListStore): # Check whether the symbol is a simple quote, or a portfolio value is_simple_quote = True - for purchase in invest.STOCKS[ticker]["purchases"]: + for purchase in mate-invest.STOCKS[ticker]["purchases"]: if purchase["amount"] != 0: is_simple_quote = False break @@ -279,7 +279,7 @@ class QuoteUpdater(gtk.ListStore): row = self.insert(0, [ticker, label, val["currency"], True, 0, 0, val["trade"], val["variation_pct"], pb]) simple_quotes_change += val['variation_pct'] else: - (balance, change) = self.balance(invest.STOCKS[ticker]["purchases"], val["trade"]) + (balance, change) = self.balance(mate-invest.STOCKS[ticker]["purchases"], val["trade"]) row = self.insert(0, [ticker, label, val["currency"], False, balance, change, val["trade"], val["variation_pct"], pb]) self.add_balance_change(balance, change, val["currency"]) @@ -288,7 +288,7 @@ class QuoteUpdater(gtk.ListStore): else: url = 'http://ichart.yahoo.com/h?s=%s' % ticker - image_retriever = invest.chart.ImageRetriever(url) + image_retriever = mate-invest.chart.ImageRetriever(url) image_retriever.connect("completed", self.set_pb_callback, row) image_retriever.start() @@ -313,21 +313,21 @@ class QuoteUpdater(gtk.ListStore): self.quotes_valid = True except Exception, msg: - invest.debug("Failed to populate quotes: %s" % msg) - invest.debug(quotes) + mate-invest.debug("Failed to populate quotes: %s" % msg) + mate-invest.debug(quotes) self.quotes_valid = False # start retrieving currency conversion rates - if invest.CONFIG.has_key("currency"): - target_currency = invest.CONFIG["currency"] + if mate-invest.CONFIG.has_key("currency"): + target_currency = mate-invest.CONFIG["currency"] symbols = [] - invest.debug("These currencies occur: %s" % self.currencies) + mate-invest.debug("These currencies occur: %s" % self.currencies) for currency in self.currencies: if currency == target_currency: continue - invest.debug("%s will be converted to %s" % ( currency, target_currency )) + mate-invest.debug("%s will be converted to %s" % ( currency, target_currency )) symbol = currency + target_currency + "=X" symbols.append(symbol) @@ -339,7 +339,7 @@ class QuoteUpdater(gtk.ListStore): def convert_currencies(self, quotes): # if there is no target currency, this method should never have been called - if not invest.CONFIG.has_key("currency"): + if not mate-invest.CONFIG.has_key("currency"): return # reset the overall balance @@ -353,7 +353,7 @@ class QuoteUpdater(gtk.ListStore): rates[currency] = rate # convert all non target currencies - target_currency = invest.CONFIG["currency"] + target_currency = mate-invest.CONFIG["currency"] iter = self.get_iter_first() while iter != None: currency = self.get_value(iter, self.CURRENCY) @@ -367,7 +367,7 @@ class QuoteUpdater(gtk.ListStore): if not self.get_value(iter, self.TICKER_ONLY): ticker = self.get_value(iter, self.SYMBOL) value = self.get_value(iter, self.VALUE) - (balance, change) = self.balance(invest.STOCKS[ticker]["purchases"], value, rates[currency]) + (balance, change) = self.balance(mate-invest.STOCKS[ticker]["purchases"], value, rates[currency]) self.set(iter, self.BALANCE, balance) self.set(iter, self.BALANCE_PCT, change) self.add_balance_change(balance, change, target_currency) @@ -402,7 +402,7 @@ class QuoteUpdater(gtk.ListStore): # check if we have only simple quotes def simple_quotes_only(self): res = True - for entry, data in invest.STOCKS.iteritems(): + for entry, data in mate-invest.STOCKS.iteritems(): purchases = data["purchases"] for purchase in purchases: if purchase["amount"] != 0: diff --git a/invest-applet/invest/test.py b/invest-applet/invest/test.py index aea5f5f3..47ae2167 100755 --- a/invest-applet/invest/test.py +++ b/invest-applet/invest/test.py @@ -9,7 +9,7 @@ sys.path.insert(0, abspath(dirname(__file__) + "/..")) print sys.path import quotes -import invest +import mate-invest def null_function (*args): pass @@ -17,7 +17,7 @@ def null_function (*args): class TestQuotes (unittest.TestCase): def testQuoteUpdater_populate (self): qu = quotes.QuoteUpdater (null_function, null_function) - invest.STOCKS = {'GOGO': {'label': "Google Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}, 'JAVA': {'label':"Sun Microsystems Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}} + mate-invest.STOCKS = {'GOGO': {'label': "Google Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}, 'JAVA': {'label':"Sun Microsystems Inc.", 'purchases': [{'amount' : 1, 'comission' : 0.0, 'bought': 0.0}]}} quote = { 'GOGO': { "ticker": 'GOGO', "trade": 386.91, "time": "10/3/2008", "date": "4.00pm", "variation": -3.58, "open": 397.14, "variation_pct": 10 }} qu.populate (quote) self.assertEqual (qu.quotes_valid, True) diff --git a/invest-applet/invest/widgets.py b/invest-applet/invest/widgets.py index 3f5bc91b..c8083450 100644 --- a/invest-applet/invest/widgets.py +++ b/invest-applet/invest/widgets.py @@ -4,7 +4,7 @@ import mateapplet, gtk, gtk.gdk, mateconf, gobject, pango from gettext import gettext as _ import locale import csv -import invest, invest.about, invest.chart +import mate-invest, mate-invest.about, mate-invest.chart COLORSCALE_POSITIVE = [ "white", @@ -154,7 +154,7 @@ class InvestWidget(gtk.TreeView): if ticker == None: return - invest.chart.show_chart([ticker]) + mate-invest.chart.show_chart([ticker]) #class InvestTicker(gtk.Label): # def __init__(self): @@ -215,7 +215,7 @@ class InvestTrend(gtk.Image): int(color.red*factor)<<24|int(color.green*factor)<<16|int(color.blue*factor)<<8|opacity) self.set_from_pixbuf(self.pixbuf) except Exception, msg: - invest.error("Could not set color: %s" % msg) + mate-invest.error("Could not set color: %s" % msg) def on_quotes_update(self, updater): start_total = 0 @@ -230,7 +230,7 @@ class InvestTrend(gtk.Image): start = now / (1 + var) - portfolio_number = sum([purchase["amount"] for purchase in invest.STOCKS[row[updater.SYMBOL]]["purchases"]]) + portfolio_number = sum([purchase["amount"] for purchase in mate-invest.STOCKS[row[updater.SYMBOL]]["purchases"]]) start_total += start * portfolio_number now_total += now * portfolio_number -- cgit v1.2.1