Skip to content

Commit 4623609

Browse files
committed
fix: use logger.warning
1 parent 34f5ff6 commit 4623609

File tree

15 files changed

+33
-51
lines changed

15 files changed

+33
-51
lines changed

docs/conf.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# python-hl7 documentation build configuration file, created by
43
# sphinx-quickstart on Tue Jul 12 10:57:30 2011.
@@ -43,8 +42,8 @@
4342
master_doc = "index"
4443

4544
# General information about the project.
46-
project = u"python-hl7"
47-
copyright = u"2011-{}, John Paulett".format(date.today().year)
45+
project = "python-hl7"
46+
copyright = "2011-{}, John Paulett".format(date.today().year)
4847

4948
# The version info for the project you're documenting, acts as replacement for
5049
# |version| and |release|, also used in various other places throughout the
@@ -189,7 +188,7 @@
189188
# Grouping the document tree into LaTeX files. List of tuples
190189
# (source start file, target name, title, author, documentclass [howto/manual]).
191190
latex_documents = [
192-
("index", "python-hl7.tex", u"python-hl7 Documentation", u"John Paulett", "manual"),
191+
("index", "python-hl7.tex", "python-hl7 Documentation", "John Paulett", "manual"),
193192
]
194193

195194
# The name of an image file (relative to this directory) to place at the top of
@@ -220,16 +219,16 @@
220219

221220
# One entry per manual page. List of tuples
222221
# (source start file, name, description, authors, manual section).
223-
man_pages = [("mllp_send", "mllp_send", "MLLP network client", [u"John Paulett"], 1)]
222+
man_pages = [("mllp_send", "mllp_send", "MLLP network client", ["John Paulett"], 1)]
224223

225224

226225
# -- Options for Epub output ---------------------------------------------------
227226

228227
# Bibliographic Dublin Core info.
229-
epub_title = u"python-hl7"
230-
epub_author = u"John Paulett"
231-
epub_publisher = u"John Paulett"
232-
epub_copyright = u"2011, John Paulett"
228+
epub_title = "python-hl7"
229+
epub_author = "John Paulett"
230+
epub_publisher = "John Paulett"
231+
epub_copyright = "2011, John Paulett"
233232

234233
# The language of the text. It defaults to the language option
235234
# or en if the language is not set.

hl7/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""python-hl7 is a simple library for parsing messages of Health Level 7
32
(HL7) version 2.x into Python objects.
43

hl7/accessor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from collections import namedtuple
32

43

