-
Notifications
You must be signed in to change notification settings - Fork 257
Fixes #220 for platforms that do not support typing #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# SPDX-FileCopyrightText: 2022 Chris Wilson <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
""" | ||
`adafruit_platformdetect.protocols` | ||
================================================================================ | ||
|
||
Protocol definitions | ||
|
||
* Author(s): Chris Wilson | ||
|
||
Implementation Notes | ||
-------------------- | ||
|
||
**Software and Dependencies:** | ||
|
||
* Linux and Python 3.7 or Higher | ||
|
||
""" | ||
|
||
from typing import Optional | ||
|
||
# Protocol was introduced in Python 3.8. | ||
try: | ||
from typing import Protocol | ||
except ImportError: | ||
from typing_extensions import Protocol | ||
|
||
|
||
class DetectorProtocol(Protocol): | ||
"""Wrap various platform detection functions.""" | ||
|
||
def get_cpuinfo_field(self, field: str) -> Optional[str]: | ||
""" | ||
Search /proc/cpuinfo for a field and return its value, if found, | ||
otherwise None. | ||
""" | ||
... | ||
|
||
def check_dt_compatible_value(self, value: str) -> bool: | ||
""" | ||
Search /proc/device-tree/compatible for a value and return True, if found, | ||
otherwise False. | ||
""" | ||
... | ||
|
||
def get_armbian_release_field(self, field: str) -> Optional[str]: | ||
""" | ||
Search /etc/armbian-release, if it exists, for a field and return its | ||
value, if found, otherwise None. | ||
""" | ||
... | ||
|
||
def get_device_model(self) -> Optional[str]: | ||
""" | ||
Search /proc/device-tree/model for the device model and return its value, if found, | ||
otherwise None. | ||
""" | ||
... | ||
|
||
def get_device_compatible(self) -> Optional[str]: | ||
""" | ||
Search /proc/device-tree/compatible for the compatible chip name. | ||
""" | ||
... | ||
|
||
def check_board_asset_tag_value(self) -> Optional[str]: | ||
""" | ||
Search /sys/devices/virtual/dmi/id for the device model and return its value, if found, | ||
otherwise None. | ||
""" | ||
... | ||
|
||
def check_board_name_value(self) -> Optional[str]: | ||
""" | ||
Search /sys/devices/virtual/dmi/id for the board name and return its value, if found, | ||
otherwise None. Debian/ubuntu based | ||
""" | ||
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2022 Chris Wilson <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
typing_extensions; python_version <= '3.7' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,12 @@ | |
description="Platform detection for use by libraries like Adafruit-Blinka.", | ||
long_description=long_description, | ||
long_description_content_type="text/x-rst", | ||
python_requires=">=3.6.0", | ||
python_requires=">=3.7.0", | ||
url="https://github.com/adafruit/Adafruit_Python_PlatformDetect", | ||
# If your package is a single module, use this instead of 'packages': | ||
author="Adafruit Industries", | ||
author_email="[email protected]", | ||
install_requires=[], | ||
install_requires=["typing_extensions; python_version <= '3.7'"], | ||
# Choose your license | ||
license="MIT", | ||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
|
@@ -44,7 +44,7 @@ | |
"Topic :: System :: Hardware", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
], | ||
packages=["adafruit_platformdetect", "adafruit_platformdetect.constants"], | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dhalbert or @makermelissa can you give me some context as to why these lines are included in
__init__.py
,board.py
, andchip.py
(vs. just having it in__init__.py
)? Just wondering if these should be added to any new files I add (likeprotocols.py
that I added in this draft)