Browse Source

porting the code to python3

damien 10 years ago
parent
commit
5688ab1369

+ 0 - 3
pboard/README.txt View File

@@ -22,6 +22,3 @@ While developing you may want the server to reload after changes in package file
22 22
     $ gearbox serve --reload --debug
23 23
 
24 24
 Then you are ready to go.
25
-
26
-# Icons are the glyphicons icon set taken from https://github.com/ericzhang-cn/full-glyphicons
27
-

+ 61 - 5
pboard/pboard.egg-info/SOURCES.txt View File

@@ -15,6 +15,8 @@ pboard/config/app_cfg.py
15 15
 pboard/config/environment.py
16 16
 pboard/config/middleware.py
17 17
 pboard/controllers/__init__.py
18
+pboard/controllers/api.py
19
+pboard/controllers/debug.py
18 20
 pboard/controllers/error.py
19 21
 pboard/controllers/root.py
20 22
 pboard/controllers/secure.py
@@ -23,30 +25,84 @@ pboard/i18n/ru/LC_MESSAGES/pboard.po
23 25
 pboard/lib/__init__.py
24 26
 pboard/lib/app_globals.py
25 27
 pboard/lib/base.py
28
+pboard/lib/dbapi.py
26 29
 pboard/lib/helpers.py
27 30
 pboard/model/__init__.py
28 31
 pboard/model/auth.py
32
+pboard/model/data.py
29 33
 pboard/public/favicon.ico
34
+pboard/public/css/bootstrap-datetimepicker.min.css
30 35
 pboard/public/css/bootstrap-responsive.min.css
36
+pboard/public/css/bootstrap.css
31 37
 pboard/public/css/bootstrap.min.css
38
+pboard/public/css/glyphicons.css
32 39
 pboard/public/css/style.css
40
+pboard/public/css/external/font-awesome-4.0.3/css/font-awesome.min.css
41
+pboard/public/css/external/font-awesome-4.0.3/fonts/FontAwesome.otf
42
+pboard/public/css/external/font-awesome-4.0.3/fonts/fontawesome-webfont.eot
43
+pboard/public/css/external/font-awesome-4.0.3/fonts/fontawesome-webfont.svg
44
+pboard/public/css/external/font-awesome-4.0.3/fonts/fontawesome-webfont.ttf
45
+pboard/public/css/external/font-awesome-4.0.3/fonts/fontawesome-webfont.woff
46
+pboard/public/css/external/google-code-prettify/prettify.css
47
+pboard/public/img/glyphicons-grey.png
48
+pboard/public/img/glyphicons-halflings-white.original.png
33 49
 pboard/public/img/glyphicons-halflings-white.png
50
+pboard/public/img/glyphicons-halflings.original.png
34 51
 pboard/public/img/glyphicons-halflings.png
52
+pboard/public/img/glyphicons-white.png
53
+pboard/public/img/glyphicons.png
35 54
 pboard/public/img/turbogears_logo.png
36 55
 pboard/public/img/turbogears_logo_big.png
37 56
 pboard/public/img/under_the_hood_blue.png
38 57
 pboard/public/javascript/bootstrap.min.js
58
+pboard/public/javascript/external/bootstrap-datetimepicker.min.js
59
+pboard/public/javascript/external/bootstrap-wysiwyg.js
60
+pboard/public/javascript/external/bootstrap.js
61
+pboard/public/javascript/external/bootstrap.min.js
62
+pboard/public/javascript/external/jquery.hotkeys.js
63
+pboard/public/javascript/external/google-code-prettify/lang-apollo.js
64
+pboard/public/javascript/external/google-code-prettify/lang-basic.js
65
+pboard/public/javascript/external/google-code-prettify/lang-clj.js
66
+pboard/public/javascript/external/google-code-prettify/lang-css.js
67
+pboard/public/javascript/external/google-code-prettify/lang-dart.js
68
+pboard/public/javascript/external/google-code-prettify/lang-erlang.js
69
+pboard/public/javascript/external/google-code-prettify/lang-go.js
70
+pboard/public/javascript/external/google-code-prettify/lang-hs.js
71
+pboard/public/javascript/external/google-code-prettify/lang-lisp.js
72
+pboard/public/javascript/external/google-code-prettify/lang-llvm.js
73
+pboard/public/javascript/external/google-code-prettify/lang-lua.js
74
+pboard/public/javascript/external/google-code-prettify/lang-matlab.js
75
+pboard/public/javascript/external/google-code-prettify/lang-ml.js
76
+pboard/public/javascript/external/google-code-prettify/lang-mumps.js
77
+pboard/public/javascript/external/google-code-prettify/lang-n.js
78
+pboard/public/javascript/external/google-code-prettify/lang-pascal.js
79
+pboard/public/javascript/external/google-code-prettify/lang-proto.js
80
+pboard/public/javascript/external/google-code-prettify/lang-r.js
81
+pboard/public/javascript/external/google-code-prettify/lang-rd.js
82
+pboard/public/javascript/external/google-code-prettify/lang-scala.js
83
+pboard/public/javascript/external/google-code-prettify/lang-sql.js
84
+pboard/public/javascript/external/google-code-prettify/lang-tcl.js
85
+pboard/public/javascript/external/google-code-prettify/lang-tex.js
86
+pboard/public/javascript/external/google-code-prettify/lang-vb.js
87
+pboard/public/javascript/external/google-code-prettify/lang-vhdl.js
88
+pboard/public/javascript/external/google-code-prettify/lang-wiki.js
89
+pboard/public/javascript/external/google-code-prettify/lang-xq.js
90
+pboard/public/javascript/external/google-code-prettify/lang-yaml.js
91
+pboard/public/javascript/external/google-code-prettify/prettify.js
92
+pboard/public/javascript/external/google-code-prettify/run_prettify.js
39 93
 pboard/templates/__init__.py
40
-pboard/templates/__init__.pyc
41
-pboard/templates/about.mak
42
-pboard/templates/data.mak
43
-pboard/templates/environ.mak
94
+pboard/templates/dashboard.mak
95
+pboard/templates/document.mak
44 96
 pboard/templates/error.mak
45 97
 pboard/templates/index.mak
46 98
 pboard/templates/login.mak
47
-pboard/templates/master.html
48 99
 pboard/templates/master.mak
100
+pboard/templates/pod.mak
49 101
 pboard/templates/simple_mako.mak
102
+pboard/templates/debug/__init__.py
103
+pboard/templates/debug/environ.mak
104
+pboard/templates/debug/iconset.mak
105
+pboard/templates/debug/identity.mak
50 106
 pboard/tests/__init__.py
51 107
 pboard/tests/functional/__init__.py
52 108
 pboard/tests/functional/test_authentication.py

+ 3 - 4
pboard/pboard.egg-info/requires.txt View File

@@ -1,10 +1,9 @@
1
-TurboGears2 >= 2.3.0b3
2
-Babel
1
+TurboGears2 >= 2.3.1
3 2
 Genshi
4 3
 Mako
5 4
 zope.sqlalchemy >= 0.4
6 5
 sqlalchemy
7 6
 alembic
8 7
 repoze.who
9
-tw2.forms
10
-tgext.admin >= 0.5.1
8
+psycopg2
9
+pillow

+ 2 - 1
pboard/pboard/config/app_cfg.py View File

@@ -21,7 +21,8 @@ from pboard.lib import app_globals, helpers
21 21
 
22 22
 base_config = AppConfig()
23 23
 base_config.renderers = []
24
-base_config.prefer_toscawidgets2 = True
24
+base_config.use_toscawidgets = False
25
+base_config.use_toscawidgets2 = False
25 26
 
26 27
 base_config.package = pboard
27 28
 

+ 16 - 8
pboard/pboard/controllers/api.py View File

@@ -2,8 +2,16 @@
2 2
 """Sample controller with all its actions protected."""
3 3
 from datetime import datetime
4 4
 
