nico@207: nico@207: nico@207: CanFestival: /home/epimerde/documents/tc11/CanFestival-3/objdictgen/objdictgen.py Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@207:

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

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

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