Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ianj-als/pcl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Johnson <ian.johnson@appliedlanguage.com>2013-05-28 16:07:07 +0400
committerIan Johnson <ian.johnson@appliedlanguage.com>2013-05-28 16:07:07 +0400
commit4e51345cd6b405551ba327d91a7d905e204587b1 (patch)
treeceb9cb62ed1f313d8e26353e4eba45b2d7b78808 /examples
parente4bf694a55ec4d8dae1bb5532711bcde6c824a81 (diff)
Refactor. Added an example of how to use environment variables in a configuration file.
Diffstat (limited to 'examples')
-rw-r--r--examples/environment_variables/environment_variables.cfg5
-rw-r--r--examples/environment_variables/environment_variables.pcl29
-rw-r--r--examples/environment_variables/motd.py42
3 files changed, 76 insertions, 0 deletions
diff --git a/examples/environment_variables/environment_variables.cfg b/examples/environment_variables/environment_variables.cfg
new file mode 100644
index 0000000..9f14c93
--- /dev/null
+++ b/examples/environment_variables/environment_variables.cfg
@@ -0,0 +1,5 @@
+[Configuration]
+motd = It was all so different before everything changed, your home is $(HOME)
+
+[Inputs]
+input_string = 42
diff --git a/examples/environment_variables/environment_variables.pcl b/examples/environment_variables/environment_variables.pcl
new file mode 100644
index 0000000..b7995c9
--- /dev/null
+++ b/examples/environment_variables/environment_variables.pcl
@@ -0,0 +1,29 @@
+#
+# Copyright Capita Translation and Interpreting 2013
+#
+# This file is part of Pipeline Creation Language (PCL).
+#
+# Pipeline Creation Language (PCL) 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.
+#
+# Pipeline Creation Language (PCL) 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 Pipeline Creation Language (PCL). If not, see <http://www.gnu.org/licenses/>.
+#
+import motd as message_of_the_day
+
+component environment_variables
+ inputs input_string
+ output output_string
+ configuration motd
+ declare
+ motd := new message_of_the_day with motd -> message
+ as
+ wire input_string -> string >>> motd >>> wire string -> output_string
+
diff --git a/examples/environment_variables/motd.py b/examples/environment_variables/motd.py
new file mode 100644
index 0000000..ef1c47f
--- /dev/null
+++ b/examples/environment_variables/motd.py
@@ -0,0 +1,42 @@
+#
+# Copyright Capita Translation and Interpreting 2013
+#
+# This file is part of Pipeline Creation Language (PCL).
+#
+# Pipeline Creation Language (PCL) 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.
+#
+# Pipeline Creation Language (PCL) 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 Pipeline Creation Language (PCL). If not, see <http://www.gnu.org/licenses/>.
+#
+import sys
+
+def get_name():
+ return 'motd'
+
+def get_inputs():
+ return ['string']
+
+def get_outputs():
+ return ['string']
+
+def get_configuration():
+ return ['message']
+
+def configure(args):
+ return {'motd' : args['message']}
+
+def initialise(config):
+ def echo_fn(a, s):
+ print >> sys.stdout, "%s: %s" % (config['motd'], a['string'])
+ return {'string' : a['string']}
+
+ return echo_fn
+