5
-import cStringIO as csio
6
-import Image as pil
5
+# TODO - D.A. - 2013-11-19
6
+# Check if the new import (ie import io instead of cStringIO)
7
+# is working correctly
8
+#import io as csio
9
+
10
+# INFO - D.A. - 2013-11-19
11
+# The PIL import is now taken from the pillow
12
+# which is the python3 port of PIL
13
+#
14
+from PIL import Image as pil
7 15
 
8 16
 import tg
9 17
 from tg import expose, flash, require, url, lurl, request, redirect, tmpl_context
@@ -24,8 +32,8 @@ FIXME_ERROR_CODE=-1
24 32
 class PODPublicApiController(BaseController):
25 33
 
26 34
     @expose()
27
-    def create_account(self, email=u'', password=u'', retyped_password=u'', **kw):
28
-      if email==u'' or password==u'' or retyped_password==u'':
35
+    def create_account(self, email='', password='', retyped_password='', **kw):
36
+      if email=='' or password=='' or retyped_password=='':
29 37
         flash(_('Account creation error: please fill all the fields'), 'error')
30 38
         redirect(lurl('/'))
31 39
       elif password!=retyped_password:
@@ -54,7 +62,7 @@ class PODApiController(BaseController):
54 62
     allow_only = tgp.in_group('user', msg=l_('You need to login in order to access this ressource'))
55 63
     
56 64
     @expose()
57
-    def create_event(self, parent_id=None, data_label=u'', data_datetime=None, data_content=u'', data_reminder_datetime=None, add_reminder=False, **kw):
65
+    def create_event(self, parent_id=None, data_label='', data_datetime=None, data_content='', data_reminder_datetime=None, add_reminder=False, **kw):
58 66
       loCurrentUser   = pld.PODStaticController.getCurrentUser()
59 67
       loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
60 68
       
@@ -71,7 +79,7 @@ class PODApiController(BaseController):
71 79
       redirect(lurl('/document/%i'%(loNewNode.parent_id)))
72 80
 
73 81
     @expose()
74
-    def create_contact(self, parent_id=None, data_label=u'', data_content=u'', **kw):
82
+    def create_contact(self, parent_id=None, data_label='', data_content='', **kw):
75 83
       loCurrentUser   = pld.PODStaticController.getCurrentUser()
76 84
       loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
77 85
       
@@ -85,7 +93,7 @@ class PODApiController(BaseController):
85 93
       redirect(lurl('/document/%i'%(loNewNode.parent_id)))
86 94
 
87 95
     @expose()
88
-    def create_comment(self, parent_id=None, data_label=u'', data_content=u'', **kw):
96
+    def create_comment(self, parent_id=None, data_label='', data_content='', **kw):
89 97
       loCurrentUser   = pld.PODStaticController.getCurrentUser()
90 98
       loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
91 99
       
@@ -99,7 +107,7 @@ class PODApiController(BaseController):
99 107
       redirect(lurl('/document/%i'%(loNewNode.parent_id)))
100 108
 
101 109
     @expose()
102
-    def create_file(self, parent_id=None, data_label=u'', data_content=u'', data_file=None, **kw):
110
+    def create_file(self, parent_id=None, data_label='', data_content='', data_file=None, **kw):
103 111
       loCurrentUser   = pld.PODStaticController.getCurrentUser()
104 112
       loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
105 113
       

+ 0 - 2
pboard/pboard/controllers/debug.py View File

@@ -7,8 +7,6 @@ from tg import predicates
7 7
 from pboard import model
8 8
 from pboard.controllers.secure import SecureController
9 9
 from pboard.model import DBSession, metadata
10
-from tgext.admin.tgadminconfig import TGAdminConfig
11
-from tgext.admin.controller import AdminController
12 10
 
13 11
 from pboard.lib.base import BaseController
14 12
 from pboard.controllers.error import ErrorController

+ 10 - 4
pboard/pboard/controllers/root.py View File

@@ -7,8 +7,11 @@ from tg.i18n import ugettext as _, lazy_ugettext as l_
7 7
 from tg import predicates
8 8
 from pboard import model
9 9
 from pboard.model import DBSession, metadata
10
-from tgext.admin.tgadminconfig import TGAdminConfig
11
-from tgext.admin.controller import AdminController
10
+# FIXME - D.A. - 2013-11-19
11
+# python3 port is not yet available for the tgext.admin module
12
+#
13
+# from tgext.admin.tgadminconfig import TGAdminConfig
14
+# from tgext.admin.controller import AdminController
12 15
 
13 16
 from pboard.lib.base import BaseController
14 17
 from pboard.controllers.error import ErrorController
@@ -40,7 +43,10 @@ class RootController(BaseController):
40 43
     must be wrapped around with :class:`tg.controllers.WSGIAppController`.
41 44
 
42 45
     """
43
-    admin = AdminController(model, DBSession, config_type=TGAdminConfig)
46
+    # FIXME - D.A. - 2013-11-19
47
+    # python3 port is not yet available for the tgext.admin module
48
+    #
49
+    # admin = AdminController(model, DBSession, config_type=TGAdminConfig)
44 50
 
45 51
     api   = pbca.PODApiController()
46 52
     debug = pbcd.DebugController()
@@ -119,7 +125,7 @@ class RootController(BaseController):
119 125
         try:
120 126
           loNodeStatusList = pbmd.PBNodeStatus.getList()
121 127
           loCurrentNode    = loApiController.getNode(liNodeId)
122
-        except Exception, e:
128
+        except Exception as e:
123 129
           flash(_('Document not found'), 'error')
124 130
         
125 131
         # FIXME - D.A - 2013-11-07 - Currently, the code build a new item if no item found for current user

+ 3 - 3
pboard/pboard/lib/dbapi.py View File

@@ -112,7 +112,7 @@ class PODUserFilteredApiController(object):
112 112
         # The following line may raise an exception
113 113
         # We suppose that the parent node has already been added
114 114
         # this *should* be the case, but the code does not check it
115
-        if loTmpDict.has_key(loNode.parent_id)==False:
115
+        if loNode.parent_id in loTmpDict.keys():
116 116
           loTmpDict[loNode.parent_id] = self.getNode(loNode.parent_id)
117 117
         loTmpDict[loNode.parent_id].appendStaticChild(loNode)
118 118
   
@@ -148,7 +148,7 @@ class PODUserFilteredApiController(object):
148 148
       if loItem==loNode:
149 149
         if loPreviousItem==None:
150 150
           return FIXME_ERROR_CODE # FIXME - D.A. Do not use hard-coded error codes
151
-          print "No previous node"
151
+          print("No previous node")
152 152
         else:
153 153
           liPreviousItemOrder       = loPreviousItem.node_order
154 154
           loPreviousItem.node_order = loNode.node_order
@@ -169,7 +169,7 @@ class PODUserFilteredApiController(object):
169 169
         if loPreviousItem==None:
170 170
           return FIXME_ERROR_CODE # FIXME - D.A. Do not use hard-coded error codes
171 171
           # FIXME
172
-          print "No previous node"
172
+          print("No previous node")
173 173
         else:
174 174
           liPreviousItemOrder       = loPreviousItem.node_order
175 175
           loPreviousItem.node_order = loNode.node_order

+ 16 - 16
pboard/pboard/model/data.py View File

@@ -22,19 +22,19 @@ from pboard.model import DeclarativeBase, metadata, DBSession
22 22
     Column('node_id', Integer, Sequence('pod_nodes__node_id__sequence'), primary_key=True),
23 23
     Column('parent_id', Integer, ForeignKey('pod_nodes.node_id'), nullable=True, default=None),
24 24
     Column('node_order', Integer, nullable=True, default=1),
25
-    Column('node_type',   Unicode(16), unique=False, nullable=False, default=u'data'),
26
-    Column('node_status', Unicode(16), unique=False, nullable=False, default=u'new'),
25
+    Column('node_type',   Unicode(16), unique=False, nullable=False, default='data'),
26
+    Column('node_status', Unicode(16), unique=False, nullable=False, default='new'),
27 27
 
28 28
     Column('created_at', DateTime, unique=False, nullable=False),
29 29
     Column('updated_at', DateTime, unique=False, nullable=False),
30 30
 
31
-    Column('data_label',   Unicode(1024), unique=False, nullable=False, default=u''),
32
-    Column('data_content', Text(), unique=False, nullable=False, default=u''),
31
+    Column('data_label',   Unicode(1024), unique=False, nullable=False, default=''),
32
+    Column('data_content', Text(), unique=False, nullable=False, default=''),
33 33
     Column('data_datetime', DateTime, unique=False, nullable=False),
34 34
     Column('data_reminder_datetime', DateTime, unique=False, nullable=True),
35 35
     
36
-    Column('data_file_name', Unicode(255), unique=False, nullable=False, default=u''),
37
-    Column('data_file_mime_type', Unicode(255), unique=False, nullable=False, default=u''),
36
+    Column('data_file_name', Unicode(255), unique=False, nullable=False, default=''),
37
+    Column('data_file_mime_type', Unicode(255), unique=False, nullable=False, default=''),
38 38
     Column('data_file_content', LargeBinary(), unique=False, nullable=False, default=None),
39 39
 )
40 40
 """
