Exemple #1
0
    def __init__(self, path, store_url):
        super(CWRParserService, self).__init__()
        self._path = path
        self._decoder = default_file_decoder()
        self._encoder_json = JSONEncoder()

        self._store_url = store_url
Exemple #2
0
    def __init__(self, path, store_url):
        super(CWRParserService, self).__init__()
        self._path = path
        self._decoder = default_file_decoder()
        self._encoder_json = JSONEncoder()

        self._store_url = store_url
Exemple #3
0
    def test_file_encoding(self):
        decoder = default_file_decoder()
        data = self.get_data()

        original_lines = data['contents'].splitlines()
        for i in range(len(original_lines)):
            print(original_lines[i])

        entities = decoder.decode(data)
        file_encoder = default_file_encoder()
        result = file_encoder.encode(entities.transmission)
        original_lines = data['contents'].split("\n")
        encoded_lines = result.split("\n")

        self.assertEqual(len(original_lines), len(encoded_lines))
        for i in range(1, len(original_lines)):
            self.assertEquals(original_lines[i].strip(), encoded_lines[i].strip())
Exemple #4
0
    def test_file_encoding(self):
        decoder = default_file_decoder()
        data = self.get_data()

        original_lines = data['contents'].splitlines()
        for i in range(len(original_lines)):
            print(original_lines[i])

        entities = decoder.decode(data)
        file_encoder = default_file_encoder()
        result = file_encoder.encode(entities.transmission)
        original_lines = data['contents'].split("\n")
        encoded_lines = result.split("\n")

        self.assertEqual(len(original_lines), len(encoded_lines))
        for i in range(1, len(original_lines)):
            self.assertEquals(original_lines[i].strip(),
                              encoded_lines[i].strip())
Exemple #5
0
__author__ = 'Bernardo Martínez Garrido'
__license__ = 'MIT'
__status__ = 'Development'

if __name__ == '__main__':
    print('File to JSON test')
    path = raw_input(
        'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ')
    output = raw_input(
        'Please enter the full path to the file where the results will be stored: ')
    print('\n')
    print('Reading file %s' % path)
    print('Storing output on %s' % output)
    print('\n')

    decoder = default_file_decoder()

    data = {}
    data['filename'] = os.path.basename(path)
    data['contents'] = codecs.open(path, 'r', 'latin-1').read()

    print('Begins parsing CWR at %s' % time.ctime())
    start = time.clock()
    data = decoder.decode(data)
    end = time.clock()
    time_parse = (end - start)

    print('Parsed the file in %s seconds' % time_parse)
    print('\n')

    encoder = JSONEncoder()
Exemple #6
0
    )
    print('\n')
    print('Reading file %s' % path)
    print('Storing output on %s' % output)
    print('Saving log on %s' % log)
    print('\n')

    logging.basicConfig(
        filename=log,
        level=logging.DEBUG,
        format=
        '%(asctime)s.%(msecs)d %(levelname)s %(module)s - %(funcName)s: %(message)s'
    )
    logger = logging.getLogger(__name__)

    decoder = default_file_decoder()

    data = {}
    data['filename'] = os.path.basename(path)
    data['contents'] = codecs.open(path, 'r', 'latin-1').read()

    start = time.clock()
    data = decoder.decode(data)
    end = time.clock()
    time_parse = (end - start)

    print('Parsed the file in %s seconds' % time_parse)
    print('\n')

    logger.info('Finished parsing n %s seconds' % time_parse)
Exemple #7
0
 def setUp(self):
     self._encoder = default_file_encoder()
     self._decoder = default_file_decoder()
Exemple #8
0
 def setUp(self):
     self._encoder = default_file_encoder()
     self._decoder = default_file_decoder()
Exemple #9
0
# import sys
# sys.path.append("/Users/taylor/Create/projects/CWR-DataApi/cwr")

import codecs
import os

from cwr.parser.decoder.file import default_file_decoder
from cwr.parser.encoder.cwrjson import JSONEncoder

if __name__ == '__main__':

    # path = '/Users/taylor/Downloads/CW180001000_000.V21'
    # path = '/Users/taylor/Create/projects/CWR-DataApi/tests/examples/ackexample.V21'
    path = '/Users/taylor/Downloads/CW200090UN_PEX.V21'

    data = {}
    data['filename'] = os.path.basename(path)
    data['contents'] = codecs.open(path, 'r', 'latin-1').read()

    data = default_file_decoder().decode(data)

    print(JSONEncoder().encode(data))
    
Exemple #10
0
 def setUp(self):
     self._parser = default_file_decoder()