]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
git: ignore VSCode cache files, sat cache file and add a pre-commit config
authorGbkng <guillaume.brooking@gmail.com>
Wed, 14 Feb 2024 08:44:02 +0000 (09:44 +0100)
committerGbkng <guillaume.brooking@gmail.com>
Mon, 26 Feb 2024 11:01:01 +0000 (12:01 +0100)
.gitignore
.pre-commit-config.yaml [new file with mode: 0644]
commands/config.py
data/local.pyconf [deleted file]

index 856c9cd716eec205162f72f449e158d7c8fb021c..5d2f22756a213de02b6e8d7ea881b45479c8a400 100644 (file)
@@ -18,3 +18,9 @@ doc/src/commands/apidoc*
 
 # Byte-compiled / optimized / DLL files
 __pycache__/
+
+# IDE/editors/tools cache files
+.vscode/
+
+# cache file, generated by sat, to store configuration
+data/local.pyconf
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644 (file)
index 0000000..05a38b4
--- /dev/null
@@ -0,0 +1,81 @@
+---
+repos:
+    - repo: https://github.com/pre-commit/pre-commit-hooks
+      rev: v4.5.0  # Use the ref you want to point at
+      hooks:
+          - id: trailing-whitespace
+            exclude: |
+                (?x)^(
+                  .*\.py
+                )$
+          - id: check-added-large-files
+          - id: debug-statements
+          - id: detect-private-key
+          - id: end-of-file-fixer
+          - id: mixed-line-ending
+            exclude: |
+                (?x)^(
+                  .*\.py
+                )$
+          - id: check-case-conflict
+            exclude: |
+                (?x)^(
+                  .*\.py
+                )$
+          - id: check-json
+          - id: pretty-format-json
+          - id: check-merge-conflict
+          - id: check-toml
+          - id: check-xml
+          - id: requirements-txt-fixer
+    - repo: https://github.com/astral-sh/ruff-pre-commit
+      # Ruff version.
+      rev: v0.1.9
+      hooks:
+        # Run the linter.
+          - id: ruff
+            types_or: [python, pyi, jupyter]
+            args: [--fix]
+            exclude: |
+                (?x)^(
+                    .*[Tt]est.*|
+                    __init__.py
+                )$
+        # Run the formatter.
+          - id: ruff-format
+            types_or: [python, pyi, jupyter]
+    - repo: https://github.com/pre-commit/mirrors-mypy
+      rev: v1.8.0
+      hooks:
+          - id: mypy
+            exclude: |
+                (?x)^(
+                    .*[Tt]est.*
+                )$
+            args: [--ignore-missing-imports, --explicit-package-bases]
+    - repo: https://github.com/scop/pre-commit-shfmt
+      rev: v3.7.0-4
+      hooks:
+          # Choose one of:
+          - id: shfmt  # prebuilt upstream executable
+            args: [--indent=4, -w, -s]
+    - repo: https://github.com/shellcheck-py/shellcheck-py
+      rev: v0.9.0.6
+      hooks:
+          - id: shellcheck
+            args: [--severity=warning]
+    - repo: https://github.com/adrienverge/yamllint.git
+      rev: v1.21.0  # or higher tag
+      hooks:
+          - id: yamllint
+            args: [--strict, '--config-data={extends: relaxed, rules: {line-length: {max: 120}}}']
+    - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
+      rev: 0.2.1  # or other specific tag
+      hooks:
+          - id: yamlfmt
+    - repo: https://github.com/pre-commit/pygrep-hooks
+      rev: v1.10.0  # Use the ref you want to point at
+      hooks:
+          - id: rst-backticks
+          - id: rst-directive-colons
+          - id: rst-inline-touching-normal
index a5997bb7814fcc265dbeef9d3df3413f44d0eb58..6bb522cf6ddfa44614f85c86b4622b75e12c9fae 100644 (file)
@@ -22,6 +22,7 @@ import platform
 import datetime
 import shutil
 import gettext
+from pathlib import Path
 import pprint as PP
 
 import src
@@ -286,9 +287,15 @@ class ConfigManager:
         # Load LOCAL config file
         # search only in the data directory
         src.pyconf.streamOpener = ConfigOpener([cfg.VARS.datadir])
+
+        # if `local.pyconf` file is missing, create it from 
+        # `local_original.pyconf` template file
+        localconf_path = osJoin(cfg.VARS.datadir, 'local.pyconf')
+        if not Path(localconf_path).is_file():
+            shutil.copyfile(osJoin(cfg.VARS.datadir, 'local_original.pyconf'), localconf_path)
+
         try:
-            local_cfg = src.pyconf.Config(open( osJoin(cfg.VARS.datadir,
-                                                           'local.pyconf')),
+            local_cfg = src.pyconf.Config(open(localconf_path),
                                          PWD = ('LOCAL', cfg.VARS.datadir) )
         except src.pyconf.ConfigError as e:
             raise src.SatException(_("Error in configuration file: "
diff --git a/data/local.pyconf b/data/local.pyconf
deleted file mode 100644 (file)
index 24ee9eb..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-
-  LOCAL :
-  {
-    base : 'default'
-    workdir : 'default'
-    log_dir : 'default'
-    archive_dir : 'default'
-    VCS : 'unknown'
-    tag : 'unknown'
-  }
-  PROJECTS :
-  {
-    project_file_paths :
-    [
-    ]
-  }