@@ -146,7 +146,7 @@ class PBNode(DeclarativeBase):
146 146
     self._lStaticChildList = []
147 147
 
148 148
   def appendStaticChild(self, loNode):
149
-    print "%s has child %s" % (self.node_id, loNode.node_id)
149
+    print("%s has child %s" % (self.node_id, loNode.node_id))
150 150
     self._lStaticChildList.append(loNode)
151 151
 
152 152
   def getStaticChildList(self):
@@ -159,24 +159,24 @@ class PBNode(DeclarativeBase):
159 159
   node_id          = Column(Integer, Sequence('pod_nodes__node_id__sequence'), primary_key=True)
160 160
   parent_id        = Column(Integer, ForeignKey('pod_nodes.node_id'), nullable=True, default=None)
161 161
   node_depth       = Column(Integer, unique=False, nullable=False, default=0)
162
-  parent_tree_path = Column(Unicode(255), unique=False, nullable=False, default=u'')
162
+  parent_tree_path = Column(Unicode(255), unique=False, nullable=False, default='')
163 163
   owner_id         = Column(Integer, ForeignKey('pod_user.user_id'), nullable=True, default=None)
164 164
 
165 165
   node_order  = Column(Integer, nullable=True, default=1)
166
-  node_type   = Column(Unicode(16), unique=False, nullable=False, default=u'data')
167
-  node_status = Column(Unicode(16), unique=False, nullable=False, default=u'new')
166
+  node_type   = Column(Unicode(16), unique=False, nullable=False, default='data')
167
+  node_status = Column(Unicode(16), unique=False, nullable=False, default='new')
168 168
 
169 169
   created_at = Column(DateTime, unique=False, nullable=False)
170 170
   updated_at = Column(DateTime, unique=False, nullable=False)
171 171
 
172
-  data_label   = Column(Unicode(1024), unique=False, nullable=False, default=u'')
173
-  data_content = Column(Text(),        unique=False, nullable=False, default=u'')
172
+  data_label   = Column(Unicode(1024), unique=False, nullable=False, default='')
173
+  data_content = Column(Text(),        unique=False, nullable=False, default='')
174 174
   
175 175
   data_datetime          = Column(DateTime, unique=False, nullable=False)
176 176
   data_reminder_datetime = Column(DateTime, unique=False, nullable=True)
177 177
   
178
-  data_file_name      = Column(Unicode(255),  unique=False, nullable=False, default=u'')
179
-  data_file_mime_type = Column(Unicode(255),  unique=False, nullable=False, default=u'')
178
+  data_file_name      = Column(Unicode(255),  unique=False, nullable=False, default='')
179
+  data_file_mime_type = Column(Unicode(255),  unique=False, nullable=False, default='')
180 180
   data_file_content   = Column(LargeBinary(), unique=False, nullable=False, default=None)
181 181
 
182 182
 
@@ -283,10 +283,10 @@ class PBNode(DeclarativeBase):
283 283
     return PBNodeStatus.getStatusItem(self.node_status)
284 284
 
285 285
   def getTruncatedLabel(self, piCharNb):
286
-    lsTruncatedLabel = u''
286
+    lsTruncatedLabel = ''
287 287
     liMaxLength = int(piCharNb)
288 288
     if len(self.data_label)>liMaxLength:
289
-      lsTruncatedLabel = self.data_label[0:liMaxLength-1]+u'…'
289
+      lsTruncatedLabel = self.data_label[0:liMaxLength-1]+'…'
290 290
     else:
291 291
       lsTruncatedLabel = self.data_label
292 292
     return lsTruncatedLabel

+ 2 - 0
pboard/pboard/templates/__init__.py View File

@@ -0,0 +1,2 @@
1
+# -*- coding: utf-8 -*-
2
+"""Templates package for the application."""

+ 1 - 1
pboard/pboard/templates/master.mak View File

