1 #python xml library import
2 from xml.etree.ElementTree import parse
7 curpath = os.path.dirname( os.path.abspath( __file__ ) )
8 msgpath = os.path.join( curpath, "../error_messages/" )
9 headerpath = os.path.join( curpath, "tizen_error_private.h" )
11 shutil.copy( os.path.join( curpath, "tizen_error_private_template.h" ), headerpath )
12 fp = open( headerpath, 'a' )
14 fp.write( "\n#ifndef __TIZEN_COMMON_ERROR_PRIVATE_H__\n" )
15 fp.write( "#define __TIZEN_COMMON_ERROR_PRIVATE_H__\n\n" )
17 fp.write( "#ifdef __cplusplus\n" )
18 fp.write( "extern \"C\" {\n" )
19 fp.write( "#endif\n\n" )
21 fp.write( "#define ERR_ENTRY(name, value, msg) {value, name, msg}\n\n" )
22 fp.write( "typedef struct tizen_err_info {\n" )
23 fp.write( "\tint value;\n" )
24 fp.write( "\tconst char *name;\n" )
25 fp.write( "\tconst char *msg;\n" )
26 fp.write( "} err_info;\n\n" )
28 fp.write( "static err_info err_list[] = {\n" );
29 for root, dirs, files in os.walk( msgpath ):
32 targetXML = open( os.path.join( msgpath, file ) )
33 tree = parse( targetXML )
34 errorroot = tree.getroot()
36 for error in errorroot.findall( "error" ):
37 fp.write( "\tERR_ENTRY(\"" )
38 fp.write( error.get( "name" ) + "\", ")
39 fp.write( error.findtext( "value" ) + ", \"" )
40 fp.write( error.findtext( "msg" ) + "\"),\n" )
41 print error.get( "name" )
43 fp.write( "\t{0, NULL, NULL}\n" )
46 fp.write( "\n#ifdef __cplusplus\n" )
48 fp.write( "#endif\n\n" )
49 fp.write( "#endif\t/**<__TIZEN_COMMON_ERROR_PRIVATE_H__ */\n" )
52 privatepath = os.path.join( curpath, "../include/private/" )
53 if not os.path.isdir( privatepath ):
54 os.mkdir( privatepath )
56 # os.remove( privatepath + "tizen_error_private.h" )
57 # shutil.move( headerpath, privatepath )