/home/epimerde/documents/tc11/CanFestival-3/objdictgen/objdictgen.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 #This file is part of CanFestival, a library implementing CanOpen Stack. 
00005 #
00006 #Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
00007 #
00008 #See COPYING file for copyrights details.
00009 #
00010 #This library is free software; you can redistribute it and/or
00011 #modify it under the terms of the GNU Lesser General Public
00012 #License as published by the Free Software Foundation; either
00013 #version 2.1 of the License, or (at your option) any later version.
00014 #
00015 #This library is distributed in the hope that it will be useful,
00016 #but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 #Lesser General Public License for more details.
00019 #
00020 #You should have received a copy of the GNU Lesser General Public
00021 #License along with this library; if not, write to the Free Software
00022 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 
00024 import getopt,sys,os
00025 from types import *
00026 
00027 from nodemanager import *
00028 
00029 def usage():
00030     print "\nUsage of objdictgen.py :"
00031     print "\n   %s XMLFilePath CFilePath\n"%sys.argv[0]
00032 
00033 try:
00034     opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
00035 except getopt.GetoptError:
00036     # print help information and exit:
00037     usage()
00038     sys.exit(2)
00039 
00040 for o, a in opts:
00041     if o in ("-h", "--help"):
00042         usage()
00043         sys.exit()
00044 
00045 fileIn = ""
00046 fileOut = ""        
00047 if len(args) == 2:
00048     fileIn = args[0]
00049     fileOut = args[1]
00050 else:
00051     usage()
00052     sys.exit()
00053 
00054 if __name__ == '__main__':
00055     if fileIn != "" and fileOut != "":
00056         manager = NodeManager(sys.path[0])
00057         if os.path.isfile(fileIn):
00058             print "Parsing input file"
00059             result = manager.OpenFileInCurrent(fileIn)
00060             if type(result) != UnicodeType:
00061                 Node = result
00062             else:
00063                 print result
00064                 sys.exit(-1)
00065         else:
00066             print "%s is not a valid file!"%fileIn
00067             sys.exit(-1)
00068         print "Writing output file"
00069         result = manager.ExportCurrentToCFile(fileOut)
00070         if type(result) == UnicodeType:
00071             print result
00072             sys.exit(-1)
00073         print "All done"
00074     

Generated on Mon Jun 4 16:29:06 2007 for CanFestival by  doxygen 1.5.1