mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 14:20:59 +00:00
Remove now useless code. Still a bug to fix with about links but other than that it works
This commit is contained in:
parent
b0aa3691e4
commit
b28b14882e
@ -6,11 +6,8 @@ A script that autogenerates some information about campaigns for the
|
||||
CampaignInformation wiki page. The script is a WIP.
|
||||
"""
|
||||
|
||||
#TODO: Make it work with all campaigns (see blacklist) and investigate
|
||||
#wmlparser2.py issues. More information. Output in wiki format. Cleanup.
|
||||
|
||||
from __future__ import with_statement # For python < 2.6
|
||||
import glob, os.path, sys
|
||||
import os.path, sys
|
||||
try:
|
||||
import argparse
|
||||
except ImportError:
|
||||
@ -33,35 +30,7 @@ class Campaign:
|
||||
# count(',')+1 difficulty levels.
|
||||
self.levels = self.parser.get_text_val("difficulties").count(',') + 1
|
||||
self.credits_link = "http://wiki.wesnoth.org/Credits#" + self.id
|
||||
#self.scenarios = self.build_scenario_list()
|
||||
#self.total_scenarios = len(self.scenarios)
|
||||
# Calculate how many scenarios a player will usually go through
|
||||
#self.normal_scenarios = max([int(i.number[:2]) for i in self.scenarios ])
|
||||
self.total_scenarios = self.normal_scenarios = 0
|
||||
|
||||
def build_scenario_list(self):
|
||||
"""
|
||||
Should find a better way to do this
|
||||
"""
|
||||
scenarios = glob.glob(os.path.join('data/campaigns', self.name[:5]+ '*', 'scenarios/*.cfg'))
|
||||
print scenarios
|
||||
return [Scenario(self.name, args.wesnoth) for i in scenarios]
|
||||
|
||||
|
||||
class Scenario:
|
||||
"""
|
||||
A class for a specific scenario
|
||||
"""
|
||||
def __init__(self, name, wesnoth):
|
||||
"""
|
||||
We need wesnoth executable link to parse files.
|
||||
"""
|
||||
self.parser = wmlparser2.Parser(wesnoth, None, None, False)
|
||||
self.number = self.parser.parse_file(path)
|
||||
for scenario in self.parser.get_all(tag='scenario'):
|
||||
self.turns = scenario.get_text_val("turns")
|
||||
self.number = scenario.get_text_val("id", val=0)[:scenario.get_text_val("id", val=0).find('_')]
|
||||
|
||||
self.units_link = "http://units.wesnoth.org/trunk/mainline/en_US/%s.html" % self.id
|
||||
|
||||
def wiki_output(campaign):
|
||||
"""
|
||||
@ -74,11 +43,12 @@ def wiki_output(campaign):
|
||||
campaign.description = ''.join(campaign.description.split(i))
|
||||
text = """== {0} ==
|
||||
{1}
|
||||
Total scenarios : {2}
|
||||
Scenarios you will go through : {3}
|
||||
Difficulty levels : {4}
|
||||
* [{5} Credits]
|
||||
""".format(campaign.name, campaign.description, campaign.total_scenarios, campaign.normal_scenarios, campaign.levels, campaign.credits_link)
|
||||
|
||||
Difficulty levels : {2}
|
||||
* [{3} Custom units]
|
||||
* [{4} Credits]
|
||||
""".format(campaign.name, campaign.description, campaign.levels,
|
||||
campaign.units_link, campaign.credits_link)
|
||||
return text
|
||||
|
||||
|
||||
@ -94,7 +64,7 @@ which generates information about campaigns for the wiki.')
|
||||
dest='wesnoth', help='The wesnoth executable location')
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
output = ''
|
||||
output = '{{Autogenerated}} '
|
||||
main = wmlparser2.Parser(args.wesnoth, None, None, False)
|
||||
main.parse_file('data/_main.cfg')
|
||||
for campaign in main.get_all(tag='campaign'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user