Skip to main content

Python support functions package

Project description

skylynx

Status

Build Status

Python support functions module

Only Python 3


Version 0.0.4

skylynx

import skylynx
print('skylynx', skylynx.__version__)

>> skylynx 0.0.2

skylynx.utils

JSON

Write
import skylynx.utils as su

data_dict = dict(
    a=123,
    b='skylynx'
)
su.json_write('example.json', data_dict)
{
  "a": 123,
  "b": "skylynx"
}
Read
data = su.json_read('example.json')
print(data)

>> {'a': 123, 'b': 'skylynx'}

YAML

Write
su.yaml_write('example.yaml', data_dict)
a: 123
b: skylynx
Read
data = su.yaml_read('example.yaml')
print(data)

>> {'a': 123, 'b': 'skylynx'}

Pretty Print

data_dict = dict(
    a='This print a python dict object in a human readable form.',
    b=456,
    c=dict(
        d=123,
        e='skylynx'
    ),
    f = ['abc', 123]
)
su.pprint(data_dict, '> Header <')
======================== > Header < ========================
a: This print a python dict object in a human readable form.
b: 456
c:
  d: 123
  e: skylynx
f: ['abc', 123]
------------------------------------------------------------

Make Directories

path = 'path/to/the/folder/'
su.makedirs(path)
print(os.path.exists(path))

>> True

Simple command line arguments

Add the following code to example.py

from skylynx.utils import cli_args

if __name__ == "__main__":

  cli_params = dict(task=0,
                    length=10
                    )

  args = cli_args(cli_params)
  task = args['task']
  length = args['length']

How to use

python example.py -h
usage: test.py [-h] [-a A] [-b B]

*** Simple cli args - by Skylynx ***

optional arguments:
  -h, --help  show this help message and exit
  -a A        task (default: 0)
  -b B        length (default: 10)
python example.py -a <task value> -b <length value>

clog

Normal use

from skylynx.utils import clog

clog('Hello')

alt text

Debug Levels

clog('Hello', verbose='DEBUG')
clog('Hello', verbose='INFO')
clog('Hello', verbose='WARNING')
clog('Hello', verbose='ERROR')
clog('Hello', verbose='CRITICAL')

alt text

Colors

clog('Hello', verbose='RED')
clog('Hello', verbose='GREEN')
clog('Hello', verbose='YELLOW')
clog('Hello', verbose='BLUE')
clog('Hello', verbose='MAGENTA')
clog('Hello', verbose='CYAN')

alt text

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

skylynx-0.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

skylynx-0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file skylynx-0.1.tar.gz.

File metadata

  • Download URL: skylynx-0.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for skylynx-0.1.tar.gz
Algorithm Hash digest
SHA256 02769da607c3f0267c04c00425d117324e16fbdf7a3e57cf85f179c88c8ebc8a
MD5 f222ec8711675e17796bdcf328bfc52c
BLAKE2b-256 0746f52c222bcaa30d9422b11686aab4e0d27707b69a78dbce675c6520e86cca

See more details on using hashes here.

File details

Details for the file skylynx-0.1-py3-none-any.whl.

File metadata

  • Download URL: skylynx-0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for skylynx-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00feaaf2e1857b26d54731b152bf285c9fd01767e2d79aa4c7b540160a73c1a5
MD5 d56ed1f2107635d6dd953f29942300a5
BLAKE2b-256 eb835ff5e3bf2f8c1a75ed8e556268319fe26e72e446cae731aef0606422ac42

See more details on using hashes here.

Supported by

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