Skip to content

Commit 65229c9

Browse files
committed
restore Python3.5 support
1 parent 983bb89 commit 65229c9

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: python
22
python:
3-
- "3.6"
3+
- "3.5"
4+
- "3.8"
45
install:
56
- python setup.py bdist_wheel
67
- pip install dist/iso_20275-*.whl

iso20275/__init__.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,28 @@
22
import os
33
import re
44
import pathlib
5+
import collections
56

67
__version__ = 0, 0, 5
78
__all__ = 'Elf', 'OriginalElf',
89

910

10-
class ElfEntry:
11+
class OrderedProperties(type):
12+
"metaclass for custom ordered properties access on Python 3.5 and earlier"
13+
14+
@classmethod
15+
def __prepare__(mcs, name, bases):
16+
"provide order-keeping support"
17+
return collections.OrderedDict()
18+
19+
def __new__(cls, name, bases, classdict):
20+
"inject a custom __properties__ magic method"
21+
customclass = type.__new__(cls, name, bases, classdict)
22+
customclass.__properties__ = tuple(k for k,v in classdict.items() if isinstance(v, property))
23+
return customclass
24+
25+
26+
class ElfEntry(metaclass=OrderedProperties):
1127
def __init__(self, data):
1228
self.__data = data
1329

@@ -75,9 +91,6 @@ def modification_date(self):
7591
def reason(self):
7692
return self._ElfEntry__data['reason']
7793

78-
@classmethod
79-
def labels(cls):
80-
return tuple((k for k, v in cls.__dict__.items() if isinstance(v, property)))
8194

8295
def __str__(self):
8396
return self.elf + ': ' + self.local_name
@@ -104,7 +117,7 @@ def __len__(self):
104117
def read_from_csv(filepath:pathlib.Path, sep=','):
105118
"read CSV file at a given path"
106119
table = {}
107-
columns = ElfEntry.labels()
120+
columns = ElfEntry.__properties__
108121
with filepath.open('r', encoding='utf-8') as csvfile:
109122
next(csvfile)
110123
spamreader = csv.reader(csvfile, delimiter=',', quotechar='"', strict=True)

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ def get_install_requirements():
4343
'Intended Audience :: Developers',
4444
'License :: OSI Approved :: MIT License',
4545
'Operating System :: OS Independent',
46+
'Programming Language :: Python :: 3.5',
4647
'Programming Language :: Python :: 3.6',
4748
'Programming Language :: Python :: 3.7',
49+
'Programming Language :: Python :: 3.8',
4850
'Programming Language :: Python :: Implementation :: CPython',
4951
'Programming Language :: Python :: Implementation :: PyPy',
5052
'Programming Language :: Python :: Implementation :: Stackless',

0 commit comments

Comments
 (0)