author | Mongo |
Wed, 01 Feb 2012 15:55:45 +0100 | |
changeset 711 | 4b64e17396af |
parent 580 | 2ae92a99ac10 |
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 |
||
580 | 29 |
_ = lambda x: x |
30 |
||
0 | 31 |
def usage(): |
580 | 32 |
print _("\nUsage of objdictgen.py :") |
0 | 33 |
print "\n %s XMLFilePath CFilePath\n"%sys.argv[0] |
34 |
||
35 |
try: |
|
36 |
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
37 |
except getopt.GetoptError: |
|
38 |
# print help information and exit: |
|
39 |
usage() |
|
40 |
sys.exit(2) |
|
41 |
||
42 |
for o, a in opts: |
|
43 |
if o in ("-h", "--help"): |
|
44 |
usage() |
|
45 |
sys.exit() |
|
46 |
||
47 |
fileIn = "" |
|
48 |
fileOut = "" |
|
49 |
if len(args) == 2: |
|
50 |
fileIn = args[0] |
|
51 |
fileOut = args[1] |
|
52 |
else: |
|
53 |
usage() |
|
54 |
sys.exit() |
|
55 |
||
56 |
if __name__ == '__main__': |
|
57 |
if fileIn != "" and fileOut != "": |
|
283
e0b3096230e5
Fixed typo in objdictgen.py preventing generation of examples' ODs
baf
parents:
199
diff
changeset
|
58 |
manager = NodeManager() |
0 | 59 |
if os.path.isfile(fileIn): |
580 | 60 |
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
|
61 |
result = manager.OpenFileInCurrent(fileIn) |
512 | 62 |
if not isinstance(result, (StringType, UnicodeType)): |
0 | 63 |
Node = result |
64 |
else: |
|
65 |
print result |
|
66 |
sys.exit(-1) |
|
67 |
else: |
|
580 | 68 |
print _("%s is not a valid file!")%fileIn |
0 | 69 |
sys.exit(-1) |
580 | 70 |
print _("Writing output file") |
199 | 71 |
result = manager.ExportCurrentToCFile(fileOut) |
512 | 72 |
if isinstance(result, (UnicodeType, StringType)): |
0 | 73 |
print result |
74 |
sys.exit(-1) |
|
580 | 75 |
print _("All done") |
0 | 76 |