From 65d1c9b2d261e074a1ac948542696b6e9f28da46 Mon Sep 17 00:00:00 2001 From: ativelkov Date: Mon, 27 Jan 2014 10:27:34 -0500 Subject: [PATCH] * Date fixed in CLI prompt * Obsolete files deleted * URL to github added as homepage setup.py --- examples/__init__.py | 14 --------- examples/ns/__init__.py | 13 --------- examples/ns/definition.py | 40 -------------------------- examples/ns_functions.py | 50 -------------------------------- examples/runner.py | 60 --------------------------------------- setup.py | 2 +- yaql/cli/cli_functions.py | 2 +- 7 files changed, 2 insertions(+), 179 deletions(-) delete mode 100644 examples/__init__.py delete mode 100644 examples/ns/__init__.py delete mode 100644 examples/ns/definition.py delete mode 100644 examples/ns_functions.py delete mode 100644 examples/runner.py diff --git a/examples/__init__.py b/examples/__init__.py deleted file mode 100644 index f2d6477..0000000 --- a/examples/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# 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/ns/__init__.py b/examples/ns/__init__.py deleted file mode 100644 index 7d93825..0000000 --- a/examples/ns/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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/ns/definition.py b/examples/ns/definition.py deleted file mode 100644 index ddc613a..0000000 --- a/examples/ns/definition.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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. - -short_names = {} -values = {} - - -def register_shortening(short_name, fqns): - existing = short_names.get(short_name) - if existing and existing != fqns: - raise Exception( - "A namespace ('{0}') is already registered as '{1}'".format( - existing, short_name)) - short_names[short_name] = fqns - - -def register_symbol(fqns, symbol): - if not fqns in values: - values[fqns] = {symbol} - else: - values[fqns].add(symbol) - - -def get_fqns(short_name): - return short_names.get(short_name) - - -def validate(fqns, value): - return fqns in values and value in values[fqns] \ No newline at end of file diff --git a/examples/ns_functions.py b/examples/ns_functions.py deleted file mode 100644 index 43dd7a9..0000000 --- a/examples/ns_functions.py +++ /dev/null @@ -1,50 +0,0 @@ -# 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. - -import types -import examples.ns.definition -from yaql.functions.old.decorators import arg - - -@arg('short_name', type=types.StringType) -@arg('value', type=types.StringType) -def expand_property_namespace(short_name, value): - fqns = examples.ns.definition.get_fqns(short_name) - if not fqns: - raise Exception( - "Namespace with alias '{0}' is unknown".format(short_name)) - 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) - -@arg('short_name', type=types.StringType) -@arg('value', eval_arg=False, function_only=True) -def expand_function_namespace(short_name, value): - fqns = examples.ns.definition.get_fqns(short_name) - if not fqns: - raise Exception( - "Namespace with alias '{0}' is unknown".format(short_name)) - if not examples.ns.definition.validate(fqns, value.function_name): - raise Exception( - "Namespace '{0}' does not contain name '{1}'".format(fqns, value)) - value.function_name = "{0}.{1}".format(fqns, value.function_name) - return value - - - -def register_in_context(context): - context.register_function(expand_property_namespace, 'operator_:') - context.register_function(expand_function_namespace, 'operator_:') - diff --git a/examples/runner.py b/examples/runner.py deleted file mode 100644 index c7c8b36..0000000 --- a/examples/runner.py +++ /dev/null @@ -1,60 +0,0 @@ -# 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. - -import types - -import containers -from examples.ns import definition -from examples import ns_functions -from yaql.tests import testdata -import yaql - - -# DEPRECATED. Use cli to run samples - -context = yaql.create_context() -ns_functions.register_in_context(context) -data = testdata.data - -definition.register_shortening('tst', 'com.examples.test') -definition.register_symbol('com.examples.test', 'Symbol') -definition.register_symbol('com.examples.test', 'Function') - -context.register_function(testdata.process_customer, 'com.examples.test.Function') - - - - -expression_list = [ - # "$.services.join($.users, $1.yaql:owner=$2.id, dict('Service Name'=>$1.yaql:name,'User email'=>$2.email, 'Parent type'=>$1.yaql:parent_service))[$.'Parent type'=ex:Service0]", - # "range(0, 10 * random()).select(dict(num => $)).list()", - # "range(0).select(random()).takeWhile($ < 0.9).sum()", - # "$.users[0].tst:Function()" - "$.services" -] - - -parsed_list = [yaql.parse(expr) for expr in expression_list] -results = [expr.evaluate(data, context) for expr in parsed_list] - -i = 1 -for res in results: - print "result #{0}".format(i) - i += 1 - if isinstance(res, containers.Iterable) and not isinstance(res, types.StringType): - for r in res: - print r - else: - print res - diff --git a/setup.py b/setup.py index f5e9f3f..a5ac195 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup(name='yaql', description="Yet Another Query Language", author='Mirantis, Inc.', author_email='info@mirantis.com', - url='http://mirantis.com', + url='https://github.com/ativelkov/yaql', install_requires=['ply'], entry_points={ 'console_scripts': [ diff --git a/yaql/cli/cli_functions.py b/yaql/cli/cli_functions.py index 0eb85a4..09f462a 100644 --- a/yaql/cli/cli_functions.py +++ b/yaql/cli/cli_functions.py @@ -37,7 +37,7 @@ PROMPT = "yaql> " def main(context, show_tokens): print "Yet Another Query Language - command-line query tool" print "Version {0}".format(version) - print "Copyright (c) 2013 Mirantis, Inc" + print "Copyright (c) 2014 Mirantis, Inc" print if not context.get_data(): print "No data loaded into context "