コード例 #1
0
ファイル: test_gatherer_request.py プロジェクト: dekoza/mtg
 def should_separate_type_and_subtypes(self):
     options = dict(type='land,dryad')
     request = SearchRequest(options)
     subt = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     type_ = SearchFilter('type', keywords=[SearchKeyword('land', 'and')])
     self.assertEqual(request.get_filters(), {'type':type_,
                                              'subtype': subt})
コード例 #2
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_separate_type_and_subtypes(self):
     options = dict(type='land,dryad')
     request = SearchRequest(options)
     subt = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     type_ = SearchFilter('type', keywords=[SearchKeyword('land', 'and')])
     self.assertEqual(request.get_filters(), {'type':type_,
                                              'subtype': subt})
コード例 #3
0
ファイル: test_gatherer_request.py プロジェクト: Miserlou/mtg
 def should_separate_many_types_with_not_modifier(self):
     options = dict(type='legendary,artifact,!equipment,!creature')
     request = SearchRequest(options)
     type_keywords = [SearchKeyword('legendary', 'and'),
                      SearchKeyword('artifact', 'and'),
                      SearchKeyword('creature', 'not')]
     subtype_keywords = [SearchKeyword('equipment', 'not')]
     subt = SearchFilter('subtype', keywords=subtype_keywords)
     type_ = SearchFilter('type', keywords=type_keywords)
     self.assertEqual(request.get_filters(), [type_, subt])
コード例 #4
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_separate_many_types_with_not_modifier(self):
     options = dict(type='legendary,artifact,!equipment,!creature')
     request = SearchRequest(options)
     type_keywords = [SearchKeyword('legendary', 'and'),
                      SearchKeyword('artifact', 'and'),
                      SearchKeyword('creature', 'not')]
     subtype_keywords = [SearchKeyword('equipment', 'not')]
     subt = SearchFilter('subtype', keywords=subtype_keywords)
     type_ = SearchFilter('type', keywords=type_keywords)
     self.assertEqual(request.get_filters(), {'type': type_,
                                              'subtype': subt})
コード例 #5
0
ファイル: test_gatherer_request.py プロジェクト: Miserlou/mtg
 def should_allow_color_exclusion(self):
     request = SearchRequest({'color': 'wu'}, exclude_others=['color'])
     self.assertTrue(request.get_filters()[0].exclude_others)
コード例 #6
0
ファイル: test_gatherer_request.py プロジェクト: Miserlou/mtg
 def should_recognize_creature_type_as_subtype(self):
     options = dict(type='dryad')
     request = SearchRequest(options)
     fl = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     self.assertEqual(request.get_filters(), [fl])
コード例 #7
0
# coding: utf-8
from mtglib.gatherer_request import SearchRequest
from mtglib.card_extractor import CardExtractor
from django.utils.encoding import smart_str

# ~ sets = [('Return to Ravnica', 'RTR'), ('Gatecrash', 'GTC'), ("Dragon's Maze", 'DGM'), ('Magic 2014 Core Set', 'M14')]
# sets = [('Theros', 'THS'),]
# sets = [('Commander 2013', 'C13'),]
sets = [
    # ('Magic 2015 Core Set', 'M15'),
    # ('Khans of Tarkir', 'KTK'),
    ("Fate Reforged", "FRF"),
]
for s in sets:
    #
    request = SearchRequest({"set": s[0]})
    cards = []
    oldcards = []
    for i in range(20):
        tmp = CardExtractor(request.url + "&page=%s" % i).cards
        if len(oldcards) > 0 and tmp[0].name == oldcards[0].name:
            break
        else:
            cards.extend(tmp)
            oldcards = tmp

    with open("%s.pot" % s[1], "wb") as dumpfile:
        dumpfile.write("#. Please leave mana costs and tap symbol intact!\n")
        for card in cards:
            dumpfile.write("#: %s\n" % smart_str(card.name))
            lines = (smart_str(card.rules_text).replace(" ; ", ";").replace(
コード例 #8
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def setUp(self):
     self.request = SearchRequest({'text': 'first strike'})
コード例 #9
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_include_special_option_in_url(self):
     request = SearchRequest({'name': 'only,blood,ends,your,nightmares'},
                           special=True)
     assert request.special_fragment in request.url
コード例 #10
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def setUp(self):
     self.request = SearchRequest({'name': 'only,blood,ends,your,nightmares'},
                           special=True)
コード例 #11
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_allow_type_and_subtype_exclusion(self):
     request = SearchRequest({'type': 'dryad,creature'}, exclude_others=['type'])
     self.assertTrue(request.get_filters()['type'].exclude_others)
     self.assertTrue(request.get_filters()['subtype'].exclude_others)
コード例 #12
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_allow_type_exclusion(self):
     request = SearchRequest({'type': 'elemental'}, exclude_others=['type'])
     self.assertTrue(request.get_filters()['subtype'].exclude_others)
コード例 #13
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_allow_color_exclusion(self):
     request = SearchRequest({'color': 'wu'}, exclude_others=['color'])
     self.assertTrue(request.get_filters()['color'].exclude_others)
コード例 #14
0
ファイル: test_gatherer_request.py プロジェクト: Miserlou/mtg
 def should_allow_type_exclusion(self):
     request = SearchRequest({'type': 'elemental'}, exclude_others=['type'])
     self.assertTrue(request.get_filters()[0].exclude_others)
コード例 #15
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_assume_special_if_looking_for_a_special_type(self):
     request = SearchRequest({'type': 'plane'})
     self.assertIn('&special=true', request.url)
コード例 #16
0
ファイル: test_gatherer_request.py プロジェクト: Miserlou/mtg
 def should_allow_type_and_subtype_exclusion(self):
     request = SearchRequest({'type': 'dryad,creature'}, exclude_others=['type'])
     self.assertTrue(request.get_filters()[0].exclude_others)
     self.assertTrue(request.get_filters()[1].exclude_others)
コード例 #17
0
ファイル: test_gatherer_request.py プロジェクト: two-jays/mtg
 def should_recognize_creature_type_as_subtype(self):
     options = dict(type='dryad')
     request = SearchRequest(options)
     fl = SearchFilter('subtype', keywords=[SearchKeyword('dryad', 'and')])
     self.assertEqual(request.get_filters(), {'subtype': fl})