@@ -745,7 +745,7 @@ tr:Hover td div.pod-toolbar {
745 745
               </li>
746 746
             % else:
747 747
               <li class="dropdown">
748
-                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> ${request.identity['user']}</a>
748
+                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> ${request.identity['user'].display_name}</a>
749 749
                 <ul class="dropdown-menu pull-right">
750 750
                   <li class="text-center">
751 751
                     <fieldset>

+ 1 - 1
pboard/pboard/templates/pod.mak View File

@@ -1,5 +1,5 @@
1 1
 <%def name="Button(piId, pbWithLabel, psButtonCssClass, psButtonTitle, psButtonIcon, psButtonLabel)" >
2
-  <button id='${piId}' type="button" class="${psButtonCssClass}" title="${psButtonTitle}"><i class="${psButtonIcon}"></i>${u'' if (pbWithLabel==False) else u' %s'%(psButtonLabel)}</button>
2
+  <button id='${piId}' type="button" class="${psButtonCssClass}" title="${psButtonTitle}"><i class="${psButtonIcon}"></i>${'' if (pbWithLabel==False) else ' %s'%(psButtonLabel)}</button>
3 3
 </%def>
4 4
 
5 5
 <%def name="SaveButton(piId, pbWithLabel=False)" >

+ 2 - 4
pboard/setup.py View File

@@ -28,19 +28,17 @@ except ImportError:
28 28
 testpkgs=['WebTest >= 1.2.3',
29 29
                'nose',
30 30
                'coverage',
31
+               'gearbox'
31 32
                ]
32 33
 
33 34
 install_requires=[
34
-    "TurboGears2 >= 2.3.0b3",
35
-    "Babel",
35
+    "TurboGears2 >= 2.3.1",
36 36
     "Genshi",
37 37
     "Mako",
38 38
     "zope.sqlalchemy >= 0.4",
39 39
     "sqlalchemy",
40 40
     "alembic",
41 41
     "repoze.who",
42
-    "tw2.forms",
43
-    "tgext.admin >= 0.5.1",
44 42
     ]
45 43
 
46 44
 setup(

+ 6 - 2
run.sh View File

@@ -2,11 +2,15 @@
2 2
 
3 3
 OLD_PATH=`pwd`
4 4
 
5
-ROOT_FOLDER=/home/daccorsi/sources/protos/pboard
5
+POD_BIN_PATH=`dirname $0`
6
+POD_INSTALL_PATH=`dirname ${POD_BIN_PATH}`
7
+POD_INSTALL_FULL_PATH=`realpath ${POD_INSTALL_PATH}`
8
+
9
+ROOT_FOLDER=${POD_INSTALL_FULL_PATH}
6 10
 
7 11
 cd ${ROOT_FOLDER}
8 12
 source tg2env/bin/activate
9 13
 cd ${ROOT_FOLDER}/pboard/
10
-gearbox serve -c development.ini --reload
14
+gearbox serve -c development.ini --reload --debug
11 15
 cd ${OLD_PATH}
12 16
 

+ 0 - 76
tg2env/bin/activate View File

@@ -1,76 +0,0 @@
1
-# This file must be used with "source bin/activate" *from bash*
2
-# you cannot run it directly
3
-
4
-deactivate () {
5
-    # reset old environment variables
6
-    if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
7
-        PATH="$_OLD_VIRTUAL_PATH"
8
-        export PATH
9
-        unset _OLD_VIRTUAL_PATH
10
-    fi
11
-    if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
12
-        PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
13
-        export PYTHONHOME
14
-        unset _OLD_VIRTUAL_PYTHONHOME
15
-    fi
16
-
17
-    # This should detect bash and zsh, which have a hash command that must
18
-    # be called to get it to forget past commands.  Without forgetting
19
-    # past commands the $PATH changes we made may not be respected
20
-    if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
21
-        hash -r
22
-    fi
23
-
24
-    if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
25
-        PS1="$_OLD_VIRTUAL_PS1"
26
-        export PS1
27
-        unset _OLD_VIRTUAL_PS1
28
-    fi
29
-
30
-    unset VIRTUAL_ENV
31
-    if [ ! "$1" = "nondestructive" ] ; then
32
-    # Self destruct!
33
-        unset -f deactivate
34
-    fi
35
-}
36
-
37
-# unset irrelavent variables
38
-deactivate nondestructive
39
-
40
-VIRTUAL_ENV="/home/daccorsi/sources/protos/pboard/tg2env"
41
-export VIRTUAL_ENV
42
-
43
-_OLD_VIRTUAL_PATH="$PATH"
44
-PATH="$VIRTUAL_ENV/bin:$PATH"
45
-export PATH
46
-
47
-# unset PYTHONHOME if set
48
-# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
49
-# could use `if (set -u; : $PYTHONHOME) ;` in bash
50
-if [ -n "$PYTHONHOME" ] ; then
51
-    _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
52
-    unset PYTHONHOME
53
-fi
54
-
55
-if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
56
-    _OLD_VIRTUAL_PS1="$PS1"
57
-    if [ "x" != x ] ; then
58
-        PS1="$PS1"
59
-    else
60
-    if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
61
-        # special case for Aspen magic directories
62
-        # see http://www.zetadev.com/software/aspen/
63
-        PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
64
-    else
65
-        PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
66
-    fi
67
-    fi
68
-    export PS1
69
-fi
70
-
71
-# This should detect bash and zsh, which have a hash command that must
72
-# be called to get it to forget past commands.  Without forgetting
73
-# past commands the $PATH changes we made may not be respected
74
-if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
75
-    hash -r
76
-fi

+ 0 - 32
tg2env/bin/activate.csh View File

@@ -1,32 +0,0 @@
1
-# This file must be used with "source bin/activate.csh" *from csh*.
2
-# You cannot run it directly.
3
-# Created by Davide Di Blasi <davidedb@gmail.com>.
4
-
5
-alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
6
-
7
-# Unset irrelavent variables.
8
-deactivate nondestructive
9
-
10
-setenv VIRTUAL_ENV "/home/daccorsi/sources/protos/pboard/tg2env"
11
-
12
-set _OLD_VIRTUAL_PATH="$PATH"
13
-setenv PATH "$VIRTUAL_ENV/bin:$PATH"
14
-
15
-set _OLD_VIRTUAL_PROMPT="$prompt"
16
-
17
-if ("" != "") then
18
-    set env_name = ""
19
-else
20
-    if (`basename "$VIRTUAL_ENV"` == "__") then
21
-        # special case for Aspen magic directories
22
-        # see http://www.zetadev.com/software/aspen/
23
-        set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
24
-    else
25
-        set env_name = `basename "$VIRTUAL_ENV"`
26
-    endif
27
-endif
28
-set prompt = "[$env_name] $prompt"
29
-unset env_name
30
-
31
-rehash
32
-

+ 0 - 79
tg2env/bin/activate.fish View File

@@ -1,79 +0,0 @@
1
-# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
2
-# you cannot run it directly
3
-
4
-function deactivate  -d "Exit virtualenv and return to normal shell environment"
5
-    # reset old environment variables
6
-    if test -n "$_OLD_VIRTUAL_PATH" 
7
-        set -gx PATH $_OLD_VIRTUAL_PATH
8
-        set -e _OLD_VIRTUAL_PATH
9
-    end
10
-    if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
-        set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
-        set -e _OLD_VIRTUAL_PYTHONHOME
13
-    end
14
-
15
-    if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
-        functions -e fish_prompt
17
-        set -e _OLD_FISH_PROMPT_OVERRIDE
18
-    end
19
-
20
-    set -e VIRTUAL_ENV
21
-    if test "$argv[1]" != "nondestructive"
22
-        # Self destruct!
23
-        functions -e deactivate
24
-    end
25
-end
26
-
27
-# unset irrelavent variables
28
-deactivate nondestructive
29
-
30
-set -gx VIRTUAL_ENV "/home/daccorsi/sources/protos/pboard/tg2env"
31
-
32
-set -gx _OLD_VIRTUAL_PATH $PATH
33
-set -gx PATH "$VIRTUAL_ENV/bin" $PATH
34
-
35
-# unset PYTHONHOME if set
36
-if set -q PYTHONHOME
37
-    set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
38
-    set -e PYTHONHOME
39
-end
40
-
41
-if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
42
-    # fish shell uses a function, instead of env vars,
43
-    # to produce the prompt. Overriding the existing function is easy.
44
-    # However, adding to the current prompt, instead of clobbering it,
45
-    # is a little more work.
46
-    set -l oldpromptfile (tempfile)
47
-    if test $status
48
-        # save the current fish_prompt function...
49
-        echo "function _old_fish_prompt" >> $oldpromptfile
50
-        echo -n \# >> $oldpromptfile
51
-        functions fish_prompt >> $oldpromptfile
52
-        # we've made the "_old_fish_prompt" file, source it.
53
-        . $oldpromptfile
54
-        rm -f $oldpromptfile
55
-        
56
-        if test -n ""
57
-            # We've been given us a prompt override.
58
-            # 
59
-            # FIXME: Unsure how to handle this *safely*. We could just eval()
60
-            #   whatever is given, but the risk is a bit much.
61
-            echo "activate.fish: Alternative prompt prefix is not supported under fish-shell." 1>&2
62
-            echo "activate.fish: Alter the fish_prompt in this file as needed." 1>&2
63
-        end        
64
-        
65
-        # with the original prompt function renamed, we can override with our own.
66
-        function fish_prompt                
67
-            set -l _checkbase (basename "$VIRTUAL_ENV")
68
-            if test $_checkbase = "__"
69
-                # special case for Aspen magic directories
70
-                # see http://www.zetadev.com/software/aspen/
71
-                printf "%s[%s]%s %s" (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) (_old_fish_prompt)
72
-            else
73
-                printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
74
-            end
75
-        end 
76
-        set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
77
-    end
78
-end
79
-

+ 0 - 34
tg2env/bin/activate_this.py View File

@@ -1,34 +0,0 @@
1
-"""By using execfile(this_file, dict(__file__=this_file)) you will
2
-activate this virtualenv environment.
3
-
4
-This can be used when you must use an existing Python interpreter, not
5
-the virtualenv bin/python
6
-"""
7
-
8
-try:
9
-    __file__
10
-except NameError:
11
-    raise AssertionError(
12
-        "You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
13
-import sys
14
-import os
15
-
16
-old_os_path = os.environ['PATH']
17
-os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
18
-base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19
-if sys.platform == 'win32':
20
-    site_packages = os.path.join(base, 'Lib', 'site-packages')
21
-else:
22
-    site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
23
-prev_sys_path = list(sys.path)
24
-import site
25
-site.addsitedir(site_packages)
26
-sys.real_prefix = sys.prefix
27
-sys.prefix = base
28
-# Move the added items to the front of the path:
29
-new_sys_path = []
30
-for item in list(sys.path):
31
-    if item not in prev_sys_path:
32
-        new_sys_path.append(item)
33
-        sys.path.remove(item)
34
-sys.path[:0] = new_sys_path

+ 0 - 10
tg2env/bin/alembic View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'alembic==0.6.0','console_scripts','alembic'
3
-__requires__ = 'alembic==0.6.0'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('alembic==0.6.0', 'console_scripts', 'alembic')()
10
-    )

+ 0 - 10
tg2env/bin/easy_install View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'distribute==0.6.24','console_scripts','easy_install'
3
-__requires__ = 'distribute==0.6.24'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('distribute==0.6.24', 'console_scripts', 'easy_install')()
10
-    )

+ 0 - 10
tg2env/bin/easy_install-2.7 View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'distribute==0.6.24','console_scripts','easy_install-2.7'
3
-__requires__ = 'distribute==0.6.24'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('distribute==0.6.24', 'console_scripts', 'easy_install-2.7')()
10
-    )

