Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/turtleart.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-07-29 20:13:16 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-07-29 20:13:16 (GMT)
commitbee1f6f2c0813756e50cce2ce1778bd298df6e72 (patch)
tree0aca4f6f092fd0611268128d2281cba279b446da /turtleart.py
parenta1cd4a81c243aba28ff54806b6761261b339bbe9 (diff)
cleaned up cmdline code
Diffstat (limited to 'turtleart.py')
-rwxr-xr-xturtleart.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/turtleart.py b/turtleart.py
index 13c4018..814a1ca 100755
--- a/turtleart.py
+++ b/turtleart.py
@@ -23,11 +23,15 @@
import pygtk
pygtk.require('2.0')
import gtk
+
import getopt
import sys
import os
import os.path
+argv = sys.argv[:] # Workaround for import behavior of gst in tagplay
+sys.argv[1:] = [] # Execution of import gst cannot see '--help' or '-h'
+
from gettext import gettext as _
from taconstants import OVERLAY_LAYER
@@ -36,8 +40,11 @@ from tawindow import TurtleArtWindow
from taexporthtml import save_html
from taexportlogo import save_logo
-HELP_MSG = "turtleart.py: " + _("usage is") +\
- "\n\tturtleart.py --taproject project.ta --output_png"
+HELP_MSG = 'turtleart.py: ' + _('usage is') + """
+ \tturtleart.py
+ \tturtleart.py project.ta
+ \tturtleart.py --output_png project.ta
+ \tturtleart.py -o project"""
def _make_sub_menu(menu, name):
@@ -80,35 +87,32 @@ class TurtleMain():
# Parse command line
try:
- opts, args = getopt.getopt(sys.argv[1:], "hot:v", ["taproject",
- "help", "output_png"])
+ opts, args = getopt.getopt(argv[1:], 'ho',
+ ['help', 'output_png'])
except getopt.GetoptError, err:
print str(err)
print HELP_MSG
sys.exit(2)
for o, a in opts:
- if o in ['-o', '--output_png']:
- self.output_png = True
- self.ta_file = args[0]
- elif o in ['-h', '--help']:
+ if o in ('-h', '--help'):
print HELP_MSG
sys.exit()
- elif o in ['-t']:
- self.ta_file = a
- elif o in ['--taproject']:
- self.ta_file = args[0]
+ if o in ('-o', '--output_png'):
+ self.output_png = True
else:
- assert False, 'unhandled option'
+ assert False, 'No option action for ' + o
+ if args:
+ self.ta_file = args[0]
- if self.output_png and self.ta_file is None:
+ if len(args) > 1 or self.output_png and self.ta_file is None:
print HELP_MSG
sys.exit()
if self.ta_file is not None:
- if not self.ta_file.endswith(['.ta']):
+ if not self.ta_file.endswith(('.ta')):
self.ta_file += '.ta'
if not os.path.exists(self.ta_file):
- assert False, "%s: %s" % (self.ta_file, _("file not found"))
+ assert False, ('%s: %s' % (self.ta_file, _('file not found')))
self.i = 0
self.scale = 2.0