Skip to content

Commit

Permalink
Add humanfriendly.compat.on_macos()
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Dec 10, 2020
1 parent 44cbc41 commit 1abbe85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -11,6 +11,15 @@ Changelog`_. This project adheres to `semantic versioning`_.
.. _Keep a Changelog: http://keepachangelog.com/
.. _semantic versioning: http://semver.org/

`Release 9.1`_ (2020-12-10)
---------------------------

Added :func:`~humanfriendly.compat.on_macos()` function to detect Apple MacOS
(I need this in an upcoming :pypi:`coloredlogs` release and don't want to have
to think about how to detect MacOS again in the future 😇).

.. _Release 9.1: https://github.com/xolox/python-humanfriendly/compare/9.0...9.1

`Release 9.0`_ (2020-12-01)
---------------------------

Expand Down
4 changes: 2 additions & 2 deletions humanfriendly/__init__.py
@@ -1,7 +1,7 @@
# Human friendly input/output in Python.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: December 1, 2020
# Last Change: December 10, 2020
# URL: https://humanfriendly.readthedocs.io

"""The main module of the `humanfriendly` package."""
Expand Down Expand Up @@ -51,7 +51,7 @@
)

# Semi-standard module versioning.
__version__ = '9.0'
__version__ = '9.1'

# Named tuples to define units of size.
SizeUnit = collections.namedtuple('SizeUnit', 'divider, symbol, name')
Expand Down
12 changes: 11 additions & 1 deletion humanfriendly/compat.py
@@ -1,7 +1,7 @@
# Human friendly input/output in Python.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: March 1, 2020
# Last Change: December 10, 2020
# URL: https://humanfriendly.readthedocs.io

"""
Expand Down Expand Up @@ -52,6 +52,7 @@
'is_unicode',
'monotonic',
'name2codepoint',
'on_macos',
'on_windows',
'unichr',
'unicode',
Expand Down Expand Up @@ -132,6 +133,15 @@ def is_unicode(value):
return isinstance(value, unicode)


def on_macos():
"""
Check if we're running on Apple MacOS.
:returns: :data:`True` if running MacOS, :data:`False` otherwise.
"""
return sys.platform.startswith('darwin')


def on_windows():
"""
Check if we're running on the Microsoft Windows OS.
Expand Down

0 comments on commit 1abbe85

Please sign in to comment.