+ 0 - 10
tg2env/bin/gearbox View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'gearbox==0.0.2','console_scripts','gearbox'
3
-__requires__ = 'gearbox==0.0.2'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('gearbox==0.0.2', 'console_scripts', 'gearbox')()
10
-    )

+ 0 - 5
tg2env/bin/mako-render View File

@@ -1,5 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-SCRIPT: 'Mako==0.9.0','mako-render'
3
-__requires__ = 'Mako==0.9.0'
4
-import pkg_resources
5
-pkg_resources.run_script('Mako==0.9.0', 'mako-render')

+ 0 - 96
tg2env/bin/pilconvert.py View File

@@ -1,96 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-#
3
-# The Python Imaging Library.
4
-# $Id$
5
-#
6
-# convert image files
7
-#
8
-# History:
9
-# 0.1   96-04-20 fl     Created
10
-# 0.2   96-10-04 fl     Use draft mode when converting images
11
-# 0.3   96-12-30 fl     Optimize output (PNG, JPEG)
12
-# 0.4   97-01-18 fl     Made optimize an option (PNG, JPEG)
13
-# 0.5   98-12-30 fl     Fixed -f option (from Anthony Baxter)
14
-#
15
-
16
-import site
17
-import getopt, string, sys
18
-
19
-from PIL import Image
20
-
21
-def usage():
22
-    print "PIL Convert 0.5/1998-12-30 -- convert image files"
23
-    print "Usage: pilconvert [option] infile outfile"
24
-    print
25
-    print "Options:"
26
-    print
27
-    print "  -c <format>  convert to format (default is given by extension)"
28
-    print
29
-    print "  -g           convert to greyscale"
30
-    print "  -p           convert to palette image (using standard palette)"
31
-    print "  -r           convert to rgb"
32
-    print
33
-    print "  -o           optimize output (trade speed for size)"
34
-    print "  -q <value>   set compression quality (0-100, JPEG only)"
35
-    print
36
-    print "  -f           list supported file formats"
37
-    sys.exit(1)
38
-
39
-if len(sys.argv) == 1:
40
-    usage()
41
-
42
-try:
43
-    opt, argv = getopt.getopt(sys.argv[1:], "c:dfgopq:r")
44
-except getopt.error, v:
45
-    print v
46
-    sys.exit(1)
47
-
48
-format = None
49
-convert = None
50
-
51
-options = { }
52
-
53
-for o, a in opt:
54
-
55
-    if o == "-f":
56
-        Image.init()
57
-        id = Image.ID[:]
58
-        id.sort()
59
-        print "Supported formats (* indicates output format):"
60
-        for i in id:
61
-            if Image.SAVE.has_key(i):
62
-                print i+"*",
63
-            else:
64
-                print i,
65
-        sys.exit(1)
66
-
67
-    elif o == "-c":
68
-        format = a
69
-
70
-    if o == "-g":
71
-        convert = "L"
72
-    elif o == "-p":
73
-        convert = "P"
74
-    elif o == "-r":
75
-        convert = "RGB"
76
-
77
-    elif o == "-o":
78
-        options["optimize"] = 1
79
-    elif o == "-q":
80
-        options["quality"] = string.atoi(a)
81
-
82
-if len(argv) != 2:
83
-    usage()
84
-
85
-try:
86
-    im = Image.open(argv[0])
87
-    if convert and im.mode != convert:
88
-        im.draft(convert, im.size)
89
-        im = im.convert(convert)
90
-    if format:
91
-        apply(im.save, (argv[1], format), options)
92
-    else:
93
-        apply(im.save, (argv[1],), options)
94
-except:
95
-    print "cannot convert image",
96
-    print "(%s:%s)" % (sys.exc_type, sys.exc_value)

+ 0 - 524
tg2env/bin/pildriver.py View File

