-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete generated files by moban (#381)
* 🔥 remove unwanted error message * ✨ add delete support. resolves #167 * 📚 update change log * 📰 add missing file
- Loading branch information
Showing
20 changed files
with
187 additions
and
61 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
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,11 @@ | ||
targets: | ||
- intermediate.jj2: original.jj2 | ||
- intermediate2.jj2: original.jj2 | ||
- intermediate3.jj2: original.jj2 | ||
- final: intermediate.jj2 | ||
- output: what_ever_here_will_be_ignored | ||
template: intermediate.jj2 | ||
template_type: delete | ||
- output: '' | ||
template: intermediate2.jj2 | ||
- delete!: intermediate3.jj2 |
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,42 @@ | ||
Level 25: delete intermediate targets | ||
================================================================================ | ||
|
||
Continue with level 22, we would like to delete intermediate files. | ||
|
||
.. note:: | ||
|
||
What is intermediate targets? Simply they are the files moban generates | ||
but in the end those files are not really used. | ||
|
||
|
||
For safety reasons, we only delete intermediate targets. We are not allowing | ||
moban to delete any files in template folders and staic folder. | ||
|
||
Here is the short syntax:: | ||
|
||
targets: | ||
- delete!: intermediate_file.jj2 | ||
|
||
Here are the full syntax:: | ||
|
||
targets: | ||
- output: what_ever_here_will_be_ignored | ||
template: intermediate.jj2 | ||
template_type: delete | ||
- output: '' | ||
template: intermediate2.jj2 | ||
|
||
|
||
Example mobanfile:: | ||
|
||
targets: | ||
- intermediate.jj2: original.jj2 | ||
- intermediate2.jj2: original.jj2 | ||
- intermediate3.jj2: original.jj2 | ||
- output: x | ||
template: intermediate.jj2 | ||
template_type: delete | ||
- output: '' | ||
template: intermediate2.jj2 | ||
- delete!: intermediate3.jj2 | ||
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 @@ | ||
hello: world |
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 @@ | ||
a {{hello}} |
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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
from moban.core.definitions import Store | ||
class Store: | ||
def __init__(self): | ||
self.init() | ||
|
||
def add(self, target): | ||
self.targets.append(target) | ||
self.look_up_by_output[target.output] = target | ||
|
||
def init(self): | ||
self.targets = [] | ||
self.look_up_by_output = {} | ||
self.intermediate_targets = [] | ||
|
||
|
||
STORE = Store() |
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
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,36 @@ | ||
import fs | ||
from lml.plugin import PluginInfo | ||
|
||
from moban import constants | ||
from moban.core.mobanfile.store import STORE | ||
|
||
|
||
@PluginInfo(constants.TEMPLATE_ENGINE_EXTENSION, tags=["delete"]) | ||
class ContentForwardEngine(object): | ||
""" | ||
Does no templating but delete generated intermediate targets | ||
""" | ||
|
||
ACTION_IN_PRESENT_CONTINUOUS_TENSE = "Deleting" | ||
ACTION_IN_PAST_TENSE = "Deleted" | ||
|
||
def __init__(self, template_fs, extensions=None): | ||
self.template_fs = template_fs | ||
|
||
def get_template(self, template_file): | ||
if template_file in STORE.intermediate_targets: | ||
with fs.open_fs(".") as the_fs: | ||
if the_fs.exists(template_file): | ||
the_fs.remove(template_file) | ||
return True | ||
else: | ||
return False | ||
else: | ||
raise Exception(f"Cannot remove {template_file}") | ||
|
||
def get_template_from_string(self, string): | ||
raise NotImplementedError("Not sure what to do") | ||
|
||
def apply_template(self, template, *_): | ||
raise NotImplementedError("Not sure what to do") |
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