From a25deac906845bba8a2853eb5e36930adb735cde Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 12 Apr 2008 03:44:20 -0700 Subject: [PATCH] layout: move views and controllers into a subdirectory Signed-off-by: David Aguilar --- scripts/wscript | 4 ++-- ugit/{controllers.py => controllers/__init__.py} | 25 +++++++++---------- .../createbranch.py} | 8 +++---- ugit/{pushcontroller.py => controllers/push.py} | 8 +++---- .../repobrowser.py} | 11 +++++---- ugit/{utilcontroller.py => controllers/util.py} | 17 ++++++------- {ui => ugit/controllers}/wscript | 5 ++-- ugit/{views.py => views/__init__.py} | 8 ++++--- {ui => ugit/views}/wscript | 5 ++-- ugit/wscript | 8 ++++--- ui/wscript | 2 +- wscript | 28 +++++++++++++++------- 12 files changed, 74 insertions(+), 55 deletions(-) rename ugit/{controllers.py => controllers/__init__.py} (98%) rename ugit/{createbranchcontroller.py => controllers/createbranch.py} (96%) rename ugit/{pushcontroller.py => controllers/push.py} (96%) rename ugit/{repobrowsercontroller.py => controllers/repobrowser.py} (96%) rename ugit/{utilcontroller.py => controllers/util.py} (97%) copy {ui => ugit/controllers}/wscript (53%) rename ugit/{views.py => views/__init__.py} (97%) copy {ui => ugit/views}/wscript (55%) diff --git a/scripts/wscript b/scripts/wscript index 27be771..dc9e54f 100644 --- a/scripts/wscript +++ b/scripts/wscript @@ -3,7 +3,7 @@ import Common def gen_install(path): def install(): - Common.install_files('PYMODS_UGIT', '', path) + Common.install_files('UGIT_MODULES', '', path) return install def build(bld): @@ -17,4 +17,4 @@ def build(bld): vgen.command = 'gitversion.sh' vgen.stdin = 'gitversion.sh' vgen.stdout = 'version.py' - vgen.install = gen_install('scripts/version.py') + vgen.install = gen_install('../scripts/version.py') diff --git a/ugit/controllers.py b/ugit/controllers/__init__.py similarity index 98% rename from ugit/controllers.py rename to ugit/controllers/__init__.py index 7a273a5..74ee740 100644 --- a/ugit/controllers.py +++ b/ugit/controllers/__init__.py @@ -9,18 +9,19 @@ from PyQt4.QtGui import QMessageBox from PyQt4.QtGui import QMenu from PyQt4.QtGui import QFont -import utils -import qtutils -import defaults -from qobserver import QObserver -from repobrowsercontroller import browse_git_branch -from createbranchcontroller import create_new_branch -from pushcontroller import push_branches -from utilcontroller import choose_branch -from utilcontroller import select_commits -from utilcontroller import search_revisions -from utilcontroller import update_options -from utilcontroller import log_window +from ugit import utils +from ugit import qtutils +from ugit import defaults +from ugit.qobserver import QObserver + +from push import push_branches +from util import choose_branch +from util import select_commits +from util import search_revisions +from util import update_options +from util import log_window +from repobrowser import browse_git_branch +from createbranch import create_new_branch class Controller(QObserver): """Controller manages the interaction between the model and views.""" diff --git a/ugit/createbranchcontroller.py b/ugit/controllers/createbranch.py similarity index 96% rename from ugit/createbranchcontroller.py rename to ugit/controllers/createbranch.py index 54d2efb..560753d 100644 --- a/ugit/createbranchcontroller.py +++ b/ugit/controllers/createbranch.py @@ -2,10 +2,10 @@ import os from PyQt4.QtGui import QDialog -import utils -import qtutils -from qobserver import QObserver -from views import CreateBranchGUI +from ugit import utils +from ugit import qtutils +from ugit.views import CreateBranchGUI +from ugit.qobserver import QObserver def create_new_branch(model,parent): model = model.clone() diff --git a/ugit/pushcontroller.py b/ugit/controllers/push.py similarity index 96% rename from ugit/pushcontroller.py rename to ugit/controllers/push.py index ec9d27e..0c528ce 100644 --- a/ugit/pushcontroller.py +++ b/ugit/controllers/push.py @@ -1,10 +1,10 @@ import os from PyQt4.QtGui import QDialog -import utils -import qtutils -from qobserver import QObserver -from views import PushGUI +from ugit import utils +from ugit import qtutils +from ugit.views import PushGUI +from ugit.qobserver import QObserver def push_branches(model, parent): model = model.clone() diff --git a/ugit/repobrowsercontroller.py b/ugit/controllers/repobrowser.py similarity index 96% rename from ugit/repobrowsercontroller.py rename to ugit/controllers/repobrowser.py index b33b9ca..93b30b2 100644 --- a/ugit/repobrowsercontroller.py +++ b/ugit/controllers/repobrowser.py @@ -1,11 +1,12 @@ #!/usr/bin/env python import os from PyQt4.QtGui import QDialog -from qobserver import QObserver -import utils -import qtutils -import defaults -from views import CommitGUI + +from ugit import utils +from ugit import qtutils +from ugit import defaults +from ugit.views import CommitGUI +from ugit.qobserver import QObserver def browse_git_branch(model, parent, branch): if not branch: return diff --git a/ugit/utilcontroller.py b/ugit/controllers/util.py similarity index 97% rename from ugit/utilcontroller.py rename to ugit/controllers/util.py index 5b5e0ee..652162d 100644 --- a/ugit/utilcontroller.py +++ b/ugit/controllers/util.py @@ -2,14 +2,15 @@ import time from PyQt4.QtGui import QDialog from PyQt4.QtGui import QFont -import utils -import qtutils -from qobserver import QObserver -from views import BranchGUI -from views import CommitGUI -from views import OptionsGUI -from views import OutputGUI -from model import Model + +from ugit import utils +from ugit import qtutils +from ugit.model import Model +from ugit.views import BranchGUI +from ugit.views import CommitGUI +from ugit.views import OptionsGUI +from ugit.views import OutputGUI +from ugit.qobserver import QObserver def set_diff_font(model, widget): if model.has_param('global_ugit_fontdiff'): diff --git a/ui/wscript b/ugit/controllers/wscript similarity index 53% copy from ui/wscript copy to ugit/controllers/wscript index eb50da4..d455111 100644 --- a/ui/wscript +++ b/ugit/controllers/wscript @@ -1,6 +1,7 @@ #!/usr/bin/env python +import Common def build(bld): + # Compile the ugit support modules pyqt = bld.create_obj('py') - pyqt.inst_var = 'PYMODS_UGIT' + pyqt.inst_var = 'UGIT_CONTROLLERS' pyqt.find_sources_in_dirs('.') - diff --git a/ugit/views.py b/ugit/views/__init__.py similarity index 97% rename from ugit/views.py rename to ugit/views/__init__.py index 2b75fac..8f9460f 100644 --- a/ugit/views.py +++ b/ugit/views/__init__.py @@ -5,6 +5,11 @@ from PyQt4.QtGui import QDialog from PyQt4.QtGui import QMainWindow from PyQt4.QtGui import QCheckBox from PyQt4.QtGui import QSplitter + +from ugit import qtutils +from ugit.syntax import DiffSyntaxHighlighter +from ugit.syntax import LogSyntaxHighlighter + from maingui import Ui_maingui from outputgui import Ui_outputgui from optionsgui import Ui_optionsgui @@ -12,9 +17,6 @@ from branchgui import Ui_branchgui from commitgui import Ui_commitgui from createbranchgui import Ui_createbranchgui from pushgui import Ui_pushgui -from syntax import DiffSyntaxHighlighter -from syntax import LogSyntaxHighlighter -import qtutils class View(Ui_maingui, QMainWindow): '''The main ugit interface.''' diff --git a/ui/wscript b/ugit/views/wscript similarity index 55% copy from ui/wscript copy to ugit/views/wscript index eb50da4..2644953 100644 --- a/ui/wscript +++ b/ugit/views/wscript @@ -1,6 +1,7 @@ #!/usr/bin/env python +import Common def build(bld): + # Compile the ugit support modules pyqt = bld.create_obj('py') - pyqt.inst_var = 'PYMODS_UGIT' + pyqt.inst_var = 'UGIT_VIEWS' pyqt.find_sources_in_dirs('.') - diff --git a/ugit/wscript b/ugit/wscript index 249a699..c655b96 100644 --- a/ugit/wscript +++ b/ugit/wscript @@ -1,11 +1,13 @@ #!/usr/bin/env python import Common def build(bld): + # Compile the controllers + bld.add_subdirs('views controllers') # Compile the ugit support modules pyqt = bld.create_obj('py') - pyqt.inst_var = 'PYMODS_UGIT' + pyqt.inst_var = 'UGIT_MODULES' pyqt.find_sources_in_dirs('.') # Install the git-ugit launcher - Common.install_files('BIN', '', 'git-ugit', chmod=0755) - Common.symlink_as('BIN', 'git-ugit', 'ugit') + Common.install_files('UGIT_BINDIR', '', 'git-ugit', chmod=0755) + Common.symlink_as('UGIT_BINDIR', 'git-ugit', 'ugit') diff --git a/ui/wscript b/ui/wscript index eb50da4..b517e3b 100644 --- a/ui/wscript +++ b/ui/wscript @@ -1,6 +1,6 @@ #!/usr/bin/env python def build(bld): pyqt = bld.create_obj('py') - pyqt.inst_var = 'PYMODS_UGIT' + pyqt.inst_var = 'UGIT_VIEWS' pyqt.find_sources_in_dirs('.') diff --git a/wscript b/wscript index 691ee85..a503554 100644 --- a/wscript +++ b/wscript @@ -4,11 +4,13 @@ import sys import glob import Params import Common +from os.path import join +from distutils.sysconfig import get_python_version # Release versioning def get_version(): """Runs version.sh and returns the output.""" - cmd = os.path.join(os.getcwd(), 'scripts', 'version.sh') + cmd = join(os.getcwd(), 'scripts', 'version.sh') pipe = os.popen(cmd) version = pipe.read() pipe.close() @@ -33,10 +35,19 @@ def set_options(opt): # Configure def configure(conf): env = conf.env - env['PYMODS'] = pymod(env['PREFIX']) - env['PYMODS_UGIT'] = os.path.join(env['PYMODS'], 'ugit') - env['ICONS'] = os.path.join(env['PREFIX'], 'share', 'ugit', 'icons') - env['BIN'] = os.path.join(env['PREFIX'], 'bin') + prefix = env['PREFIX'] + bindir = join(prefix, 'bin') + sitepackages = pymod(prefix) + modules = join(sitepackages, 'ugit') + views = join(modules, 'views') + controllers = join(modules, 'controllers') + icons = join(prefix, 'share', 'ugit', 'icons') + + env['UGIT_BINDIR'] = bindir + env['UGIT_MODULES'] = modules + env['UGIT_VIEWS'] = views + env['UGIT_CONTROLLERS'] = controllers + env['UGIT_ICONS'] = icons conf.check_tool('misc') conf.check_tool('python') @@ -52,12 +63,11 @@ def build(bld): qm.find_sources_in_dirs('po') for icon in glob.glob('icons/*.png'): - Common.install_files('ICONS', '', icon) + Common.install_files('UGIT_ICONS', '', icon) ############################################################################# # Other def pymod(prefix): """Returns a lib/python2.x/site-packages path relative to prefix""" - api_version = sys.version[:3] - python_api = 'python' + api_version - return os.path.join(prefix, 'lib', python_api, 'site-packages') + python_api = 'python' + get_python_version() + return join(prefix, 'lib', python_api, 'site-packages') -- 2.11.4.GIT