Exemplo n.º 1
0
 def __init__(self, wesnoth_exe, config_dir, data_dir, transdir):
     self.unit_lookup = {}
     self.race_lookup = {}
     self.terrain_lookup = {}
     self.movetype_lookup = {}
     self.era_lookup = {}
     self.campaign_lookup = {}
     self.parser = wmlparser3.Parser(wesnoth_exe, config_dir, data_dir)
Exemplo n.º 2
0
    def add_languages(self, languages):
        """
        Returns a dictionary mapping isocodes to languages.
        """
        self.languages_found = {}

        parser = wmlparser3.Parser(options.wesnoth, options.config_dir,
            options.data_dir, no_preprocess = False)
        parser.parse_text("{languages}")

        for locale in parser.get_all(tag="locale"):
            isocode = locale.get_text_val("locale")
            name = locale.get_text_val("name")
            if isocode == "ang_GB":
                continue
            self.languages_found[isocode] = name
Exemplo n.º 3
0
 def decode_WML(self, data):
     p = wmlparser.Parser()
     p.parse_binary(data)
     return p.root
Exemplo n.º 4
0
    # Possible arguments
    arg_parser = argparse.ArgumentParser(
        description='campaign2wiki is a script\
which generates information about campaigns for the wiki.')
    arg_parser.add_argument('-d',
                            '--data',
                            default='data/',
                            dest='data_dir',
                            help="The location of wesnoth data directory")
    arg_parser.add_argument('-o',
                            '--output',
                            default='/tmp/CampaignWML',
                            dest='output_path',
                            help="The location of the output file.")
    arg_parser.add_argument('-w',
                            '--wesnoth',
                            default='./wesnoth',
                            dest='wesnoth',
                            help='The wesnoth executable location')
    args = arg_parser.parse_args()

    output = ['{{Autogenerated}} ']
    main = wmlparser3.Parser(args.wesnoth, None, None)
    main.parse_file('data/_main.cfg')
    for campaign in main.get_all(tag='campaign'):
        a = Campaign(campaign)
        output.append(wiki_output(a))

    with open(args.output_path, "w", encoding="utf8") as wiki_format:
        wiki_format.write(''.join(output))