Skip to content

[Feature] refactor scripts to put shared code in a shared library #91

Closed
@TimidRobot

Description

@TimidRobot

Problem

put shared code in a shared library

Description

Potential new shared module:

# Standard library
import datetime
import os.path


def setup():
    # Datetime
    datetime_today = datetime.datetime.today()

    # Paths
    path_work_dir = os.path.dirname(
        os.path.abspath(os.path.realpath(__file__))
    )
    path_repo_root = os.path.dirname(
        os.path.abspath(os.path.realpath(path_work_dir))
    )
    path_dotenv = os.path.abspath(
        os.path.realpath(os.path.join(path_work_dir, ".env"))
    )
    return path_repo_root, path_work_dir, path_dotenv, datetime_today

used in scripts (assumes above is named quantify):

# First-party/Local
import quantify

# ...

PATH_REPO_ROOT, PATH_WORK_DIR, PATH_DOTENV, DATETIME_TODAY = quantify.setup()
load_dotenv(PATH_DOTENV)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions