Docstrings for mapid.py

This commit is contained in:
Malte Bublitz 2023-10-26 15:32:53 +02:00
parent c4f3d29be0
commit 23195805be
Signed by: malte70
GPG key ID: 605DA5C729F9C184

View file

@ -1,3 +1,8 @@
"""MAPID utility library.
This module contains an utility class to control MAPID/CP using pyserial.
"""
import os import os
import time import time
import dotenv # import dotenv #
@ -5,8 +10,15 @@ import serial
DOTENV_LOADED = False DOTENV_LOADED = False
"""bool: Is .env loaded?
Prevents loading .env multiple times for speed.
"""
def load_dotenv(): def load_dotenv():
"""Load .env file
"""
basedir = os.path.abspath(os.path.dirname(__file__)) basedir = os.path.abspath(os.path.dirname(__file__))
dotenv.load_dotenv(os.path.join(basedir, ".env")) dotenv.load_dotenv(os.path.join(basedir, ".env"))
global DOTENV_LOADED global DOTENV_LOADED
@ -14,6 +26,12 @@ def load_dotenv():
def get_serial_dev(): def get_serial_dev():
"""Get SERIAL_DEV setting from dotenv.
Returns:
str: The device file.
"""
global DOTENV_LOADED global DOTENV_LOADED
if not DOTENV_LOADED: if not DOTENV_LOADED:
load_dotenv() load_dotenv()
@ -21,6 +39,12 @@ def get_serial_dev():
def get_serial_speed(): def get_serial_speed():
"""Get SERIAL_SPEED setting from dotenv.
Returns:
int: Serial speed in baud.
"""
global DOTENV_LOADED global DOTENV_LOADED
if not DOTENV_LOADED: if not DOTENV_LOADED:
load_dotenv() load_dotenv()