Skip to content

Commit

Permalink
remove MappingPackFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
mete0r committed Mar 19, 2019
1 parent e803f4d commit 9992a29
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 70 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ notebook:
.PHONY: test
test: requirements/test.txt
$(VENV) rm -f .coverage.*
$(VENV) tox --parallel=4 -e py27,py34,pypy
$(VENV) tox --parallel=4 -e lint,py27,py34,pypy

.PHONY: test-report
test-report:
Expand Down
4 changes: 0 additions & 4 deletions src/ktug_hanyang_pua/fileformats/table_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import logging
import struct

from ..formats import MappingPackFormat
from ..models import Mapping
from ..table import split_table
from ..table import make_groups
Expand All @@ -45,8 +44,6 @@ def write_struct(fp, struct, tpl):


def load_mappings_as_binary_table(input_fp):
packFormat = MappingPackFormat()
packSize = packFormat.structfmt.size

# 그룹 갯수
n_groups = read_struct(input_fp, ushort)[0]
Expand Down Expand Up @@ -84,7 +81,6 @@ def load_mappings_as_binary_table(input_fp):


def dump_mappings_as_binary_table(mappings, output_fp):
mappingPackFormat = MappingPackFormat()

mappings = (
Mapping(
Expand Down
25 changes: 0 additions & 25 deletions src/ktug_hanyang_pua/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,6 @@ def format_comment(self, comment):
return '%%%{}'.format(comment.text)


class MappingPackFormat(object):

__slots__ = (
'structfmt',
)

def __init__(self):
self.structfmt = Struct('<HH')

def format(self, mapping):
source = mapping.source
target = mapping.target
return self.structfmt.pack(source, target)

def parse(self, byteseq):
if len(byteseq) != self.structfmt.size:
raise ValueError(len(byteseq))
source, target = self.structfmt.unpack(byteseq)
return Mapping(
source=source,
target=target,
comment=None,
)


class MappingDictFormat(object):

__slots__ = (
Expand Down
40 changes: 0 additions & 40 deletions tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,46 +259,6 @@ def test_format_and_parse_without_comment(self):
)


class MappingPackFormatTest(TestCase):

def make_one(self):
from ktug_hanyang_pua.formats import MappingPackFormat
return MappingPackFormat()

def test_format(self):
from ktug_hanyang_pua.models import Mapping
packFormat = self.make_one()

targets = []
for index, mapping in enumerate(TABLE.MAPPINGLIST):
targets.extend(mapping.target)
mapping = Mapping(
source=mapping.source[0],
target=len(mapping.target),
comment=mapping.comment,
)
binary = packFormat.format(mapping)
self.assertEqual(
TABLE.MAPPINGPACKS[index],
binary
)

parsed = packFormat.parse(binary)
parsed = Mapping(
source=tuple([parsed.source]),
target=tuple(
targets[-parsed.target:]
if parsed.target != 0
else []
),
comment=parsed.comment,
)
self.assertEqual(
TABLE.MAPPINGLIST[index],
parsed,
)


class NodeDictFormatTest(TestCase):

def make_one(self):
Expand Down

0 comments on commit 9992a29

Please sign in to comment.