NewsFeaturesDownloadsDevelopmentSupportAbout Us

lifetype-1.1.6/bin-devel/chklocale.py

Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import sys
00004 import string
00005 import re
00006 
00007 class mySys:
00008         argc = 0
00009         argv = ""
00010         def __init__(self, args):
00011                 self.argc = len(args)
00012                 self.argv = args
00013         def isArg(self, findArg):
00014                 for arg in self.argv:
00015                         if( arg == findArg ):
00016                                 return 1
00017 
00018                 else:
00019                         return 0
00020 
00021 
00022                 
00023 
00024 if len( sys.argv ) < 2:
00025         print "Argument missing"
00026         sys.exit( -1 );
00027 
00028 # check for the parameter
00029 params   = mySys( sys.argv )
00030 keysOnly = params.isArg( "--keys" )
00031 
00032 # open the file
00033 localeFile = open( sys.argv[1], 'r' )
00034 
00035 # and compile the regexp
00036 #pattern = "\$messages\[\"(.+)\"] *= *\"(.+)\";"
00037 pattern = "\$messages\[\"(.+)\"] *= \"(.*)\n"
00038 regExp = re.compile( pattern, re.IGNORECASE|re.MULTILINE|re.DOTALL )
00039 
00040 # output list
00041 result = []
00042 # and now loop through the lines of the file checking which ones match
00043 # the regular experession given above
00044 for line in localeFile.readlines():
00045         grp = regExp.search( line )
00046         if( grp ):
00047                 if( keysOnly ):
00048                         result.append( grp.group(1))
00049                 else:
00050                         item = grp.group(1) + " - " + grp.group(2)
00051                         result.append( item )
00052 
00053 # sort the output list
00054 result.sort()
00055 # and print it, since calling "print result" would print something
00056 # really awful ;)
00057 for item in result:
00058         print item