author | etisserant |
Tue, 05 Feb 2008 10:18:25 +0100 | |
changeset 383 | 7d8afedb8769 |
parent 283 | e0b3096230e5 |
child 512 | e84806c0ada4 |
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 != "": |
|
283
e0b3096230e5
Fixed typo in objdictgen.py preventing generation of examples' ODs
baf
parents:
199
diff
changeset
|
56 |
manager = NodeManager() |
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" |
|
199 | 69 |
result = manager.ExportCurrentToCFile(fileOut) |
0 | 70 |
if type(result) == UnicodeType: |
71 |
print result |
|
72 |
sys.exit(-1) |
|
73 |
print "All done" |
|
74 |