base_url = ('http://gatherer.wizards.com/Pages/Search/Default.aspx'
            '?action=advanced&')

random_url = 'http://gatherer.wizards.com/Pages/Card/Details.aspx?action=random'

TYPES = set(['artifact', 'basic', 'creature', 'enchantment', 'instant', 'land',
             'legendary', 'ongoing', 'plane', 'planeswalker', 'scheme', 'snow',
             'sorcery', 'tribal', 'vanguard', 'world'])

COLORS = {'w': 'W', 'u': 'U', 'b': 'B', 'r': 'R', 'g': 'G', 'c': 'C'}

COLOR_PROPER_NAMES = {
    'white': 'w',
    'blue': 'u',
    'black': 'b',
    'red': 'r',
    'green': 'g',
    'colorless': 'c',
    'boros': 'rw',
    'golgari': 'bg',
    'selesnya': 'wg',
    'dimir': 'ub',
    'orzhov': 'wb',
    'izzet': 'ur',
    'gruul': 'rg',
    'azorius': 'uw',
    'rakdos': 'br',
    'simic': 'ug',
    'bant': 'wug',
    'esper': 'ubw',
    'grixis': 'bru',
    'jund': 'rbg',
    'naya': 'wrg',
}

RARITY_PATTERN = r'(.*?) ((Unc|C)ommon|(Mythic )?Rare|Special|Promo|Land)$'

RARITIES = {
    'c': 'C',
    'common': 'C',
    'u': 'U',
    'uncommon': 'U',
    'r': 'R',
    'rare': 'R',
    'mythic': 'M',
    'm': 'M',
    'l': 'L',
    'land': 'L',
    's': 'S',
    'special': 'S',
    'p': 'P',
    'promo': 'P',
}

VALID_WORDS = {'rarity': RARITIES, 'color': COLORS}

separator = '\n------------------------------'

readme = """Usage: %prog [options] [cardname]

Examples:

    Look up a card by name:
    $ mtg sengir vampire

    Limit by color.  Use the one-letter abbreviations: w, u, b, r, g, or c.
    $ mtg thrull --color=w

    To match multiple colors, combine letters.  How you separate them
    determines the type of search.

    Search for angels that are white OR black:
    $ mtg angel --color=w|b

    Search for angels that are white AND black (no comma separation
    forces multicolored matches).
    $ mtg angel --color=wb

    Exclude unselected colors with -x.  Search for angels that are black only.
    $ mtg angel --color=b -x

    Limit by card text, including reminder text.  A string of comma
    separated terms searches cards containing all terms, not the exact
    phrase:
    $ mtg --text=flying,islandwalk

    To search by exact phrase, specify the phrase:
    $ mtg --text='destroy all creatures'

    Limiting by type is done with the --type option.  This option will
    accept anything: card types, creature types, supertypes, etc.  For
    example:

    Limit by card type:
    $ mtg --text='destroy all creatures' --type=instant

    Limit by creature type and rarity:
    $ mtg --type=goblin --rarity=m

    Limit by supertype and two possible subtypes:
    $ mtg --type='snow,construct|goblin'

    Limit by subtype and card type:
    $ mtg --type='elf,!creature'

    To limit by power, toughness, or converted mana cost, you can use
    the inequality operators > and < as follows.  Some shells require
    these characters to be escaped or enclosed in quotation marks.

    Creatures with power greater than 11:
    $ mtg --power='>11'

    Creatures power/toughness = 7/3:
    $ mtg --power=7 --tough=3

    Enchantments costing less than 2 mana that give something -1/-1:
    $ mtg --cmc='<2' --text='-1/-1' --type=enchantment

    It is possible to combine or negate characteristics using the OR
    (|) and NOT (!) operators.  Commas are used to delimit options.
    Examples:

    $ mtg zendikon --color='!b'
    $ mtg --type='legendary,artifact,!equipment'
    $ mtg --text='win the game' --set='!unhinged,!unglued'
    $ mtg guildmage --color=r|g
    $ mtg --text='gain life' --set=zendikar --color="u|b|r" -x
    $ mtg --text='counter target' --color="w|g" -x
"""

@@ -190,16 +190,21 @@
  = set(%5B
+%0A    
 'artifac
@@ -206,16 +206,20 @@
 tifact',
+%0A   
  'basic'
@@ -219,16 +219,38 @@
 'basic',
+%0A    'conspiracy',%0A   
  'creatu
@@ -253,16 +253,20 @@
 eature',
+%0A   
  'enchan
@@ -272,16 +272,20 @@
 ntment',
+%0A   
  'instan
@@ -287,16 +287,20 @@
 nstant',
+%0A   
  'land',
@@ -300,25 +300,16 @@
 'land',%0A
-         
     'leg
@@ -316,16 +316,20 @@
 endary',
+%0A   
  'ongoin
@@ -331,16 +331,38 @@
 ngoing',
+%0A    'phenomenon',%0A   
  'plane'
@@ -362,16 +362,20 @@
 'plane',
+%0A   
  'planes
@@ -382,16 +382,20 @@
 walker',
+%0A   
  'scheme
@@ -396,16 +396,20 @@
 scheme',
+%0A   
  'snow',
@@ -409,25 +409,16 @@
 'snow',%0A
-         
     'sor
@@ -423,16 +423,20 @@
 orcery',
+%0A   
  'tribal
@@ -437,16 +437,20 @@
 tribal',
+%0A   
  'vangua
@@ -457,16 +457,20 @@
 rd',
+%0A   
  'world'
 %5D)%0A%0A
@@ -465,16 +465,18 @@
  'world'
+,%0A
 %5D)%0A%0ACOLO

Add "conspiracy" and "phenomenon" card types.