bzr branch
http://bzr.ed.am/gtk/prep-images
1
by edam
- initial commit, includes project and build setup |
1 |
#!/usr/bin/env python |
2 |
||
3
by edam
- renamed project from add-copyright-to-images to prep-images |
3 |
# prep-images |
1
by edam
- initial commit, includes project and build setup |
4 |
# |
5 |
# Copyright (C) 2011 Tim Marston <edam@waxworlds.org> |
|
6 |
# |
|
3
by edam
- renamed project from add-copyright-to-images to prep-images |
7 |
# This file is part of prep-images (hereafter referred to as "this program"). |
8 |
# See http://www.waxworlds.org/edam/software/gtk/prep-images for more |
|
1
by edam
- initial commit, includes project and build setup |
9 |
# information. |
10 |
# |
|
11 |
# This program is free software: you can redistribute it and/or modify |
|
3
by edam
- renamed project from add-copyright-to-images to prep-images |
12 |
# it under the terms of the GNU General Public License as published by |
13 |
# the Free Software Foundation, either version 3 of the License, or |
|
1
by edam
- initial commit, includes project and build setup |
14 |
# (at your option) any later version. |
15 |
# |
|
16 |
# This program is distributed in the hope that it will be useful, |
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
3
by edam
- renamed project from add-copyright-to-images to prep-images |
19 |
# GNU General Public License for more details. |
1
by edam
- initial commit, includes project and build setup |
20 |
# |
3
by edam
- renamed project from add-copyright-to-images to prep-images |
21 |
# You should have received a copy of the GNU General Public License |
1
by edam
- initial commit, includes project and build setup |
22 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 |
||
24 |
||
4
by edam
- removed '.0' from the end of the version no. |
25 |
# @PACKAGE_NAME@ version @PACKAGE_VERSION@ |
1
by edam
- initial commit, includes project and build setup |
26 |
|
10
by Tim Marston
added command line support |
27 |
import sys, os |
1
by edam
- initial commit, includes project and build setup |
28 |
from os.path import join, abspath, exists |
10
by Tim Marston
added command line support |
29 |
import getopt |
30 |
||
1
by edam
- initial commit, includes project and build setup |
31 |
|
32 |
# check for a development source directory and use that if it's there |
|
3
by edam
- renamed project from add-copyright-to-images to prep-images |
33 |
PACKAGE_DIR = join( abspath( sys.path[ 0 ] ), "..", "lib" ) |
34 |
if exists( join( PACKAGE_DIR, "prep_images", "prefs_dialog.py" ) ): |
|
10
by Tim Marston
added command line support |
35 |
print >> sys.stderr, "!!! using development packages !!!" |
3
by edam
- renamed project from add-copyright-to-images to prep-images |
36 |
sys.path.insert( 0, PACKAGE_DIR ) |
1
by edam
- initial commit, includes project and build setup |
37 |
else: |
3
by edam
- renamed project from add-copyright-to-images to prep-images |
38 |
del PACKAGE_DIR |
1
by edam
- initial commit, includes project and build setup |
39 |
|
10
by Tim Marston
added command line support |
40 |
|
41 |
def usage( error = True ): |
|
42 |
print >> sys.stderr, 'Try "@PACKAGE_NAME@ --help" for help' |
|
43 |
exit( 1 ) |
|
44 |
||
45 |
||
46 |
def help(): |
|
47 |
print "Usage: @PACKAGE_NAME@ [OPTION]... FILE..." |
|
48 |
||
49 |
print "Prepare the specified image FILEs for publishing." |
|
50 |
||
51 |
print "Options:" |
|
52 |
print " --help display this help and exit" |
|
53 |
print " --version output version information and exit" |
|
54 |
exit( 0 ) |
|
55 |
||
56 |
||
57 |
def version(): |
|
58 |
print "@PACKAGE_NAME@ @PACKAGE_VERSION@" |
|
59 |
||
60 |
print "Copyright (C) 2011 to 2013 Tim Marston" |
|
61 |
print "License GPLv3+: GNU GPL version 3 or later " + \ |
|
62 |
"<http://gnu.org/licenses/gpl.html>" |
|
63 |
print "This is free software: you are free to change and " + \ |
|
64 |
"redistribute it." |
|
65 |
||
66 |
print "For more information, including documentation, see the " +\ |
|
67 |
"project website, at" |
|
68 |
print "<@PACKAGE_URL@>. Please report bugs to <@PACKAGE_BUGREPORT@>." |
|
69 |
exit( 0 ) |
|
70 |
||
71 |
||
72 |
# handle command line |
|
73 |
try: |
|
74 |
opts, args = getopt.gnu_getopt( |
|
75 |
sys.argv[ 1: ], "", |
|
76 |
[ "help", "version" ] ) |
|
77 |
except getopt.GetoptError as e: |
|
78 |
print str( e ) |
|
79 |
usage() |
|
80 |
||
81 |
# process options |
|
82 |
for opt, args in opts: |
|
83 |
if opt == "--help": |
|
84 |
help() |
|
85 |
elif opt == "--version": |
|
86 |
version() |
|
87 |
else: |
|
88 |
print >> sys.stderr, "unknown option" |
|
89 |
usage() |
|
90 |
||
91 |
# check for files |
|
92 |
if len( args ) == 0: |
|
93 |
print >> sys.stderr, "no files specified" |
|
94 |
usage() |
|
95 |
||
96 |
# try to detect no DISPLAY |
|
97 |
if os.getenv( 'DISPLAY', '' ) == '': |
|
98 |
print >> sys.stderr, 'could not open display' |
|
99 |
exit( 1 ) |
|
100 |
||
101 |
# we only now import the main window stuff, because it pulls in PyGTK which |
|
102 |
# complains if it can't connect to a display |
|
3
by edam
- renamed project from add-copyright-to-images to prep-images |
103 |
from prep_images.main_window import * |
1
by edam
- initial commit, includes project and build setup |
104 |
|
105 |
# process each image in turn |
|
10
by Tim Marston
added command line support |
106 |
for filename in args: |
3
by edam
- renamed project from add-copyright-to-images to prep-images |
107 |
MainWindow( filename ).main() |