Skip to content

Commit

Permalink
Standardize line separator to \n
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Xiao committed Dec 16, 2018
1 parent 7208d29 commit 869108c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
5 changes: 1 addition & 4 deletions cabrillo/cabrillo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""Contains code pertaining to parsing and holding individual Cabrillo data.
"""
# pylint: disable=E1101, E0203

import os

from cabrillo import data
from cabrillo.errors import InvalidLogException

Expand Down Expand Up @@ -137,7 +134,7 @@ def write_text(self):

lines.append('END-OF-LOG:')

return os.linesep.join(lines)
return '\n'.join(lines)

def __str__(self):
return '<Cabrillo for {}>'.format(self.callsign)
5 changes: 2 additions & 3 deletions cabrillo/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Contains utilities to parse a Cabrillo file."""
import os
from datetime import datetime
from cabrillo import QSO, Cabrillo

Expand Down Expand Up @@ -73,9 +72,9 @@ def parse_log_text(text, ignore_unknown_key=False, check_categories=True):
results = dict()
results['x_anything'] = dict()

for line in text.split(os.linesep):
for line in text.split('\n'):
try:
key, value = [x.strip() for x in line.split(':')]
key, value = [x.replace('\r', '').strip() for x in line.split(':')]
except ValueError:
raise InvalidLogException('Line not delimited by `:`, '
'got {}.'.format(line))
Expand Down
5 changes: 2 additions & 3 deletions tests/test_cabrillo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Test the Cabrillo class."""

from datetime import datetime
from os import linesep

import pytest

Expand Down Expand Up @@ -96,7 +95,7 @@ def test_all_attributes():
'X-QSO: 7006 CW 2009-05-30 0015 AA1ZZZ 599 2 EF8M 599 34',
'X-TEST-1: ignore',
'END-OF-LOG:']
lines = cab.write_text().split(linesep)
lines = cab.write_text().split('\n')
assert sorted(correct) == sorted(lines)


Expand All @@ -105,7 +104,7 @@ def test_unicode():
"""
cab = Cabrillo(callsign='VR2TEST',
address=['毛澤大道東89號', '鶴咀'], address_city='石澳')
lines = cab.write_text().split(linesep)
lines = cab.write_text().split('\n')
correct = ['START-OF-LOG: 3.0', 'CALLSIGN: VR2TEST',
'ADDRESS: 毛澤大道東89號', 'ADDRESS: 鶴咀', 'ADDRESS-CITY: 石澳',
'CREATED-BY: cabrillo (Python)', 'END-OF-LOG:']
Expand Down

0 comments on commit 869108c

Please sign in to comment.