Source code for pykern.pkplatform

# -*- coding: utf-8 -*-
u"""Wrapper for Python's :mod:`platform` to provide cleaner programmatic
control of system features.

:copyright: Copyright (c) 2015 Bivio Software, Inc.  All Rights Reserved.
from __future__ import absolute_import, division, print_function

import platform
import re
import sys

[docs]def is_darwin(): """All flavors of Mac (OS X) Returns: bool: True if :attr:`sys.platform` is Mac. """ return sys.platform.startswith('darwin')
[docs]def is_linux(): """All flavors of linux Returns: bool: True if :attr:`sys.platform` is Linux. """ return sys.platform.startswith('linux')
[docs]def is_unix(): """All flavors of Unix. Currently, it's darwin, linux, cygwin, freebsd, netbsd, sunos, solaris, unixware, irix, aix, and next. Returns: bool: True if :attr:`sys.platform` is a pure Unix system (e.g. not beos) """ return re.match(r'aix|cygwin|darwin|freebsd|irix|linux|netbsd|solaris|sunos|unix', sys.platform) is not None
[docs]def is_windows(): """All flavors of Windows (32, 64, cygwin, etc.). If your program expects a unix flavor, you will want :func:`is_unix`. Returns: bool: True if :attr:`sys.platform` is ``win32`` or ``cygwin`` """ return re.match(r'win|cygwin', sys.platform) is not None