Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.0 - Add support for specifying platform #17

Merged
merged 1 commit into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.2
hash=e17a2a1feecf3316dd227e4ef69c4351
hash=a4e47be8738ab981e11e2267b94bc9fc
=====================================
-->

# rcmpy ([1.1.1](https://pypi.org/project/rcmpy/))
# rcmpy ([1.2.0](https://pypi.org/project/rcmpy/))

[![python](https://img.shields.io/pypi/pyversions/rcmpy.svg)](https://pypi.org/project/rcmpy/)
![Build Status](https://github.com/vkottler/rcmpy/workflows/Python%20Package/badge.svg)
Expand Down
4 changes: 2 additions & 2 deletions local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 1
minor: 1
patch: 1
minor: 2
patch: 0
entry: rcmpy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "rcmpy"
version = "1.1.1"
version = "1.2.0"
description = "A configuration-file management system."
readme = "README.md"
requires-python = ">=3.7"
Expand Down
4 changes: 2 additions & 2 deletions rcmpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.2
# hash=8cf27e726efd71565b56531e6b4da766
# hash=7d9db5b03071a6b0e78c3e545b31a7ea
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "A configuration-file management system."
PKG_NAME = "rcmpy"
VERSION = "1.1.1"
VERSION = "1.2.0"
3 changes: 3 additions & 0 deletions rcmpy/commands/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def apply_env(args: _Namespace, env: Environment) -> int:
env.logger.error("Template '%s' not found!", file.template)
continue

if not file.platform:
continue

is_new = env.state.is_new()

# Check if this file has any updated templates.
Expand Down
1 change: 1 addition & 0 deletions rcmpy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def init(self, data: _JsonObject) -> None:
Path(expandvars(file["directory"])).expanduser(),
file.get("name", file["template"]),
file["link"],
set(file.get("platforms", [])),
)

# Keep track of all templates used in any file.
Expand Down
8 changes: 8 additions & 0 deletions rcmpy/config/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dataclasses import dataclass
from pathlib import Path
from shutil import copyfile
import sys
from typing import Set

# third-party
Expand All @@ -28,11 +29,18 @@ class ManagedFile:

link: bool

platforms: Set[str]

@property
def output(self) -> Path:
"""Get the full output path."""
return self.directory.joinpath(self.name)

@property
def platform(self) -> bool:
"""Determine if the platform is correct for handling this file."""
return not self.platforms or sys.platform in self.platforms

def update_root(self, root: Path) -> None:
"""
If the output directory is a relative path, update it to be an
Expand Down
6 changes: 6 additions & 0 deletions rcmpy/data/schemas/ManagedFile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ properties:
name:
type: string

platforms:
type: array
items:
type: string
enum: ["linux", "cygwin", "darwin", "win32"]

# Templates that may be included in the main template.
extra_templates:
type: array
Expand Down
7 changes: 7 additions & 0 deletions tests/data/valid/scenarios/simple/rcmpy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ files:

- template: basic.txt
link: false

- template: linux.txt
platforms: [linux]
- template: darwin.txt
platforms: [darwin]
- template: win32.txt
platforms: [win32]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This will be handled on 'darwin' platforms.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This will be handled 'linux' platforms.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This will be handled on 'win32' platforms.