New: normal arg parsing

This commit is contained in:
L-Nafaryus 2021-07-14 23:30:50 +05:00
parent 4f528318da
commit 2a8742cfc2
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
4 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#from anisotropy import Anisotropy

20
anisotropy/__main__.py Normal file
View File

@ -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()

View File

@ -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
##