@@ -1,524 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-"""PILdriver, an image-processing calculator using PIL.
3
-
4
-An instance of class PILDriver is essentially a software stack machine
5
-(Polish-notation interpreter) for sequencing PIL image
6
-transformations.  The state of the instance is the interpreter stack.
7
-
8
-The only method one will normally invoke after initialization is the
9
-`execute' method.  This takes an argument list of tokens, pushes them
10
-onto the instance's stack, and then tries to clear the stack by
11
-successive evaluation of PILdriver operators.  Any part of the stack
12
-not cleaned off persists and is part of the evaluation context for
13
-the next call of the execute method.
14
-
15
-PILDriver doesn't catch any exceptions, on the theory that these
16
-are actually diagnostic information that should be interpreted by
17
-the calling code.
18
-
19
-When called as a script, the command-line arguments are passed to
20
-a PILDriver instance.  If there are no command-line arguments, the
21
-module runs an interactive interpreter, each line of which is split into
22
-space-separated tokens and passed to the execute method.
23
-
24
-In the method descriptions below, a first line beginning with the string
25
-`usage:' means this method can be invoked with the token that follows
26
-it.  Following <>-enclosed arguments describe how the method interprets
27
-the entries on the stack.  Each argument specification begins with a
28
-type specification: either `int', `float', `string', or `image'.
29
-
30
-All operations consume their arguments off the stack (use `dup' to
31
-keep copies around).  Use `verbose 1' to see the stack state displayed
32
-before each operation.
33
-
34
-Usage examples:
35
-
36
-    `show crop 0 0 200 300 open test.png' loads test.png, crops out a portion
37
-of its upper-left-hand corner and displays the cropped portion.
38
-
39
-    `save rotated.png rotate 30 open test.tiff' loads test.tiff, rotates it
40
-30 degrees, and saves the result as rotated.png (in PNG format).
41
-"""
42
-# by Eric S. Raymond <esr@thyrsus.com>
43
-# $Id$
44
-
45
-# TO DO:
46
-# 1. Add PILFont capabilities, once that's documented.
47
-# 2. Add PILDraw operations.
48
-# 3. Add support for composing and decomposing multiple-image files.
49
-#
50
-
51
-from PIL import Image
52
-import string
53
-
54
-class PILDriver:
55
-
56
-    verbose = 0
57
-
58
-    def do_verbose(self):
59
-        """usage: verbose <int:num>
60
-
61
-        Set verbosity flag from top of stack.
62
-        """
63
-        self.verbose = self.do_pop()
64
-
65
-    # The evaluation stack (internal only)
66
-
67
-    stack = []          # Stack of pending operations
68
-
69
-    def push(self, item):
70
-        "Push an argument onto the evaluation stack."
71
-        self.stack = [item] + self.stack
72
-
73
-    def top(self):
74
-        "Return the top-of-stack element."
75
-        return self.stack[0]
76
-
77
-    # Stack manipulation (callable)
78
-
79
-    def do_clear(self):
80
-        """usage: clear
81
-
82
-        Clear the stack.
83
-        """
84
-        self.stack = []
85
-
86
-    def do_pop(self):
87
-        """usage: pop
88
-
89
-        Discard the top element on the stack.
90
-        """
91
-        top = self.stack[0]
92
-        self.stack = self.stack[1:]
93
-        return top
94
-
95
-    def do_dup(self):
96
-        """usage: dup
97
-
98
-        Duplicate the top-of-stack item.
99
-        """
100
-        if hasattr(self, 'format'):     # If it's an image, do a real copy
101
-            dup = self.stack[0].copy()
102
-        else:
103
-            dup = self.stack[0]
104
-        self.stack = [dup] + self.stack
105
-
106
-    def do_swap(self):
107
-        """usage: swap
108
-
109
-        Swap the top-of-stack item with the next one down.
110
-        """
111
-        self.stack = [self.stack[1], self.stack[0]] + self.stack[2:]
112
-
113
-    # Image module functions (callable)
114
-
115
-    def do_new(self):
116
-        """usage: new <int:xsize> <int:ysize> <int:color>:
117
-
118
-        Create and push a greyscale image of given size and color.
119
-        """
120
-        xsize = int(self.do_pop())
121
-        ysize = int(self.do_pop())
122
-        color = int(self.do_pop())
123
-        self.push(Image.new("L", (xsize, ysize), color))
124
-
125
-    def do_open(self):
126
-        """usage: open <string:filename>
127
-
128
-        Open the indicated image, read it, push the image on the stack.
129
-        """
130
-        self.push(Image.open(self.do_pop()))
131
-
132
-    def do_blend(self):
133
-        """usage: blend <image:pic1> <image:pic2> <float:alpha>
134
-
135
-        Replace two images and an alpha with the blended image.
136
-        """
137
-        image1 = self.do_pop()
138
-        image2 = self.do_pop()
139
-        alpha = float(self.do_pop())
140
-        self.push(Image.blend(image1, image2, alpha))
141
-
142
-    def do_composite(self):
143
-        """usage: composite <image:pic1> <image:pic2> <image:mask>
144
-
145
-        Replace two images and a mask with their composite.
146
-        """
147
-        image1 = self.do_pop()
148
-        image2 = self.do_pop()
149
-        mask = self.do_pop()
150
-        self.push(Image.composite(image1, image2, mask))
151
-
152
-    def do_merge(self):
153
-        """usage: merge <string:mode> <image:pic1> [<image:pic2> [<image:pic3> [<image:pic4>]]]
154
-
155
-        Merge top-of stack images in a way described by the mode.
156
-        """
157
-        mode = self.do_pop()
158
-        bandlist = []
159
-        for band in mode:
160
-            bandlist.append(self.do_pop())
161
-        self.push(Image.merge(mode, bandlist))
162
-
163
-    # Image class methods
164
-
165
-    def do_convert(self):
166
-        """usage: convert <string:mode> <image:pic1>
167
-
168
-        Convert the top image to the given mode.
169
-        """
170
-        mode = self.do_pop()
171
-        image = self.do_pop()
172
-        self.push(image.convert(mode))
173
-
174
-    def do_copy(self):
175
-        """usage: copy <image:pic1>
176
-
177
-        Make and push a true copy of the top image.
178
-        """
179
-        self.dup()
180
-
181
-    def do_crop(self):
182
-        """usage: crop <int:left> <int:upper> <int:right> <int:lower> <image:pic1>
183
-
184
-        Crop and push a rectangular region from the current image.
185
-        """
186
-        left = int(self.do_pop())
187
-        upper = int(self.do_pop())
188
-        right = int(self.do_pop())
189
-        lower = int(self.do_pop())
190
-        image = self.do_pop()
191
-        self.push(image.crop((left, upper, right, lower)))
192
-
193
-    def do_draft(self):
194
-        """usage: draft <string:mode> <int:xsize> <int:ysize>
195
-
196
-        Configure the loader for a given mode and size.
197
-        """
198
-        mode = self.do_pop()
199
-        xsize = int(self.do_pop())
200
-        ysize = int(self.do_pop())
201
-        self.push(self.draft(mode, (xsize, ysize)))
202
-
203
-    def do_filter(self):
204
-        """usage: filter <string:filtername> <image:pic1>
205
-
206
-        Process the top image with the given filter.
207
-        """
208
-        import ImageFilter
209
-        filter = eval("ImageFilter." + string.upper(self.do_pop()))
210
-        image = self.do_pop()
211
-        self.push(image.filter(filter))
212
-
213
-    def do_getbbox(self):
214
-        """usage: getbbox
215
-
216
-        Push left, upper, right, and lower pixel coordinates of the top image.
217
-        """
218
-        bounding_box = self.do_pop().getbbox()
219
-        self.push(bounding_box[3])
220
-        self.push(bounding_box[2])
221
-        self.push(bounding_box[1])
222
-        self.push(bounding_box[0])
223
-
224
-    def do_getextrema(self):
225
-        """usage: extrema
226
-
227
-        Push minimum and maximum pixel values of the top image.
228
-        """
229
-        extrema = self.do_pop().extrema()
230
-        self.push(extrema[1])
231
-        self.push(extrema[0])
232
-
233
-    def do_offset(self):
234
-        """usage: offset <int:xoffset> <int:yoffset> <image:pic1>
235
-
236
-        Offset the pixels in the top image.
237
-        """
238
-        xoff = int(self.do_pop())
239
-        yoff = int(self.do_pop())
240
-        image = self.do_pop()
241
-        self.push(image.offset(xoff, yoff))
242
-
243
-    def do_paste(self):
244
-        """usage: paste <image:figure> <int:xoffset> <int:yoffset> <image:ground>
245
-
246
-        Paste figure image into ground with upper left at given offsets.
247
-        """
248
-        figure = self.do_pop()
249
-        xoff = int(self.do_pop())
250
-        yoff = int(self.do_pop())
251
-        ground = self.do_pop()
252
-        if figure.mode == "RGBA":
253
-            ground.paste(figure, (xoff, yoff), figure)
254
-        else:
255
-            ground.paste(figure, (xoff, yoff))
256
-        self.push(ground)
257
-
258
-    def do_resize(self):
259
-        """usage: resize <int:xsize> <int:ysize> <image:pic1>
260
-
261
-        Resize the top image.
262
-        """
263
-        ysize = int(self.do_pop())
264
-        xsize = int(self.do_pop())
265
-        image = self.do_pop()
266
-        self.push(image.resize((xsize, ysize)))
267
-
268
-    def do_rotate(self):
269
-        """usage: rotate <int:angle> <image:pic1>
270
-
271
-        Rotate image through a given angle
272
-        """
273
-        angle = int(self.do_pop())
274
-        image = self.do_pop()
275
-        self.push(image.rotate(angle))
276
-
277
-    def do_save(self):
278
-        """usage: save <string:filename> <image:pic1>
279
-
280
-        Save image with default options.
281
-        """
282
-        filename = self.do_pop()
283
-        image = self.do_pop()
284
-        image.save(filename)
285
-
286
-    def do_save2(self):
287
-        """usage: save2 <string:filename> <string:options> <image:pic1>
288
-
289
-        Save image with specified options.
290
-        """
291
-        filename = self.do_pop()
292
-        options = self.do_pop()
293
-        image = self.do_pop()
294
-        image.save(filename, None, options)
295
-
296
-    def do_show(self):
297
-        """usage: show <image:pic1>
298
-
299
-        Display and pop the top image.
300
-        """
301
-        self.do_pop().show()
302
-
303
-    def do_thumbnail(self):
304
-        """usage: thumbnail <int:xsize> <int:ysize> <image:pic1>
305
-
306
-        Modify the top image in the stack to contain a thumbnail of itself.
307
-        """
308
-        ysize = int(self.do_pop())
309
-        xsize = int(self.do_pop())
310
-        self.top().thumbnail((xsize, ysize))
311
-
312
-    def do_transpose(self):
313
-        """usage: transpose <string:operator> <image:pic1>
314
-
315
-        Transpose the top image.
316
-        """
317
-        transpose = string.upper(self.do_pop())
318
-        image = self.do_pop()
319
-        self.push(image.transpose(transpose))
320
-
321
-    # Image attributes
322
-
323
-    def do_format(self):
324
-        """usage: format <image:pic1>
325
-
326
-        Push the format of the top image onto the stack.
327
-        """
328
-        self.push(self.pop().format)
329
-
330
-    def do_mode(self):
331
-        """usage: mode <image:pic1>
332
-
333
-        Push the mode of the top image onto the stack.
334
-        """
335
-        self.push(self.pop().mode)
336
-
337
-    def do_size(self):
338
-        """usage: size <image:pic1>
339
-
340
-        Push the image size on the stack as (y, x).
341
-        """
342
-        size = self.pop().size
343
-        self.push(size[0])
344
-        self.push(size[1])
345
-
346
-    # ImageChops operations
347
-
348
-    def do_invert(self):
349
-        """usage: invert <image:pic1>
350
-
351
-        Invert the top image.
352
-        """
353
-        import ImageChops
354
-        self.push(ImageChops.invert(self.do_pop()))
355
-
356
-    def do_lighter(self):
357
-        """usage: lighter <image:pic1> <image:pic2>
358
-
359
-        Pop the two top images, push an image of the lighter pixels of both.
360
-        """
361
-        import ImageChops
362
-        image1 = self.do_pop()
363
-        image2 = self.do_pop()
364
-        self.push(ImageChops.lighter(image1, image2))
365
-
366
-    def do_darker(self):
367
-        """usage: darker <image:pic1> <image:pic2>
368
-
369
-        Pop the two top images, push an image of the darker pixels of both.
370
-        """
371
-        import ImageChops
372
-        image1 = self.do_pop()
373
-        image2 = self.do_pop()
374
-        self.push(ImageChops.darker(image1, image2))
375
-
376
-    def do_difference(self):
377
-        """usage: difference <image:pic1> <image:pic2>
378
-
379
-        Pop the two top images, push the difference image
380
-        """
381
-        import ImageChops
382
-        image1 = self.do_pop()
383
-        image2 = self.do_pop()
384
-        self.push(ImageChops.difference(image1, image2))
385
-
386
-    def do_multiply(self):
387
-        """usage: multiply <image:pic1> <image:pic2>
388
-
389
-        Pop the two top images, push the multiplication image.
390
-        """
391
-        import ImageChops
392
-        image1 = self.do_pop()
393
-        image2 = self.do_pop()
394
-        self.push(ImageChops.multiply(image1, image2))
395
-
396
-    def do_screen(self):
397
-        """usage: screen <image:pic1> <image:pic2>
398
-
399
-        Pop the two top images, superimpose their inverted versions.
400
-        """
401
-        import ImageChops
402
-        image2 = self.do_pop()
403
-        image1 = self.do_pop()
404
-        self.push(ImageChops.screen(image1, image2))
405
-
406
-    def do_add(self):
407
-        """usage: add <image:pic1> <image:pic2> <int:offset> <float:scale>
408
-
409
-        Pop the two top images, produce the scaled sum with offset.
410
-        """
411
-        import ImageChops
412
-        image1 = self.do_pop()
413
-        image2 = self.do_pop()
414
-        scale = float(self.do_pop())
415
-        offset = int(self.do_pop())
416
-        self.push(ImageChops.add(image1, image2, scale, offset))
417
-
418
-    def do_subtract(self):
419
-        """usage: subtract <image:pic1> <image:pic2> <int:offset> <float:scale>
420
-
421
-        Pop the two top images, produce the scaled difference with offset.
422
-        """
423
-        import ImageChops
424
-        image1 = self.do_pop()
425
-        image2 = self.do_pop()
426
-        scale = float(self.do_pop())
427
-        offset = int(self.do_pop())
428
-        self.push(ImageChops.subtract(image1, image2, scale, offset))
429
-
430
-    # ImageEnhance classes
431
-
432
-    def do_color(self):
433
-        """usage: color <image:pic1>
434
-
435
-        Enhance color in the top image.
436
-        """
437
-        import ImageEnhance
438
-        factor = float(self.do_pop())
439
-        image = self.do_pop()
440
-        enhancer = ImageEnhance.Color(image)
441
-        self.push(enhancer.enhance(factor))
442
-
443
-    def do_contrast(self):
444
-        """usage: contrast <image:pic1>
445
-
446
-        Enhance contrast in the top image.
447
-        """
448
-        import ImageEnhance
449
-        factor = float(self.do_pop())
450
-        image = self.do_pop()
451
-        enhancer = ImageEnhance.Color(image)
452
-        self.push(enhancer.enhance(factor))
453
-
454
-    def do_brightness(self):
455
-        """usage: brightness <image:pic1>
456
-
457
-        Enhance brightness in the top image.
458
-        """
459
-        import ImageEnhance
460
-        factor = float(self.do_pop())
461
-        image = self.do_pop()
462
-        enhancer = ImageEnhance.Color(image)
463
-        self.push(enhancer.enhance(factor))
464
-
465
-    def do_sharpness(self):
466
-        """usage: sharpness <image:pic1>
467
-
468
-        Enhance sharpness in the top image.
469
-        """
470
-        import ImageEnhance
471
-        factor = float(self.do_pop())
472
-        image = self.do_pop()
473
-        enhancer = ImageEnhance.Color(image)
474
-        self.push(enhancer.enhance(factor))
475
-
476
-    # The interpreter loop
477
-
478
-    def execute(self, list):
479
-        "Interpret a list of PILDriver commands."
480
-        list.reverse()
481
-        while len(list) > 0:
482
-            self.push(list[0])
483
-            list = list[1:]
484
-            if self.verbose:
485
-                print "Stack: " + `self.stack`
486
-            top = self.top()
487
-            if type(top) != type(""):
488
-                continue;
489
-            funcname = "do_" + top
490
-            if not hasattr(self, funcname):
491
-                continue
492
-            else:
493
-                self.do_pop()
494
-                func = getattr(self, funcname)
495
-                func()
496
-
497
-if __name__ == '__main__':
498
-    import sys
499
-    try:
500
-        import readline
501
-    except ImportError:
502
-        pass # not available on all platforms
503
-
504
-    # If we see command-line arguments, interpret them as a stack state
505
-    # and execute.  Otherwise go interactive.
506
-
507
-    driver = PILDriver()
508
-    if len(sys.argv[1:]) > 0:
509
-        driver.execute(sys.argv[1:])
510
-    else:
511
-        print "PILDriver says hello."
512
-        while 1:
513
-            try:
514
-                line = raw_input('pildriver> ');
515
-            except EOFError:
516
-                print "\nPILDriver says goodbye."
517
-                break
518
-            driver.execute(string.split(line))
519
-            print driver.stack
520
-
521
-# The following sets edit modes for GNU EMACS
522
-# Local Variables:
523
-# mode:python
524
-# End:

