Skip to main content

Utility functions that cut across most qgofer projects

Project description

qgoferutils

Install

pip install qgoferutils

Or

conda install qgofer::qgoferutils

Available classes in qgoferutils are:

  • Configuration Module
from qgoferutils.config import QGoferConfig, create_config_table
  • Database Module
from qgoferutils.db import QGoferDBWrapper
  • Logger Module
from qgoferutils.logger import get_logger, get_log_path
  • Requests Module
from qgoferutils.requests import make_api_request, get_failed_response
  • Utility Functions Module
from qgoferutils import get_env_var, generate_uuid, init_path

Code Snippets or Examples

pip install qgoferutils
Requirement already satisfied: qgoferutils in c:\users\admi\miniconda3\envs\env4\lib\site-packages (0.0.7)
Requirement already satisfied: orjson in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from qgoferutils) (3.9.10)
Requirement already satisfied: requests in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from qgoferutils) (2.31.0)
Requirement already satisfied: aiofiles in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from qgoferutils) (22.1.0)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from requests->qgoferutils) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from requests->qgoferutils) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from requests->qgoferutils) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\admi\miniconda3\envs\env4\lib\site-packages (from requests->qgoferutils) (2024.2.2)
Note: you may need to restart the kernel to use updated packages.

Example 1: Configuring QGofer

from qgoferutils.config import QGoferConfig, create_config_table

# Create a QGoferConfig instance
config_instance = QGoferConfig()

# Accessing attributes of QGoferConfig
print("Home directory:", config_instance.home)
print("Root directory:", config_instance.root_dir)
2024-03-09 18:57:17,308 - qgofer - INFO - Logging to C:\Users\admi\.qgofer\logs/W87gwqBURyOma4QkPG6L2g_log_24_03_09_18_57_17.log
Home directory: C:\Users\admi
Root directory: C:\Users\admi

Example 2: Interacting with the Database

from qgoferutils.db import QGoferDBWrapper

# Initialize QGoferDBWrapper with a specific database path
db_wrapper = QGoferDBWrapper("C:/data/dbb")

Example 3: Logging in QGofer

from qgoferutils.logger import get_logger, get_log_path

# Get a logger with a specified log path
logger = get_logger("C:/data/db")
logger.debug("Debug message")

# Get the log path
log_path = get_log_path("")
print("Log path:", log_path)
2024-03-09 18:57:17,500 - qgofer - DEBUG - Debug message
Log path: C:\Users\admi\saf-app\qgofertext\nbs

Example 4: Making API Requests

!pip install nest_asyncio
import nest_asyncio
from qgoferutils.requests import make_api_request, get_failed_response

nest_asyncio.apply()

async def main():
    # Make an API request to https://httpbin.org/get asynchronously
    api_url = "https://httpbin.org/get"
    response = await make_api_request(api_url)
    print("API Response:", response)

# Run the event loop
asyncio.run(main())
API Response: <Response [200]>

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

qgoferutils-0.0.8.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

qgoferutils-0.0.8-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file qgoferutils-0.0.8.tar.gz.

File metadata

  • Download URL: qgoferutils-0.0.8.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for qgoferutils-0.0.8.tar.gz
Algorithm Hash digest
SHA256 64055517e3a468f30ebcff3d2ec75a37e4e3f0d93ee19facae372fb8eee21805
MD5 11afe208eed13f496bb78c28074fc979
BLAKE2b-256 bec2d10fdad06eb27f30040add6f6a20db976828af92927fe2530ab20489a50e

See more details on using hashes here.

File details

Details for the file qgoferutils-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: qgoferutils-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.18

File hashes

Hashes for qgoferutils-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a732517fb665f41135ac48d1e3a338e6c473e8fedb948d8f226592f9c573d4b3
MD5 80b8af89dec4d3a39c04635982eb9739
BLAKE2b-256 062587acd2b2ccb16a6455c3ff3ecb95131b1e3e5e0966010a2465cfde781d8f

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