Log in Page Discussion History Go to the site toolbox

David Vallner/Discworld Charms

From BluWiki

Contents

Charms - Spank (ruby)

  1. alligator (blue moon) - Blue Moon Park, Bes Pelargic
  2. barnacle (hillshire) - Hillshire
  3. basilisk (changer) - Ankh Bridge Money Changer, Ankh-Morpork
  4. bat (genua) - National Bank, Genua
  5. boot (doctor) - Doctor, Flintwick Building
  6. Berilia (ohulan) - Market Stall, Ohulan-Cutash
  7. cat (jonas)- Jonas' Vault, Ankh
  8. chimera (sto lat) - Sto Lat Royal Market
  9. claw shrimp (nico) - Nicolette Leveaux' shop, Thieves' Guild, Morpork
  10. crab (widdershins) - Widdershins Gate, Morpork
  11. cupid (tuna walk) - Tuna Walk, Bes Pelargic
  12. dog (pishe) - Pishe Gardens, Ankh
  13. duck (blank)
  14. elephant (lancre) - City Square, Lancre Town
  15. feather (bop) - Birds of Paradise bank, Morpork
  16. fish (bandits) - Bandit Camp
  17. goat (djeli) - Bazaar crossroads, Djelibeybi
  18. hand (jungle) - Top hat monkey jungle
  19. horse (sek) - The High Altar of Sek in Morpork
  20. horse head (sheepridge) - Sheepridge
  21. Jerakeen (gloomy) - West Signpost, Gloomy Forest
  22. ox (lanfear) - Warriors' Guild Hall of Heroes, Ankh-Morpork
  23. pig (blank)
  24. raven (holy wood) - Holy Wood
  25. squid (listeners) - Listeners' Valley
  26. throwing knife (cool) - Temple of Cool
  27. tiger (drum) - The Mended Drum

Reidentification script

This script creates a string of semicolon-separated commands that will fix your charm identify tags if a bug ate them.

Python source

#!/usr/bin/python
"""Create a charm reidentification macro.

Converts a Textile-formatted list of charms and their corresponding 
destination identifiers to create an macro that will restore the identify tags.
"""

__revision__ = 1

import sys
import re

from string import Template

charm_re = re.compile(r'^#([\w\s]+)_\(([\w\s]+)\)_')
charm_alias_line_template = Template(';'.join((
                                      'remove $design charm from bracelets',
                                      'identify $design charm as $destination',
                                      'add $destination to bracelets')))


def make_charm_macro_command(line):
    """Create the commands to reidentify a charm.
    
    Creates commands for the charm reidentification macro for the charm that 
    line describes.
    
    Returns the commands or None if line isn't a charm description.
    """
    stripped_line = line.strip()
    
    if (stripped_line == ''):
        return None
    match = charm_re.match(stripped_line)
    if (match == None):
        return None
    else:
        print >> sys.stderr, 'Found charm description: %s' % stripped_line
        return charm_alias_line_template.substitute(
          dict(design=match.group(1).strip(),
               destination=match.group(2).strip()))

def make_charm_macro(charm_file):
    """Create the charm reidentification macro.
    
    Creates a macro that will reidentify all the charms described in the 
    in_file stream.
    """
    return ';'.join(
        (command for command 
          in (make_charm_macro_command(line) for line in charm_file)
          if command != None))

if __name__ == '__main__':
    if len(sys.argv) == 1:
        print >> sys.stderr, 'Reading charm descriptions from standard input.'
        print make_charm_macro(sys.stdin)
    else:
        print >> sys.stderr, 'Reading charm descriptions from %s.' % (
          sys.argv[1])
        in_file = file(sys.argv[1])
        print make_charm_macro(in_file)
        in_file.close()

Example Input

The input is formatted using the Textile language, and generates the list on the start of the page.

# alligator _(blue moon)_ - Blue Moon Park, Bes Pelargic
# barnacle _(hillshire)_ - Hillshire
# basilisk _(changer)_ - Ankh Bridge Money Changer, Ankh-Morpork
# bat _(genua)_ - National Bank, Genua
# Berilia _(ohulan)_ - Market Stall, Ohulan-Cutash
# boot _(doctor)_ - Doctor, Flintwick Building
# broomstick _(blank)_
# cat _(jonas)_ - Jonas' Vault, Ankh
# chimera _(sto lat)_ - Sto Lat Royal Market
# claw shrimp _(nico)_ - Nicolette Leveaux' shop, Thieves' Guild, Morpork
# cobra _(giants)_ - Giantland
# crab _(widdershins)_ - Widdershins Gate, Morpork
# cupid _(tuna walk)_ - Tuna Walk, Bes Pelargic
# dog _(pishe)_ - Pishe Gardens, Ankh
# duck _(ctf)_ - Beezing Monastery
# elephant _(lancre)_ - City Square, Lancre Town
# feather _(bop)_ - Birds of Paradise bank, Morpork
# fish _(bandits)_ - Bandit Camp
# goat _(djeli)_ - Bazaar crossroads, Djelibeybi
# hand _(jungle)_ - Top hat monkey jungle
# horse _(sek)_ - The High Altar of Sek in Morpork
# horse head _(sheepridge)_ - Sheepridge
# Jerakeen _(gloomy)_ - West Signpost, Gloomy Forest
# mouse _(razorback)_ - Razorback Village Green
# ox _(lanfear)_ - Warriors' Guild Hall of Heroes, Ankh-Morpork
# pig _(clubs)_ - Club room, Patrician's Palace
# raven _(holy wood)_ - Holy Wood
# squid _(listeners)_ - Listeners' Valley
# throwing knife _(cool)_ - Temple of Cool
# tiger _(drum)_ - The Mended Drum

Site Toolbox:

Personal tools
GNU Free Documentation License 1.2
This page was last modified on 3 December 2006, at 03:31.
Disclaimers - About BluWiki