From fe8ce17ae1d9a4b1e7a2df1b9588fbe42bec2000 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 9 Jun 2013 11:41:41 +0100 Subject: Add story element classes --- yarnlib/__init__.py | 2 +- yarnlib/elements.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 yarnlib/elements.py (limited to 'yarnlib') diff --git a/yarnlib/__init__.py b/yarnlib/__init__.py index 44e83e3..2abc3ad 100644 --- a/yarnlib/__init__.py +++ b/yarnlib/__init__.py @@ -17,4 +17,4 @@ from mdparser import MarkdownParser - +from elements import Story, StoryStep, Implementation diff --git a/yarnlib/elements.py b/yarnlib/elements.py new file mode 100644 index 0000000..a1dea0d --- /dev/null +++ b/yarnlib/elements.py @@ -0,0 +1,51 @@ +# Copyright 2013 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# =*= License: GPL-3+ =*= + + +# This is a step in a story: GIVEN, WHEN, THEN, etc. + +class StoryStep(object): + + def __init__(self, what, text): + self.what = what + self.text = text + self.implementation = None + + +# This is the story itself. + +class Story(object): + + def __init__(self, name): + self.name = name + self.steps = [] + + +# This is an IMPLEMENTS chunk. + +class Implementation(object): + + def __init__(self, what, regexp, shell): + self.what = what + self.regexp = regexp + self.shell = shell + + def execute(self): + exit, out, err = cliapp.runcmd_unchecked( + ['sh', '-c', 'set -eu\n' + self.shell]) + return exit + -- cgit v1.2.1