]> Nutra Git (v1) - nutratech/cli.git/commitdiff
fix production issue, reorganize & shrink tarball 5/head
authorShane Jaroch <chown_tee@proton.me>
Tue, 12 Jul 2022 19:19:23 +0000 (15:19 -0400)
committerShane Jaroch <chown_tee@proton.me>
Tue, 12 Jul 2022 21:58:07 +0000 (17:58 -0400)
exclude 2nd LICENSE in ntclient/ntsqlite from pypi

move nt_init out of main services call

bump version

move changelog back up, reduce tarball size

fix: NTSQLITE_DESTINATION is not defined

bump to release version

CHANGELOG.rst [moved from ntclient/CHANGELOG.rst with 100% similarity]
MANIFEST.in
ntclient/__init__.py
ntclient/ntsqlite
ntclient/persistence/sql/nt/__init__.py
ntclient/services/__init__.py
requirements-lint.txt

similarity index 100%
rename from ntclient/CHANGELOG.rst
rename to CHANGELOG.rst
index 1345ae8acd7209b152dd132ce9656b5419e7fbbe..58ecfc5a19405ed27fbb367113011e9cdd28d742 100644 (file)
@@ -1,16 +1,8 @@
 include requirements.txt
 include requirements-*.txt
 
-include ntclient/LICENSE
-include ntclient/CHANGELOG.rst
-
-include ntclient/ntsqlite/LICENSE
-include ntclient/ntsqlite/README.rst
-include ntclient/ntsqlite/CHANGELOG.rst
 include ntclient/ntsqlite/sql/*.sql
 include ntclient/ntsqlite/sql/data/*.csv
 include ntclient/ntsqlite/sql/upgrade_scripts/*.sql
 
 global-exclude nt.sqlite3
-
-global-exclude __pycache__/*
index 57717f85596c28c9be816a524e96589a42633416..9f234f2057b69547749b5d38a7f5cb4479caad8e 100755 (executable)
@@ -35,7 +35,7 @@ from ntclient.ntsqlite.sql import NT_DB_NAME
 
 # Package info
 __title__ = "nutra"
-__version__ = "0.2.3"
+__version__ = "0.2.4"
 __author__ = "Shane Jaroch"
 __email__ = "chown_tee@proton.me"
 __license__ = "GPL v3"
index 4f9eec211c1073f093411f15e29cb2347534e7cd..47c6db2a418db690ba1b8e407756240ec2f296f3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4f9eec211c1073f093411f15e29cb2347534e7cd
+Subproject commit 47c6db2a418db690ba1b8e407756240ec2f296f3
index cc1e75043e9741aaec6ca5040c2ff5e41f944a79..5300f1d811b1f8117f9141df9d93d3aa19fa8ee2 100644 (file)
@@ -2,11 +2,60 @@
 import os
 import sqlite3
 
-from ntclient import NT_DB_NAME, NUTRA_DIR, __db_target_nt__
+from ntclient import (
+    NT_DB_NAME,
+    NTSQLITE_BUILDPATH,
+    NTSQLITE_DESTINATION,
+    NUTRA_DIR,
+    __db_target_nt__,
+)
 from ntclient.persistence.sql import _sql, _sql_headers, version
 from ntclient.utils.exceptions import SqlConnectError, SqlInvalidVersionError
 
 
+def nt_ver() -> str:
+    """Gets version string for nt.sqlite3 database"""
+    con = nt_sqlite_connect(version_check=False)
+    return version(con)
+
+
+def nt_init() -> None:
+    """
+    Similar to usda_init(). This builds the nt.sqlite3 image, and copies into ~/.nutra
+    """
+
+    # TODO: don't overwrite,
+    #  verbose toggle for download,
+    #  option to upgrade
+    if os.path.isfile(NTSQLITE_DESTINATION):
+        if nt_ver() != __db_target_nt__:
+            # TODO: hard requirement? raise error?
+            print(
+                "WARN: upgrades/downgrades not supported "
+                + "(actual: {0} vs. target: {1}), ".format(nt_ver(), __db_target_nt__)
+                + "please remove `~/.nutra/nt.sqlite3` file or ignore this warning"
+            )
+        print("..DONE!")
+        os.remove(NTSQLITE_BUILDPATH)  # clean up
+    else:
+        # TODO: is this logic (and these error messages) the best?
+        #  what if .isdir() == True ? Fails with stacktrace?
+        os.rename(NTSQLITE_BUILDPATH, NTSQLITE_DESTINATION)
+        if not nt_ver() == __db_target_nt__:
+            raise SqlInvalidVersionError(
+                "ERROR: nt target [{0}] mismatch actual [{1}], ".format(
+                    __db_target_nt__, nt_ver()
+                )
+                + ", please contact support or try again"
+            )
+        print("..DONE!")
+
+
+# ------------------------------------------------
+# SQL connection & utility methods
+# ------------------------------------------------
+
+
 def nt_sqlite_connect(version_check=True) -> sqlite3.Connection:
     """Connects to the nt.sqlite3 file, or throws an exception"""
     db_path = os.path.join(NUTRA_DIR, NT_DB_NAME)
@@ -29,12 +78,6 @@ def nt_sqlite_connect(version_check=True) -> sqlite3.Connection:
     raise SqlConnectError("ERROR: nt database doesn't exist, please run `nutra init`")
 
 
-def nt_ver() -> str:
-    """Gets version string for nt.sqlite3 database"""
-    con = nt_sqlite_connect(version_check=False)
-    return version(con)
-
-
 def sql(query, values=None) -> list:
     """Executes a SQL command to nt.sqlite3"""
     con = nt_sqlite_connect()
index b57f0dbf9ded1c54c09fc5cebd26c18710bd8a19..4f3450ea66c582e85c417a007cb05dfbbeffcb26 100644 (file)
@@ -1,17 +1,11 @@
 """Services module, currently only home to SQL/persistence init method"""
 import os
 
-from ntclient import (
-    NTSQLITE_BUILDPATH,
-    NTSQLITE_DESTINATION,
-    NUTRA_DIR,
-    __db_target_nt__,
-)
+from ntclient import NUTRA_DIR
 from ntclient.ntsqlite.sql import build_ntsqlite
-from ntclient.persistence.sql.nt import nt_ver
+from ntclient.persistence.sql.nt import nt_init
 from ntclient.persistence.sql.usda import usda_init
 from ntclient.services import analyze, recipe, usda
-from ntclient.utils.exceptions import SqlInvalidVersionError
 
 
 def init(yes=False):
@@ -35,31 +29,7 @@ def init(yes=False):
 
     print("Nutra db         ", end="")
     build_ntsqlite()
-    # TODO: don't overwrite,
-    #  verbose toggle for download,
-    #  option to upgrade
-    if os.path.isfile(NTSQLITE_DESTINATION):
-        if nt_ver() != __db_target_nt__:
-            # TODO: hard requirement? raise error?
-            print(
-                "WARN: upgrades/downgrades not supported "
-                + "(actual: {0} vs. target: {1}), ".format(nt_ver(), __db_target_nt__)
-                + "please remove `~/.nutra/nt.sqlite3` file or ignore this warning"
-            )
-        print("..DONE!")
-        os.remove(NTSQLITE_BUILDPATH)  # clean up
-    else:
-        # TODO: is this logic (and these error messages) the best?
-        #  what if .isdir() == True ? Fails with stacktrace?
-        os.rename(NTSQLITE_BUILDPATH, NTSQLITE_DESTINATION)
-        if not nt_ver() == __db_target_nt__:
-            raise SqlInvalidVersionError(
-                "ERROR: nt target [{0}] mismatch actual [{1}], ".format(
-                    __db_target_nt__, nt_ver()
-                )
-                + ", please contact support or try again"
-            )
-        print("..DONE!")
+    nt_init()
 
     print("\nAll checks have passed!")
     return 0, True
index 642306ba9e724793f861d9a1fd5861dfb1897cf1..1d5b3b689ba80731602178daffebe4ecfade577a 100644 (file)
@@ -5,4 +5,4 @@ doc8~=0.11
 flake8~=4.0
 mypy~=0.960
 pylint~=2.13
-yamllint~=1.26
+yamllint~=1.27