An extension for "filestate" package, which adds GIT management operations.
Project description
filestate
filestate
is a Python package that allows you to manage the state of files and directories using YAML configuration files.
Features
- Apply and Modify Permissions and Ownership: Manage file and directory permissions and ownership individually or recursively.
- Create, Modify, and Delete Directories: Use patterns and regex to create, modify, and delete directories and subdirectories (e.g., ensure each
Entity/MyEntity.php
file has a correspondingRepository/MyEntityRepository.php
). - Create Files Using Templates and Placeholders: Generate files from templates with dynamic placeholders.
Installation
Install filestate
with pip:
pip install wexample-filestate
Usage
Configuration File Example
# example.yaml
children:
- path: /path/to/file
owner: user
group: group
mode: '0644'
- path: /path/to/directory
recursive: true
mode: '0755'
create: true
Usage
Here's how you can use filestate in your Python code:
from filestate import FileStateManager
# Initialize the state manager with the root directory
state_manager = FileStateManager('root/directory/')
# Configure the state manager from a YAML configuration file
state_manager.configure_from_file('configuration.yaml')
# Perform a dry run to see what changes would be made
result = state_manager.dry_run()
result.print()
# Check if the configuration can be successfully applied
if state_manager.succeed():
# Apply the configuration
state_manager.apply()
else:
print("Configuration could not be applied successfully.")
Applying and Modifying Permissions
state_manager = FileStateManager('/var/www/')
state_manager.configure({
'files': [
{'path': '/var/www/index.html', 'owner': 'www-data', 'group': 'www-data', 'mode': '0644'},
{'path': '/var/www/css/', 'recursive': True, 'owner': 'www-data', 'group': 'www-data', 'mode': '0755'}
]
})
state_manager.apply()
Applying and Modifying Permissions
state_manager = FileStateManager('/project/')
state_manager.configure({
'directories': [
{'path': '/project/src/Entity/', 'create': True},
{'path': '/project/src/Repository/', 'create': True, 'pattern': 'Entity/*Entity.php', 'target': 'Repository/*Repository.php'}
]
})
state_manager.apply()
Testing
pytest -s pip/filestate/tests/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wexample_filestate_git-0.0.11.tar.gz
.
File metadata
- Download URL: wexample_filestate_git-0.0.11.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0fe6f1c12e48a078a028b1d87eb457b0b2d9ed234164646726f892e00f5f1313
|
|
MD5 |
bcc07073dba80b02f5348ba3c9ac2e1a
|
|
BLAKE2b-256 |
519c32e2a4b8e8e30c6ad0f0e5ecb716b0ce34e408f7e05e4907bf7c7dca2d9c
|
File details
Details for the file wexample_filestate_git-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: wexample_filestate_git-0.0.11-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4fb1af218675381b0d1923b522bc20e632dc39b59152f77d787adca7bcdebaf3
|
|
MD5 |
ca02f00b9ae4f77c6b9629cd3421295b
|
|
BLAKE2b-256 |
fb3559360d700f917ed2b41c4e60010e194299767c3e3584f796ffcd106feffd
|