diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 0000000..f2d6477 --- /dev/null +++ b/examples/__init__.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + diff --git a/examples/mydata.json b/examples/mydata.json new file mode 100644 index 0000000..eacfbf5 --- /dev/null +++ b/examples/mydata.json @@ -0,0 +1,22 @@ +{ + "glossary": { + "title": "example glossary", + "GlossDiv": { + "title": "S", + "GlossList": { + "GlossEntry": { + "ID": "SGML", + "SortAs": "SGML", + "GlossTerm": "Standard Generalized Markup Language", + "Acronym": "SGML", + "Abbrev": "ISO 8879:1986", + "GlossDef": { + "para": "A meta-markup language, used to create markup languages such as DocBook.", + "GlossSeeAlso": ["GML", "XML"] + }, + "GlossSee": "markup" + } + } + } + } +} diff --git a/ns/__init__.py b/examples/ns/__init__.py similarity index 100% rename from ns/__init__.py rename to examples/ns/__init__.py diff --git a/ns/definition.py b/examples/ns/definition.py similarity index 100% rename from ns/definition.py rename to examples/ns/definition.py diff --git a/ns_functions.py b/examples/ns_functions.py similarity index 90% rename from ns_functions.py rename to examples/ns_functions.py index 629615c..d111766 100644 --- a/ns_functions.py +++ b/examples/ns_functions.py @@ -13,13 +13,13 @@ # under the License. import types -import ns.definition +import examples.ns.definition from yaql.context import EvalArg @EvalArg('short_name', arg_type=types.StringType) def expand_namespace(short_name): - fqns = ns.definition.get_fqns(short_name) + fqns = examples.ns.definition.get_fqns(short_name) if not fqns: raise Exception( "Namespace with alias '{0}' is unknown".format(short_name)) @@ -30,7 +30,7 @@ def expand_namespace(short_name): @EvalArg('fqns', arg_type=types.StringType) @EvalArg('value', arg_type=types.StringType) def validate(fqns, value): - if not ns.definition.validate(fqns, value): + if not examples.ns.definition.validate(fqns, value): raise Exception( "Namespace '{0}' does not contain name '{1}'".format(fqns, value)) return "{0}.{1}".format(fqns, value) diff --git a/runner.py b/examples/runner.py similarity index 94% rename from runner.py rename to examples/runner.py index 3e3315d..4dcd5d8 100644 --- a/runner.py +++ b/examples/runner.py @@ -13,9 +13,10 @@ # under the License. import collections +from examples import testdata, ns_functions import yaql -import ns_functions -import testdata + +# DEPRECATED. Use cli to run samples context = yaql.create_context() ns_functions.register_in_context(context) diff --git a/testdata.py b/examples/testdata.py similarity index 73% rename from testdata.py rename to examples/testdata.py index 1536d58..a437327 100644 --- a/testdata.py +++ b/examples/testdata.py @@ -12,7 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -import ns.definition +import examples.ns.definition + +# DEPRECATED. Use cli to run samples class Customer(): @@ -65,13 +67,13 @@ services = [ data = {'users': users, 'services': services} -ns.definition.register_shortening('yaql', 'com.mirantis.murano.yaql') -ns.definition.register_shortening('ex', 'com.mirantis.murano.examples') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'version') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'name') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'position') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'description') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'owner') -ns.definition.register_symbol('com.mirantis.murano.yaql', 'parent_service') -ns.definition.register_symbol('com.mirantis.murano.examples', 'Service0') -ns.definition.register_symbol('com.mirantis.murano.examples', 'Service1') +examples.ns.definition.register_shortening('yaql', 'com.mirantis.murano.yaql') +examples.ns.definition.register_shortening('ex', 'com.mirantis.murano.examples') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'version') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'name') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'position') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'description') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'owner') +examples.ns.definition.register_symbol('com.mirantis.murano.yaql', 'parent_service') +examples.ns.definition.register_symbol('com.mirantis.murano.examples', 'Service0') +examples.ns.definition.register_symbol('com.mirantis.murano.examples', 'Service1')