first commit

This commit is contained in:
rnsrk 2025-04-30 08:39:11 +02:00
commit 5412ec1323
3 changed files with 1019 additions and 0 deletions

99
README.md Normal file
View file

@ -0,0 +1,99 @@
# Drupal Configuration Selector
A Python utility to selectively copy configuration files from a source directory to a target directory based on file prefixes.
## Overview
This script helps you manage and transfer specific Drupal configuration files by:
- Reading a list of configuration file prefixes from a JSON file
- Identifying matching files in a source directory
- Copying selected files to a target directory
- Providing a TUI (Text User Interface) to manage the selection process
## Requirements
- Python 3.6+
- curses library (built into most Python installations on Linux/Mac)
## Installation and Setup
The script operates in the current working directory where you run it. It will create the following subdirectories if they don't exist:
- `original_config/` - Place your source configuration files here
- `config/` - Matched files will be copied here
## Usage
1. Copy or move the script to your working directory (or use the full path to run it)
2. Place your source configuration files in the `original_config` directory
3. Run the script:
```bash
python3 config_selector.py
```
4. The script will create a default `config_prefixes.json` in the current directory if it doesn't exist
5. Use the TUI to manage your file selections and copy files
## Hierarchical Navigation
The script organizes configuration files in a tree-like structure based on dot-separated prefixes:
- Files like `field.storage.node.comment.yml` are split into segments: `field` > `field.storage` > `field.storage.node` > etc.
- Use **RIGHT ARROW** to navigate deeper into a selected prefix
- Use **LEFT ARROW** to go back up one level in the hierarchy
- At each level, you see only the unique segments available at that level
- Each segment shows the total count of files under it
- Segments with children have a "▶" indicator
- You can perform actions (add, delete, select files) at any level in the hierarchy
## TUI Navigation
The Text User Interface provides the following controls:
- **UP/DOWN**: Navigate through the list of prefixes
- **LEFT/RIGHT**: Navigate through the hierarchy tree (drill down/go back)
- **SPACE**: Toggle between matched and unmatched prefixes view
- **ENTER**: Select individual files from the selected prefix
- **A**: Add a new prefix (press ESC or Enter with empty input to cancel)
- **O**: Choose a prefix from the list of unmatched prefixes
- **D**: Delete the selected prefix (in matched view) or add the selected prefix (in unmatched view)
- **C**: Copy all matched files to the config directory
- **S**: Save the current list of prefixes to the JSON file
- **Q**: Quit the application
## Individual File Selection
When you press **ENTER** on a prefix, a dialog opens that allows you to:
- In matched view: Select individual files to remove from the matching set
- In unmatched view: Select individual files to add to a matching prefix
Within the file selection dialog:
- Use **UP/DOWN** to navigate between files
- Press **SPACE** to toggle selection of a file
- Press **ENTER** to confirm your selection
- Press **ESC** to cancel
## Configuration File
The script uses a JSON file to store prefixes. The default file is created at first run:
```json
{
"prefixes": [
"put.your.prefixes.here"
]
}
```
You can modify this file directly or use the TUI to manage the prefixes.
## Directory Structure
```
/your/working/directory/
├── config_selector.py # Main script
├── config_prefixes.json # Configuration prefixes list
├── original_config/ # Source directory containing all configuration files
└── config/ # Target directory where matched files will be copied
```