1#!/usr/bin/env python 2 3# 4# The contents of this file are subject to the Mozilla Public 5# License Version 1.1 (the "License"); you may not use this file 6# except in compliance with the License. You may obtain a copy of 7# the License at http://www.mozilla.org/MPL/ 8# 9# Software distributed under the License is distributed on an "AS 10# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 11# implied. See the License for the specific language governing 12# rights and limitations under the License. 13# 14# The Original Code is State Machine Compiler (SMC). 15# 16# The Initial Developer of the Original Code is Charles W. Rapp. 17# Portions created by Charles W. Rapp are 18# Copyright (C) 2000 - 2005 Charles W. Rapp. 19# All Rights Reserved. 20# 21# Contributor(s): 22# Port to Python by Francois Perrad, francois.perrad@gadz.org 23# 24# Function 25# Main 26# 27# Description 28# This routine starts the finite state machine running. 29# 30# RCS ID 31# $Id: checkstring.py,v 1.2 2005/06/03 19:58:28 cwrapp Exp $ 32# 33# CHANGE LOG 34# $Log: checkstring.py,v $ 35# Revision 1.2 2005/06/03 19:58:28 cwrapp 36# Further updates for release 4.0.0 37# 38# Revision 1.1 2005/05/28 17:48:29 cwrapp 39# Added Python examples 1 - 4 and 7. 40# 41# 42 43import sys 44 45import AppClass 46 47retcode = 0 48if len(sys.argv) < 2: 49 print "No string to check.\n" 50 retcode = 2 51elif len(sys.argv) > 2: 52 print "Only one argument is accepted.\n" 53 retcode = 3 54else: 55 appobject = AppClass.AppClass() 56 str = sys.argv[1] 57 if appobject.CheckString(str) == False: 58 result = "not acceptable" 59 retcode = 1 60 else: 61 result = "acceptable" 62 print 'The string "%s" is %s.\n' % (str, result) 63sys.exit(retcode) 64