From ef76b07a4ff0c2e7f4e25cb8c143b83ff849ca8e Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@cd1c1023-2f26-0410-ae45-c471fc1f0318> Date: Sun, 2 Mar 2008 15:30:52 +0000 Subject: [PATCH] Spritz: - move spritz constants to a separate file git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1360 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- spritz/src/callbacks.py | 2 +- spritz/src/dialogs.py | 2 +- spritz/src/entropyapi.py | 2 +- spritz/src/etpgui/widgets.py | 2 +- spritz/src/gui.py | 3 +- spritz/src/misc.py | 216 -------------------------------- spritz/src/spritz.py | 2 +- spritz/src/spritz_setup.py | 231 +++++++++++++++++++++++++++++++++++ spritz/src/views.py | 2 +- 9 files changed, 239 insertions(+), 223 deletions(-) create mode 100644 spritz/src/spritz_setup.py diff --git a/spritz/src/callbacks.py b/spritz/src/callbacks.py index 4009209fb..9e0e61173 100644 --- a/spritz/src/callbacks.py +++ b/spritz/src/callbacks.py @@ -26,7 +26,7 @@ import logging from urlgrabber.progress import * # Yumex imports -from misc import const +from spritz_setup import const #from yumgui.callbacks import RPMInstallCallback #from yumgui import * from i18n import _ diff --git a/spritz/src/dialogs.py b/spritz/src/dialogs.py index abb4392d0..dd160fcd9 100644 --- a/spritz/src/dialogs.py +++ b/spritz/src/dialogs.py @@ -28,7 +28,7 @@ except: from ConfigParser import ConfigParser,SafeConfigParser -from misc import const,cleanMarkupSting,SpritzConf,unicode2htmlentities +from spritz_setup import const,cleanMarkupSting,SpritzConf,unicode2htmlentities from i18n import _ class ConfirmationDialog: diff --git a/spritz/src/entropyapi.py b/spritz/src/entropyapi.py index 3ea0d637b..f52571093 100644 --- a/spritz/src/entropyapi.py +++ b/spritz/src/entropyapi.py @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -from misc import const,cleanMarkupSting +from spritz_setup import const,cleanMarkupSting from i18n import _ from dialogs import questionDialog,LicenseDialog diff --git a/spritz/src/etpgui/widgets.py b/spritz/src/etpgui/widgets.py index 0dfb6f4a9..ea90f4daa 100644 --- a/spritz/src/etpgui/widgets.py +++ b/spritz/src/etpgui/widgets.py @@ -23,7 +23,7 @@ import etpgui import gobject import types import sys, os -from misc import const +from spritz_setup import const import vte class SpritzConsole(vte.Terminal): diff --git a/spritz/src/gui.py b/spritz/src/gui.py index a2c33ed73..d7a4c4464 100644 --- a/spritz/src/gui.py +++ b/spritz/src/gui.py @@ -18,7 +18,8 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. from etpgui import * -from misc import SpritzQueue, SpritzConf, const, cleanMarkupSting +from spritz_setup import SpritzConf, const, cleanMarkupSting +from misc import SpritzQueue from views import * from etpgui.widgets import SpritzConsole from i18n import _ diff --git a/spritz/src/misc.py b/spritz/src/misc.py index 4412e7837..3f46401ab 100644 --- a/spritz/src/misc.py +++ b/spritz/src/misc.py @@ -17,109 +17,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import logging -import gtk -import gobject -import time from i18n import _ -import packages -from entropyConstants import * - - -class const: - ''' This Class contains all the Constants in Yumex''' - __spritz_version__ = etpConst['entropyversion'] - # Paths - MAIN_PATH = os.path.abspath( os.path.dirname( sys.argv[0] ) ) - GLADE_FILE = MAIN_PATH+'/spritz.glade' - if not os.path.isfile(GLADE_FILE): - MAIN_PATH = '/usr/lib/entropy/spritz' - GLADE_FILE = MAIN_PATH+'/spritz.glade' - if MAIN_PATH == '/usr/lib/entropy/spritz': - PIXMAPS_PATH = '/usr/share/pixmaps/spritz' - else: - PIXMAPS_PATH = MAIN_PATH+'/../gfx' - if MAIN_PATH == '/usr/lib/entropy/spritz': - ICONS_PATH = '/usr/share/pixmaps/spritz' - else: - ICONS_PATH = MAIN_PATH+'/pixmaps' - - # package categories - PACKAGE_CATEGORIES = [ - "None", - "Groups", - "RPM Groups", - "Age"] - - DAY_IN_SECONDS = 86400 - # Page -> Notebook page numbers - PAGE_REPOS = 0 - PAGE_PKG = 1 - PAGE_OUTPUT = 2 - PAGE_GROUP = 3 - PAGE_QUEUE = 4 - PAGE_FILESCONF = 5 - PAGES = { - 'packages' : PAGE_PKG, - 'repos' : PAGE_REPOS, - 'output' : PAGE_OUTPUT, - 'queue' : PAGE_QUEUE, - 'group' : PAGE_GROUP, - 'filesconf' : PAGE_FILESCONF - } - - PACKAGE_PROGRESS_STEPS = ( 0.1, # Depsolve - 0.5, # Download - 0.1, # Transaction Test - 0.3 ) # Running Transaction - - SETUP_PROGRESS_STEPS = ( 0.1, # Yum Config - 0.2, # Repo Setup - 0.1, # Sacksetup - 0.2, # Updates - 0.1, # Group - 0.3) # get package Lists - - CREDITS = ( - (('Spritz Package Manager - %s' % __spritz_version__), - ('Copyright 2008','Fabio Erculiani')), - - (_("Programming:"), - ("Fabio Erculiani",)), - - (_("Yum Extender Programmers:"), - ("Tim Lauridsen", "David Zamirski")), - - (_("Translation:"), - ("Tim Lauridsen (Danish)", - "MATSUURA Takanori (Japanese)", - "Rodrigo Padula de Oliveira (Brazilian)", - "Eric Tanguy (French)", - "Soohyung Cho (Korean)", - "Danilo (Italian)", - "Serta . YILDIZ (Turkish)", - "Dawid Zamirski, Patryk Zawadzki (Polish)", - "Piotr Drag (Polish)", - "Tero Hietanen (Finnish)", - "Dieter Komendera (German)", - "Maxim Dziumanenko (Ukrainian)", - "Novotny Lukas (Czech)", - "Szll Tams (Hungarian)", - "Leonid Kanter, Nikita (Russian)", - "Diego Alonso (Spanish)", - "A Singh Alam (Punjabi)", - "Hao Song (Chinese(Simplified))")), - - - (_("Dedicated to:"), - ("Sergio Erculiani",) - ) - - ) class SpritzQueue: def __init__(self): - self.logger = logging.getLogger('yumex.YumexQueue') self.packages = {} self.groups = {} self.before = [] @@ -437,120 +338,3 @@ class SpritzQueue: if grp in self.groups[action]: return action return None - -class SpritzConf: - """ Yum Extender Config Setting""" - autorefresh = True - recentdays = 14 - debug = False - plugins = True - usecache = False - proxy = "" - font_console = 'Monospace 8' - font_pkgdesc = 'Monospace 8' - color_console_background = '#FFFFFF' - color_console_font = '#000000' - color_pkgdesc = '#68228B' - color_install = 'darkgreen' - color_update = 'red' - color_normal = 'black' - color_obsolete = 'blue' - filelist = True - changelog = False - disable_repo_page = False - branding_title = 'Spritz Package Manager' - -def cleanMarkupSting(msg): - msg = str(msg) # make sure it is a string - msg = gobject.markup_escape_text(msg) - #msg = msg.replace('@',' AT ') - #msg = msg.replace('<','[') - #msg = msg.replace('>',']') - return msg - -class fakeoutfile: - """ - A fake output file object. It sends output to a GTK TextView widget, - and if asked for a file number, returns one set on instance creation - """ - - def __init__(self, fn): - self.fn = fn - self.text_written = [] - - def close(self): - pass - - def flush(self): - self.close() - - def fileno(self): - return self.fn - - def isatty(self): - return False - - def read(self, a): - return '' - - def readline(self): - return '' - - def readlines(self): - return [] - - def write(self, s): - os.write(self.fn,s) - self.text_written.append(s) - # cut at 1024 entries - if len(self.text_written) > 1024: - self.text_written = self.text_written[-1024:] - #sys.stdout.write(s+"\n") - - def write_line(self, s): - self.write(s) - - def writelines(self, l): - for s in l: - self.write(s) - - def seek(self, a): - raise IOError, (29, 'Illegal seek') - - def tell(self): - raise IOError, (29, 'Illegal seek') - - def truncate(self): - self.tell() - -class fakeinfile: - """ - A fake input file object. It receives input from a GTK TextView widget, - and if asked for a file number, returns one set on instance creation - """ - - def __init__(self, fn): - self.fn = fn - def close(self): pass - flush = close - def fileno(self): return self.fn - def isatty(self): return False - def read(self, a): return self.readline() - def readline(self): ## just a fake - return os.read(self.fn,2048) - def readlines(self): return [] - def write(self, s): return None - def writelines(self, l): return None - def seek(self, a): raise IOError, (29, 'Illegal seek') - def tell(self): raise IOError, (29, 'Illegal seek') - truncate = tell - -from htmlentitydefs import codepoint2name -def unicode2htmlentities(u): - htmlentities = list() - for c in u: - if ord(c) < 128: - htmlentities.append(c) - else: - htmlentities.append('&%s;' % codepoint2name[ord(c)]) - return ''.join(htmlentities) \ No newline at end of file diff --git a/spritz/src/spritz.py b/spritz/src/spritz.py index 381d06407..88b247fc0 100644 --- a/spritz/src/spritz.py +++ b/spritz/src/spritz.py @@ -46,7 +46,7 @@ from etpgui import * import filters from gui import SpritzGUI from dialogs import * -from misc import const, fakeoutfile, fakeinfile +from spritz_setup import const, fakeoutfile, fakeinfile from i18n import _ import time diff --git a/spritz/src/spritz_setup.py b/spritz/src/spritz_setup.py new file mode 100644 index 000000000..3082fab75 --- /dev/null +++ b/spritz/src/spritz_setup.py @@ -0,0 +1,231 @@ +#!/usr/bin/python -tt +# -*- coding: iso-8859-1 -*- +# Yum Exteder (yumex) - A GUI for yum +# Copyright (C) 2006 Tim Lauridsen < timyum-extenderorg > +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import gtk, gobject +import os, sys +from i18n import _ +from entropyConstants import * + +class const: + ''' This Class contains all the Constants in Yumex''' + __spritz_version__ = etpConst['entropyversion'] + # Paths + MAIN_PATH = os.path.abspath( os.path.dirname( sys.argv[0] ) ) + GLADE_FILE = MAIN_PATH+'/spritz.glade' + if not os.path.isfile(GLADE_FILE): + MAIN_PATH = '/usr/lib/entropy/spritz' + GLADE_FILE = MAIN_PATH+'/spritz.glade' + if MAIN_PATH == '/usr/lib/entropy/spritz': + PIXMAPS_PATH = '/usr/share/pixmaps/spritz' + else: + PIXMAPS_PATH = MAIN_PATH+'/../gfx' + if MAIN_PATH == '/usr/lib/entropy/spritz': + ICONS_PATH = '/usr/share/pixmaps/spritz' + else: + ICONS_PATH = MAIN_PATH+'/pixmaps' + + # package categories + PACKAGE_CATEGORIES = [ + "None", + "Groups", + "RPM Groups", + "Age"] + + DAY_IN_SECONDS = 86400 + # Page -> Notebook page numbers + PAGE_REPOS = 0 + PAGE_PKG = 1 + PAGE_OUTPUT = 2 + PAGE_GROUP = 3 + PAGE_QUEUE = 4 + PAGE_FILESCONF = 5 + PAGES = { + 'packages' : PAGE_PKG, + 'repos' : PAGE_REPOS, + 'output' : PAGE_OUTPUT, + 'queue' : PAGE_QUEUE, + 'group' : PAGE_GROUP, + 'filesconf' : PAGE_FILESCONF + } + + PACKAGE_PROGRESS_STEPS = ( 0.1, # Depsolve + 0.5, # Download + 0.1, # Transaction Test + 0.3 ) # Running Transaction + + SETUP_PROGRESS_STEPS = ( 0.1, # Yum Config + 0.2, # Repo Setup + 0.1, # Sacksetup + 0.2, # Updates + 0.1, # Group + 0.3) # get package Lists + + CREDITS = ( + (('Spritz Package Manager - %s' % __spritz_version__), + ('Copyright 2008','Fabio Erculiani')), + + (_("Programming:"), + ("Fabio Erculiani",)), + + (_("Yum Extender Programmers:"), + ("Tim Lauridsen", "David Zamirski")), + + (_("Translation:"), + ("Tim Lauridsen (Danish)", + "MATSUURA Takanori (Japanese)", + "Rodrigo Padula de Oliveira (Brazilian)", + "Eric Tanguy (French)", + "Soohyung Cho (Korean)", + "Danilo (Italian)", + "Serta . YILDIZ (Turkish)", + "Dawid Zamirski, Patryk Zawadzki (Polish)", + "Piotr Drag (Polish)", + "Tero Hietanen (Finnish)", + "Dieter Komendera (German)", + "Maxim Dziumanenko (Ukrainian)", + "Novotny Lukas (Czech)", + "Szll Tams (Hungarian)", + "Leonid Kanter, Nikita (Russian)", + "Diego Alonso (Spanish)", + "A Singh Alam (Punjabi)", + "Hao Song (Chinese(Simplified))")), + + + (_("Dedicated to:"), + ("Sergio Erculiani",) + ) + + ) + +class SpritzConf: + """ Yum Extender Config Setting""" + autorefresh = True + recentdays = 14 + debug = False + plugins = True + usecache = False + proxy = "" + font_console = 'Monospace 8' + font_pkgdesc = 'Monospace 8' + color_console_background = '#FFFFFF' + color_console_font = '#000000' + color_pkgdesc = '#68228B' + color_install = 'darkgreen' + color_update = 'red' + color_normal = 'black' + color_obsolete = 'blue' + filelist = True + changelog = False + disable_repo_page = False + branding_title = 'Spritz Package Manager' + +def cleanMarkupSting(msg): + msg = str(msg) # make sure it is a string + msg = gobject.markup_escape_text(msg) + #msg = msg.replace('@',' AT ') + #msg = msg.replace('<','[') + #msg = msg.replace('>',']') + return msg + +class fakeoutfile: + """ + A fake output file object. It sends output to a GTK TextView widget, + and if asked for a file number, returns one set on instance creation + """ + + def __init__(self, fn): + self.fn = fn + self.text_written = [] + + def close(self): + pass + + def flush(self): + self.close() + + def fileno(self): + return self.fn + + def isatty(self): + return False + + def read(self, a): + return '' + + def readline(self): + return '' + + def readlines(self): + return [] + + def write(self, s): + os.write(self.fn,s) + self.text_written.append(s) + # cut at 1024 entries + if len(self.text_written) > 1024: + self.text_written = self.text_written[-1024:] + #sys.stdout.write(s+"\n") + + def write_line(self, s): + self.write(s) + + def writelines(self, l): + for s in l: + self.write(s) + + def seek(self, a): + raise IOError, (29, 'Illegal seek') + + def tell(self): + raise IOError, (29, 'Illegal seek') + + def truncate(self): + self.tell() + +class fakeinfile: + """ + A fake input file object. It receives input from a GTK TextView widget, + and if asked for a file number, returns one set on instance creation + """ + + def __init__(self, fn): + self.fn = fn + def close(self): pass + flush = close + def fileno(self): return self.fn + def isatty(self): return False + def read(self, a): return self.readline() + def readline(self): ## just a fake + return os.read(self.fn,2048) + def readlines(self): return [] + def write(self, s): return None + def writelines(self, l): return None + def seek(self, a): raise IOError, (29, 'Illegal seek') + def tell(self): raise IOError, (29, 'Illegal seek') + truncate = tell + +from htmlentitydefs import codepoint2name +def unicode2htmlentities(u): + htmlentities = list() + for c in u: + if ord(c) < 128: + htmlentities.append(c) + else: + htmlentities.append('&%s;' % codepoint2name[ord(c)]) + return ''.join(htmlentities) \ No newline at end of file diff --git a/spritz/src/views.py b/spritz/src/views.py index 0ceed01f8..963735d18 100644 --- a/spritz/src/views.py +++ b/spritz/src/views.py @@ -22,7 +22,7 @@ import gobject import logging import glob import ConfigParser -from misc import const +from spritz_setup import const from etpgui.widgets import UI from etpgui import * from entropyConstants import *