#!/usr/bin/python3

#  Copyright (C) 2012 Hai Bison
#
#  See the file LICENSE at the root directory of this project for copying
#  permission.

'''
This tool parses `messages.properties` and generates all strings to their
respective IDs, which can be put into class R.string.
'''

import os
import re

SOURCE_FILE = os.sep.join(['..','code','src','group','pals','desktop','app',
                           'apksigner','i18n','messages_en.properties'])

# PARSE SOURCE FILE

# Should start from 1...
count = 1

with open(SOURCE_FILE, 'r') as f:
    for line in f:
        line = line.strip()
        if not line.startswith('#') and len(line) > 0:
            print('public static final int {} = 0x{:08x};'\
                   .format(re.sub(r'(?s)=.*', '', line).strip(), count))
            count += 1

@@ -295,44 +295,156 @@
 ort 
-re%0A%0ASOURCE_FILE = os.sep.join(%5B'..',
+os.path%0Aimport re%0Aimport sys%0A%0ASOURCE_FILE = os.sep.join(%5Bos.path.dirname(os.path.dirname(os.path.abspath(sys.argv%5B0%5D))),%0A                           
 'cod

Update RGen.py