mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 19:40:21 +01:00
* Code clean up.
* Removed unnecessary imports. * Adapted to PEP8.
This commit is contained in:
@@ -21,13 +21,18 @@
|
|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
|
import gtk
|
||||||
|
except ImportError:
|
||||||
|
print "You need to install pyGTK v2.10.x or newer."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
import gtk
|
|
||||||
|
|
||||||
def setup_path():
|
def setup_path():
|
||||||
"""Sets up the python include paths to include needed directories"""
|
"""Sets up the python include paths to include needed directories"""
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
|
||||||
from src.utils.globals import TOPDIR
|
from src.utils.globals import TOPDIR
|
||||||
sys.path = [os.path.join(TOPDIR, "src")] + sys.path
|
sys.path = [os.path.join(TOPDIR, "src")] + sys.path
|
||||||
return
|
return
|
||||||
@@ -35,15 +40,15 @@ def setup_path():
|
|||||||
|
|
||||||
def check_requirements():
|
def check_requirements():
|
||||||
"""Checks versions and other requirements"""
|
"""Checks versions and other requirements"""
|
||||||
import gtkmvc; gtkmvc.require("1.2.0")
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import gtkmvc
|
||||||
|
gtkmvc.require("1.2.0")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from models.m_config import ConfigModel
|
from models.m_config import ConfigModel
|
||||||
except:
|
except ImportError:
|
||||||
print "Some fundamental files are missing. Try runnig pyGTKtalog in his root directory"
|
print "Some fundamental files are missing.",
|
||||||
|
print "Try runnig pyGTKtalog in his root directory"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
conf = ConfigModel()
|
conf = ConfigModel()
|
||||||
@@ -53,63 +58,63 @@ def check_requirements():
|
|||||||
import pygtk
|
import pygtk
|
||||||
#tell pyGTK, if possible, that we want GTKv2
|
#tell pyGTK, if possible, that we want GTKv2
|
||||||
pygtk.require("2.0")
|
pygtk.require("2.0")
|
||||||
except:
|
except ImportError:
|
||||||
#Some distributions come with GTK2, but not pyGTK
|
#Some distributions come with GTK2, but not pyGTK
|
||||||
pass
|
pass
|
||||||
try:
|
|
||||||
import gtk
|
|
||||||
import gtk.glade
|
|
||||||
except:
|
|
||||||
print "You need to install pyGTK v2.10.x or newer.",
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pysqlite2 import dbapi2 as sqlite
|
from pysqlite2 import dbapi2 as sqlite
|
||||||
except:
|
except ImportError:
|
||||||
print "pyGTKtalog uses SQLite DB.\nYou'll need to get it and the python bindings as well.\nhttp://www.sqlite.org\nhttp://initd.org/tracker/pysqlite"
|
print "pyGTKtalog uses SQLite DB.\nYou'll need to get it and the",
|
||||||
|
print "python bindings as well.",
|
||||||
|
print "http://www.sqlite.org"
|
||||||
|
print "http://initd.org/tracker/pysqlite"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if conf.confd['exportxls']:
|
if conf.confd['exportxls']:
|
||||||
try:
|
try:
|
||||||
import pyExcelerator
|
import pyExcelerator
|
||||||
except:
|
except ImportError:
|
||||||
print "You'll need pyExcelerator, if you want to export DB to XLS format.\nhttp://sourceforge.net/projects/pyexcelerator"
|
print "WARNING: You'll need pyExcelerator, if you want to export",
|
||||||
sys.exit(1)
|
print "DB to XLS format."
|
||||||
|
print "http://sourceforge.net/projects/pyexcelerator"
|
||||||
|
|
||||||
if conf.confd['thumbs'] and conf.confd['retrive']:
|
if conf.confd['thumbs'] and conf.confd['retrive']:
|
||||||
try:
|
try:
|
||||||
import Image, ImageEnhance
|
import Image
|
||||||
except:
|
except ImportError:
|
||||||
print "You'll need Python Imaging Library (PIL), if you want to make thumbnails"
|
print "WARNING: You'll need Python Imaging Library (PIL), if you",
|
||||||
sys.exit(1)
|
print "want to make\nthumbnails!"
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def get_parameters():
|
def get_parameters():
|
||||||
"""Determine application command line options, return db full pathname"""
|
"""Determine application command line options, return db full pathname"""
|
||||||
import sys, os
|
import os
|
||||||
# if we've got two arguments, shell script passed through command line
|
# if we've got two arguments, shell script passed through command line
|
||||||
# options: current path and probably filename of compressed collection
|
# options: current path and probably filename of compressed collection
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
return os.path.join(sys.argv[1],sys.argv[2])
|
return os.path.join(sys.argv[1], sys.argv[2])
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def main(*args, **kargs):
|
|
||||||
|
def main(*args):
|
||||||
|
"""Main function of module pyGTKtalog"""
|
||||||
from models.m_main import MainModel
|
from models.m_main import MainModel
|
||||||
from ctrls.c_main import MainController
|
from ctrls.c_main import MainController
|
||||||
from views.v_main import MainView
|
from views.v_main import MainView
|
||||||
|
|
||||||
m = MainModel()
|
model = MainModel()
|
||||||
if args and args[0]:
|
if args and args[0]:
|
||||||
m.open(args[0])
|
model.open(args[0])
|
||||||
c = MainController(m)
|
controler = MainController(model)
|
||||||
v = MainView(c)
|
view = MainView(controler)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gtk.main()
|
gtk.main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
import os
|
model.config.save()
|
||||||
m.config.save()
|
model.cleanup()
|
||||||
m.cleanup()
|
|
||||||
gtk.main_quit
|
gtk.main_quit
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user