Skip to main content

sam_pytools is a collection of Python utilities that provide commonly used functions, so we do not need to write

Project description

PY Tools

sam_pytools is a collection of Python utilities that provide commonly used functions for handling dates, HTTP requests, JSON manipulation, logging, and more. These tools help streamline various tasks in Python projects.

Installation

pip install samPytools

Available Modules

GlobalValues: Manages global values like home and log directories.
CoreUtils: Contains utility methods for general operations 
like downloading images, decoding bytes, generating unique IDs, etc.
DateUtils: Provides date manipulation functions, 
including time difference calculations and interval additions.
HttpUtils: Offers HTTP helper methods for GET and POST requests.
JsonUtils: Contains JSON helper functions, like converting dictionaries to objects.
LogUtils: Manages logging and error handling.
AsyncUtils: Enables asynchronous execution of given tasks with asyncio or ThreadPoolExecutor.

pip install sam_pytools

Special features

For easier and clean error tracing

LogUtils.getErrorMessage() is the one that can make life easier

Another is AsyncUtils

    from sam_tools import AsyncUtils

      def task1():
          time.sleep(2)
          return 'task1 finished ' + DateUtils.now_str()
      
      def task2(par1):
          time.sleep(3)
          return f'task2 finished {DateUtils.now_str()}, received params => {par1}'
      
      def task3(par1, par2):
          time.sleep(1)
          return f'task3 finished {DateUtils.now_str()}, received params => {par1},{par2}'

      task_list = [(task1, []), (task2, [1]), (task3, [1, 2])]
      #Execute tasks asynchronously
      print(f'Tasks reached at {DateUtils.now_str()}')
      AsyncUtils.execute_tasks_with_no_wait(task_list)
      print(f'Tasks started at {DateUtils.now_str()}')

General about pip

If you want to reset your testing virtual environment

pip freeze | xargs pip uninstall -y

then to install your requirements

pip install -r requirements.txt

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

sam_pytools-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

sam_pytools-0.1.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sam_pytools-0.1.3.tar.gz.

File metadata

  • Download URL: sam_pytools-0.1.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for sam_pytools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 af43f0ce8b023a834e03f870c80e5c7094c8f980b555f3066fb2532552ca7d45
MD5 5cddb02195f7f8359dde7df02832e68e
BLAKE2b-256 9d55ba0909dfe7a5bfde792e663c6871efc22384f576f868263086d841db8d8d

See more details on using hashes here.

File details

Details for the file sam_pytools-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: sam_pytools-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for sam_pytools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 99bdbd56c6968d9a56618739d233b1bbb5c824cd93b9dbf87761bcd894f16d78
MD5 25b6b8104f570c72346973fb28c7a67a
BLAKE2b-256 2aa4fa3fc5b2319fc08b9730ac64ab90534c1fea6fafcd3d8eb2895c8fa21c5c

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