author | etisserant |
Sun, 13 May 2007 10:29:08 +0200 | |
changeset 195 | 1510dd61ead0 |
parent 184 | fb253029c7d4 |
child 199 | 48b59c852636 |
permissions | -rw-r--r-- |
0 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of CanFestival, a library implementing CanOpen Stack. |
|
5 |
# |
|
6 |
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD |
|
7 |
# |
|
8 |
#See COPYING file for copyrights details. |
|
9 |
# |
|
10 |
#This library is free software; you can redistribute it and/or |
|
11 |
#modify it under the terms of the GNU Lesser General Public |
|
12 |
#License as published by the Free Software Foundation; either |
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
|
14 |
# |
|
15 |
#This library is distributed in the hope that it will be useful, |
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
#Lesser General Public License for more details. |
|
19 |
# |
|
20 |
#You should have received a copy of the GNU Lesser General Public |
|
21 |
#License along with this library; if not, write to the Free Software |
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
||
24 |
import getopt,sys,os |
|
25 |
from types import * |
|
26 |
||
27 |
from nodemanager import * |
|
28 |
||
29 |
def usage(): |
|
30 |
print "\nUsage of objdictgen.py :" |
|
31 |
print "\n %s XMLFilePath CFilePath\n"%sys.argv[0] |
|
32 |
||
33 |
try: |
|
34 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
35 |
except getopt.GetoptError: |
|
36 |
# print help information and exit: |
|
37 |
usage() |
|
38 |
sys.exit(2) |
|
39 |
||
40 |
for o, a in opts: |
|
41 |
if o in ("-h", "--help"): |
|
42 |
usage() |
|
43 |
sys.exit() |
|
44 |
||
45 |
fileIn = "" |
|
46 |
fileOut = "" |
|
47 |
if len(args) == 2: |
|
48 |
fileIn = args[0] |
|
49 |
fileOut = args[1] |
|
50 |
else: |
|
51 |
usage() |
|
52 |
sys.exit() |
|
53 |
||
54 |
if __name__ == '__main__': |
|
55 |
if fileIn != "" and fileOut != "": |
|
184 | 56 |
manager = NodeManager(sys.path[0]) |
0 | 57 |
if os.path.isfile(fileIn): |
58 |
print "Parsing input file" |
|
93
16c8ceea8f18
Removed all non-supported and uncontrolled source code. Please refer to CVS version "Before_..." to see old code.
etisserant
parents:
0
diff
changeset
|
59 |
result = manager.OpenFileInCurrent(fileIn) |
0 | 60 |
if type(result) != UnicodeType: |
61 |
Node = result |
|
62 |
else: |
|
63 |
print result |
|
64 |
sys.exit(-1) |
|
65 |
else: |
|
66 |
print "%s is not a valid file!"%fileIn |
|
67 |
sys.exit(-1) |
|
68 |
print "Writing output file" |
|
69 |
result = manager.ExportCurrentToFile(fileOut) |
|
70 |
if type(result) == UnicodeType: |
|
71 |
print result |
|
72 |
sys.exit(-1) |
|
73 |
print "All done" |
|
74 |