Example #1
0
    def test_open_or_stringIO(self):
        fileobj = open_or_stringIO('1234.json')
        self.assertIsInstance(fileobj, io.TextIOWrapper)

        stringobj = open_or_stringIO("fakefile")
        self.assertIsInstance(stringobj, io.StringIO)

        stringobj = open_or_stringIO("1234.json", as_string=True)
        self.assertIsInstance(stringobj, io.StringIO)
Example #2
0
    def test_open_or_stringIO(self):
        fileobj = open_or_stringIO('1234.json')
        self.assertIsInstance(fileobj, io.TextIOWrapper)

        stringobj = open_or_stringIO("fakefile")
        self.assertIsInstance(stringobj, io.StringIO)

        stringobj = open_or_stringIO("1234.json", as_string=True)
        self.assertIsInstance(stringobj, io.StringIO)
Example #3
0
def parse_items(item_file='../items.txt'):
    with open_or_stringIO(item_file) as f:

        blocks = []
        for line in f:
            if (line.startswith(_start_item_pattern)):
                block = get_item_block(f, line)
                blocks.append(block)

    item_d = _construct_json(blocks)
    with open("../items_parsed.json", 'w') as f:
        json.dump(item_d, f)
        print("Parsed Items.")
Example #4
0
def parse_heroes(hero_file='../npc_heroes.txt'):
    with open_or_stringIO(hero_file) as f:
        hero_blocks = []
        for line in f:
            if line.startswith(_start_hero_pattern):
                hero_block = get_hero_block(f, line)
                hero_blocks.append(hero_block)

    hero_d = _construct_json(hero_blocks)

    with open("../heroes_parsed.json", 'w') as f:
        json.dump(hero_d, f)
        print("Parsed Heros.")
Example #5
0
def parse_items(item_file='../items.txt'):
    with open_or_stringIO(item_file) as f:

        blocks = []
        for line in f:
            if (line.startswith(_start_item_pattern)):
                block = get_item_block(f, line)
                blocks.append(block)

    item_d = _construct_json(blocks)
    with open("../items_parsed.json", 'w') as f:
        json.dump(item_d, f)
        print("Parsed Items.")
Example #6
0
def parse_heroes(hero_file='../npc_heroes.txt'):
    with open_or_stringIO(hero_file) as f:
        hero_blocks = []
        for line in f:
            if line.startswith(_start_hero_pattern):
                hero_block = get_hero_block(f, line)
                hero_blocks.append(hero_block)

    hero_d = _construct_json(hero_blocks)

    with open("../heroes_parsed.json", 'w') as f:
        json.dump(hero_d, f)
        print("Parsed Heros.")
Example #7
0
def parse_abilities(ability_file='../npc_abilities.txt'):

    with open_or_stringIO(ability_file) as f:
        blocks = []
        for line in f:
            if (line.startswith(_start_ability_pattern) and
                    not line.startswith('\t"Version"')):
                block = get_ability_block(f, line)
                blocks.append(block)

    ability_d = _construct_json(blocks)

    with open("../abilities_parsed.json", 'w') as f:
        json.dump(ability_d, f)
        print("Parsed Abilities.")
Example #8
0
def parse_abilities(ability_file='../npc_abilities.txt'):

    with open_or_stringIO(ability_file) as f:
        blocks = []
        for line in f:
            if (line.startswith(_start_ability_pattern)
                    and not line.startswith('\t"Version"')):
                block = get_ability_block(f, line)
                blocks.append(block)

    ability_d = _construct_json(blocks)

    with open("../abilities_parsed.json", 'w') as f:
        json.dump(ability_d, f)
        print("Parsed Abilities.")