Decorator to return a default value for a function when offline
Project description
## Decorator to return a default value for a function when offline
Decorate your functions with a default value and set OfflineSandbox.SANDBOX to your Online/Offline status
```
import OfflineSandbox
OfflineSandbox.SANDBOX = False
@OfflineSandbox.offline_sandbox_value('mundo')
def greet():
return 'hola'
print(greet())
OfflineSandbox.SANDBOX = True
print(greet())
```
You can also respond given the availability of a specific URL
```
@OfflineSandbox.offline_sandbox_value('mundo', url='https://im-online.herokuapp.com/')
def greet_with_url():
return 'hola'
print(greet_with_url())
```
Decorate your functions with a default value and set OfflineSandbox.SANDBOX to your Online/Offline status
```
import OfflineSandbox
OfflineSandbox.SANDBOX = False
@OfflineSandbox.offline_sandbox_value('mundo')
def greet():
return 'hola'
print(greet())
OfflineSandbox.SANDBOX = True
print(greet())
```
You can also respond given the availability of a specific URL
```
@OfflineSandbox.offline_sandbox_value('mundo', url='https://im-online.herokuapp.com/')
def greet_with_url():
return 'hola'
print(greet_with_url())
```
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
offline_sandbox-1.tar.gz
(1.6 kB
view hashes)
Built Distributions
Close
Hashes for offline_sandbox-1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4ede388b32b3e85ea6b7e68c69ec35742177d86baf01081a1b54e929edc18a |
|
MD5 | b9d96997fd25ff682cf9ade155083109 |
|
BLAKE2b-256 | e0723957adb18e1ac9f4c828de857debf0b710c74e15e663c6afef2145c589f0 |
Close
Hashes for offline_sandbox-1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31294a573b5bee7360e14a60812437c3e020cb23d3b97f45a27dd082d36db29 |
|
MD5 | dab65ff936eacb8b388994dc716a423c |
|
BLAKE2b-256 | ec5ac8c463a985886afa23cb198c2a939261b8edbfa9dff4541da194ee36ff3f |