1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2025-12-17 11:30:19 +01:00

Moved start script into bin directory.

Removed makefile, substituded by the pavement script from paver package.
This commit is contained in:
2009-05-08 20:14:21 +00:00
parent bcacb75229
commit 8a24e30bde
4 changed files with 164 additions and 137 deletions

4
MANIFEST.in Normal file
View File

@@ -0,0 +1,4 @@
include setup.py
include pavement.py
include paver-minilib.zip
include pygtktalog/locale/*/*/*.mo

View File

@@ -1,78 +0,0 @@
PYTHON_EXEC = PYTHONPATH=/home/gryf/Devel/Python/pyGTKtalog:/home/gryf/.python_lib python
LOCALE = LC_ALL=pl_PL.utf8
FILE = pygtktalog.py
DIST = bin/prepare_dist_package.sh
POT_GEN = bin/generate_pot.py
.PHONY: run
run:
@$(PYTHON_EXEC) $(FILE)
.PHONY: runpl
runpl:
@export $(LOCALE) && $(PYTHON_EXEC) $(FILE)
.PHONY: clean
clean:
@find . -name \*~ -exec rm '{}' ';'
@find . -name \*pyc -exec rm '{}' ';'
@find . -name \*pyo -exec rm '{}' ';'
@echo "cleaned."
.PHONY: distclean
distclean: clean
@rm -fr locale/*
@echo "all cleaned up"
.PHONY: pot
pot:
@if [ ! -d locale ]; then mkdir locale; fi
@python $(POT_GEN) pygtktalog pygtktalog > locale/pygtktalog.pot
@echo "locale/pygtktalog.pot (re)generated."
.PHONY: pltrans
pltrans: pot
@if [ -f locale/pl.po ]; then \
echo "Merging existing *.po file with regenerated *.pot"; \
msgmerge -U locale/pl.po locale/pygtktalog.pot; \
else \
echo "Creating fresh *.po file"; \
cp locale/pygtktalog.pot locale/pl.po; \
fi;
@$$EDITOR locale/pl.po
@if [ ! -d locale/pl/LC_MESSAGES ]; then mkdir -p locale/pl/LC_MESSAGES; fi
@echo "Compile message catalog for pl_PL.utf8"
@msgfmt locale/pl.po -o locale/pl/LC_MESSAGES/pygtktalog.mo
@echo "Message catalog for pl_PL.utf8 saved in locale/pl/LC_MESSAGES/pygtktalog.mo"
.PHONY: plgen
plgen:
@if [ ! -d locale/pl/LC_MESSAGES ]; then mkdir -p locale/pl/LC_MESSAGES; fi
@echo "Compile message catalog for pl_PL.utf8"
@msgfmt locale/pl.po -o locale/pl/LC_MESSAGES/pygtktalog.mo
@echo "Message catalog for pl_PL.utf8 saved in locale/pl/LC_MESSAGES/pygtktalog.mo"
.PHONY: test
test:
cd test && $(PYTHON_EXEC) run_tests.py
.PHONY: dist
dist:
@$(DIST)
.PHONY: help
help:
@echo "Possible commands for make are:"
@echo
@echo " run: Run pyGTKtalog. Default."
@echo " runpl: Run pyGTKtalog with LC_ALL set to pl_PL.utf8."
@echo " clean: Remove .pyc, .pyo and .~ files."
@echo " distclean: As above, also removes generated locale files."
@echo " pot: Generate .pot file from sources and .glade files."
@echo " pltrans: Generate/merge polish translation file and then invoke editor."
@echo " Environment variable EDITOR is expected"
@echo " plgen: Just generate polish translation file without merging and"
@echo " editing."
@echo " test: Launch unit tests for application."
@echo " dist: Make distribution package."
@echo

160
pavement.py Normal file
View File

@@ -0,0 +1,160 @@
"""
Project: pyGTKtalog
Description: Makefile and setup.py replacement. Used package: paver
Type: management
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2009-05-07
"""
import os
import sys
import shutil
from paver.easy import sh, dry, call_task
from paver.tasks import task, needs, help
from paver.setuputils import setup
#import setuptools.command.sdist
from paver.misctasks import generate_setup, minilib
try:
from pylint import lint
have_lint = True
except:
have_lint = False
# distutil/setuptool setup method.
setup(
name='pyGTKtalog',
version='1.99',
long_description='pyGTKtalog is application similar to WhereIsIT, '
'for collecting information on files from CD/DVD '
'or directories.',
description='pyGTKtalog is a file indexing tool written in pyGTK',
author='Roman Dobosz',
author_email='gryf73@gmail.com',
url='http://google.com',
platforms=['Linux', 'BSD'],
license='GNU General Public License (GPL)',
classifiers=['Development Status :: 2 - Pre-Alpha',
'Environment :: X11 Applications :: GTK',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License '
'(GPL)',
'Natural Language :: English',
'Natural Language :: Polish',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Topic :: Desktop Environment',
'Topic :: Utilities'],
include_package_data=True,
exclude_package_data={'': ['*.patch']},
packages=["pygtktalog"],
scripts=['bin/gtktalog.py'],
test_suite = 'nose.collector'
)
@task
@needs(['genpl', 'minilib', 'generate_setup'])
def sdist():
"""sdist with message catalogs"""
call_task("setuptools.command.sdist")
@task
@needs(['genpl'])
def build():
"""build with message catalogs"""
call_task("setuptools.command.build")
@task
def clean():
"""remove 'pyo', 'pyc' and '~' files"""
# clean *.pyc, *.pyo and jEdit backup files *~
for root, dummy, files in os.walk("."):
for fname in files:
if fname.endswith(".pyc") or fname.endswith(".pyo") or \
fname.endswith("~"):
fdel = os.path.join(root, fname)
os.unlink(fdel)
print "deleted", fdel
@task
@needs(["clean"])
def distclean():
"""make clean, and remove any dist/build/egg stuff from project"""
for dirname in [os.path.join('pygtktalog', 'locale'), 'build', 'dist',
'pyGTKtalog.egg-info']:
if os.path.exists(dirname):
shutil.rmtree(dirname, ignore_errors=True)
print "removed directory", dirname
for filename in ['paver-minilib.zip', 'setup.py']:
if os.path.exists(filename):
os.unlink(filename)
print "deleted", filename
@task
def run():
"""run application"""
sh("PYTHONPATH=%s:$PYTHONPATH bin/gtktalog.py" % _setup_env())
@task
@needs(['genpl'])
def runpl():
"""run application with pl_PL localization"""
os.environ['LC_ALL'] = 'pl_PL.utf8'
run()
@task
def pot():
"""generate 'pot' file out of python/glade files"""
if not os.path.exists('locale'):
os.mkdir('locale')
sh("python bin/generate_pot.py > locale/pygtktalog.pot")
@task
@needs(['pot'])
def mergepl():
"""create or merge if exists polish 'po' translation file"""
if os.path.exists(os.path.join('locale', 'pl.po')):
sh('msgmerge -U locale/pl.po locale/pygtktalog.pot')
else:
shutil.copy(os.path.join('locale', 'pygtktalog.pot'),
os.path.join('locale', 'pl.po'))
@task
@needs(['mergepl'])
def genpl():
"""generate message catalog file for polish locale"""
if not os.path.exists(os.path.join('pygtktalog', 'locale')):
full_path = 'pygtktalog'
for name in ['locale', 'pl', 'LC_MESSAGES']:
full_path = os.path.join(full_path, name)
os.mkdir(full_path)
sh('msgfmt locale/pl.po -o pygtktalog/locale/pl/LC_MESSAGES/pygtktalog.mo')
if have_lint:
@task
def pylint():
'''Check the module you're building with pylint.'''
pylintopts = ['pygtktalog']
dry('pylint %s' % (" ".join(pylintopts)), lint.Run, pylintopts)
@task
def test():
"""run unit tests"""
os.system("PYTHONPATH=%s:$PYTHONPATH nosetests -w test" % _setup_env())
def _setup_env():
"""Helper function to set up paths"""
# current directory
this_path = os.path.dirname(os.path.abspath(__file__))
if this_path not in sys.path:
sys.path.insert(0, this_path)
# return
return this_path

View File

@@ -1,59 +0,0 @@
"""
Project: pyGTKtalog
Description: Application main launch file.
Type: core
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
Created: 2007-05-01
"""
import sys
import os
import locale
import gettext
import __builtin__
import gtk
import pygtk
pygtk.require("2.0")
import gtkmvc
gtkmvc.require("1.99.0")
# Setup i18n
# adapted from example by Armin Ronacher:
# http://lucumr.pocoo.org/2007/6/10/internationalized-pygtk-applications2
GETTEXT_DOMAIN = 'pygtktalog'
LOCALE_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'locale')
locale.setlocale(locale.LC_ALL, '')
for module in gtk.glade, gettext:
module.bindtextdomain(GETTEXT_DOMAIN, LOCALE_PATH)
module.textdomain(GETTEXT_DOMAIN)
# register the gettext function for the whole interpreter as "_"
__builtin__._ = gettext.gettext
from pygtktalog.models.main import MainModel
from pygtktalog.controllers.main import MainController
from pygtktalog.views.main import MainView
def run():
"""Create model, controller and view and launch it."""
model = MainModel()
if len(sys.argv) > 1:
model.open(os.path.join(execution_dir, sys.argv[1]))
view = MainView()
controler = MainController(model, view)
try:
gtk.main()
except KeyboardInterrupt:
#model.config.save()
#model.cleanup()
gtk.main_quit
if __name__ == "__main__":
run()