Added 'examples' package
This commit is contained in:
parent
5e8d975830
commit
1a66835d1c
14
examples/__init__.py
Normal file
14
examples/__init__.py
Normal file
@ -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.
|
||||
|
22
examples/mydata.json
Normal file
22
examples/mydata.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
@ -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)
|
@ -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')
|
Loading…
Reference in New Issue
Block a user