Hi, pretty basic stuff. I found some TypeErrors (code smell) from improper usage of your from_file function. Oddly enough, it looks like you're not type-checking your arguments. And essentially this creates downstream problems with your functions that depend on name being properly instantiated.
>>>from kpal.klib import Profile
>>>p=Profile.from_file("./my_sample.k12")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/.venv/lib/python2.7/site-packages/kpal/klib.py", line 74, in from_file
name = name or sorted(handle['profiles'].keys())[0]
TypeError: string indices must be integers, not unicode
>>>p=Profile.from_file(open("./my_sample.k12",'r'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path/to/.venv/lib/python2.7/site-packages/kpal/klib.py", line 75, in from_file
counts = handle["profiles/" + name][:]
TypeError: 'file' object has no attribute '__getitem__'
So, first off, the TypeErrors and then It'd be nice if the documentation were expanded to include something this simple:
Hi, pretty basic stuff. I found some TypeErrors (code smell) from improper usage of your
from_file
function. Oddly enough, it looks like you're not type-checking your arguments. And essentially this creates downstream problems with your functions that depend onname
being properly instantiated.So, first off, the TypeErrors and then It'd be nice if the documentation were expanded to include something this simple: