-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --write option to trigger running Transforms
Transforms, including read/write of YAML files, will be added in a follow-up PR.
- Loading branch information
1 parent
4103e7e
commit 46b27dd
Showing
4 changed files
with
53 additions
and
0 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
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,28 @@ | ||
"""Transformer implementation.""" | ||
import logging | ||
from typing import List, Set | ||
|
||
from ansiblelint.errors import MatchError | ||
from ansiblelint.file_utils import Lintable | ||
from ansiblelint.runner import LintResult | ||
|
||
__all__ = ["Transformer"] | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class Transformer: | ||
"""Transformer class marshals transformations. | ||
The Transformer is similar to the ``ansiblelint.runner.Runner`` which manages | ||
running each of the rules. We only expect there to be one ``Transformer`` instance | ||
which should be instantiated from the main entrypoint function. | ||
""" | ||
|
||
def __init__(self, result: LintResult): | ||
"""Initialize a Transformer instance.""" | ||
self.matches: List[MatchError] = result.matches | ||
self.files: Set[Lintable] = result.files | ||
|
||
def run(self) -> None: | ||
"""For each file, read it, execute transforms on it, then write it.""" |