Metadata-Version: 2.1
Name: WebScriptsTools
Version: 0.0.2
Summary: This package implements tools for WebScripts Scripts.
Home-page: https://github.com/mauricelambert/WebScriptsTools
Author: Maurice Lambert
Author-email: mauricelambert434@gmail.com
Maintainer: Maurice Lambert
Maintainer-email: mauricelambert434@gmail.com
License: GPL-3.0 License
Project-URL: Documentation, https://mauricelambert.github.io/info/python/code/WebScriptsTools.html
Keywords: WebScripts,Tools
Platform: Windows
Platform: Linux
Platform: MacOS
Classifier: Programming Language :: Python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE.txt

![WebScripts Logo](https://mauricelambert.github.io/info/python/code/WebScripts/small_logo.png "WebScripts logo")

# WebScriptsTools

## Description

This package implements tools for WebScripts Scripts.

## Requirements

This package require:

 - python3
 - python3 Standard Library

## Installation

```bash
pip install WebScriptsTools
```

## Usages

### Command line

#### Module

```bash
# These command lines should be launch in a WebScripts Scripts Environment !

python3 -m WebScriptsTools
python3 -m WebScriptsTools get_log_file
python3 -m WebScriptsTools get_webscripts_data_path
```

If you run these command lines outside the WebScripts scripting environment, you get this error:
```text
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
```

Example of usage in a script bash:
```bash
logfile=$(python3 -m WebScriptsTools get_log_file)
echo "DEBUG: Get log file from WebScriptsTools" > "${logfile}"
cat "$(python3 -m WebScriptsTools get_webscripts_data_path)/datafile.txt"
echo "INFO: print data using WebScripts data directory" > "${logfile}"
```

### Python script

```python
# To use this module you should be in a WebScripts Scripts Environment

from WebScriptsTools import *

set_excepthook() # manage exceptions without printing sensible informations

# Get the upload module, to read, delete or write a shared file
upload = get_upload_module()
upload.get_file("my_webscripts_shared_file.txt")

# Use the data path to change databases
with open(f"{get_webscripts_data_path()}/datafile.txt") as datafile:
    print(datafile.read())

# Get the log file to configure your logger or read your logs
logs = open(get_log_file())
log = logs.readline()
while log:
    print(log)
    log = logs.readline()

# Get the user to check permission or get informations like ID or name
user = get_user()
print(f"You are named '{user['name']}' here !")
```

## Links

 - [Github Page](https://github.com/mauricelambert/WebScriptsTools/)
 - [Documentation](https://mauricelambert.github.io/info/python/code/WebScriptsTools.html)
 - [Pypi package](https://pypi.org/project/WebScriptsTools/)

## Licence

Licensed under the [GPL, version 3](https://www.gnu.org/licenses/).


