Skip to main content

{description}

Project description

oswhich

This package allows for cross-platform implementations on-the-go with a very sugary decorator syntax. It works also for classes, its methods and properties. Although, development is still incipient so feel free to open an issue on the bug tracker.

Examples

from oswhich import linux, macosx, windows, solaris

@linux
def f(x):
    return 2 * x

@macosx
def f(x):
    return x ** 2

@windows
def f(x):
    return x + 2

>>> f(3) # in Linux
6
>>> f(3) # in MacOSx
9
>>> f(3) # in Windows
5
>>> f(3) # in Solaris
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Sorry, function `f` was not implemented for your platform. 

Advanced usage

You may define your own definition selector. Internally, OsWhich relies on platform.system() to select current platform. If OsWhich.__init__ takes a string as parameter, it just compares it with platform.system()'s output. If you pass a callable to the constructor, you are allowed to do whatever you want, as long as this function follows the signature foo(system: str) -> bool.

from oswhich import OsWhich

mysystem = OsWhich(foo)

@mysystem
def f(x):
    return -x

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oswhich-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oswhich-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file oswhich-0.1.0.tar.gz.

File metadata

  • Download URL: oswhich-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for oswhich-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48f63b14c1e7bd0ab6462f3798829b3a29645eeb68187695854087f0e1f0d6e6
MD5 be44b720f3f2fa43519f3e5193100438
BLAKE2b-256 f2495d11c5293fc22ee0727d065477233eaef2e7dff7a0d52aa664f0be6a1dac

See more details on using hashes here.

File details

Details for the file oswhich-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oswhich-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for oswhich-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d828283b9f17b0c40dae8f7116f65c10f6c5e6e50f834ea58e2d0018c6ea489c
MD5 a0de41735af56a016ff72eb5537f54f8
BLAKE2b-256 1e268cffac9cd24c3b12df5b9e45877100718a6a145542ab41f53b4504505a6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page