diff --git a/anisotropy/__init__.py b/anisotropy/__init__.py index e69de29..3c36a1f 100644 --- a/anisotropy/__init__.py +++ b/anisotropy/__init__.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +#from anisotropy import Anisotropy diff --git a/anisotropy/__main__.py b/anisotropy/__main__.py new file mode 100644 index 0000000..925e065 --- /dev/null +++ b/anisotropy/__main__.py @@ -0,0 +1,20 @@ +import click +from anisotropy.anisotropy import Anisotropy + +pass_anisotropy = click.make_pass_decorator(Anisotropy) + +@click.group() +@click.version_option(version = "", message = Anisotropy.version()) +@click.pass_context +def anisotropy(ctx): + ctx.obj = Anisotropy() + + +@anisotropy.command() +@click.option("-s", "--stage", "stage", type = click.Choice(["all", "mesh", "flow"]), default = "all") +@click.option("-p", "--param", "params", metavar = "key=value", multiple = True) +@pass_anisotropy +def compute(anisotropy, stage, params): + pass + +anisotropy() diff --git a/anisotropy/anisotropy.py b/anisotropy/anisotropy.py index a2e3956..478a325 100644 --- a/anisotropy/anisotropy.py +++ b/anisotropy/anisotropy.py @@ -6,10 +6,11 @@ import shutil ROOT = "/".join(__file__.split("/")[:-2]) sys.path.append(os.path.abspath(ROOT)) -from utils import struct +from anisotropy.utils import struct import toml import logging +__version__ = "1.1" ### # Shell args ## @@ -50,6 +51,38 @@ logging.basicConfig( ) logger = logging.getLogger(config.logger.name) + +class Anisotropy(object): + def __init__(self): + #self.db = self.setupDB() + pass + + @staticmethod + def version(): + versions = { + "anisotropy": __version__, + "Python": sys.version.split(" ")[0], + "Salome": "[missed]", + "OpenFOAM": "[missed]" + } + + try: + salomeplVersion = salomeVersion() + openfoamVersion = openfoam.foamVersion() + + except Exception: + pass + + return "\n".join([ f"{ k }: { v }" for k, v in versions.items() ]) + + @staticmethod + def setupDB(): + db.init(env["db_path"]) + + if not os.path.exists(env["db_path"]): + db.create_tables([Structures, Mesh]) + + return db ### # Main ## diff --git a/anisotropy/db.py b/anisotropy/models.py similarity index 100% rename from anisotropy/db.py rename to anisotropy/models.py