• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2019 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16from __future__ import print_function
17import sys
18
19args = sys.argv
20
21if len(args) != 3:
22  print("Usage: jdigen <input> <output>")
23  sys.exit(1)
24
25TEMPLATE = """
26// Copyright (C) 2019 The Android Open Source Project
27//
28// Licensed under the Apache License, Version 2.0 (the "License");
29// you may not use this file except in compliance with the License.
30// You may obtain a copy of the License at
31//
32//     http://www.apache.org/licenses/LICENSE-2.0
33//
34// Unless required by applicable law or agreed to in writing, software
35// distributed under the License is distributed on an "AS IS" BASIS,
36// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37// See the License for the specific language governing permissions and
38// limitations under the License.
39
40package com.sun.tools.jdi.resources;
41import java.util.ListResourceBundle;
42public final class jdi extends ListResourceBundle {{
43  protected final Object[][] getContents() {{
44    return new Object[][] {{
45      {values}
46    }};
47  }}
48}}
49"""
50
51INSTANCE_FORMAT = '{{ "{key}", "{value}" }},\n'
52
53VALUES = ""
54with open(args[1], 'r') as inp:
55  for l in inp.readlines():
56    key, value = l.split('=')
57    VALUES += INSTANCE_FORMAT.format(key = key.strip(), value = value.strip())
58
59with open(args[2], 'w') as out:
60  out.write(TEMPLATE.format(values = VALUES))
61