{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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48f63b14c1e7bd0ab6462f3798829b3a29645eeb68187695854087f0e1f0d6e6
|
|
| MD5 |
be44b720f3f2fa43519f3e5193100438
|
|
| BLAKE2b-256 |
f2495d11c5293fc22ee0727d065477233eaef2e7dff7a0d52aa664f0be6a1dac
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d828283b9f17b0c40dae8f7116f65c10f6c5e6e50f834ea58e2d0018c6ea489c
|
|
| MD5 |
a0de41735af56a016ff72eb5537f54f8
|
|
| BLAKE2b-256 |
1e268cffac9cd24c3b12df5b9e45877100718a6a145542ab41f53b4504505a6b
|