Skip to content

Instantly share code, notes, and snippets.

@pineapplemachine
Last active January 24, 2016 20:32
Show Gist options
  • Select an option

  • Save pineapplemachine/4e1c22adafdb15eb064a to your computer and use it in GitHub Desktop.

Select an option

Save pineapplemachine/4e1c22adafdb15eb064a to your computer and use it in GitHub Desktop.
Quick script to generate a StarNamesText.xml file for GalCiv III using a more convenient input format
names = '''
One
Star
Name
Per
Line
Hello
World
'''
names = (n.strip() for n in names.split('\n') if len(n.strip()) > 0)
with open('StarNamesText.xml', 'wb') as xml:
xml.write('''
<?xml version="1.0" encoding="utf-8"?>
<StringTableList
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../Schema/Lib/StringTable.xsd">
''' +
''.join(
'''
<StringTable>
<Label>RANDOM_STAR_NAME_%d</Label>
<String>%s</String>
</StringTable>
''' % (i, n) for i, n in enumerate(names)
) +
'</StringTableList>'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment