-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from vkottler/dev/1.1.0
1.1.0 - Add a few features and improvements
- Loading branch information
Showing
17 changed files
with
190 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ htmlcov | |
*-stubs | ||
coverage*.xml | ||
tags | ||
*-output | ||
*-out* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[DESIGN] | ||
max-attributes=8 | ||
max-attributes=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
major: 1 | ||
minor: 0 | ||
minor: 1 | ||
patch: 0 | ||
entry: rcmpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
A module implementing an interface for package-managed files. | ||
""" | ||
|
||
# built-in | ||
from contextlib import suppress | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from shutil import copyfile | ||
from typing import Set | ||
|
||
# third-party | ||
from vcorelib.logging import LoggerType | ||
from vcorelib.paths import rel | ||
|
||
|
||
@dataclass | ||
class ManagedFile: | ||
""" | ||
A data structure for managed files specified in the configuration data. | ||
""" | ||
|
||
template: str | ||
extra_templates: Set[str] | ||
|
||
directory: Path | ||
name: str | ||
|
||
link: bool | ||
|
||
@property | ||
def output(self) -> Path: | ||
"""Get the full output path.""" | ||
return self.directory.joinpath(self.name) | ||
|
||
def update_root(self, root: Path) -> None: | ||
""" | ||
If the output directory is a relative path, update it to be an | ||
absolute one based on the provided root directory. | ||
""" | ||
|
||
if not self.directory.is_absolute(): | ||
self.directory = root.joinpath(self.directory) | ||
assert self.directory.is_absolute(), self.directory | ||
|
||
def update(self, source: Path, logger: LoggerType) -> None: | ||
"""Update this managed file based on the provided source file.""" | ||
|
||
output = self.output | ||
|
||
# At some point this could be skipped for existing symlinks. | ||
with suppress(FileNotFoundError): | ||
output.unlink() | ||
|
||
# Ensure the output directory exists. | ||
self.directory.mkdir(parents=True, exist_ok=True) | ||
|
||
if self.link: | ||
output.symlink_to(source) | ||
else: | ||
copyfile(source, output) | ||
|
||
logger.info("'%s' -> '%s'.", rel(source), rel(output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.