compactpath-commit Mailing List for compactpath
Status: Beta
Brought to you by:
jurner
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(28) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <ju...@us...> - 2008-06-24 13:40:33
|
Revision: 28
http://compactpath.svn.sourceforge.net/compactpath/?rev=28&view=rev
Author: jurner
Date: 2008-06-24 06:40:18 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
beautified user feedback
Modified Paths:
--------------
trunk/src/compactpath/scripts/gen_docs.py
Modified: trunk/src/compactpath/scripts/gen_docs.py
===================================================================
--- trunk/src/compactpath/scripts/gen_docs.py 2008-06-19 08:01:27 UTC (rev 27)
+++ trunk/src/compactpath/scripts/gen_docs.py 2008-06-24 13:40:18 UTC (rev 28)
@@ -31,13 +31,20 @@
"""enshures epydoc docdir exists"""
save_create_dir(EPYDOC_DIR)
+def pprint(msg, *params):
+ """helper to pprint user feedback"""
+ print '>' + msg
+ for i in params:
+ print ' ' + i
+
#**************************************************************************
#
#**************************************************************************
def main():
""""""
+ pprint('dumping docs to:', EPYDOC_DIR)
enshure_doc_dir_dxists()
- print 'calling epydoc'
+ pprint('calling epydoc')
sys.argv = [
__file__,
'-v',
@@ -47,11 +54,11 @@
PACKAGE_DIR,
]
cli.cli()
- print 'ok'
-
+
# create a redirect to 'epydoc/index.html'
- print 'creating redirect'
- fp = open(os.path.join(DOC_DIR, 'index.html'), 'w')
+ html_index = os.path.join(DOC_DIR, 'index.html')
+ pprint('creating redirect:', html_index)
+ fp = open(html_index, 'w')
try:
fp.write('''<html>
<head>
@@ -62,8 +69,7 @@
finally:
fp.close()
- print 'ok'
- print 'done'
+ pprint('done')
#**************************************************************************************
#
@@ -73,6 +79,3 @@
if wantsHelp not in ('-?', '--help'):
sys.exit(main())
print __doc__
-
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 08:01:29
|
Revision: 27
http://compactpath.svn.sourceforge.net/compactpath/?rev=27&view=rev
Author: jurner
Date: 2008-06-19 01:01:27 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
release
Added Paths:
-----------
tags/compactpath-0.5.0/
Removed Paths:
-------------
tags/compactpath/
Copied: tags/compactpath-0.5.0 (from rev 26, tags/compactpath)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 08:01:04
|
Revision: 26
http://compactpath.svn.sourceforge.net/compactpath/?rev=26&view=rev
Author: jurner
Date: 2008-06-19 01:00:57 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
...
Added Paths:
-----------
tags/compactpath/
Copied: tags/compactpath (from rev 25, trunk/src/compactpath)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:57:05
|
Revision: 25
http://compactpath.svn.sourceforge.net/compactpath/?rev=25&view=rev
Author: jurner
Date: 2008-06-19 00:57:02 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
...
Removed Paths:
-------------
tags/compactpath/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:54:47
|
Revision: 24
http://compactpath.svn.sourceforge.net/compactpath/?rev=24&view=rev
Author: jurner
Date: 2008-06-19 00:54:46 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
release
Added Paths:
-----------
tags/compactpath/
Copied: tags/compactpath (from rev 23, trunk/src/compactpath)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:52:55
|
Revision: 23
http://compactpath.svn.sourceforge.net/compactpath/?rev=23&view=rev
Author: jurner
Date: 2008-06-19 00:52:53 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
...
Removed Paths:
-------------
tags/compactpath/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:52:20
|
Revision: 22
http://compactpath.svn.sourceforge.net/compactpath/?rev=22&view=rev
Author: jurner
Date: 2008-06-19 00:52:19 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
...
Added Paths:
-----------
tags/compactpath/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:44:12
|
Revision: 21
http://compactpath.svn.sourceforge.net/compactpath/?rev=21&view=rev
Author: jurner
Date: 2008-06-19 00:43:59 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
this and that
Modified Paths:
--------------
trunk/src/compactpath/scripts/gen_docs.py
Modified: trunk/src/compactpath/scripts/gen_docs.py
===================================================================
--- trunk/src/compactpath/scripts/gen_docs.py 2008-06-19 07:40:55 UTC (rev 20)
+++ trunk/src/compactpath/scripts/gen_docs.py 2008-06-19 07:43:59 UTC (rev 21)
@@ -47,7 +47,7 @@
PACKAGE_DIR,
]
cli.cli()
- print 'done'
+ print 'ok'
# create a redirect to 'epydoc/index.html'
print 'creating redirect'
@@ -62,12 +62,13 @@
finally:
fp.close()
+ print 'ok'
print 'done'
#**************************************************************************************
#
#**************************************************************************************
-if __name__ == '__main__2':
+if __name__ == '__main__':
wantsHelp = len(sys.argv) > 1 and sys.argv[1] or None
if wantsHelp not in ('-?', '--help'):
sys.exit(main())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:40:57
|
Revision: 20
http://compactpath.svn.sourceforge.net/compactpath/?rev=20&view=rev
Author: jurner
Date: 2008-06-19 00:40:55 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
docs
Modified Paths:
--------------
trunk/src/compactpath/scripts/gen_docs.py
Modified: trunk/src/compactpath/scripts/gen_docs.py
===================================================================
--- trunk/src/compactpath/scripts/gen_docs.py 2008-06-19 07:40:24 UTC (rev 19)
+++ trunk/src/compactpath/scripts/gen_docs.py 2008-06-19 07:40:55 UTC (rev 20)
@@ -1,8 +1,8 @@
-"""Generates epydoc documentation for the package in --> packageDir/docs
+"""Generates epydoc documentation for the package in --> packageDir/doc
gen_docs.py
-@note: the script assumes it is located in the scripts subdirectory of the package
+@note: the script assumes it is located in the <doc> or any other emidiate subdirectory of the package
@note: Use gen_docs.py -? or --help to print out this help text
@requires: epydoc
@@ -67,7 +67,7 @@
#**************************************************************************************
#
#**************************************************************************************
-if __name__ == '__main__':
+if __name__ == '__main__2':
wantsHelp = len(sys.argv) > 1 and sys.argv[1] or None
if wantsHelp not in ('-?', '--help'):
sys.exit(main())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:40:27
|
Revision: 19
http://compactpath.svn.sourceforge.net/compactpath/?rev=19&view=rev
Author: jurner
Date: 2008-06-19 00:40:24 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
minor change
Modified Paths:
--------------
trunk/src/compactpath/qt4/pathlabelwrap.py
Modified: trunk/src/compactpath/qt4/pathlabelwrap.py
===================================================================
--- trunk/src/compactpath/qt4/pathlabelwrap.py 2008-06-19 07:29:11 UTC (rev 18)
+++ trunk/src/compactpath/qt4/pathlabelwrap.py 2008-06-19 07:40:24 UTC (rev 19)
@@ -49,8 +49,8 @@
@note: currently the wrapper does not know how anything about rich text. no use to pass
a label containing rich text. the rich text it won't show up and behaviour of the label is undefined
- @note: when used on a statusbar you may want to adjust the stretch facor. otherwise the label
- might be invisible because it never gets resized
+ @note: when used on a statusbar you may want to adjust the stretch facor. otherwise label
+ contents may not be visible because it never gets resized
"""
self.fpath = fpath
self.label = label
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:29:14
|
Revision: 18
http://compactpath.svn.sourceforge.net/compactpath/?rev=18&view=rev
Author: jurner
Date: 2008-06-19 00:29:11 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
minor change
Modified Paths:
--------------
trunk/src/compactpath/qt4/sample_gui.py
Modified: trunk/src/compactpath/qt4/sample_gui.py
===================================================================
--- trunk/src/compactpath/qt4/sample_gui.py 2008-06-19 07:28:41 UTC (rev 17)
+++ trunk/src/compactpath/qt4/sample_gui.py 2008-06-19 07:29:11 UTC (rev 18)
@@ -92,7 +92,7 @@
# default QLabel to see test label to see if our owner drawn labels are ok
- self.labelTest = QtGui.QLabel("sorry, no shortcuts, no rich text yet", self.mainWidget)
+ self.labelTest = QtGui.QLabel("no shortcuts, no rich text yet", self.mainWidget)
self.labelTest.setFrameStyle(frameStyle)
layout.addWidget(self.labelTest)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:28:43
|
Revision: 17
http://compactpath.svn.sourceforge.net/compactpath/?rev=17&view=rev
Author: jurner
Date: 2008-06-19 00:28:41 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
docs
Modified Paths:
--------------
trunk/src/compactpath/qt4/pathlabelwrap.py
Modified: trunk/src/compactpath/qt4/pathlabelwrap.py
===================================================================
--- trunk/src/compactpath/qt4/pathlabelwrap.py 2008-06-19 07:28:17 UTC (rev 16)
+++ trunk/src/compactpath/qt4/pathlabelwrap.py 2008-06-19 07:28:41 UTC (rev 17)
@@ -61,7 +61,7 @@
def setPath(self, fpath, prefix=None, path_module=None):
- """sets the filepath or url to be displayed
+ """sets the filepath to be displayed by the label
@param fpath: the filepath or url the label should display
@param path_module: module to use to split and join the filepath or None to keep the current one
@@ -82,7 +82,7 @@
def paintEvent(self, event):
- """overwritten paintEvent() hanlder of QLabel"""
+ """reimplemented QLabel.paintEvent()"""
style = self.label.style()
painter = QtGui.QPainter(self.label)
palette = self.label.palette()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-19 07:28:20
|
Revision: 16
http://compactpath.svn.sourceforge.net/compactpath/?rev=16&view=rev
Author: jurner
Date: 2008-06-19 00:28:17 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
ups, take the local ellipsis not the global one
Modified Paths:
--------------
trunk/src/compactpath/compactpath.py
Modified: trunk/src/compactpath/compactpath.py
===================================================================
--- trunk/src/compactpath/compactpath.py 2008-06-18 09:56:39 UTC (rev 15)
+++ trunk/src/compactpath/compactpath.py 2008-06-19 07:28:17 UTC (rev 16)
@@ -148,15 +148,15 @@
head, tail = path_module.split(fpath)
n = len(head)
- while n >= len(ELLIPSIS):
+ while n >= len(ellipsis):
head = ltrunc(n, head, ellipsis=ellipsis)
n -= 1
fpath = path_module.join(head, tail)
if measure(fpath) < w:
return fpath
- if head == ELLIPSIS:
- tail = ELLIPSIS + tail
+ if head == ellipsis:
+ tail = ellipsis + tail
n = len(tail) - 1
elif head:
tail = path_module.join(head, tail, ellipsis=ellipsis)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 09:56:42
|
Revision: 15
http://compactpath.svn.sourceforge.net/compactpath/?rev=15&view=rev
Author: jurner
Date: 2008-06-18 02:56:39 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
this and that
Modified Paths:
--------------
trunk/src/compactpath/qt4/sample_gui.py
Modified: trunk/src/compactpath/qt4/sample_gui.py
===================================================================
--- trunk/src/compactpath/qt4/sample_gui.py 2008-06-18 09:56:21 UTC (rev 14)
+++ trunk/src/compactpath/qt4/sample_gui.py 2008-06-18 09:56:39 UTC (rev 15)
@@ -1,4 +1,4 @@
-"""compactpath sample gui"""
+"""qt4 sample gui"""
import os, sys
import ntpath
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 09:56:34
|
Revision: 14
http://compactpath.svn.sourceforge.net/compactpath/?rev=14&view=rev
Author: jurner
Date: 2008-06-18 02:56:21 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
this and that
Modified Paths:
--------------
trunk/src/compactpath/LICENCE.MIT
Modified: trunk/src/compactpath/LICENCE.MIT
===================================================================
--- trunk/src/compactpath/LICENCE.MIT 2008-06-18 09:55:58 UTC (rev 13)
+++ trunk/src/compactpath/LICENCE.MIT 2008-06-18 09:56:21 UTC (rev 14)
@@ -1,6 +1,6 @@
"compactpath" is a python package to handle compacting of filepaths
-Copyright (c) 2008 Juergen Urner
+Copyright (c) 2006-2008 Juergen Urner
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 09:56:08
|
Revision: 13
http://compactpath.svn.sourceforge.net/compactpath/?rev=13&view=rev
Author: jurner
Date: 2008-06-18 02:55:58 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
this and that
Modified Paths:
--------------
trunk/src/compactpath/__init__.py
Modified: trunk/src/compactpath/__init__.py
===================================================================
--- trunk/src/compactpath/__init__.py 2008-06-18 07:48:57 UTC (rev 12)
+++ trunk/src/compactpath/__init__.py 2008-06-18 09:55:58 UTC (rev 13)
@@ -7,7 +7,7 @@
"""
__author__ = 'Juergen Urner'
-__copyright__ = '(c) 2008 Juergen Urner'
+__copyright__ = '(c) 2006-2008 Juergen Urner'
__email__ = 'jU...@ar...'
__licence__ = 'Mit'
__version__ = '0.5.0'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:49:04
|
Revision: 12
http://compactpath.svn.sourceforge.net/compactpath/?rev=12&view=rev
Author: jurner
Date: 2008-06-18 00:48:57 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
removed with statement for compat
Modified Paths:
--------------
trunk/src/compactpath/scripts/gen_docs.py
Modified: trunk/src/compactpath/scripts/gen_docs.py
===================================================================
--- trunk/src/compactpath/scripts/gen_docs.py 2008-06-18 07:47:56 UTC (rev 11)
+++ trunk/src/compactpath/scripts/gen_docs.py 2008-06-18 07:48:57 UTC (rev 12)
@@ -6,11 +6,8 @@
@note: Use gen_docs.py -? or --help to print out this help text
@requires: epydoc
-@requires: python >= 2.4
"""
-from __future__ import with_statement
-
import sys, os
from epydoc import cli
import subprocess
@@ -54,13 +51,16 @@
# create a redirect to 'epydoc/index.html'
print 'creating redirect'
- with open(os.path.join(DOC_DIR, 'index.html'), 'w') as fp:
+ fp = open(os.path.join(DOC_DIR, 'index.html'), 'w')
+ try:
fp.write('''<html>
<head>
<meta http-equiv="Refresh" content="0; URL=%s">
</head>
</html>
''' % (EPYDOC_FOLDER + '/' + 'index.html') )
+ finally:
+ fp.close()
print 'done'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:48:06
|
Revision: 11
http://compactpath.svn.sourceforge.net/compactpath/?rev=11&view=rev
Author: jurner
Date: 2008-06-18 00:47:56 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
minor changes
Modified Paths:
--------------
trunk/src/compactpath/README
Modified: trunk/src/compactpath/README
===================================================================
--- trunk/src/compactpath/README 2008-06-18 07:35:33 UTC (rev 10)
+++ trunk/src/compactpath/README 2008-06-18 07:47:56 UTC (rev 11)
@@ -14,7 +14,7 @@
news:
- x. reimplemented compactpath algo. bells and whistels have gone. this makes it ~15* faster
+ x. reimplemented compactpath algo. bells and whistels have gone. this makes it ~15x faster
x. combed over PathLabelWrap (qt4). styling and enabling / disabling works now
x. added a script to auto generate epydoc docs. you will find it in the [scripts] folder
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:35:36
|
Revision: 10
http://compactpath.svn.sourceforge.net/compactpath/?rev=10&view=rev
Author: jurner
Date: 2008-06-18 00:35:33 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
whitespace
Modified Paths:
--------------
trunk/src/compactpath/compactpath.py
Modified: trunk/src/compactpath/compactpath.py
===================================================================
--- trunk/src/compactpath/compactpath.py 2008-06-18 07:30:53 UTC (rev 9)
+++ trunk/src/compactpath/compactpath.py 2008-06-18 07:35:33 UTC (rev 10)
@@ -50,7 +50,6 @@
n = len(chars)
if n < 0:
n = 0
-
x = len(ellipsis) - n
if x < 0:
x = 0
@@ -93,7 +92,6 @@
n = len(chars)
if n < 0:
n = 0
-
e = ellipsis[:n]
return chars[ :n - len(e)] + e
@@ -142,7 +140,6 @@
'..'
'.'
''
-
"""
if measure(fpath) < w:
return fpath
@@ -178,7 +175,6 @@
#************************************************************************************************
#
#************************************************************************************************
-
if __name__ == '__main__':
import doctest
print 'doctests failed: %s/%s' % doctest.testmod()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:30:55
|
Revision: 9
http://compactpath.svn.sourceforge.net/compactpath/?rev=9&view=rev
Author: jurner
Date: 2008-06-18 00:30:53 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
rework
Modified Paths:
--------------
trunk/src/setup.py
Modified: trunk/src/setup.py
===================================================================
--- trunk/src/setup.py 2008-06-18 07:30:17 UTC (rev 8)
+++ trunk/src/setup.py 2008-06-18 07:30:53 UTC (rev 9)
@@ -1,55 +1,49 @@
-
+"""a python package to compact filepaths to a desired length
+
+the package provides means to handle compacting of filepaths. compacting of filepaths
+may be useful in gui programming for example where filepaths of arbitrary length have
+to be displayed in widgets with limited visula space.
+
+the package is designed so you can use it as from everywhere. no need to install it to
+site-packages, in case you want to include it in a project. it comes equipped with a
+wrapper for labels to handle filepaths of arbitrary length in qt4.
+"""
+
from distutils.core import setup
AUTHOR = 'Juergen Urner'
AUTHOR_EMAIL = 'jU...@ar...'
CLASSIFIERS = [
- 'Development Status :: 3 - Alpha',
+ 'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: System :: Filesystems',
]
-DESCRIPTION = 'a python package to compact filepaths to a desired length'
DOWNLOAD=''
-LONG_DESCRIPTION = '''the package provides means to handle compacting of filepaths.
-this may be useful for gui programming for example where filepaths may be too long
-to fit into a certain widget and need to be compacted. compacting is done by inserting
-an ellipsis for unneeded parts, making shure the last component of a filepath remains
-visible to the user as long as possible.
-
-the package is designed so you can use it as from everywhere. no need to install it to
-site-packages, in case you want to include it in a project. it comes equipped with a
-wrapper for labels to handle filepaths of arbitrary length in qt4.
-
-to generate the documentation use epydoc
-'''
NAME = 'compactpath'
URL = 'https://sourceforge.net/projects/compactpath/'
VERSION = '0.5.0'
MODULES = ['compactpath', ]
-#PKG = {'': ''}
DATA = {}
+
if __name__ == '__main__':
setup(
author = AUTHOR,
author_email = AUTHOR_EMAIL,
classifiers=CLASSIFIERS,
- description=DESCRIPTION,
+ description=__doc__.split('\n')[0],
download_url=DOWNLOAD,
- long_description=DESCRIPTION,
+ long_description='\n'.join(__doc__.split('\n')[2:]),
name=NAME,
url=URL,
version=VERSION,
license='MIT licence',
platforms=['Many', ],
-
- #package_dir=PKG,
-
py_modules=MODULES,
package_data = DATA
)
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:30:24
|
Revision: 8
http://compactpath.svn.sourceforge.net/compactpath/?rev=8&view=rev
Author: jurner
Date: 2008-06-18 00:30:17 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
update
Modified Paths:
--------------
trunk/src/MANIFEST
Modified: trunk/src/MANIFEST
===================================================================
--- trunk/src/MANIFEST 2008-06-18 07:04:49 UTC (rev 7)
+++ trunk/src/MANIFEST 2008-06-18 07:30:17 UTC (rev 8)
@@ -6,7 +6,6 @@
compactpath/compactpath.py
compactpath/qt4/__init__.py
compactpath/qt4/pathlabelwrap.py
-compactpath/qt4/qlabel.cpp
compactpath/qt4/sample_gui.py
compactpath/scripts/__init__.py
compactpath/scripts/gen_docs.py
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 07:04:51
|
Revision: 7
http://compactpath.svn.sourceforge.net/compactpath/?rev=7&view=rev
Author: jurner
Date: 2008-06-18 00:04:49 -0700 (Wed, 18 Jun 2008)
Log Message:
-----------
...
Removed Paths:
-------------
trunk/MANIFEST
trunk/setup.py
Deleted: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2008-06-18 06:52:49 UTC (rev 6)
+++ trunk/MANIFEST 2008-06-18 07:04:49 UTC (rev 7)
@@ -1,12 +0,0 @@
-MANIFEST
-setup.py
-compactpath/LICENCE.MIT
-compactpath/README
-compactpath/__init__.py
-compactpath/compactpath.py
-compactpath/qt4/__init__.py
-compactpath/qt4/pathlabelwrap.py
-compactpath/qt4/qlabel.cpp
-compactpath/qt4/sample_gui.py
-compactpath/scripts/__init__.py
-compactpath/scripts/gen_docs.py
Deleted: trunk/setup.py
===================================================================
--- trunk/setup.py 2008-06-18 06:52:49 UTC (rev 6)
+++ trunk/setup.py 2008-06-18 07:04:49 UTC (rev 7)
@@ -1,55 +0,0 @@
-
-from distutils.core import setup
-
-AUTHOR = 'Juergen Urner'
-AUTHOR_EMAIL = 'jU...@ar...'
-CLASSIFIERS = [
- 'Development Status :: 3 - Alpha',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: MIT License',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python',
- 'Topic :: System :: Filesystems',
- ]
-DESCRIPTION = 'a python package to compact filepaths to a desired length'
-DOWNLOAD=''
-LONG_DESCRIPTION = '''the package provides means to handle compacting of filepaths.
-this may be useful for gui programming for example where filepaths may be too long
-to fit into a certain widget and need to be compacted. compacting is done by inserting
-an ellipsis for unneeded parts, making shure the last component of a filepath remains
-visible to the user as long as possible.
-
-the package is designed so you can use it as from everywhere. no need to install it to
-site-packages, in case you want to include it in a project. it comes equipped with a
-wrapper for labels to handle filepaths of arbitrary length in qt4.
-
-to generate the documentation use epydoc
-'''
-NAME = 'compactpath'
-URL = 'https://sourceforge.net/projects/compactpath/'
-VERSION = '0.5.0'
-
-MODULES = ['compactpath', ]
-#PKG = {'': ''}
-DATA = {}
-
-if __name__ == '__main__':
- setup(
- author = AUTHOR,
- author_email = AUTHOR_EMAIL,
- classifiers=CLASSIFIERS,
- description=DESCRIPTION,
- download_url=DOWNLOAD,
- long_description=DESCRIPTION,
- name=NAME,
- url=URL,
- version=VERSION,
-
- license='MIT licence',
- platforms=['Many', ],
-
- #package_dir=PKG,
-
- py_modules=MODULES,
- package_data = DATA
- )
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 06:52:50
|
Revision: 6
http://compactpath.svn.sourceforge.net/compactpath/?rev=6&view=rev
Author: jurner
Date: 2008-06-17 23:52:49 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
...
Removed Paths:
-------------
trunk/compactpath/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 06:51:58
|
Revision: 5
http://compactpath.svn.sourceforge.net/compactpath/?rev=5&view=rev
Author: jurner
Date: 2008-06-17 23:51:56 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
...
Added Paths:
-----------
trunk/src/MANIFEST
trunk/src/compactpath/
trunk/src/compactpath/LICENCE.MIT
trunk/src/compactpath/README
trunk/src/compactpath/__init__.py
trunk/src/compactpath/compactpath.py
trunk/src/compactpath/qt4/
trunk/src/compactpath/qt4/__init__.py
trunk/src/compactpath/qt4/pathlabelwrap.py
trunk/src/compactpath/qt4/sample_gui.py
trunk/src/compactpath/scripts/
trunk/src/compactpath/scripts/__init__.py
trunk/src/compactpath/scripts/gen_docs.py
trunk/src/setup.py
Added: trunk/src/MANIFEST
===================================================================
--- trunk/src/MANIFEST (rev 0)
+++ trunk/src/MANIFEST 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,12 @@
+MANIFEST
+setup.py
+compactpath/LICENCE.MIT
+compactpath/README
+compactpath/__init__.py
+compactpath/compactpath.py
+compactpath/qt4/__init__.py
+compactpath/qt4/pathlabelwrap.py
+compactpath/qt4/qlabel.cpp
+compactpath/qt4/sample_gui.py
+compactpath/scripts/__init__.py
+compactpath/scripts/gen_docs.py
Added: trunk/src/compactpath/LICENCE.MIT
===================================================================
--- trunk/src/compactpath/LICENCE.MIT (rev 0)
+++ trunk/src/compactpath/LICENCE.MIT 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,24 @@
+"compactpath" is a python package to handle compacting of filepaths
+
+Copyright (c) 2008 Juergen Urner
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+
Added: trunk/src/compactpath/README
===================================================================
--- trunk/src/compactpath/README (rev 0)
+++ trunk/src/compactpath/README 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,71 @@
+"compactpath" is a python package to handle compacting of filepaths
+
+project web: https://sourceforge.net/projects/compactpath/
+
+
+
+Version history
+#*******************************************************************
+compactpath 0.5.0
+#********************************************************************
+release: 06/15/2008
+
+did a complete rewrite of the package. sorry for any inconveniences and incompatibilities
+
+news:
+
+ x. reimplemented compactpath algo. bells and whistels have gone. this makes it ~15* faster
+ x. combed over PathLabelWrap (qt4). styling and enabling / disabling works now
+ x. added a script to auto generate epydoc docs. you will find it in the [scripts] folder
+
+
+fixes:
+
+
+incompatibilieites:
+
+ x. the "compactPath" function is named "compactpath" now
+ x. the function takes the desired width as first parameter now --> compactpath(w, fpath)
+ x. the keyword parameters "type" has gone. use "path_module" now
+ x. the keyword "max_pardirs" has gone. not supported anymore
+
+ x. qt4 implementations of the algo have been moved to --> compactpath/qt4/*
+ use: from compactpath.qt4 import <whatever>
+
+ x. PathLabelWrap (qt3) has gone. that is, no more support for qt3
+
+ x. PathLabelWrap (qt4) getPath() method is now PathLabelWrap.path()
+ x. the keyword parameters "type" has gone. use "path_module" now
+ x. the keyword "max_pardirs" has gone. not supported anymore
+
+ x. documentation is now uses epydoc markup
+
+
+#*******************************************************************
+compactpath 0.4.2
+#********************************************************************
+news:
+ x. PathLabelWrap.setPath() now takes the same keywords as constructor
+
+fixes:
+
+ x. root of nt posix paths was chewed off emidiately - fixed
+ x. root of mac paths was chewed off to soon - fixed
+
+
+#*******************************************************************
+compactpath 0.4.1
+#********************************************************************
+news:
+
+ x. updated inline docs ("sep" keyword was still there. This has changed to "type")
+
+
+#*******************************************************************
+compactpath 0.4.0
+#********************************************************************
+news:
+
+ x. added support for mac paths.
+ x. removed the "sep" keyword argument. Use the "type" keyword to explicitely
+ specify the type of path to be compacted if required.
\ No newline at end of file
Added: trunk/src/compactpath/__init__.py
===================================================================
--- trunk/src/compactpath/__init__.py (rev 0)
+++ trunk/src/compactpath/__init__.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,16 @@
+"""compact a filepath to fit into a desired width
+
+@note: the package is designed so you can drop it into any project
+and use it right away. no need to install it to --> lib/site-packages
+
+@note: you may use --> scripts/gen_docs.py to generate epydoc documentation for the package
+
+"""
+__author__ = 'Juergen Urner'
+__copyright__ = '(c) 2008 Juergen Urner'
+__email__ = 'jU...@ar...'
+__licence__ = 'Mit'
+__version__ = '0.5.0'
+
+
+
Added: trunk/src/compactpath/compactpath.py
===================================================================
--- trunk/src/compactpath/compactpath.py (rev 0)
+++ trunk/src/compactpath/compactpath.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,184 @@
+"""compactpath algorithm
+
+compacts a filepath to fit into a desired length by replacing chars with ellipsis. the funktion
+preserves the last component of the filepath as long as possible. assumption is that this component
+is of major importance for the user.
+"""
+
+import os
+#****************************************************************************************************
+# consts
+#****************************************************************************************************
+ELLIPSIS = '...'
+
+#****************************************************************************************************
+# helpers
+#****************************************************************************************************
+def rtrunc(n, chars, ellipsis=ELLIPSIS):
+ """truncates a string to from the right to the desired number of chars, replacing chars with ellipsis
+
+ @param n: (int) desired number of truncated chars
+ @param chars: (str) chars to truncate
+ @param ellipsis: (str) ellipsis to use for char substitution
+ @return: (str) the truncated string
+
+ >>> rtrunc(4, 'abcd')
+ '...d'
+
+ >>> rtrunc(99, 'abc')
+ '...'
+
+ >>> rtrunc(1, 'abc')
+ '.'
+
+ >>> rtrunc(0, 'abc')
+ ''
+
+ >>> rtrunc(-1, 'abc')
+ ''
+
+ >>> ellipsis = '01234'
+ >>> for n in range(len(ellipsis), 0, -1):
+ ... rtrunc(n, ellipsis, ellipsis=ellipsis)
+ '01234'
+ '1234'
+ '234'
+ '34'
+ '4'
+ """
+ if n > len(chars):
+ n = len(chars)
+ if n < 0:
+ n = 0
+
+ x = len(ellipsis) - n
+ if x < 0:
+ x = 0
+ e = ellipsis[x:]
+ return e + chars[len(chars) - n + len(e): ]
+
+
+def ltrunc(n, chars, ellipsis=ELLIPSIS):
+ """truncates a string to from the left to the desired number of chars, replacing chars with ellipsis
+
+ @param n: (int) desired number of truncated chars
+ @param chars: (str) chars to truncate
+ @param ellipsis: (str) ellipsis to use for char substitution
+ @return: (str) the truncated string
+
+ >>> ltrunc(4, 'abcd')
+ 'a...'
+
+ >>> ltrunc(99, 'abc')
+ '...'
+
+ >>> ltrunc(1, 'abc')
+ '.'
+
+ >>> ltrunc(0, 'abc')
+ ''
+
+ >>> ltrunc(-1, 'abc')
+ ''
+ >>> ellipsis = '01234'
+ >>> for n in range(len(ellipsis), 0, -1):
+ ... ltrunc(n, ellipsis, ellipsis=ellipsis)
+ '01234'
+ '0123'
+ '012'
+ '01'
+ '0'
+ """
+ if n > len(chars):
+ n = len(chars)
+ if n < 0:
+ n = 0
+
+ e = ellipsis[:n]
+ return chars[ :n - len(e)] + e
+
+#************************************************************************************************
+#
+#************************************************************************************************
+#NOTE:
+# a nicer but more complicated (and slower) implementation would preserve
+# components more intelligently. e.g. the emidiate parent component of the
+# last component would be preserved longer than some intermediate component
+
+def compactpath(w, fpath, measure=len, ellipsis=ELLIPSIS, path_module=os.path):
+ """compacts a filepath to fit into a desired width
+
+ @param fpath: (str) filepath to compact
+ @param measure: function to measure length of the filepath. the function
+ should take one parameter: the filepath and should return its length
+ @param ellipsis: (str) ellipsis to use for char substitution
+ @param path_module: path module to use to split and join filepath
+
+ @note: you can always assume that on return measure(fpath) is < w
+ for measure(fpath) > 0
+
+
+ >>> import posixpath
+ >>> compactpath(10, '/aaa/bbb/ccc', path_module=posixpath)
+ '/a.../ccc'
+
+ >>> compactpath(0, '', path_module=posixpath)
+ ''
+
+ >>> compactpath(-1, '', path_module=posixpath)
+ ''
+
+ >>> p = 'aaa/bbb/ccc'
+ >>> for n in range(len(p), 0, -1):
+ ... compactpath(n, p, path_module=posixpath)
+ 'aaa.../ccc'
+ 'aa.../ccc'
+ 'a.../ccc'
+ '.../ccc'
+ '...ccc'
+ '...cc'
+ '...c'
+ '...'
+ '..'
+ '.'
+ ''
+
+ """
+ if measure(fpath) < w:
+ return fpath
+
+ if w > 0:
+ head, tail = path_module.split(fpath)
+ n = len(head)
+
+ while n >= len(ELLIPSIS):
+ head = ltrunc(n, head, ellipsis=ellipsis)
+ n -= 1
+ fpath = path_module.join(head, tail)
+ if measure(fpath) < w:
+ return fpath
+
+ if head == ELLIPSIS:
+ tail = ELLIPSIS + tail
+ n = len(tail) - 1
+ elif head:
+ tail = path_module.join(head, tail, ellipsis=ellipsis)
+ n = len(tail)
+ else:
+ n = len(tail)
+
+ while tail:
+ if measure(tail) < w:
+ return tail
+ tail = rtrunc(n, tail)
+ n -= 1
+
+ return ''
+
+#************************************************************************************************
+#
+#************************************************************************************************
+
+if __name__ == '__main__':
+ import doctest
+ print 'doctests failed: %s/%s' % doctest.testmod()
Added: trunk/src/compactpath/qt4/__init__.py
===================================================================
--- trunk/src/compactpath/qt4/__init__.py (rev 0)
+++ trunk/src/compactpath/qt4/__init__.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1 @@
+"""compactpath implementations for qt4"""
Added: trunk/src/compactpath/qt4/pathlabelwrap.py
===================================================================
--- trunk/src/compactpath/qt4/pathlabelwrap.py (rev 0)
+++ trunk/src/compactpath/qt4/pathlabelwrap.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,226 @@
+"""QLabel wrapper to turn a QLabel into a label that displays a compacted filepath
+"""
+
+import os, sys
+from PyQt4 import QtCore, QtGui
+
+#--> rel import hack
+class SysPathHack(object):
+ def __init__(self, n):
+ fpath = os.path.abspath(__file__)
+ for i in xrange(n): fpath = os.path.dirname(fpath)
+ sys.path.insert(0, fpath)
+ def __del__(self): sys.path.pop(0)
+hack = SysPathHack(2)
+
+from compactpath import compactpath
+
+del hack
+#<-- rel import hack
+#********************************************************************************
+#
+#********************************************************************************
+class PathLabelWrap(object):
+ """class wrapping a QLabel to display a filepath or url that is compacted or decompacted on resizing of the label
+
+ usage::
+ # create a label in designer or wherever and wrap it afterwards
+ self.wrap = PathLabelWrap(self.myLabel, '/foo/bar/baz', prefix='MyPath: ')
+
+ @ivar fpath: filepath wrapped. setting this attr directly will not update the label. use L{setPath} instead
+ @ivar label: the QLabel wrapped
+ @ivar path_module: module to use to split and join the filepath. setting this attr directly will not update the label. use L{setPath} instead
+ @ivar prefix: fixed size string to prefix the filepath with. setting this attr directly will not update the label. use L{setPath} instead
+ """
+
+ def __init__(self, label, fpath='', prefix='', path_module=os.path):
+ """constructor
+
+ @param label: an initialized QLabel to wrap compactPath funktionality around
+ @param fpath: the filepath or url the label should display
+ @param path_module: module to use to split and join the filepath. hint: if you want
+ to display a macpath on linux pass macpath.
+ @param prefix: fixed size string to prefix the filepath with (will never be compacted)
+
+ @note: problem to tackle is that qt adjusts the size of any label to fit its contents. this wrapper
+ does it vice versa and adjusts the contents to the size of the label. so by default qt has to assume
+ the label is empty. you can set a text to the label (wich never gets displayed) to force a minimum label size
+
+ @note: currently the wrapper does not know how anything about rich text. no use to pass
+ a label containing rich text. the rich text it won't show up and behaviour of the label is undefined
+
+ @note: when used on a statusbar you may want to adjust the stretch facor. otherwise the label
+ might be invisible because it never gets resized
+ """
+ self.fpath = fpath
+ self.label = label
+ self.path_module = path_module
+ self.prefix = prefix
+
+ self.label.paintEvent = self.paintEvent # overwrite
+
+
+ def setPath(self, fpath, prefix=None, path_module=None):
+ """sets the filepath or url to be displayed
+
+ @param fpath: the filepath or url the label should display
+ @param path_module: module to use to split and join the filepath or None to keep the current one
+ @param prefix: fixed size string to prefix the filepath with (will never be compacted) or None to keep the current one
+ """
+ if prefix is not None:
+ self.prefix = prefix
+ if path_module is not None:
+ path_module = path_module
+ self.fpath = fpath
+ self.label.update()
+
+
+ def path(self):
+ """retrieves the (uncompacted) filepath wrapped
+ """
+ return self.fpath
+
+
+ def paintEvent(self, event):
+ """overwritten paintEvent() hanlder of QLabel"""
+ style = self.label.style()
+ painter = QtGui.QPainter(self.label)
+ palette = self.label.palette()
+ fm = self.label.fontMetrics()
+ cr = self.label.contentsRect()
+ align = style.visualAlignment(self.label.layoutDirection(), self.label.alignment())
+
+ cr.adjust(self.label.margin(), self.label.margin(), -self.label.margin(), -self.label.margin())
+
+ indent = self.label.indent()
+ if indent < 0: # see Qt docs: label.indent()
+ if indent > 0:
+ indent = fm.width("x") / 2
+ else:
+ indent = 0
+ if indent > 0:
+ if align & QtCore.Qt.AlignLeft:
+ cr.setLeft( cr.left() + indent);
+ if align & QtCore.Qt.AlignRight:
+ cr.setRight(cr.right() - indent)
+ if align & QtCore.Qt.AlignTop:
+ cr.setTop(cr.top() + indent)
+ if align & QtCore.Qt.AlignBottom:
+ cr.setBottom(cr.bottom() - indent)
+
+ w = cr.width()
+ if self.prefix:
+ w -= fm.width(self.prefix)
+ fpath = compactpath(
+ w,
+ self.fpath,
+ measure=fm.width,
+ path_module=self.path_module
+ )
+ self.label.drawFrame(painter)
+ style.drawItemText(painter, cr, align, palette, self.label.isEnabled(), self.prefix + fpath, self.label.foregroundRole())
+
+
+ #************************************************************************************************
+ # the original QLabel.painEvent() handler (for readability pixmap and movie stuff removed)
+ # quite a beast with calls to obscure private methods ...the reason why PathLabelWrap() currently
+ # does not support rich text
+ #
+ # as a hint: QTextDocument can be retrieved like this:
+ ##textDocument = None
+ ##for i in self.label.children():
+ ## for j in i.children():
+ ## if isinstance(j, QtGui.QTextDocument):
+ ## textDocument = j
+ ##
+ ##if textDocument is not None:
+ ## # process
+
+ """
+ void QLabel::paintEvent(QPaintEvent *)
+ {
+ Q_D(QLabel);
+ QStyle *style = QWidget::style();
+ QPainter painter(this);
+ drawFrame(&painter);
+ QRect cr = contentsRect();
+ cr.adjust(d->margin, d->margin, -d->margin, -d->margin);
+ int align = QStyle::visualAlignment(layoutDirection(), QFlag(d->align));
+
+
+ if (d->isTextLabel) {
+ QRectF lr = d->layoutRect();
+ if (d->control) {
+ #ifndef QT_NO_SHORTCUT
+ const bool underline = (bool)style->styleHint(QStyle::SH_UnderlineShortcut, 0, this, 0);
+ if (d->shortcutId != 0
+ && underline != d->shortcutCursor.charFormat().fontUnderline()) {
+ QTextCharFormat fmt;
+ fmt.setFontUnderline(underline);
+ d->shortcutCursor.mergeCharFormat(fmt);
+ }
+ #endif
+ d->ensureTextLayouted();
+
+ QAbstractTextDocumentLayout::PaintContext context;
+ QStyleOption opt(0);
+ opt.init(this);
+
+ if (!isEnabled() && style->styleHint(QStyle::SH_EtchDisabledText, &opt, this)) {
+ context.palette = palette();
+ context.palette.setColor(QPalette::Text, context.palette.light().color());
+ painter.save();
+ painter.translate(lr.x() + 1, lr.y() + 1);
+ painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1));
+ QAbstractTextDocumentLayout *layout = d->control->document()->documentLayout();
+ layout->draw(&painter, context);
+ painter.restore();
+ }
+
+ // Adjust the palette
+ context.palette = palette();
+ if (foregroundRole() != QPalette::Text && isEnabled())
+ context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole()));
+
+ painter.save();
+ painter.translate(lr.topLeft());
+ painter.setClipRect(lr.translated(-lr.x(), -lr.y()));
+ d->control->setPalette(context.palette);
+ d->control->drawContents(&painter, QRectF(), this);
+ painter.restore();
+ } else {
+ int flags = align;
+ if (d->hasShortcut) {
+ flags |= Qt::TextShowMnemonic;
+ QStyleOption opt;
+ opt.initFrom(this);
+ if (!style->styleHint(QStyle::SH_UnderlineShortcut, &opt, this))
+ flags |= Qt::TextHideMnemonic;
+ }
+ style->drawItemText(&painter, lr.toRect(), flags, palette(), isEnabled(), d->text, foregroundRole());
+ }
+ } else
+ #ifndef QT_NO_PICTURE
+
+ (...)
+
+ """
+
+#******************************************************************************
+#
+#******************************************************************************
+if __name__ == "__main__":
+
+ # for playing around...
+ a = QtGui.QApplication(sys.argv)
+ QtCore.QObject.connect(a,QtCore.SIGNAL("lastWindowClosed()"),a,QtCore.SLOT("quit()"))
+ w = QtGui.QLabel('aaa')
+ w.setIndent(39)
+ w.setStyleSheet('QLabel {background: yellow; border: 1py solid black}')
+ w.setTextFormat(QtCore.Qt.RichText)
+
+ PathLabelWrap(w, os.path.join(*[i*5 for i in 'abcdefg']))
+ w.show()
+ a.exec_()
+
+
\ No newline at end of file
Added: trunk/src/compactpath/qt4/sample_gui.py
===================================================================
--- trunk/src/compactpath/qt4/sample_gui.py (rev 0)
+++ trunk/src/compactpath/qt4/sample_gui.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,122 @@
+"""compactpath sample gui"""
+
+import os, sys
+import ntpath
+import macpath
+import posixpath
+
+from PyQt4 import QtCore, QtGui
+
+
+#--> rel import hack
+class SysPathHack(object):
+ def __init__(self, n):
+ fpath = os.path.abspath(__file__)
+ for i in xrange(n): fpath = os.path.dirname(fpath)
+ sys.path.insert(0, fpath)
+ def __del__(self): sys.path.pop(0)
+hack = SysPathHack(1)
+
+from pathlabelwrap import PathLabelWrap, compactpath
+
+del hack
+#<-- rel import hack
+#********************************************************************************
+# test GUI
+#*******************************************************************************
+CAPTION = "compactPath - [%s]"
+PATHS = (
+ (posixpath, "/my/very/long/path/containing/many/compoponents/here.txt"),
+ (ntpath, "c:\\my\\very\\long\\path\\containing\\many\\compoponents\\here.txt"),
+ (macpath, "my:very:long:path:containing:many:compoponents:here.txt"),
+ (posixpath, "http://my/very/long/path/containing/many/compoponents/here.txt"),
+ )
+BLINDTEXT = "xxxxxxxxxx" # this is set as text to the labels to force a minimum size. Adjust to your needs
+
+#******************************************************************************
+#
+#******************************************************************************
+class SampleGui(QtGui.QMainWindow):
+ """test gui"""
+
+ def __init__(self):
+ QtGui.QMainWindow.__init__(self)
+
+ self.mainWidget = QtGui.QWidget(self)
+ self.setCentralWidget(self.mainWidget)
+
+ # NOTE:
+ #
+ # too bad, no label or the like is retrievable for the caption bar. so no way to adjust it anything
+ # on the caption dynamically. best practice seems to be to init to some fixed width. plus is that
+ # the width of the caption bar label seems to have no effect on the GUI width. but this may
+ # vary from window manager to window manager.
+ #
+ pathModule, fpath = PATHS[0]
+ fpath = compactpath(50 - len(CAPTION), fpath, path_module=pathModule)
+ self.setWindowTitle(CAPTION % fpath)
+
+
+ def newPathlabelWrap(mainWidget, layout, frameStyle, pathModule, fpath, prefix=None):
+ label = QtGui.QLabel(BLINDTEXT, mainWidget)
+ label.setFrameStyle(frameStyle)
+ layout.addWidget(label)
+ if prefix is None:
+ prefix = pathModule.__name__ + ': '
+ wrap = PathLabelWrap(label, fpath=fpath, prefix=prefix, path_module=pathModule)
+ mainWidget.pathLabels.append(wrap)
+ return wrap
+
+ # throw labels into the Gui
+ layout = QtGui.QVBoxLayout(self.centralWidget())
+ frameStyle = QtGui.QLabel.Sunken | QtGui.QLabel.Box
+ self.pathLabels = []
+ for pathModule, fpath in PATHS:
+ newPathlabelWrap(self, layout, frameStyle, pathModule, fpath, prefix=None)
+
+ # add a disabled label
+ wrap = newPathlabelWrap(self, layout, frameStyle, pathModule, fpath, prefix='disabled: ')
+ wrap.label.setEnabled(False)
+
+ # for kicks a styled one
+ wrap = newPathlabelWrap(self, layout, frameStyle, pathModule, fpath, prefix='styled: ')
+ wrap.label.setStyleSheet('QLabel{border: 2px solid cyan; background: blue; color: white}')
+
+ # indent should work, too
+ wrap = newPathlabelWrap(self, layout, frameStyle, pathModule, fpath, prefix='indented: ')
+ wrap.label.setIndent(20)
+
+ # as should margin
+ wrap = newPathlabelWrap(self, layout, frameStyle, pathModule, fpath, prefix='margined: ')
+ wrap.label.setMargin(20)
+
+
+ # default QLabel to see test label to see if our owner drawn labels are ok
+ self.labelTest = QtGui.QLabel("sorry, no shortcuts, no rich text yet", self.mainWidget)
+ self.labelTest.setFrameStyle(frameStyle)
+ layout.addWidget(self.labelTest)
+
+ layout.addItem(QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding))
+
+ # add another wrap on the statusbar
+ self.status = self.statusBar()
+ self.statusLabelWrap = PathLabelWrap(QtGui.QLabel(BLINDTEXT, self.status), fpath=fpath, prefix='status: ')
+ self.statusLabelWrap.label.setFrameStyle(frameStyle)
+ self.status.addWidget(self.statusLabelWrap.label, 10)
+ self.status.addWidget(QtGui.QLabel('foo-bar', self.status))
+
+
+ def styleChange(self, oldStyle):
+ """styleChange handler"""
+ self.update()
+
+
+#******************************************************************************
+#
+#******************************************************************************
+if __name__ == "__main__":
+ a = QtGui.QApplication(sys.argv)
+ QtCore.QObject.connect(a,QtCore.SIGNAL("lastWindowClosed()"),a,QtCore.SLOT("quit()"))
+ w = SampleGui()
+ w.show()
+ a.exec_()
Added: trunk/src/compactpath/scripts/__init__.py
===================================================================
--- trunk/src/compactpath/scripts/__init__.py (rev 0)
+++ trunk/src/compactpath/scripts/__init__.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1 @@
+"""scripts and helpers for the package"""
Added: trunk/src/compactpath/scripts/gen_docs.py
===================================================================
--- trunk/src/compactpath/scripts/gen_docs.py (rev 0)
+++ trunk/src/compactpath/scripts/gen_docs.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,77 @@
+"""Generates epydoc documentation for the package in --> packageDir/docs
+
+gen_docs.py
+
+@note: the script assumes it is located in the scripts subdirectory of the package
+@note: Use gen_docs.py -? or --help to print out this help text
+
+@requires: epydoc
+@requires: python >= 2.4
+"""
+
+from __future__ import with_statement
+
+import sys, os
+from epydoc import cli
+import subprocess
+#************************************************************************************
+# consts
+#************************************************************************************
+PACKAGE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+DOC_DIR = os.path.join(PACKAGE_DIR, 'doc')
+EPYDOC_FOLDER = 'epydoc'
+EPYDOC_DIR = os.path.join(DOC_DIR, EPYDOC_FOLDER)
+
+#************************************************************************************
+# helpers
+#************************************************************************************
+def save_create_dir(directory):
+ """creates a directory if it does not exist already"""
+ if not os.path.isdir(directory):
+ os.makedirs(directory)
+
+def enshure_doc_dir_dxists():
+ """enshures epydoc docdir exists"""
+ save_create_dir(EPYDOC_DIR)
+
+#**************************************************************************
+#
+#**************************************************************************
+def main():
+ """"""
+ enshure_doc_dir_dxists()
+ print 'calling epydoc'
+ sys.argv = [
+ __file__,
+ '-v',
+ '-o%s' % EPYDOC_DIR,
+ '--src-code-tab-width', '4',
+ #'--debug',
+ PACKAGE_DIR,
+ ]
+ cli.cli()
+ print 'done'
+
+ # create a redirect to 'epydoc/index.html'
+ print 'creating redirect'
+ with open(os.path.join(DOC_DIR, 'index.html'), 'w') as fp:
+ fp.write('''<html>
+ <head>
+ <meta http-equiv="Refresh" content="0; URL=%s">
+ </head>
+</html>
+''' % (EPYDOC_FOLDER + '/' + 'index.html') )
+
+ print 'done'
+
+#**************************************************************************************
+#
+#**************************************************************************************
+if __name__ == '__main__':
+ wantsHelp = len(sys.argv) > 1 and sys.argv[1] or None
+ if wantsHelp not in ('-?', '--help'):
+ sys.exit(main())
+ print __doc__
+
+
+
Added: trunk/src/setup.py
===================================================================
--- trunk/src/setup.py (rev 0)
+++ trunk/src/setup.py 2008-06-18 06:51:56 UTC (rev 5)
@@ -0,0 +1,55 @@
+
+from distutils.core import setup
+
+AUTHOR = 'Juergen Urner'
+AUTHOR_EMAIL = 'jU...@ar...'
+CLASSIFIERS = [
+ 'Development Status :: 3 - Alpha',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: MIT License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: System :: Filesystems',
+ ]
+DESCRIPTION = 'a python package to compact filepaths to a desired length'
+DOWNLOAD=''
+LONG_DESCRIPTION = '''the package provides means to handle compacting of filepaths.
+this may be useful for gui programming for example where filepaths may be too long
+to fit into a certain widget and need to be compacted. compacting is done by inserting
+an ellipsis for unneeded parts, making shure the last component of a filepath remains
+visible to the user as long as possible.
+
+the package is designed so you can use it as from everywhere. no need to install it to
+site-packages, in case you want to include it in a project. it comes equipped with a
+wrapper for labels to handle filepaths of arbitrary length in qt4.
+
+to generate the documentation use epydoc
+'''
+NAME = 'compactpath'
+URL = 'https://sourceforge.net/projects/compactpath/'
+VERSION = '0.5.0'
+
+MODULES = ['compactpath', ]
+#PKG = {'': ''}
+DATA = {}
+
+if __name__ == '__main__':
+ setup(
+ author = AUTHOR,
+ author_email = AUTHOR_EMAIL,
+ classifiers=CLASSIFIERS,
+ description=DESCRIPTION,
+ download_url=DOWNLOAD,
+ long_description=DESCRIPTION,
+ name=NAME,
+ url=URL,
+ version=VERSION,
+
+ license='MIT licence',
+ platforms=['Many', ],
+
+ #package_dir=PKG,
+
+ py_modules=MODULES,
+ package_data = DATA
+ )
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ju...@us...> - 2008-06-18 06:47:46
|
Revision: 4
http://compactpath.svn.sourceforge.net/compactpath/?rev=4&view=rev
Author: jurner
Date: 2008-06-17 23:47:43 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
...
Added Paths:
-----------
trunk/src/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|