summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-01-30 10:28:42 +0200
committerLars Wirzenius <liw@liw.fi>2021-01-30 11:52:59 +0200
commitadda6613d7fdf47967d5d55057044ac618d40d1a (patch)
tree92170df486172b5b032f1f5bcddb57eefded1dca /subplot
parentd0e404c6fe86cd4771ab11e1b458ca6c1d6e93cf (diff)
downloadewww-adda6613d7fdf47967d5d55057044ac618d40d1a.tar.gz
refactor: use Subplot's lib/files
Diffstat (limited to 'subplot')
-rw-r--r--subplot/ewww.py7
-rw-r--r--subplot/ewww.yaml3
2 files changed, 10 insertions, 0 deletions
diff --git a/subplot/ewww.py b/subplot/ewww.py
index d53b74c..6c93733 100644
--- a/subplot/ewww.py
+++ b/subplot/ewww.py
@@ -40,6 +40,13 @@ def fixme(*args, **kwargs):
assert 0
+# Create a directory.
+def create_directory(ctx, dirname=None):
+ dirname = "./" + dirname
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+
# Create a file.
def create_file(ctx, filename=None, content=None):
logging.debug(f"Creating file {filename} with {content}")
diff --git a/subplot/ewww.yaml b/subplot/ewww.yaml
index 375558d..ec5395f 100644
--- a/subplot/ewww.yaml
+++ b/subplot/ewww.yaml
@@ -8,6 +8,9 @@
- given: "{count} files in {dirname}"
function: fixme
+- given: directory {dirname}
+ function: create_directory
+
- given: file (?P<filename>\S+) with "(?P<content>.*)"
regex: true
function: create_file