Open kaanaksit opened 5 years ago
The class being imported is the dlpc
class, which you're right should follow the UpperCaseCamelCase convention.
I am able to use pycrafter4500 in an Ubuntu 18.04 system using Python 3 only when it is uppercase.
That's really curious. I'm not sure why the case of the class name would cause it stop working.
To reproduce the error, I replace D
wioth d
in __init__.py
found in /usr/local/lib/python3.6/dist-packages/pycrafter4500
. This is what I get with a small letter:
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycrafter4500
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pycrafter4500/__init__.py", line 3, in <module>
from .pycrafter4500 import dlpc350, pattern_mode, video_mode, power_down, power_up
ImportError: cannot import name 'dlpc350'
I never tested the library on Ubuntu, but I just tried it again on Windows and couldn't replicate the issue:
(pycrafter) C:\Users\tomlinsa\PycharmProjects\xlsx_to_csv>python
Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 18:50:55) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycrafter4500
>>>
I believe this is because of the nature of Windows. It doesn't care about a capital letter or a small letter, and maps it the same. Though, it is not the right convention as two letters map to different values in every computer.
In pyCrafter4500/pycrafter4500.py:93
, the class is named with a lowercase: class dlpc350(object):
, so it needs to be imported similarly in the __init__.py
.
You are right. I see what is going on here. I think last time I cloned pylightcrafter4500, I cloned a fork rather than the original.
And now I remember why I did that as well. Since I am on a Linux
machine, the problem that I encountered earlier required some of the additions at the fork. So that pyusb
won't raise a device busy error.
In this case, the import name is probably fine. However, if you want Linux
to be supported, some additions are required at the time of initialization of the device.
So if you want me to add these additions, I can do so. If yes, what is the proper way for me to help you? Should I first fork and edit and merge afterwards?
Yeah that would be best. Thank you for contributing! I'll merge a PR if that works for you.
Third line in init.py, Doesn't it has to be changed from this:
from .pycrafter4500 import dlpc350, pattern_mode, video_mode, power_down, power_up
to this:
from .pycrafter4500 import Dlpc350, pattern_mode, video_mode, power_down, power_up