+ 0 - 94
tg2env/bin/pilfile.py View File

@@ -1,94 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-#
3
-# The Python Imaging Library.
4
-# $Id$
5
-#
6
-# a utility to identify image files
7
-#
8
-# this script identifies image files, extracting size and
9
-# pixel mode information for known file formats.  Note that
10
-# you don't need the PIL C extension to use this module.
11
-#
12
-# History:
13
-# 0.0 1995-09-01 fl   Created
14
-# 0.1 1996-05-18 fl   Modified options, added debugging mode
15
-# 0.2 1996-12-29 fl   Added verify mode
16
-# 0.3 1999-06-05 fl   Don't mess up on class exceptions (1.5.2 and later)
17
-# 0.4 2003-09-30 fl   Expand wildcards on Windows; robustness tweaks
18
-#
19
-
20
-import site
21
-import getopt, glob, sys
22
-
23
-from PIL import Image
24
-
25
-if len(sys.argv) == 1:
26
-    print "PIL File 0.4/2003-09-30 -- identify image files"
27
-    print "Usage: pilfile [option] files..."
28
-    print "Options:"
29
-    print "  -f  list supported file formats"
30
-    print "  -i  show associated info and tile data"
31
-    print "  -v  verify file headers"
32
-    print "  -q  quiet, don't warn for unidentified/missing/broken files"
33
-    sys.exit(1)
34
-
35
-try:
36
-    opt, args = getopt.getopt(sys.argv[1:], "fqivD")
37
-except getopt.error, v:
38
-    print v
39
-    sys.exit(1)
40
-
41
-verbose = quiet = verify = 0
42
-
43
-for o, a in opt:
44
-    if o == "-f":
45
-        Image.init()
46
-        id = Image.ID[:]
47
-        id.sort()
48
-        print "Supported formats:"
49
-        for i in id:
50
-            print i,
51
-        sys.exit(1)
52
-    elif o == "-i":
53
-        verbose = 1
54
-    elif o == "-q":
55
-        quiet = 1
56
-    elif o == "-v":
57
-        verify = 1
58
-    elif o == "-D":
59
-        Image.DEBUG = Image.DEBUG + 1
60
-
61
-def globfix(files):
62
-    # expand wildcards where necessary
63
-    if sys.platform == "win32":
64
-        out = []
65
-        for file in files:
66
-            if glob.has_magic(file):
67
-                out.extend(glob.glob(file))
68
-            else:
69
-                out.append(file)
70
-        return out
71
-    return files
72
-
73
-for file in globfix(args):
74
-    try:
75
-        im = Image.open(file)
76
-        print "%s:" % file, im.format, "%dx%d" % im.size, im.mode,
77
-        if verbose:
78
-            print im.info, im.tile,
79
-        print
80
-        if verify:
81
-            try:
82
-                im.verify()
83
-            except:
84
-                if not quiet:
85
-                    print "failed to verify image",
86
-                    print "(%s:%s)" % (sys.exc_type, sys.exc_value)
87
-    except IOError, v:
88
-        if not quiet:
89
-            print file, "failed:", v
90
-    except:
91
-        import traceback
92
-        if not quiet:
93
-            print file, "failed:", "unexpected error"
94
-            traceback.print_exc(file=sys.stdout)

+ 0 - 54
tg2env/bin/pilfont.py View File

@@ -1,54 +0,0 @@
1
-#
2
-# The Python Imaging Library
3
-# $Id$
4
-#
5
-# PIL raster font compiler
6
-#
7
-# history:
8
-# 1997-08-25 fl   created
9
-# 2002-03-10 fl   use "from PIL import"
10
-#
11
-
12
-VERSION = "0.4"
13
-
14
-import site
15
-import glob, os, sys
16
-
17
-# drivers
18
-from PIL import BdfFontFile
19
-from PIL import PcfFontFile
20
-
21
-if len(sys.argv) <= 1:
22
-    print "PILFONT", VERSION, "-- PIL font compiler."
23
-    print
24
-    print "Usage: pilfont fontfiles..."
25
-    print
26
-    print "Convert given font files to the PIL raster font format."
27
-    print "This version of pilfont supports X BDF and PCF fonts."
28
-    sys.exit(1)
29
-
30
-files = []
31
-for f in sys.argv[1:]:
32
-    files = files + glob.glob(f)
33
-
34
-for f in files:
35
-
36
-    print f + "...",
37
-
38
-    try:
39
-
40
-        fp = open(f, "rb")
41
-
42
-        try:
43
-            p = PcfFontFile.PcfFontFile(fp)
44
-        except SyntaxError:
45
-            fp.seek(0)
46
-            p = BdfFontFile.BdfFontFile(fp)
47
-
48
-        p.save(f)
49
-
50
-    except (SyntaxError, IOError):
51
-        print "failed"
52
-
53
-    else:
54
-        print "OK"

+ 0 - 93
tg2env/bin/pilprint.py View File

@@ -1,93 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-#
3
-# The Python Imaging Library.
4
-# $Id$
5
-#
6
-# print image files to postscript printer
7
-#
8
-# History:
9
-# 0.1   1996-04-20 fl   Created
10
-# 0.2   1996-10-04 fl   Use draft mode when converting.
11
-# 0.3   2003-05-06 fl   Fixed a typo or two.
12
-#
13
-
14
-VERSION = "pilprint 0.3/2003-05-05"
15
-
16
-from PIL import Image
17
-from PIL import PSDraw
18
-
19
-letter = ( 1.0*72, 1.0*72, 7.5*72, 10.0*72 )
20
-
21
-def description(file, image):
22
-    import os
23
-    title = os.path.splitext(os.path.split(file)[1])[0]
24
-    format = " (%dx%d "
25
-    if image.format:
26
-        format = " (" + image.format + " %dx%d "
27
-    return title + format % image.size + image.mode + ")"
28
-
29
-import getopt, os, sys
30
-
31
-if len(sys.argv) == 1:
32
-    print "PIL Print 0.2a1/96-10-04 -- print image files"
33
-    print "Usage: pilprint files..."
34
-    print "Options:"
35
-    print "  -c            colour printer (default is monochrome)"
36
-    print "  -p            print via lpr (default is stdout)"
37
-    print "  -P <printer>  same as -p but use given printer"
38
-    sys.exit(1)
39
-
40
-try:
41
-    opt, argv = getopt.getopt(sys.argv[1:], "cdpP:")
42
-except getopt.error, v:
43
-    print v
44
-    sys.exit(1)
45
-
46
-printer = None # print to stdout
47
-monochrome = 1 # reduce file size for most common case
48
-
49
-for o, a in opt:
50
-    if o == "-d":
51
-        # debug: show available drivers
52
-        Image.init()
53
-        print Image.ID
54
-        sys.exit(1)
55
-    elif o == "-c":
56
-        # colour printer
57
-        monochrome = 0
58
-    elif o == "-p":
59
-        # default printer channel
60
-        printer = "lpr"
61
-    elif o == "-P":
62
-        # printer channel
63
-        printer = "lpr -P%s" % a
64
-
65
-for file in argv:
66
-    try:
67
-
68
-        im = Image.open(file)
69
-
70
-        title = description(file, im)
71
-
72
-        if monochrome and im.mode not in ["1", "L"]:
73
-            im.draft("L", im.size)
74
-            im = im.convert("L")
75
-
76
-        if printer:
77
-            fp = os.popen(printer, "w")
78
-        else:
79
-            fp = sys.stdout
80
-
81
-        ps = PSDraw.PSDraw(fp)
82
-
83
-        ps.begin_document()
84
-        ps.setfont("Helvetica-Narrow-Bold", 18)
85
-        ps.text((letter[0], letter[3]+24), title)
86
-        ps.setfont("Helvetica-Narrow-Bold", 8)
87
-        ps.text((letter[0], letter[1]-30), VERSION)
88
-        ps.image(letter, im)
89
-        ps.end_document()
90
-
91
-    except:
92
-        print "cannot print image",
93
-        print "(%s:%s)" % (sys.exc_type, sys.exc_value)

+ 0 - 10
tg2env/bin/pip View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.1','console_scripts','pip'
3
-__requires__ = 'pip==1.1'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('pip==1.1', 'console_scripts', 'pip')()
10
-    )

+ 0 - 10
tg2env/bin/pip-2.7 View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.1','console_scripts','pip-2.7'
3
-__requires__ = 'pip==1.1'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('pip==1.1', 'console_scripts', 'pip-2.7')()
10
-    )

+ 0 - 10
tg2env/bin/pybabel View File

@@ -1,10 +0,0 @@
1
-#!/home/daccorsi/sources/protos/pboard/tg2env/bin/python
2
-# EASY-INSTALL-ENTRY-SCRIPT: 'Babel==1.3','console_scripts','pybabel'
3
-__requires__ = 'Babel==1.3'
4
-import sys
5
-from pkg_resources import load_entry_point
6
-
7
-if __name__ == '__main__':
8
-    sys.exit(
9
-        load_entry_point('Babel==1.3', 'console_scripts', 'pybabel')()
10
-    )

BIN
tg2env/bin/python View File