@@ -27,7 +26,7 @@ def __new__(
2726
subcomponent_num=None,
2827
):
2928
"""Create a new instance of Accessor for *segment*. Index numbers start from 1."""
30-
return super(Accessor, cls).__new__(
29+
return super().__new__(
3130
cls,
3231
segment,
3332
segment_num,

hl7/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MLLPException(Exception):
1919
pass
2020

2121

22-
class MLLPClient(object):
22+
class MLLPClient:
2323
"""
2424
A basic, blocking, HL7 MLLP client based upon :py:mod:`socket`.
2525

hl7/containers.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import datetime
32
import logging
43

@@ -53,7 +52,7 @@ def __init__(
5352
# Initialize the list object, optionally passing in the
5453
# sequence. Since list([]) == [], using the default
5554
# parameter will not cause any issues.
56-
super(Container, self).__init__(sequence)
55+
super().__init__(sequence)
5756
self.separator = separator
5857
self.esc = esc
5958
self.separators = separators
@@ -125,7 +124,7 @@ def create_component(self, seq):
125124
def __getitem__(self, item):
126125
# Python slice operator was returning a regular list, not a
127126
# Container subclass
128-
sequence = super(Container, self).__getitem__(item)
127+
sequence = super().__getitem__(item)
129128
if isinstance(item, slice):
130129
return self.__class__(
131130
self.separator,
@@ -136,10 +135,6 @@ def __getitem__(self, item):
136135
)
137136
return sequence
138137

139-
def __getslice__(self, i, j):
140-
# Python 2.x compatibility. __getslice__ is deprecated, and
141-
# we want to wrap the logic from __getitem__ when handling slices
142-
return self.__getitem__(slice(i, j))
143138

144139
def __str__(self):
145140
return self.separator.join((str(x) for x in self))
@@ -158,7 +153,7 @@ def __init__(
158153
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
159154
):
160155
assert not separator or separator == separators[0]
161-
super(File, self).__init__(
156+
super().__init__(
162157
separator=separators[0],
163158
sequence=sequence,
164159
esc=esc,
@@ -226,11 +221,11 @@ def __str__(self):
226221
"Either both header and trailer must be present or neither"
227222
)
228223
return (
229-
super(File, self).__str__()
224+
super().__str__()
230225
if not self.header
231226
else str(self.header)
232227
+ self.separator
233-
+ super(File, self).__str__()
228+
+ super().__str__()
234229
+ str(self.trailer)
235230
+ self.separator
236231
)
@@ -249,7 +244,7 @@ def __init__(
249244
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
250245
):
251246
assert not separator or separator == separators[0]
252-
super(Batch, self).__init__(
247+
super().__init__(
253248
separator=separators[0],
254249
sequence=sequence,
255250
esc=esc,
@@ -317,11 +312,11 @@ def __str__(self):
317312
"Either both header and trailer must be present or neither"
318313
)
319314
return (
320-
super(Batch, self).__str__()
315+
super().__str__()
321316
if not self.header
322317
else str(self.header)
323318
+ self.separator
324-
+ super(Batch, self).__str__()
319+
+ super().__str__()
325320
+ str(self.trailer)
326321
+ self.separator
327322
)
@@ -332,7 +327,7 @@ def __init__(
332327
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
333328
):
334329
assert not separator or separator == separators[0]
335-
super(Message, self).__init__(
330+
super().__init__(
336331
separator=separators[0],
337332
sequence=sequence,
338333
esc=esc,
@@ -373,7 +368,7 @@ def __getitem__(self, key):
373368
return self.extract_field(*Accessor.parse_key(key))
374369
elif isinstance(key, Accessor):
375370
return self.extract_field(*key)
376-
return super(Message, self).__getitem__(key)
371+
return super().__getitem__(key)
377372

378373
def __setitem__(self, key, value):
379374
"""Index or accessor assignment.
@@ -396,7 +391,7 @@ def __setitem__(self, key, value):
396391
return self.assign_field(value, *Accessor.parse_key(key))
397392
elif isinstance(key, Accessor):
398393
return self.assign_field(value, *key)
399-
return super(Message, self).__setitem__(key, value)
394+
return super().__setitem__(key, value)
400395

401396
def segment(self, segment_id):
402397
"""Gets the first segment with the *segment_id* from the parsed
@@ -607,15 +602,15 @@ def __str__(self):
607602
"""
608603
# Per spec, Message Construction Rules, Section 2.6 (v2.8), Message ends
609604
# with the carriage return
610-
return super(Message, self).__str__() + self.separator
605+
return super().__str__() + self.separator
611606

612607

613608
class Segment(Container):
614609
def __init__(
615610
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
616611
):
617612
assert not separator or separator == separators[1]
618-
super(Segment, self).__init__(
613+
super().__init__(
619614
separator=separators[1],
620615
sequence=sequence,
621616
esc=esc,
@@ -774,15 +769,15 @@ def __str__(self):
774769
+ str(self[1])
775770
+ self.separator.join((str(x) for x in self[3:]))
776771
)
777-
return super(Segment, self).__str__()
772+
return super().__str__()
778773

779774

780775
class Field(Container):
781776
def __init__(
782777
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
783778
):
784779
assert not separator or separator == separators[2]
785-
super(Field, self).__init__(
780+
super().__init__(
786781
separator=separators[2],
787782
sequence=sequence,
788783
esc=esc,
@@ -801,7 +796,7 @@ def __init__(
801796
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
802797
):
803798
assert not separator or separator == separators[3]
804-
super(Repetition, self).__init__(
799+
super().__init__(
805800
separator=separators[3],
806801
sequence=sequence,
807802
esc=esc,
@@ -819,7 +814,7 @@ def __init__(
819814
self, separator=None, sequence=[], esc="\\", separators="\r|~^&", factory=None
820815
):
821816
assert not separator or separator == separators[4]
822-
super(Component, self).__init__(
817+
super().__init__(
823818
separator=separators[4],
824819
sequence=sequence,
825820
esc=esc,
@@ -832,7 +827,7 @@ def __init__(
832827
"""
833828

834829

835-
class Factory(object):
830+
class Factory:
836831
"""Factory used to create each type of Container.
837832
838833
A subclass can be used to create specialized subclasses of each container.

hl7/datatypes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import datetime
32
import math
43
import re

hl7/parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from string import whitespace
32

43
from .containers import Factory
@@ -380,7 +379,7 @@ def create_parse_plan(strmsg, factory=Factory):
380379
return _ParsePlan(separators[0], separators, containers, esc, factory)
381380

382381

383-
class _ParsePlan(object):
382+
class _ParsePlan:
384383
"""Details on how to parse an HL7 message. Typically this object
385384
should be created via :func:`hl7.create_parse_plan`
386385
"""

hl7/util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import datetime
32
import logging
43
import random
@@ -194,7 +193,7 @@ def unescape(container, field, app_map=None): # noqa: C901
194193
value = "".join(collecting)
195194
collecting = []
196195
if not value:
197-
logger.warn(
196+
logger.warning(
198197
"Error unescaping value [%s], empty sequence found at %d",
199198
field,
200199
offset,
@@ -219,15 +218,15 @@ def unescape(container, field, app_map=None): # noqa: C901
219218
value[0] == "C"
220219
): # Convert to new Single Byte character set : 2.10.2
221220
# Two HEX values, first value chooses the character set (ISO-IR), second gives the value
222-
logger.warn(
221+
logger.warning(
223222
"Error inline character sets [%s] not implemented, field [%s], offset [%s]",
224223
value,
225224
field,
226225
offset,
227226
)
228227
elif value[0] == "M": # Switch to new Multi Byte character set : 2.10.2
229228
# Three HEX values, first value chooses the character set (ISO-IR), rest give the value
230-
logger.warn(
229+
logger.warning(
231230
"Error inline character sets [%s] not implemented, field [%s], offset [%s]",
232231
value,
233232
field,

tests/samples.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# Sample message from HL7 Normative Edition
42
# http://healthinfo.med.dal.ca/hl7intro/CDA_R2_normativewebedition/help/v3guide/v3guide.htm#v3gexamples
53
sample_hl7 = "\r".join(

tests/test_accessor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from unittest import TestCase
32

43
from hl7 import Accessor, Field, Message, Segment

0 commit comments

Comments
 (0)