--- /dev/null
+import sys
+import os
+import site
+
+
+def is_venv() -> bool:
+ """Detect if the script is running inside a virtual environment."""
+ return sys.prefix != sys.base_prefix
+
+
+def get_venv_name() -> str | None:
+ """Get the name of the virtual environment if it exists."""
+ if is_venv():
+ return os.path.basename(sys.prefix)
+ return None
+
+
+def print_status() -> None:
+ """Print the current status of the Matrix (virtual environment)."""
+ if is_venv():
+ print("MATRIX STATUS: Welcome to the construct")
+ print(f"Current Python: {sys.executable}")
+ print(f"Virtual Environment: {get_venv_name()}")
+ print(f"Environment Path: {sys.prefix}")
+ print("SUCCESS: You're in an isolated environment!")
+ print("Safe to install packages without affecting")
+ print("the global system.")
+ print("Package installation path:")
+ # site.getsitepackages() might return multiple paths,
+ # usually we want the one in sys.prefix
+ site_packages = site.getsitepackages()
+ for path in site_packages:
+ if path.startswith(sys.prefix):
+ print(path)
+ break
+ else:
+ print("MATRIX STATUS: You're still plugged in")
+ print(f"Current Python: {sys.executable}")
+ print("Virtual Environment: None detected")
+ print("WARNING: You're in the global environment!")
+ print("The machines can see everything you install.")
+ print("To enter the construct, run:")
+ print("python -m venv matrix_env")
+ print("source matrix_env/bin/activate # On Unix")
+ print("matrix_env\\Scripts\\activate # On Windows")
+ print("Then run this program again.")
+
+
+def main() -> None:
+ """Main function to run the construct program."""
+ try:
+ print_status()
+ except Exception as e:
+ print(f"An error occurred: {e}")
+
+
+if __name__ == "__main__":
+ main()
--- /dev/null
+import importlib.metadata
+
+
+def check_dependencies() -> bool:
+ """Check if all required dependencies are installed."""
+ dependencies = ["pandas", "numpy", "matplotlib", "requests"]
+ all_ok = True
+ print("Checking dependencies:")
+ for dep in dependencies:
+ try:
+ version = importlib.metadata.version(dep)
+ description = {
+ "pandas": "Data manipulation ready",
+ "numpy": "Numerical computations ready",
+ "matplotlib": "Visualization ready",
+ "requests": "Network access ready",
+ }.get(dep, "Ready")
+ print(f"[OK] {dep} ({version}) - {description}")
+ except importlib.metadata.PackageNotFoundError:
+ print(f"[ERROR] {dep} is not installed.")
+ all_ok = False
+
+ if not all_ok:
+ print("\nTo install missing dependencies, run:")
+ print("pip install -r requirements.txt")
+ print("OR")
+ print("poetry install")
+ return all_ok
+
+
+def analyze_data() -> None:
+ """Analyze simulated Matrix data and generate a visualization."""
+ import pandas as pd
+ import numpy as np
+ import matplotlib.pyplot as plt
+
+ print("Analyzing Matrix data...")
+ print("Processing 1000 data points...")
+
+ # Create sample data
+ data = pd.DataFrame(
+ {
+ "signal": np.random.normal(0, 1, 1000).cumsum(),
+ "noise": np.random.uniform(-1, 1, 1000),
+ }
+ )
+
+ print("Generating visualization...")
+ plt.figure(figsize=(10, 6))
+ plt.plot(data["signal"], label="Matrix Signal", color="green")
+ plt.title("Matrix Data Analysis")
+ plt.xlabel("Time")
+ plt.ylabel("Intensity")
+ plt.legend()
+ plt.grid(True)
+ plt.savefig("matrix_analysis.png")
+ print("Analysis complete!")
+ print("Results saved to: matrix_analysis.png")
+
+
+def main() -> None:
+ """Main function to run the loading program."""
+ try:
+ print("LOADING STATUS: Loading programs...")
+ if check_dependencies():
+ analyze_data()
+ except Exception as e:
+ print(f"An error occurred: {e}")
+
+
+if __name__ == "__main__":
+ main()
--- /dev/null
+[tool.poetry]
+name = "ex01"
+version = "0.1.0"
+description = "Matrix data loader"
+authors = ["Your Name <you@example.com>"]
+
+[tool.poetry.dependencies]
+python = "^3.10"
+pandas = "*"
+numpy = "*"
+matplotlib = "*"
+requests = "*"
+
+[build-system]
+requires = ["poetry-core>=1.0.0"]
+build-backend = "poetry.core.masonry.api"
+
+[tool.black]
+line-length = 79
--- /dev/null
+pandas
+numpy
+matplotlib
+requests
--- /dev/null
+# Matrix Configuration Template
+MATRIX_MODE=development
+DATABASE_URL=postgres://user:password@localhost:5432/matrix
+API_KEY=your_secret_api_key_here
+LOG_LEVEL=DEBUG
+ZION_ENDPOINT=https://zion.network/api
--- /dev/null
+import os
+from dotenv import load_dotenv
+
+
+def load_config() -> dict[str, str | None]:
+ """Load configuration from environment variables."""
+ # Load .env file if it exists
+ load_dotenv()
+
+ config = {
+ "MATRIX_MODE": os.getenv("MATRIX_MODE"),
+ "DATABASE_URL": os.getenv("DATABASE_URL"),
+ "API_KEY": os.getenv("API_KEY"),
+ "LOG_LEVEL": os.getenv("LOG_LEVEL"),
+ "ZION_ENDPOINT": os.getenv("ZION_ENDPOINT"),
+ }
+ return config
+
+
+def check_security() -> None:
+ """Perform a basic environment security check."""
+ print("Environment security check:")
+ # Checking if .env is in .gitignore
+ gitignore_path = ".gitignore"
+ dot_env_ignored = False
+ if os.path.exists(gitignore_path):
+ with open(gitignore_path, "r") as f:
+ if ".env" in f.read():
+ dot_env_ignored = True
+
+ if dot_env_ignored:
+ print("[OK] .env file properly configured")
+ else:
+ print("[WARNING] .env file might be tracked by git!")
+
+ # Simulate other checks
+ print("[OK] No hardcoded secrets detected")
+ print("[OK] Production overrides available")
+
+
+def display_config(config: dict[str, str | None]) -> None:
+ """Display the loaded configuration."""
+ print("Configuration loaded:")
+
+ mode = config.get("MATRIX_MODE", "unknown")
+ print(f"Mode: {mode}")
+
+ db_url = config.get("DATABASE_URL")
+ if db_url:
+ print("Database: Connected to local instance")
+ else:
+ print("Database: Missing connection string")
+
+ api_key = config.get("API_KEY")
+ if api_key:
+ print("API Access: Authenticated")
+ else:
+ print("API Access: Unauthorized")
+
+ print(f"Log Level: {config.get('LOG_LEVEL', 'INFO')}")
+
+ zion = config.get("ZION_ENDPOINT")
+ if zion:
+ print("Zion Network: Online")
+ else:
+ print("Zion Network: Offline")
+
+
+def main() -> None:
+ """Main function to run the oracle program."""
+ try:
+ print("ORACLE STATUS: Reading the Matrix...")
+ config = load_config()
+ display_config(config)
+ check_security()
+ print("The Oracle sees all configurations.")
+ except Exception as e:
+ print(f"An error occurred: {e}")
+
+
+if __name__ == "__main__":
+ main()
--- /dev/null
+[tool.black]
+line-length = 79
+target-version = ['py310']