Rohit Yadav 76ea0e7c45 api: Annotate and fill name field of @APICommand from commands.properties.in
- Reads and fills name field of all cmd class and api name mapping from
  commands.properties.in
- Automation using following python script ensures correctness of the change

import os
file_prefix = "api/src/"
search_pattern = "@APICommand("
pattern_len = len(search_pattern)
prop_file = "client/tomcatconf/commands.properties.in"
f = open(prop_file, 'r')
data = f.read()
f.close()
apis = filter(lambda x: x.strip()!='' and (not x.startswith('#')), data.split('\n'))
for api in apis:
    api_name = api.split('=')[0]
    cmd_name = file_prefix + api.split('=')[1].split(';')[0].replace('.', '/').strip() + ".java"
    if not os.path.exists(cmd_name):
        print cmd_name, api_name
    f = open(cmd_name, 'r')
    d = f.read()
    f.close()
    idx = d.find(search_pattern) + pattern_len
    new_str = d[:idx] + "name = \"%s\", " % api_name + d[idx:]
    f = open(cmd_name, 'w')
    f.write(new_str)
    f.close()

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-28 01:09:28 -08:00
..