Skip to content

Commit

Permalink
Merge pull request #41 from Bernardo-MG/merge_master
Browse files Browse the repository at this point in the history
Merge master
  • Loading branch information
Bernardo-MG committed Apr 27, 2015
2 parents b7937d4 + aac7588 commit 36823ab
Show file tree
Hide file tree
Showing 160 changed files with 4,069 additions and 851 deletions.
2 changes: 1 addition & 1 deletion cwr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
:license: MIT, see LICENSE for more details.
"""

__version__ = '0.0.9'
__version__ = '0.0.13'
__license__ = 'MIT'
3 changes: 2 additions & 1 deletion cwr/grammar/factory/decorator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from abc import ABCMeta, abstractmethod
from abc import abstractmethod

import pyparsing as pp

Expand Down Expand Up @@ -132,6 +132,7 @@ def __init__(self):
self._decoders = {}
# TODO: Do this somewhere else
self._decoders['transmission'] = TransmissionDictionaryDecoder()
self._decoders['group_info'] = GroupDictionaryDecoder()

def decorate(self, rule, data):
id = data['id']
Expand Down
8 changes: 7 additions & 1 deletion cwr/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def version(self):
"""
return self._version

def __str__(self):
return '%s %s %s %s' % (self._version, self._isan, self._episode, self._check_digit)


class AVIKey(object):
"""
Expand All @@ -203,4 +206,7 @@ def society_code(self):
Returns the society code.
:return: the society code
"""
return self._society_code
return self._society_code

def __str__(self):
return '%s %s' % (self._av_number, self._society_code)
36 changes: 36 additions & 0 deletions cwr/parser/cwrjson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-

import json

from cwr.parser.dictionary import CWRDictionaryEncoder
from cwr.parser.common import Encoder


"""
Offers classes to parse CWR objects from and into JSON structures.
"""

__author__ = 'Bernardo Martínez Garrido'
__license__ = 'MIT'
__status__ = 'Development'


class JSONEncoder(Encoder):
def __init__(self):
super(JSONEncoder, self).__init__()
self._dict_encoder = CWRDictionaryEncoder()

def encode(self, object):
encoded = self._dict_encoder.encode(object)

return json.dumps(encoded, default=_date_handler)


def _date_handler(obj):
if hasattr(obj, 'isoformat'):
result = obj.isoformat()
else:
raise TypeError("Unserializable object {} of type {}".format(obj,
type(obj)))

return result
Loading

0 comments on commit 36823ab

Please sign in to comment.