From 3a8da3c1855663909d61c79aeb28ce04118d1d6f Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 11 Feb 2013 05:54:42 +0000 Subject: Add nuvem components. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1444662 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/components/logic/environment.py | 37 +++ sca-cpp/trunk/components/logic/nuvem/__init__.py | 17 ++ sca-cpp/trunk/components/logic/nuvem/add.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/and_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/animation.py | 28 ++ sca-cpp/trunk/components/logic/nuvem/app.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/append.py | 31 +++ sca-cpp/trunk/components/logic/nuvem/bsearch.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/bzprofile.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/call.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/ceil_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/comment.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/contains.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/cos_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/delete.py | 28 ++ sca-cpp/trunk/components/logic/nuvem/divide.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/email.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/empty.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/equals.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/eval_.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/exec_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/false_.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/fbalbums.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/fbfriends.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/fbgroups.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/fbprofile.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/filedb.py | 29 ++ sca-cpp/trunk/components/logic/nuvem/filter_.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/first.py | 25 ++ sca-cpp/trunk/components/logic/nuvem/flkalbum.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/floor_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/format_.py | 47 ++++ sca-cpp/trunk/components/logic/nuvem/frames.py | 56 ++++ sca-cpp/trunk/components/logic/nuvem/gaddress.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/get.py | 29 ++ sca-cpp/trunk/components/logic/nuvem/ggeopos.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/gimages.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/gmap.py | 36 +++ sca-cpp/trunk/components/logic/nuvem/greater.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/gsearch.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/gweather.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/host.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/htattrs.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/htbutton.py | 50 ++++ sca-cpp/trunk/components/logic/nuvem/htcheck.py | 51 ++++ sca-cpp/trunk/components/logic/nuvem/htimg.py | 50 ++++ sca-cpp/trunk/components/logic/nuvem/htinline.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/htlink.py | 51 ++++ sca-cpp/trunk/components/logic/nuvem/htstyle.py | 47 ++++ sca-cpp/trunk/components/logic/nuvem/if_.py | 24 ++ sca-cpp/trunk/components/logic/nuvem/insert.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/item.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/itemnb.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/join.py | 24 ++ sca-cpp/trunk/components/logic/nuvem/keychain.py | 38 +++ sca-cpp/trunk/components/logic/nuvem/last.py | 25 ++ sca-cpp/trunk/components/logic/nuvem/left.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/lesser.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/list_.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/location.py | 23 ++ sca-cpp/trunk/components/logic/nuvem/lookup.py | 55 ++++ sca-cpp/trunk/components/logic/nuvem/lowercase.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/map_.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/max_.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/min_.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/mod.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/multiply.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/name.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/names.py | 23 ++ sca-cpp/trunk/components/logic/nuvem/nosqldb.py | 29 ++ sca-cpp/trunk/components/logic/nuvem/not_.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/nothing.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/now.py | 24 ++ sca-cpp/trunk/components/logic/nuvem/number.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/or_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/pair.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/param.py | 28 ++ sca-cpp/trunk/components/logic/nuvem/params.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/parse.py | 25 ++ sca-cpp/trunk/components/logic/nuvem/path.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/pi_.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/picalbum.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/pixels.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/post.py | 28 ++ sca-cpp/trunk/components/logic/nuvem/put.py | 28 ++ sca-cpp/trunk/components/logic/nuvem/random_.py | 33 +++ sca-cpp/trunk/components/logic/nuvem/randoms.py | 34 +++ sca-cpp/trunk/components/logic/nuvem/range_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/realm.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/reduce_.py | 27 ++ sca-cpp/trunk/components/logic/nuvem/replace.py | 23 ++ sca-cpp/trunk/components/logic/nuvem/rest.py | 23 ++ sca-cpp/trunk/components/logic/nuvem/reverse.py | 25 ++ sca-cpp/trunk/components/logic/nuvem/round_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/second.py | 25 ++ sca-cpp/trunk/components/logic/nuvem/select.py | 72 +++++ sca-cpp/trunk/components/logic/nuvem/service.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/shuffle_.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/sin_.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/single.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/split.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/sqldb.py | 29 ++ sca-cpp/trunk/components/logic/nuvem/start.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/stop.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/subtract.py | 22 ++ sca-cpp/trunk/components/logic/nuvem/sum_.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/text.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/timer.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/top.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/transform.py | 26 ++ sca-cpp/trunk/components/logic/nuvem/transition.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/triple.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/true_.py | 20 ++ .../trunk/components/logic/nuvem/twfollowers.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/twfriends.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/twprofile.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/twsms.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/twtimeline.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/uppercase.py | 21 ++ sca-cpp/trunk/components/logic/nuvem/url.py | 42 +++ sca-cpp/trunk/components/logic/nuvem/user.py | 20 ++ sca-cpp/trunk/components/logic/nuvem/valueof.py | 35 +++ sca-cpp/trunk/components/logic/nuvem/values.py | 23 ++ sca-cpp/trunk/components/logic/nuvem/ysearch.py | 20 ++ sca-cpp/trunk/components/logic/property.py | 38 +++ sca-cpp/trunk/components/logic/reference.py | 38 +++ sca-cpp/trunk/components/logic/test.py | 295 +++++++++++++++++++++ 127 files changed, 3506 insertions(+) create mode 100644 sca-cpp/trunk/components/logic/environment.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/__init__.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/add.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/and_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/animation.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/app.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/append.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/bsearch.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/bzprofile.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/call.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/ceil_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/comment.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/contains.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/cos_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/delete.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/divide.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/email.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/empty.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/equals.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/eval_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/exec_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/false_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/fbalbums.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/fbfriends.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/fbgroups.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/fbprofile.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/filedb.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/filter_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/first.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/flkalbum.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/floor_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/format_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/frames.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/gaddress.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/get.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/ggeopos.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/gimages.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/gmap.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/greater.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/gsearch.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/gweather.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/host.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htattrs.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htbutton.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htcheck.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htimg.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htinline.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htlink.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/htstyle.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/if_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/insert.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/item.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/itemnb.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/join.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/keychain.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/last.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/left.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/lesser.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/list_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/location.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/lookup.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/lowercase.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/map_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/max_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/min_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/mod.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/multiply.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/name.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/names.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/nosqldb.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/not_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/nothing.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/now.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/number.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/or_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/pair.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/param.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/params.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/parse.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/path.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/pi_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/picalbum.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/pixels.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/post.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/put.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/random_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/randoms.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/range_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/realm.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/reduce_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/replace.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/rest.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/reverse.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/round_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/second.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/select.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/service.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/shuffle_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/sin_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/single.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/split.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/sqldb.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/start.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/stop.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/subtract.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/sum_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/text.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/timer.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/top.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/transform.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/transition.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/triple.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/true_.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/twfollowers.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/twfriends.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/twprofile.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/twsms.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/twtimeline.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/uppercase.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/url.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/user.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/valueof.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/values.py create mode 100644 sca-cpp/trunk/components/logic/nuvem/ysearch.py create mode 100644 sca-cpp/trunk/components/logic/property.py create mode 100644 sca-cpp/trunk/components/logic/reference.py create mode 100755 sca-cpp/trunk/components/logic/test.py (limited to 'sca-cpp') diff --git a/sca-cpp/trunk/components/logic/environment.py b/sca-cpp/trunk/components/logic/environment.py new file mode 100644 index 0000000000..088c905424 --- /dev/null +++ b/sca-cpp/trunk/components/logic/environment.py @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Mockup request environment variable for testing + +class environment: + def __init__(self, name): + self.name = name + self.value = None + + def get(self, id): + return self.value + + def put(self, id, value): + self.value = value + return True + + def __repr__(self): + return repr((self.name, self.value)) + +def mkenv(name): + return environment(name) + diff --git a/sca-cpp/trunk/components/logic/nuvem/__init__.py b/sca-cpp/trunk/components/logic/nuvem/__init__.py new file mode 100644 index 0000000000..de5c2d1b1e --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/__init__.py @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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/sca-cpp/trunk/components/logic/nuvem/add.py b/sca-cpp/trunk/components/logic/nuvem/add.py new file mode 100644 index 0000000000..b302a07143 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/add.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return float(0 if va is None else va) + float(0 if vb is None else vb) + diff --git a/sca-cpp/trunk/components/logic/nuvem/and_.py b/sca-cpp/trunk/components/logic/nuvem/and_.py new file mode 100644 index 0000000000..048d6c22b6 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/and_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return (False if va is None else bool(va)) and (False if vb is None else bool(vb)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/animation.py b/sca-cpp/trunk/components/logic/nuvem/animation.py new file mode 100644 index 0000000000..3dac880023 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/animation.py @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, msec, loop, content): + if r[0:1] == ('setup',): + ms = msec.get(r) + if ms is None or ms == 0: + return '' + l = loop.get(r) + lv = -1 if l is True else 0 if l is None or l is False else int(l) + return 'setupAnimationHandler(' + str(int(ms)) + ', ' + str(lv) + ');' + + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/app.py b/sca-cpp/trunk/components/logic/nuvem/app.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/app.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/append.py b/sca-cpp/trunk/components/logic/nuvem/append.py new file mode 100644 index 0000000000..20e1c8547e --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/append.py @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + va = a.get(r) + la = () if va is None else va if isList(va) else (va,) + vb = b.get(r) + lb = () if vb is None else vb if isList(vb) else (vb,) + return la + lb + diff --git a/sca-cpp/trunk/components/logic/nuvem/bsearch.py b/sca-cpp/trunk/components/logic/nuvem/bsearch.py new file mode 100644 index 0000000000..9ead197351 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/bsearch.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, q, s): + return s.get((("'q", q.get(r)), ("'format", 'rss'))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/bzprofile.py b/sca-cpp/trunk/components/logic/nuvem/bzprofile.py new file mode 100644 index 0000000000..b91cff2963 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/bzprofile.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, bzid, bz): + bid = bzid.get(r) + return bz.get((bid, '@self', ("'alt", 'json'))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/call.py b/sca-cpp/trunk/components/logic/nuvem/call.py new file mode 100644 index 0000000000..ed02ad07be --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/call.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, name, proxy): + nv = name.get(r) + return proxy.get("'start" if nv is None else nv if nv[0:1] == "'" else "'" + nv, r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/ceil_.py b/sca-cpp/trunk/components/logic/nuvem/ceil_.py new file mode 100644 index 0000000000..ca63726c5b --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/ceil_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x): + import math + vx = x.get(r) + return math.ceil(float(0.0 if vx is None else vx)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/comment.py b/sca-cpp/trunk/components/logic/nuvem/comment.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/comment.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/contains.py b/sca-cpp/trunk/components/logic/nuvem/contains.py new file mode 100644 index 0000000000..d8f442446f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/contains.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, sub, s): + vsub = sub.get(r) + vs = s.get(r) + return ('' if vs is None else str(vs)).find('' if vsub is None else str(vsub)) != -1 + diff --git a/sca-cpp/trunk/components/logic/nuvem/cos_.py b/sca-cpp/trunk/components/logic/nuvem/cos_.py new file mode 100644 index 0000000000..fb3213037b --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/cos_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x): + from math import cos + vx = x.get(r) + return cos(float(0.0 if vx is None else vx)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/delete.py b/sca-cpp/trunk/components/logic/nuvem/delete.py new file mode 100644 index 0000000000..a9a22768ae --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/delete.py @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, coll, id): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + idv = id.get(r) + return coll.delete(() if idv is None else idv if isList(idv) else (idv,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/divide.py b/sca-cpp/trunk/components/logic/nuvem/divide.py new file mode 100644 index 0000000000..83f02b105b --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/divide.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return float(0 if va is None else va) / float(1 if vb is None else vb) + diff --git a/sca-cpp/trunk/components/logic/nuvem/email.py b/sca-cpp/trunk/components/logic/nuvem/email.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/email.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/empty.py b/sca-cpp/trunk/components/logic/nuvem/empty.py new file mode 100644 index 0000000000..6b3d6f8b83 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/empty.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r): + return () + diff --git a/sca-cpp/trunk/components/logic/nuvem/equals.py b/sca-cpp/trunk/components/logic/nuvem/equals.py new file mode 100644 index 0000000000..7c777ae4f4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/equals.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return (() if va is None else va) == (() if vb is None else vb) + diff --git a/sca-cpp/trunk/components/logic/nuvem/eval_.py b/sca-cpp/trunk/components/logic/nuvem/eval_.py new file mode 100644 index 0000000000..97ba1f9068 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/eval_.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, py, ref): + pye = py.get(r) + return eval('' if pye is None else pye if isinstance(pye, basestring) else pye[1][0]) diff --git a/sca-cpp/trunk/components/logic/nuvem/exec_.py b/sca-cpp/trunk/components/logic/nuvem/exec_.py new file mode 100644 index 0000000000..00cab81405 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/exec_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, py, ref): + val = None + pys = py.get(r) + exec('' if pys is None else pys if isinstance(pys, basestring) else pys[1][0]) + return val diff --git a/sca-cpp/trunk/components/logic/nuvem/false_.py b/sca-cpp/trunk/components/logic/nuvem/false_.py new file mode 100644 index 0000000000..8cd3528b15 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/false_.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r): + return False + diff --git a/sca-cpp/trunk/components/logic/nuvem/fbalbums.py b/sca-cpp/trunk/components/logic/nuvem/fbalbums.py new file mode 100644 index 0000000000..64a81a091e --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/fbalbums.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fbid, fb): + fid = fbid.get(r) + return fb.get((fid, 'albums')) + diff --git a/sca-cpp/trunk/components/logic/nuvem/fbfriends.py b/sca-cpp/trunk/components/logic/nuvem/fbfriends.py new file mode 100644 index 0000000000..960e422bc6 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/fbfriends.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fbid, fb): + fid = fbid.get(r) + return fb.get((fid, 'friends')) + diff --git a/sca-cpp/trunk/components/logic/nuvem/fbgroups.py b/sca-cpp/trunk/components/logic/nuvem/fbgroups.py new file mode 100644 index 0000000000..cf0fe9ce0d --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/fbgroups.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fbid, fb): + fid = fbid.get(r) + return fb.get((fid, 'groups')) + diff --git a/sca-cpp/trunk/components/logic/nuvem/fbprofile.py b/sca-cpp/trunk/components/logic/nuvem/fbprofile.py new file mode 100644 index 0000000000..c1d2166bb9 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/fbprofile.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fbid, fb): + fid = fbid.get(r) + return fb.get((fid,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/filedb.py b/sca-cpp/trunk/components/logic/nuvem/filedb.py new file mode 100644 index 0000000000..8b69665e84 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/filedb.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(id, db, appname): + return db.get(("'filedb", appname.eval()) + id) + +def post(id, val, db, appname): + return db.post(("'filedb", appname.eval()) + id, val) + +def put(id, val, db, appname): + return db.put(("'filedb", appname.eval()) + id, val) + +def delete(id, db, appname): + return db.delete(("'filedb", appname.eval()) + id) + diff --git a/sca-cpp/trunk/components/logic/nuvem/filter_.py b/sca-cpp/trunk/components/logic/nuvem/filter_.py new file mode 100644 index 0000000000..343abcbe2a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/filter_.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, item, cond, l): + iv = item.get(r) + + def cfun(i): + return cond.get(((iv, i),) + r) + + vl = l.get(r) + return tuple(filter(cfun, () if vl is None else vl)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/first.py b/sca-cpp/trunk/components/logic/nuvem/first.py new file mode 100644 index 0000000000..6a10d5e74a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/first.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + if lv is None: + return None + if len(lv) == 0: + return None + return lv[0] + diff --git a/sca-cpp/trunk/components/logic/nuvem/flkalbum.py b/sca-cpp/trunk/components/logic/nuvem/flkalbum.py new file mode 100644 index 0000000000..81044c49d1 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/flkalbum.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, id, flk): + idv = id.get(r) + return flk.get((("'id", idv), ("'lang", 'en-us'), ("'format", 'json'))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/floor_.py b/sca-cpp/trunk/components/logic/nuvem/floor_.py new file mode 100644 index 0000000000..313e29e789 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/floor_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x): + import math + vx = x.get(r) + return math.floor(float(0 if vx is None else vx)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/format_.py b/sca-cpp/trunk/components/logic/nuvem/format_.py new file mode 100644 index 0000000000..eb276925da --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/format_.py @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fmt, args): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + def trimq(x): + if not isinstance(x, basestring): + return x + return x[1:] if x[0:1] == "'" else x + + l = args.get(r) + lv = () if l is None else l + la = map(trimq, filter(lambda x: not isAssoc(x), lv)) + ka = dict(map(lambda x: (x[0][1:], x[1]), filter(lambda x: isAssoc(x), lv))) + + vfmt = fmt.get(r) + return ('' if vfmt is None else str(vfmt)).format(*la, **ka) + diff --git a/sca-cpp/trunk/components/logic/nuvem/frames.py b/sca-cpp/trunk/components/logic/nuvem/frames.py new file mode 100644 index 0000000000..fa446e7e82 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/frames.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, msec, loop, content): + import string + + ms = msec.get(r) + if ms is None or ms == 0: + return '' + l = loop.get(r) + lv = 'infinite' if l is True else '1' if l is None or l is False else '{0:g}'.format(l) + + def keyframe(f): + t = f[0] + v = f[1] + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + if isList(v): + return '{0:g}% {{ {1} }}'.format(t, string.join(map(lambda x: (x[0][1:] + ': ' + str(x[1]) + ';') if isAssoc(x) else (str(x) + ';'), v), ' ')) + + return '{0:g}% {{ {1} }}'.format(t, v) + + kf = ' '.join(map(keyframe, content.get(r))) + + uid = '{id}' + return 'position: absolute; -webkit-animation: {0} {1:g}s ease 0 {2} normal; -moz-animation: {0} {1:g}s ease 0 {2} normal; '.format(uid, ms / 1000.0, lv, kf) + diff --git a/sca-cpp/trunk/components/logic/nuvem/gaddress.py b/sca-cpp/trunk/components/logic/nuvem/gaddress.py new file mode 100644 index 0000000000..8a1c9f8346 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/gaddress.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, s): + return s.get((("'address", str(a.get(r))), ("'sensor", 'true'))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/get.py b/sca-cpp/trunk/components/logic/nuvem/get.py new file mode 100644 index 0000000000..fd84934e2f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/get.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, coll, id): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + idv = id.get(r) + res = coll.get(() if idv is None else idv if isList(idv) else (idv,)) + return res + diff --git a/sca-cpp/trunk/components/logic/nuvem/ggeopos.py b/sca-cpp/trunk/components/logic/nuvem/ggeopos.py new file mode 100644 index 0000000000..e222d12041 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/ggeopos.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, lat, lng, s): + return s.get((("'latlng", str(lat.get(r)) + ',' + str(lng.get(r))), ("'sensor", 'true'))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/gimages.py b/sca-cpp/trunk/components/logic/nuvem/gimages.py new file mode 100644 index 0000000000..089adb1b6a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/gimages.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, q, s): + return s.get((("'v", '1.0'), ("'rsz", 8), ("'q", q.get(r)))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/gmap.py b/sca-cpp/trunk/components/logic/nuvem/gmap.py new file mode 100644 index 0000000000..3642912121 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/gmap.py @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, markers, s): + + def ismarker(m): + return m[1] is not None + + def marker(m): + # expecting (label or icon url, (color, loc)) + label = m[0][1:] + deco = m[1][0] + loc = string.join(map(str, m[1][1:3]), ',') + if deco.find(':') == -1: + return ("'markers", 'color:{0}|label:{1}|{2}'.format(deco, label, loc)) + return ("'markers", 'icon:{0}|{1}'.format(deco, loc)) + + mv = markers.get(r) + return s.get((("'size", '320x320'), ("'maptype", 'roadmap'), ("'sensor", 'true')) + tuple(map(marker, filter(ismarker, () if mv is None else mv)))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/greater.py b/sca-cpp/trunk/components/logic/nuvem/greater.py new file mode 100644 index 0000000000..851eda908f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/greater.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + return a.get(r) > b.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/gsearch.py b/sca-cpp/trunk/components/logic/nuvem/gsearch.py new file mode 100644 index 0000000000..c213f0397b --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/gsearch.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, q, s): + return s.get((("'v", '1.0'), ("'q", q.get(r)))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/gweather.py b/sca-cpp/trunk/components/logic/nuvem/gweather.py new file mode 100644 index 0000000000..e02062feee --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/gweather.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, zip, w): + return w.get((("'weather", zip.get(r)),)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/host.py b/sca-cpp/trunk/components/logic/nuvem/host.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/host.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/htattrs.py b/sca-cpp/trunk/components/logic/nuvem/htattrs.py new file mode 100644 index 0000000000..d30bb4ad4a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htattrs.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, v): + return ("'htattrs", v.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htbutton.py b/sca-cpp/trunk/components/logic/nuvem/htbutton.py new file mode 100644 index 0000000000..193cab2bc9 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htbutton.py @@ -0,0 +1,50 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, value): + v = value.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + def mkbutton(v): + vl = filter(lambda x: not isAssoc(x), v) + al = (filter(lambda x: isAssoc(x) and x[0] == "'htattrs", v) + (("'htattrs",()),))[0][1] + l = (() if len(vl) == 0 else (("'id", vl[0]), ("'value", vl[0])) if len(vl) == 1 else (("'id", vl[0]), ("'value", vl[1]))) + al + if len(l) == 0: + return '' + satts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] == "'id", l)), ' ') + batts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] != "'id", l)), ' ') + return ''.format(satts, batts) + + return mkbutton(()) if v is None else mkbutton(v) if isList(v) and not isAssoc(v) else mkbutton((v,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htcheck.py b/sca-cpp/trunk/components/logic/nuvem/htcheck.py new file mode 100644 index 0000000000..5c15b936f8 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htcheck.py @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, value): + v = value.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + def mkcheck(v): + vl = filter(lambda x: not isAssoc(x), v) + al = (filter(lambda x: isAssoc(x) and x[0] == "'htattrs", v) + (("'htattrs",()),))[0][1] + l = (() if len(vl) == 0 else (("'id", vl[0]), ("'value", vl[0])) if len(vl) == 1 else (("'id", vl[0]), ("'value", vl[1]))) + al + if len(l) == 0: + return ''; + satts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] == "'id", l)), ' ') + catts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] != "'id", l)), ' ') + text = filter(lambda x: x[0] == "'value", l)[0][1] + return '{2}'.format(satts, catts, text) + + return mkcheck(()) if v is None else mkcheck(v) if isList(v) and not isAssoc(v) else mkcheck((v,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htimg.py b/sca-cpp/trunk/components/logic/nuvem/htimg.py new file mode 100644 index 0000000000..70c613667f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htimg.py @@ -0,0 +1,50 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, value): + v = value.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + def mkimg(v): + vl = filter(lambda x: not isAssoc(x), v) + al = (filter(lambda x: isAssoc(x) and x[0] == "'htattrs", v) + (("'htattrs",()),))[0][1] + l = (() if len(vl) == 0 else (("'id", vl[0]), ("'src", vl[0])) if len(vl) == 1 else (("'id", vl[0]), ("'src", vl[1]))) + al + if len(l) == 0: + return '' + satts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] == "'id", l)), ' ') + iatts = string.join(map(lambda x: ('style' if x[0] == "'htstyle" else x[0][1:]) + '="' + x[1] + '"', filter(lambda x: x[0] != "'id", l)), ' ') + return ''.format(satts, iatts) + + return mkimg(()) if v is None else mkimg(v) if isList(v) and not isAssoc(v) else mkimg((v,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htinline.py b/sca-cpp/trunk/components/logic/nuvem/htinline.py new file mode 100644 index 0000000000..6e0551a8aa --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htinline.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 base64 +import string + +def get(r, img): + v = img.get(r) + if v is None: + return '' + return 'data:' + v[0] + ';base64,' + base64.encodestring(string.join(v[1], '')) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htlink.py b/sca-cpp/trunk/components/logic/nuvem/htlink.py new file mode 100644 index 0000000000..4865591f55 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htlink.py @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, value): + v = value.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + def mklink(v): + vl = filter(lambda x: not isAssoc(x), v) + al = (filter(lambda x: isAssoc(x) and x[0] == "'htattrs", v) + (("'htattrs",()),))[0][1] + l = (() if len(vl) == 0 else (("'id", vl[0]), ("'href", vl[0]), ("'value", vl[0])) if len(vl) == 1 else (("'id", vl[0]), ("'href", vl[0]), ("'value", vl[1])) if len(vl) == 2 else (("'id", vl[0]), ("'href", vl[1]), ("'value", vl[2]))) + al + if len(l) == 0: + return '' + satts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] == "'id", l)), ' ') + hatts = string.join(map(lambda x: x[0][1:] + '="' + x[1] + '"', filter(lambda x: x[0] != "'id" and x[0] != "'value", l)), ' ') + text = filter(lambda x: x[0] == "'value", l)[0][1] + return '{2}'.format(satts, hatts, text) + + return mklink(()) if v is None else mklink(v) if isList(v) and not isAssoc(v) else mklink((v,)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/htstyle.py b/sca-cpp/trunk/components/logic/nuvem/htstyle.py new file mode 100644 index 0000000000..5e52b33080 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/htstyle.py @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, value): + v = value.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + if v is None: + return ("'htstyle", '') + + if isList(v): + lv = (v,) if isAssoc(v) else v + return ("'htstyle", string.join(map(lambda x: (x[0][1:] + ': ' + str(x[1]) + ';') if isAssoc(x) else (str(x) + ';'), lv), ' ')) + + return ("'htstyle", v + ';') + diff --git a/sca-cpp/trunk/components/logic/nuvem/if_.py b/sca-cpp/trunk/components/logic/nuvem/if_.py new file mode 100644 index 0000000000..17a261b0a4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/if_.py @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, cond, then, els): + vc = cond.get(r) + if vc: + return then.get(r) + else: + return els.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/insert.py b/sca-cpp/trunk/components/logic/nuvem/insert.py new file mode 100644 index 0000000000..6a78a816eb --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/insert.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, first, rest): + vf = first.get(r) + vr = rest.get(r) + return (vf,) + (() if vr is None else vr) + diff --git a/sca-cpp/trunk/components/logic/nuvem/item.py b/sca-cpp/trunk/components/logic/nuvem/item.py new file mode 100644 index 0000000000..19e565a9c8 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/item.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, v, prop): + return ("'" + prop.eval(), v.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/itemnb.py b/sca-cpp/trunk/components/logic/nuvem/itemnb.py new file mode 100644 index 0000000000..25d4cd6ce8 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/itemnb.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, i, l): + lv = l.get(r) + vi = i.get(r) + return (() if lv is None else lv)[0 if vi is None else int(vi)] + diff --git a/sca-cpp/trunk/components/logic/nuvem/join.py b/sca-cpp/trunk/components/logic/nuvem/join.py new file mode 100644 index 0000000000..d3bfd86eb7 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/join.py @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 string + +def get(r, sep, l): + s = sep.get(r) + lv = l.get(r) + return string.join(() if lv is None else lv, '' if s is None else s) + diff --git a/sca-cpp/trunk/components/logic/nuvem/keychain.py b/sca-cpp/trunk/components/logic/nuvem/keychain.py new file mode 100644 index 0000000000..44e6653e93 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/keychain.py @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n, a): + nv = n.get(r) + ntv = nv[1:] if nv[0:1] == "'" else nv + av = a.get(r) + + content = filter(lambda e: e[0] == "'content", av[0]) + account = filter(lambda e: e[0] == "'account", () if len(content) == 0 else content[0]) + keys = filter(lambda e: e[0] == "'keys", () if len(account) == 0 else account[0]) + key = filter(lambda e: e[0] == "'key", () if len(keys) == 0 else keys[0]) + ekey = () if len(key) == 0 else key[0] + akey = () if len(ekey) < 2 else ekey[1] + + def namedkey(k): + return len(filter(lambda e: e[0] == "'@name" and e[1] == ntv, k)) != 0 + + def keyvalue(k): + return filter(lambda e: e[0] == "'@value", k) + + kv = map(keyvalue, filter(namedkey, akey)) + return None if len(kv) == 0 else kv[0][0][1] + diff --git a/sca-cpp/trunk/components/logic/nuvem/last.py b/sca-cpp/trunk/components/logic/nuvem/last.py new file mode 100644 index 0000000000..81613ae60a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/last.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + if lv is None: + return None + if len(lv) == 0: + return None + return lv[len(lv) - 1] + diff --git a/sca-cpp/trunk/components/logic/nuvem/left.py b/sca-cpp/trunk/components/logic/nuvem/left.py new file mode 100644 index 0000000000..1daee3907d --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/left.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n): + vn = n.get(r) + return 'left: {0:g}px'.format(round(0 if vn is None else float(vn), 0)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/lesser.py b/sca-cpp/trunk/components/logic/nuvem/lesser.py new file mode 100644 index 0000000000..622dd36922 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/lesser.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + return a.get(r) < b.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/list_.py b/sca-cpp/trunk/components/logic/nuvem/list_.py new file mode 100644 index 0000000000..0b6114c8e1 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/list_.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(*args): + r = args[0] + return tuple(map(lambda x: x.get(r), args[1:len(args) - 1])) + diff --git a/sca-cpp/trunk/components/logic/nuvem/location.py b/sca-cpp/trunk/components/logic/nuvem/location.py new file mode 100644 index 0000000000..2f45687bc3 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/location.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, content): + if r[0:1] == ('setup',): + return 'setupLocationHandler();' + + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/lookup.py b/sca-cpp/trunk/components/logic/nuvem/lookup.py new file mode 100644 index 0000000000..d61d032636 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/lookup.py @@ -0,0 +1,55 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Return a list of name value pairs that match a name +def get(r, n, l): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + return isList(v) and len(v) == 2 and isinstance(v[0], basestring) and v[0][0:1] == "'" + + def lookup(nv, lv): + if lv == (): + return () + + # Check if list element is a name value pair assoc + a = lv[0] + if not isAssoc(a): + return lookup(nv, lv[1:]) + + # Got a match, return it and lookup rest of the list + an = "'" + a[0][2:] if a[0][0:2] == "'@" else a[0] + if an == nv: + return (a,) + lookup(nv, lv[1:]) + + # No match, lookup rest of the list + return lookup(nv, lv[1:]) + + def qsymbol(x): + if not isinstance(x, basestring): + return x + return x if x[0:1] == "'" else "'" + x + + nv = n.get(r) + lv = l.get(r) + return lookup(qsymbol(nv), () if lv is None else lv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/lowercase.py b/sca-cpp/trunk/components/logic/nuvem/lowercase.py new file mode 100644 index 0000000000..461e3ed450 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/lowercase.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, s): + vs = s.get(r) + return ('' if vs is None else str(vs)).lower() + diff --git a/sca-cpp/trunk/components/logic/nuvem/map_.py b/sca-cpp/trunk/components/logic/nuvem/map_.py new file mode 100644 index 0000000000..4194d627bb --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/map_.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, item, transform, l): + iv = item.get(r) + + def tfun(i): + return transform.get(((iv, i),) + r) + + lv = l.get(r) + return tuple(map(tfun, () if lv is None else lv)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/max_.py b/sca-cpp/trunk/components/logic/nuvem/max_.py new file mode 100644 index 0000000000..74534fc076 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/max_.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + return max(() if lv is None else lv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/min_.py b/sca-cpp/trunk/components/logic/nuvem/min_.py new file mode 100644 index 0000000000..bb0c0bca5e --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/min_.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + return min(() if lv is None else lv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/mod.py b/sca-cpp/trunk/components/logic/nuvem/mod.py new file mode 100644 index 0000000000..3f0fc05e46 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/mod.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n, x): + vx = x.get(r) + vn = n.get(r) + return float(0 if vx is None else vx) % float(1 if vn is None else vn) + diff --git a/sca-cpp/trunk/components/logic/nuvem/multiply.py b/sca-cpp/trunk/components/logic/nuvem/multiply.py new file mode 100644 index 0000000000..ad60c351c0 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/multiply.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return float(0 if va is None else va) * float(0 if vb is None else vb) + diff --git a/sca-cpp/trunk/components/logic/nuvem/name.py b/sca-cpp/trunk/components/logic/nuvem/name.py new file mode 100644 index 0000000000..f5582dc097 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/name.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return "'" + prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/names.py b/sca-cpp/trunk/components/logic/nuvem/names.py new file mode 100644 index 0000000000..f30f5d1a0c --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/names.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + if lv is None: + return lv + return tuple(map(lambda p: p[0], lv)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/nosqldb.py b/sca-cpp/trunk/components/logic/nuvem/nosqldb.py new file mode 100644 index 0000000000..6458940a8d --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/nosqldb.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(id, db, appname): + return db.get(("'nosqldb", appname.eval()) + id); + +def post(id, val, db, appname): + return db.post(("'nosqldb", appname.eval()) + id, val); + +def put(id, val, db, appname): + return db.put(("'nosqldb", appname.eval()) + id, val); + +def delete(id, db, appname): + return db.delete(("'nosqldb", appname.eval()) + id); + diff --git a/sca-cpp/trunk/components/logic/nuvem/not_.py b/sca-cpp/trunk/components/logic/nuvem/not_.py new file mode 100644 index 0000000000..fd20a95ea2 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/not_.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, expr): + return not expr.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/nothing.py b/sca-cpp/trunk/components/logic/nuvem/nothing.py new file mode 100644 index 0000000000..5b144cb0d0 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/nothing.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r): + return None + diff --git a/sca-cpp/trunk/components/logic/nuvem/now.py b/sca-cpp/trunk/components/logic/nuvem/now.py new file mode 100644 index 0000000000..b0015117cb --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/now.py @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, f): + from datetime import datetime + fv = f.get(r) + if fv is None: + return datetime.now().ctime() + return datetime.now().strftime(fv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/number.py b/sca-cpp/trunk/components/logic/nuvem/number.py new file mode 100644 index 0000000000..85484317f3 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/number.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return float(prop.eval()) + diff --git a/sca-cpp/trunk/components/logic/nuvem/or_.py b/sca-cpp/trunk/components/logic/nuvem/or_.py new file mode 100644 index 0000000000..eea7aa9915 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/or_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return (False if va is None else bool(va)) or (False if vb is None else bool(vb)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/pair.py b/sca-cpp/trunk/components/logic/nuvem/pair.py new file mode 100644 index 0000000000..dbfd41c06f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/pair.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + return (a.get(r), b.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/param.py b/sca-cpp/trunk/components/logic/nuvem/param.py new file mode 100644 index 0000000000..c67ab5a8fd --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/param.py @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, name, params): + def lookup(nv, lv): + if lv == (): + return None + a = lv[0] + if a[0] == nv: + return a[1] + return lookup(nv, lv[1:]) + + return lookup("'" + name.eval(), params.eval()) + diff --git a/sca-cpp/trunk/components/logic/nuvem/params.py b/sca-cpp/trunk/components/logic/nuvem/params.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/params.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/parse.py b/sca-cpp/trunk/components/logic/nuvem/parse.py new file mode 100644 index 0000000000..d019813c5f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/parse.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 re + +def get(r, expr, s): + ev = expr.get(r) + sv = s.get(r) + m = re.search('' if ev is None else ev, '' if sv is None else sv) + return () if m is None else m.groups() + diff --git a/sca-cpp/trunk/components/logic/nuvem/path.py b/sca-cpp/trunk/components/logic/nuvem/path.py new file mode 100644 index 0000000000..0df2a298ea --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/path.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + p = prop.eval() + return p[2:] if p[0:1] == ('components',) else p + diff --git a/sca-cpp/trunk/components/logic/nuvem/pi_.py b/sca-cpp/trunk/components/logic/nuvem/pi_.py new file mode 100644 index 0000000000..9a76a0c470 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/pi_.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r): + from math import pi + return pi + diff --git a/sca-cpp/trunk/components/logic/nuvem/picalbum.py b/sca-cpp/trunk/components/logic/nuvem/picalbum.py new file mode 100644 index 0000000000..d970ff0c8a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/picalbum.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, id, pic): + idv = id.get(r) + return pic.get((idv, ("'kind", 'photo'), ("'max-results", 20))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/pixels.py b/sca-cpp/trunk/components/logic/nuvem/pixels.py new file mode 100644 index 0000000000..f65fcc7fdd --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/pixels.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n): + vn = n.get(r) + return '{0:g}px'.format(round(0 if vn is None else float(vn), 0)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/post.py b/sca-cpp/trunk/components/logic/nuvem/post.py new file mode 100644 index 0000000000..cf774695a4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/post.py @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, coll, id, val): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + idv = id.get(r) + return coll.post(() if idv is None else idv if isList(idv) else (idv,), val.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/put.py b/sca-cpp/trunk/components/logic/nuvem/put.py new file mode 100644 index 0000000000..f7c9eea098 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/put.py @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, coll, id, val): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + idv = id.get(r) + return coll.put(() if idv is None else idv if isList(idv) else (idv,), val.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/random_.py b/sca-cpp/trunk/components/logic/nuvem/random_.py new file mode 100644 index 0000000000..d76e88caaf --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/random_.py @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, m): + import random + mv = m.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + if isList(mv): + return random.choice(mv) + + return random.random() * (1.0 if mv is None else mv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/randoms.py b/sca-cpp/trunk/components/logic/nuvem/randoms.py new file mode 100644 index 0000000000..de99b05ffa --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/randoms.py @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n, m): + import random + mv = m.get(r) + nv = n.get(r) + + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + if isList(mv): + return tuple(map(lambda i: random.choice(mv), tuple(range(0, int(0 if nv is None else nv))))) + + return tuple(map(lambda i: random.random() * (1.0 if mv is None else mv), tuple(range(0, int(0 if nv is None else nv))))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/range_.py b/sca-cpp/trunk/components/logic/nuvem/range_.py new file mode 100644 index 0000000000..cdc7c24204 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/range_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return tuple(range(int(0 if va is None else va), int(0 if vb is None else vb))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/realm.py b/sca-cpp/trunk/components/logic/nuvem/realm.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/realm.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/reduce_.py b/sca-cpp/trunk/components/logic/nuvem/reduce_.py new file mode 100644 index 0000000000..ed5e9490ce --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/reduce_.py @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, item, accum, transform, init, l): + iv = item.get(r) + av = accum.get(r) + + def tfun(a, i): + return transform.get(((av, a), (iv, i)) + r) + + lv = l.get(r) + return reduce(tfun, () if lv is None else lv, init.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/replace.py b/sca-cpp/trunk/components/logic/nuvem/replace.py new file mode 100644 index 0000000000..5ce41fd3df --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/replace.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, fr, to, s): + vfr = fr.get(r) + vto = to.get(r) + vs = s.get(r) + return ('' if vs is None else str(vs)).replace('' if vfr is None else str(vfr), '' if vto is None else str(vto)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/rest.py b/sca-cpp/trunk/components/logic/nuvem/rest.py new file mode 100644 index 0000000000..cd23115d1c --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/rest.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + vl = l.get(r) + if vl is None: + return () + return vl[1:] + diff --git a/sca-cpp/trunk/components/logic/nuvem/reverse.py b/sca-cpp/trunk/components/logic/nuvem/reverse.py new file mode 100644 index 0000000000..61361e233f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/reverse.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + vl = l.get(r) + if vl is None: + return () + rl = list(vl) + rl.reverse() + return tuple(rl) + diff --git a/sca-cpp/trunk/components/logic/nuvem/round_.py b/sca-cpp/trunk/components/logic/nuvem/round_.py new file mode 100644 index 0000000000..f2bbe0de75 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/round_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n, x): + vx = x.get(r) + vn = n.get(r) + return round(float(0 if vx is None else vx), int(0 if vn is None else vn)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/second.py b/sca-cpp/trunk/components/logic/nuvem/second.py new file mode 100644 index 0000000000..79acf79e3a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/second.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + if lv is None: + return lv + if len(lv) < 2: + return None + return lv[1] + diff --git a/sca-cpp/trunk/components/logic/nuvem/select.py b/sca-cpp/trunk/components/logic/nuvem/select.py new file mode 100644 index 0000000000..bf10a756a4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/select.py @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Return a list of name value pairs that match a name +# Search through nested lists of name value pairs +def get(r, p, l): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + return isList(v) and len(v) >= 2 and isinstance(v[0], basestring) and v[0][0:1] == "'" + + def lookup(pv, lv): + if lv == (): + return () + if isAssoc(lv): + lv = (lv,) + + # Check if list element is a name value pair assoc + a = lv[0] + if not isAssoc(a): + # Lookup children if any and rest of list + if isList(a): + return lookup(pv, a) + lookup(pv, lv[1:]) + return lookup(pv, lv[1:]) + + # Path segment match + an = "'" + a[0][2:] if a[0][0:2] == "'@" else a[0] + if an == pv[0]: + # Found leaf, return it and lookup rest of the list + if len(pv) == 1: + return (a,) + lookup(pv, lv[1:]) + # Continue to lookup children if any plus rest of the list + return lookup(pv[1:], a[1:]) + lookup(pv, lv[1:]) + + # No match, lookup any children and rest of the list + if (isList(a[1])): + return lookup(pv, a[1]) + lookup(pv, a[2:]) + lookup(pv, lv[1:]) + return lookup(pv, a[2:]) + lookup(pv, lv[1:]) + + def qsymbol(x): + if not isinstance(x, basestring): + return x + return x if x[0:1] == "'" else "'" + x + + # Support path as a list or a dot separated string + lv = l.get(r) + pv = p.get(r) + if (isList(pv)): + return lookup(map(qsymbol, pv), () if lv is None else lv) + + spv = map(qsymbol, qsymbol(pv)[1:].split('.')) + return lookup(spv, () if lv is None else lv) + diff --git a/sca-cpp/trunk/components/logic/nuvem/service.py b/sca-cpp/trunk/components/logic/nuvem/service.py new file mode 100644 index 0000000000..80b0529213 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/service.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, content): + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/shuffle_.py b/sca-cpp/trunk/components/logic/nuvem/shuffle_.py new file mode 100644 index 0000000000..7b55c45a51 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/shuffle_.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + from random import shuffle + vl = l.get(r) + if vl is None: + return () + rl = list(vl) + shuffle(rl) + return tuple(rl) + diff --git a/sca-cpp/trunk/components/logic/nuvem/sin_.py b/sca-cpp/trunk/components/logic/nuvem/sin_.py new file mode 100644 index 0000000000..1bbefc7a75 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/sin_.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x): + from math import sin + vx = x.get(r) + return sin(float(0 if vx is None else vx)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/single.py b/sca-cpp/trunk/components/logic/nuvem/single.py new file mode 100644 index 0000000000..29e237ef74 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/single.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x): + return (x.get(r),) + diff --git a/sca-cpp/trunk/components/logic/nuvem/split.py b/sca-cpp/trunk/components/logic/nuvem/split.py new file mode 100644 index 0000000000..2ff98075cd --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/split.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, sep, s): + vsep = sep.get(r) + vs = s.get(r) + return tuple(('' if vs is None else str(vs)).split('' if vsep is None else str(vsep))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/sqldb.py b/sca-cpp/trunk/components/logic/nuvem/sqldb.py new file mode 100644 index 0000000000..184d83ac04 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/sqldb.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(id, db, appname): + return db.get(("'sqldb", appname.eval()) + id); + +def post(id, val, db, appname): + return db.post(("'sqldb", appname.eval()) + id, val); + +def put(id, val, db, appname): + return db.put(("'sqldb", appname.eval()) + id, val); + +def delete(id, db, appname): + return db.delete(("'sqldb", appname.eval()) + id); + diff --git a/sca-cpp/trunk/components/logic/nuvem/start.py b/sca-cpp/trunk/components/logic/nuvem/start.py new file mode 100644 index 0000000000..80b0529213 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/start.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, content): + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/stop.py b/sca-cpp/trunk/components/logic/nuvem/stop.py new file mode 100644 index 0000000000..80b0529213 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/stop.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, content): + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/subtract.py b/sca-cpp/trunk/components/logic/nuvem/subtract.py new file mode 100644 index 0000000000..bb791df3d8 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/subtract.py @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b): + va = a.get(r) + vb = b.get(r) + return float(0 if va is None else va) - float(0 if vb is None else vb) + diff --git a/sca-cpp/trunk/components/logic/nuvem/sum_.py b/sca-cpp/trunk/components/logic/nuvem/sum_.py new file mode 100644 index 0000000000..1ecfc79b0a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/sum_.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + vl = l.get(r) + return sum(() if vl is None else vl) + diff --git a/sca-cpp/trunk/components/logic/nuvem/text.py b/sca-cpp/trunk/components/logic/nuvem/text.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/text.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/timer.py b/sca-cpp/trunk/components/logic/nuvem/timer.py new file mode 100644 index 0000000000..97a2367cc3 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/timer.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, msec, content): + if r[0:1] == ('setup',): + ms = msec.get(r) + if ms is None or ms == 0: + return '' + return 'setupIntervalHandler(' + str(int(ms)) + ');' + + return content.get(r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/top.py b/sca-cpp/trunk/components/logic/nuvem/top.py new file mode 100644 index 0000000000..87b75e6ae1 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/top.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n): + vn = n.get(r) + return 'top: {0:g}px'.format(round(0 if vn is None else float(vn), 0)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/transform.py b/sca-cpp/trunk/components/logic/nuvem/transform.py new file mode 100644 index 0000000000..4973176cef --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/transform.py @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, x, y, d): + vx = x.get(r) + vy = y.get(r) + vd = d.get(r) + rx = round(float(0 if vx is None else vx), 0) + ry = round(float(0 if vy is None else vy), 0) + rd = round(float(0 if vd is None else vd), 0) + return 'position: absolute; -webkit-transform: translate3d({0:g}px,{1:g}px,0px) rotate({2:g}deg); -moz-transform: translate({0:g}px,{1:g}px) rotate({2:g}deg); -ms-transform: translate({0:g}px,{1:g}px) rotate({2:g}deg); transform: translate({0:g}px,{1:g}px) rotate({2:g}deg)'.format(rx, ry, rd) + diff --git a/sca-cpp/trunk/components/logic/nuvem/transition.py b/sca-cpp/trunk/components/logic/nuvem/transition.py new file mode 100644 index 0000000000..99c4a1a9c5 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/transition.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, n): + vn = n.get(r) + return '-webkit-transition: all {0}s'.format(float(0 if vn is None else vn) / 1000.0) + diff --git a/sca-cpp/trunk/components/logic/nuvem/triple.py b/sca-cpp/trunk/components/logic/nuvem/triple.py new file mode 100644 index 0000000000..72ba3b8b77 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/triple.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, a, b, c): + return (a.get(r), b.get(r), c.get(r)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/true_.py b/sca-cpp/trunk/components/logic/nuvem/true_.py new file mode 100644 index 0000000000..ce806cc8ed --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/true_.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r): + return True + diff --git a/sca-cpp/trunk/components/logic/nuvem/twfollowers.py b/sca-cpp/trunk/components/logic/nuvem/twfollowers.py new file mode 100644 index 0000000000..ff1dff16b4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/twfollowers.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, twid, tw): + tid = twid.get(r) + return tw.get((("'screen_name", tid),)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/twfriends.py b/sca-cpp/trunk/components/logic/nuvem/twfriends.py new file mode 100644 index 0000000000..ff1dff16b4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/twfriends.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, twid, tw): + tid = twid.get(r) + return tw.get((("'screen_name", tid),)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/twprofile.py b/sca-cpp/trunk/components/logic/nuvem/twprofile.py new file mode 100644 index 0000000000..ff1dff16b4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/twprofile.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, twid, tw): + tid = twid.get(r) + return tw.get((("'screen_name", tid),)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/twsms.py b/sca-cpp/trunk/components/logic/nuvem/twsms.py new file mode 100644 index 0000000000..a42eae3051 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/twsms.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, sid, tok, fr, to, msg, s): + return s.get('app://twsms', ('c', 'send', ("'sid", sid.get(r)), ("'token", tok.get(r)), ("'from", fr.get(r)), ("'to", to.get(r)), ("'msg", msg.get(r)))) + diff --git a/sca-cpp/trunk/components/logic/nuvem/twtimeline.py b/sca-cpp/trunk/components/logic/nuvem/twtimeline.py new file mode 100644 index 0000000000..ff1dff16b4 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/twtimeline.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, twid, tw): + tid = twid.get(r) + return tw.get((("'screen_name", tid),)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/uppercase.py b/sca-cpp/trunk/components/logic/nuvem/uppercase.py new file mode 100644 index 0000000000..82bf0dacc1 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/uppercase.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, s): + vs = s.get(r) + return ('' if vs is None else str(vs)).upper() + diff --git a/sca-cpp/trunk/components/logic/nuvem/url.py b/sca-cpp/trunk/components/logic/nuvem/url.py new file mode 100644 index 0000000000..82bad01c0f --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/url.py @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, address, args): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def isAssoc(v): + if not isList(v): + return False + if len(v) != 2: + return False + if isinstance(v[0], basestring) and v[0][0:1] == "'": + return True + return False + + l = args.get(r) + lv = () if l is None else l + la = map(lambda x: str(x), filter(lambda x: not isAssoc(x), lv)) + ka = map(lambda x: '='.join((x[0][1:], str(x[1]))), filter(lambda x: isAssoc(x), lv)) + + va = address.get(r) + return ('' if va is None else str(va)) + '/'.join(la) + ('?' if len(ka) != 0 else '') + '&'.join(ka) + diff --git a/sca-cpp/trunk/components/logic/nuvem/user.py b/sca-cpp/trunk/components/logic/nuvem/user.py new file mode 100644 index 0000000000..d17ca78b43 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/user.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, prop): + return prop.eval() + diff --git a/sca-cpp/trunk/components/logic/nuvem/valueof.py b/sca-cpp/trunk/components/logic/nuvem/valueof.py new file mode 100644 index 0000000000..60e58786b3 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/valueof.py @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, name): + def isList(v): + if getattr(v, '__iter__', False) == False: + return False + if isinstance(v, basestring) or isinstance(v, dict): + return False + return True + + def lookup(n, r): + if r == (): + return None + a = r[0] + if isList(a) and a[0] == n: + return a[1] + return lookup(n, r[1:]) + + return lookup("'" + name.eval(), r) + diff --git a/sca-cpp/trunk/components/logic/nuvem/values.py b/sca-cpp/trunk/components/logic/nuvem/values.py new file mode 100644 index 0000000000..620eab4c8a --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/values.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, l): + lv = l.get(r) + if lv is None: + return lv + return tuple(map(lambda p: p[1], lv)) + diff --git a/sca-cpp/trunk/components/logic/nuvem/ysearch.py b/sca-cpp/trunk/components/logic/nuvem/ysearch.py new file mode 100644 index 0000000000..f6d09947e6 --- /dev/null +++ b/sca-cpp/trunk/components/logic/nuvem/ysearch.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +def get(r, q, s): + return s.get((("'appid", 'YahooDemo'), ("'query", q.get(r)), ("'output", 'json'))) + diff --git a/sca-cpp/trunk/components/logic/property.py b/sca-cpp/trunk/components/logic/property.py new file mode 100644 index 0000000000..1cbb4b2cab --- /dev/null +++ b/sca-cpp/trunk/components/logic/property.py @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Mockup component properties for testing + +class property: + def __init__(self, name, l): + self.name = name + self.l = l + + def __call__(self, *args): + return self.l(*args) + + def __getattr__(self, name): + if name == "eval": + return self + raise AttributeError() + + def __repr__(self): + return repr((self.name, self.l())) + +def mkprop(name, l): + return property(name, l) + diff --git a/sca-cpp/trunk/components/logic/reference.py b/sca-cpp/trunk/components/logic/reference.py new file mode 100644 index 0000000000..fe4a66a087 --- /dev/null +++ b/sca-cpp/trunk/components/logic/reference.py @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Mockup component references for testing + +class reference: + def __init__(self, name, l): + self.name = name + self.l = l + + def __call__(self, *args): + return self.l(*args) + + def __getattr__(self, name): + if name == "get" or name == "put": + return self + raise AttributeError() + + def __repr__(self): + return repr((self.name, self.l)) + +def mkref(name, l): + return reference(name, l) + diff --git a/sca-cpp/trunk/components/logic/test.py b/sca-cpp/trunk/components/logic/test.py new file mode 100755 index 0000000000..a6e3856e05 --- /dev/null +++ b/sca-cpp/trunk/components/logic/test.py @@ -0,0 +1,295 @@ +#!/usr/bin/python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Test the simple parallel programming components + +import unittest +from property import * +from reference import * +from environment import * + +from nuvem import true_ +from nuvem import false_ +from nuvem import number +from nuvem import text +from nuvem import comment +from nuvem import name +from nuvem import nothing +from nuvem import item +from nuvem import single +from nuvem import pair +from nuvem import triple +from nuvem import call +from nuvem import if_ +from nuvem import and_ +from nuvem import or_ +from nuvem import not_ +from nuvem import equals +from nuvem import lesser +from nuvem import greater +from nuvem import list_ +from nuvem import empty +from nuvem import first +from nuvem import second +from nuvem import rest +from nuvem import insert +from nuvem import append +from nuvem import itemnb +from nuvem import names +from nuvem import values +from nuvem import lookup +from nuvem import select +from nuvem import reverse +from nuvem import shuffle_ +from nuvem import range_ +from nuvem import map_ +from nuvem import valueof +from nuvem import filter_ +from nuvem import reduce_ +from nuvem import add +from nuvem import subtract +from nuvem import multiply +from nuvem import divide +from nuvem import random_ +from nuvem import randoms +from nuvem import sin_ +from nuvem import cos_ +from nuvem import round_ +from nuvem import floor_ +from nuvem import ceil_ +from nuvem import mod +from nuvem import sum_ +from nuvem import min_ +from nuvem import max_ +from nuvem import host +from nuvem import path +from nuvem import params +from nuvem import param +from nuvem import user +from nuvem import realm +from nuvem import email +from nuvem import keychain +from nuvem import url +from nuvem import contains +from nuvem import split +from nuvem import join +from nuvem import replace +from nuvem import lowercase +from nuvem import uppercase +from nuvem import format_ +from nuvem import parse +from nuvem import htattrs +from nuvem import htimg +from nuvem import htinline +from nuvem import htlink +from nuvem import htbutton +from nuvem import htcheck +from nuvem import htstyle +from nuvem import pixels +from nuvem import left +from nuvem import top +from nuvem import transform +from nuvem import transition +from nuvem import frames +from nuvem import eval_ +from nuvem import exec_ + +def testValues(): + assert true_.get(()) == True + assert false_.get(()) == False + assert nothing.get(()) == None + assert number.get((), mkprop('value', lambda: 1)) == 1 + assert text.get((), mkprop('value', lambda: 'abc')) == 'abc' + assert comment.get((), mkprop('value', lambda: 'abc')) == 'abc' + assert name.get((), mkprop('value', lambda: 'abc')) == "'abc" + assert item.get((), mkref('value', lambda r: 'def'), mkprop('name', lambda: 'abc')) == ("'abc", 'def') + return True + +def testLogic(): + assert call.get((), mkref('name', lambda r: "'abc"), mkref('proxy', lambda c, r: (c, r))) == ("'abc", ()) + assert call.get((), mkref('name', lambda r: 'abc'), mkref('proxy', lambda c, r: (c, r))) == ("'abc", ()) + assert if_.get((), mkref('cond', lambda r: True), mkref('then', lambda r: 'abc'), mkref('els', lambda r: 'def')) == 'abc' + assert if_.get((), mkref('cond', lambda r: False), mkref('then', lambda r: 'abc'), mkref('els', lambda r: 'def')) == 'def' + assert and_.get((), mkref('a', lambda r: False), mkref('b', lambda r: True)) == False + assert and_.get((), mkref('a', lambda r: True), mkref('b', lambda r: True)) == True + assert or_.get((), mkref('a', lambda r: False), mkref('b', lambda r: False)) == False + assert or_.get((), mkref('a', lambda r: False), mkref('b', lambda r: True)) == True + assert not_.get((), mkref('expr', lambda r: False)) == True + assert not_.get((), mkref('expr', lambda r: True)) == False + assert equals.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'abc')) == True + assert equals.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'def')) == False + assert lesser.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'abc')) == False + assert lesser.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'def')) == True + assert greater.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'abc')) == False + assert greater.get((), mkref('a', lambda r: 'def'), mkref('b', lambda r: 'abc')) == True + return True + +def testLists(): + assert single.get((), mkref('x', lambda r: 'abc')) == ('abc',) + assert pair.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'def')) == ('abc', 'def') + assert triple.get((), mkref('a', lambda r: 'abc'), mkref('b', lambda r: 'def'), mkref('c', lambda r: 'ghi')) == ('abc', 'def', 'ghi') + assert list_.get((), mkref('item', lambda r: None)) == () + assert list_.get((), mkref('item', lambda r: 'abc'), mkref('item', lambda r: None)) == ('abc',) + assert list_.get((), mkref('item', lambda r: 'abc'), mkref('item', lambda r: 'def'), mkref('item', lambda r: None)) == ('abc', 'def') + assert insert.get((), mkref('first', lambda r: 'abc'), mkref('rest', lambda r: None)) == ('abc',) + assert insert.get((), mkref('first', lambda r: 'abc'), mkref('rest', lambda r: ())) == ('abc',) + assert insert.get((), mkref('first', lambda r: 'abc'), mkref('rest', lambda r: ('def',))) == ('abc', 'def') + assert insert.get((), mkref('first', lambda r: 'abc'), mkref('rest', lambda r: ('def', 'ghi'))) == ('abc', 'def', 'ghi') + assert empty.get(()) == () + assert first.get((), mkref('l', lambda r: ('abc', 'def'))) == 'abc' + assert second.get((), mkref('l', lambda r: ('abc', 'def'))) == 'def' + assert rest.get((), mkref('l', lambda r: ('abc', 'def', 'ghi'))) == ('def', 'ghi') + assert rest.get((), mkref('l', lambda r: ('abc',))) == () + assert append.get((), mkref('l', lambda r: ('abc', 'def')), mkref('b', lambda r: ('ghi',))) == ('abc', 'def', 'ghi') + assert append.get((), mkref('l', lambda r: 'abc'), mkref('b', lambda r: ('def', 'ghi'))) == ('abc', 'def', 'ghi') + assert append.get((), mkref('l', lambda r: ('abc', 'def')), mkref('b', lambda r: 'ghi')) == ('abc', 'def', 'ghi') + assert itemnb.get((), mkref('i', lambda r: 1), mkref('l', lambda r: ('abc', 'def', 'ghi'))) == 'def' + assert names.get((), mkref('l', lambda r: (("'a", 'abc'), ("'d", 'def'), ("'g", 'ghi'), ("'d", 'def2')))) == ("'a", "'d", "'g", "'d") + assert values.get((), mkref('l', lambda r: (("'a", 'abc'), ("'d", 'def'), ("'g", 'ghi'), ("'d", 'def2')))) == ('abc', 'def', 'ghi', 'def2') + assert reverse.get((), mkref('l', lambda r: ('abc', 'def', 'ghi'))) == ('ghi', 'def', 'abc') + assert shuffle_.get((), mkref('l', lambda r: ('abc', 'def', 'ghi'))) != () + assert range_.get((), mkref('a', lambda r: '1'), mkref('b', lambda r: '4')) == (1, 2, 3) + + assert map_.get((), mkref('item', lambda r: "'i"), mkref('transform', lambda r: valueof.get(r, mkprop('name', lambda: 'i')) * 2), mkref('list', lambda r: (1, 2, 3))) == (2, 4, 6) + assert filter_.get((), mkref('item', lambda r: "'i"), mkref('cond', lambda r: valueof.get(r, mkprop('name', lambda: 'i')) % 2 == 0), mkref('list', lambda r: (1, 2, 3, 4))) == (2, 4) + assert reduce_.get((), mkref('item', lambda r: "'i"), mkref('accum', lambda r: "'a"), mkref('transform', lambda r: valueof.get(r, mkprop('name', lambda: 'a')) + valueof.get(r, mkprop('name', lambda: 'i'))), mkref('init', lambda r: 0), mkref('list', lambda r: (1, 2, 3, 4))) == 10 + return True + +def testSelect(): + assert lookup.get((), mkref('n', lambda r: "'d"), mkref('l', lambda r: (("'a", 'abc'), ("'d", 'def'), ("'g", 'ghi'), ("'d", 'def2')))) == (("'d", 'def'), ("'d", 'def2')) + assert select.get((), mkref('n', lambda r: "'d.x"), mkref('l', lambda r: (("'a", 'abc'), ("'d", (("'x", 'def'), ("'y", "yyy"))), ("'g", 'ghi'), ("'d", (("'y", 'yyy'), ("'x", 'def2')))))) == (("'x", 'def'), ("'x", 'def2')) + assert select.get((), mkref('n', lambda r: "'d.x"), mkref('l', lambda r: (("'a", 'abc'), ("'d", (("'x", 'def'), ("'y", "yyy"))), ("'g", 'ghi'), ("'d", (("'y", 'yyy'), ("'x", 'def2')))))) == (("'x", 'def'), ("'x", 'def2')) + assert select.get((), mkref('n', lambda r: ("'d", "'x")), mkref('l', lambda r: (("'a", 'abc'), ("'d", (("'x", 'def'), ("'y", "yyy"))), ("'g", 'ghi'), ("'d", (("'y", 'yyy'), ("'x", 'def2')))))) == (("'x", 'def'), ("'x", 'def2')) + + dnf = (("'status", 'ok'), ("'origin", (''),), ("'dest", ('sc'),), ("'rows", ((("'elements", ((("'status", 'notfound'),),),),),),),) + assert select.get((), mkref('n', lambda r: "'status"), mkref('l', lambda r: dnf)) == (("'status", 'ok'), ("'status", 'notfound')) + assert select.get((), mkref('n', lambda r: "'rows.elements.status"), mkref('l', lambda r: dnf)) == (("'status", 'notfound'),) + + dok = (("'status", 'ok'), ("'origin", ('scruz'),), ("'dest", ('sc'),), ("'rows", ((("'elements", ((("'status", 'ok'), ("'duration", ("'value", 3761), ("'text", '1 hour 3 mins'),), ("'distance", ("'value", 82923), ("'text", '51.5 mi'),),),),),),),),) + assert select.get((), mkref('n', lambda r: "'distance.text"), mkref('l', lambda r: dok)) == (("'text", '51.5 mi'),) + +def testMath(): + assert add.get((), mkref('a', lambda r: 3), mkref('b', lambda r: 2)) == 5 + assert subtract.get((), mkref('a', lambda r: 3), mkref('b', lambda r: 2)) == 1 + assert multiply.get((), mkref('a', lambda r: 2), mkref('b', lambda r: 3)) == 6 + assert divide.get((), mkref('a', lambda r: 3), mkref('b', lambda r: 2)) == 1.5 + r1 = random_.get((), mkref('m', lambda r: 2)) + assert r1 >= 0 and r1 <= 2 + r2 = random_.get((), mkref('m', lambda r: 2)) + assert r2 >= 0 and r2 <= 2 and r2 != r1 + r3 = random_.get((), mkref('m', lambda r: ('a', 'b'))) + assert r3 == 'a' or r3 == 'b' + r4 = randoms.get((), mkref('n', lambda r: 5.0), mkref('m', lambda r: 2)) + assert len(r4) == 5 + assert r4[0] >= 0 and r4[0] <= 2 + assert r4[1] >= 0 and r4[1] <= 2 and r4[1] != r4[0] + r5 = randoms.get((), mkref('n', lambda r: 5.0), mkref('m', lambda r: ('a', 'b'))) + assert len(r5) == 5 + assert r5[0] == 'a' or r5[0] == 'b' + assert r5[1] == 'a' or r5[1] == 'b' + assert sin_.get((), mkref('x', lambda r: 0.0)) == 0.0 + assert cos_.get((), mkref('x', lambda r: 0.0)) == 1.0 + assert round_.get((), mkref('d', lambda r: 2), mkref('x', lambda r: 2.336)) == 2.34 + assert floor_.get((), mkref('x', lambda r: 2.336)) == 2.0 + assert ceil_.get((), mkref('x', lambda r: 2.336)) == 3.0 + assert mod.get((), mkref('n', lambda r: 10), mkref('x', lambda r: 12)) == 2.0 + assert sum_.get((), mkref('l', lambda r: (1, 2, 3))) == 6 + assert min_.get((), mkref('l', lambda r: (2, 1, 3))) == 1 + assert max_.get((), mkref('l', lambda r: (1, 3, 2))) == 3 + return True + +def testHTTP(): + assert host.get((), mkprop('host', lambda: 'localhost')) == 'localhost' + assert path.get((), mkprop('path', lambda: ('abc', 'def'))) == ('abc', 'def') + assert params.get((), mkprop('params', lambda: (("'a", 'abc'), ("'d", 'def')))) == (("'a", 'abc'), ("'d", 'def')) + assert param.get((), mkprop('n', lambda: "d"), mkprop('params', lambda: (("'a", 'abc'), ("'d", 'def'), ("'g", 'ghi')))) == 'def' + assert user.get((), mkprop('user', lambda: 'joe')) == 'joe' + assert realm.get((), mkprop('realm', lambda: 'localhost')) == 'localhost' + assert email.get((), mkprop('email', lambda: 'joe@localhost')) == 'joe@localhost' + kc = (("'entry", ("'title", 'User'), ("'id", 'user'), ("'content", ("'account", ("'description", 'User'), ("'keys", ( + "'key", ((("'@name", 'key1'), ("'@value", 'value1')), (("'@name", 'key2'), ("'@value", 'value2')), (("'@name", 'key3'), ("'@value", 'value3')))))))),) + assert keychain.get((), mkref('n', lambda r: 'key2'), mkref('a', lambda r: kc)) == 'value2' + assert keychain.get((), mkref('n', lambda r: 'key4'), mkref('a', lambda r: kc)) is None + return True + +def testText(): + assert contains.get((), mkref('sub', lambda r: 'bc'), mkref('s', lambda r: 'abcd')) == True + assert split.get((), mkref('sep', lambda r: 'x'), mkref('s', lambda r: 'abcxdef')) == ('abc', 'def') + assert join.get((), mkref('sep', lambda r: 'x'), mkref('s', lambda r: ('abc', 'def'))) == 'abcxdef' + assert join.get((), mkref('sep', lambda r: None), mkref('s', lambda r: ('abc', 'def'))) == 'abcdef' + assert replace.get((), mkref('from', lambda r: 'x'), mkref('to', lambda r: 'y'), mkref('s', lambda r: 'abcxdefxghi')) == 'abcydefyghi' + assert replace.get((), mkref('from', lambda r: 'x'), mkref('to', lambda r: None), mkref('s', lambda r: 'abcxdefxghi')) == 'abcdefghi' + assert lowercase.get((), mkref('s', lambda r: 'ABC')) == 'abc' + assert uppercase.get((), mkref('s', lambda r: 'abc')) == 'ABC' + assert format_.get((), mkref('f', lambda r: '{0} + {1} = {r}'), mkref('a', lambda r: (2, 3, ("'r", 5)))) == '2 + 3 = 5' + assert parse.get((), mkref('e', lambda r: r'(\w+) (\w+)'), mkref('s', lambda r: 'a b c')) == ('a', 'b') + return True + +def testAnimation(): + assert htattrs.get((), mkref('value', lambda r: ("'value", 'abc'))) == ("'htattrs", ("'value", 'abc')) + assert htimg.get((), mkref('value', lambda r: 'http://abc.png')) == '' + assert htimg.get((), mkref('value', lambda r: ('i1', 'http://abc.png'))) == '' + assert htimg.get((), mkref('value', lambda r: ("'htattrs", (("'id", 'i1'), ("'src", 'http://abc.png'), ("'x", 'X'))))) == '' + assert htimg.get((), mkref('value', lambda r: (("'htattrs", (("'id", 'i1'), ("'src", 'http://abc.png'), ("'x", 'X'))),))) == '' + assert htinline.get((), mkref('value', lambda r: ('image/png', ('a', 'b')))) == 'data:image/png;base64,YWI=\n' + assert htlink.get((), mkref('value', lambda r: ('http://abc'))) == 'http://abc' + assert htlink.get((), mkref('value', lambda r: ('http://abc', 'abc'))) == 'abc' + assert htlink.get((), mkref('value', lambda r: ('h1', 'http://abc', 'abc'))) == 'abc' + assert htlink.get((), mkref('value', lambda r: ("'htattrs", (("'id", 'h1'), ("'href", 'http://abc'), ("'value", 'abc'), ("'x", "X"))))) == 'abc' + assert htlink.get((), mkref('value', lambda r: (("'htattrs", (("'id", 'h1'), ("'href", 'http://abc'), ("'value", 'abc'), ("'x", "X"))),))) == 'abc' + assert htbutton.get((), mkref('value', lambda r: ('abc'))) == '' + assert htbutton.get((), mkref('value', lambda r: ('b1', 'abc'))) == '' + assert htbutton.get((), mkref('value', lambda r: ("'htattrs", (("'id", 'b1'), ("'value", 'abc'), ("'x", 'X'))))) == '' + assert htbutton.get((), mkref('value', lambda r: (("'htattrs", (("'id", 'b1'), ("'value", 'abc'), ("'x", 'X'))),))) == '' + assert htcheck.get((), mkref('value', lambda r: 'abc')) == 'abc' + assert htcheck.get((), mkref('value', lambda r: ('c1', 'abc'))) == 'abc' + assert htcheck.get((), mkref('value', lambda r: ("'htattrs", (("'id", 'c1'), ("'value", 'abc'), ("'x", 'X'))))) == 'abc' + assert htcheck.get((), mkref('value', lambda r: (("'htattrs", (("'id", 'c1'), ("'value", 'abc'), ("'x", 'X'))),))) == 'abc' + assert htstyle.get((), mkref('value', lambda r: (("'width", '320px'), ("'height", '460px')))) == ("'htstyle", 'width: 320px; height: 460px;') + assert htstyle.get((), mkref('value', lambda r: ('width: 320px', ("'height", '460px')))) == ("'htstyle", 'width: 320px; height: 460px;') + assert pixels.get((), mkref('value', lambda r: 320.1)) == '320px' + assert left.get((), mkref('value', lambda r: 320.1)) == 'left: 320px' + assert top.get((), mkref('value', lambda r: 320.1)) == 'top: 320px' + assert transform.get((), mkref('x', lambda r: 320.1), mkref('y', lambda r: 480.2), mkref('d', lambda r: 90.3)) == 'position: absolute; -webkit-transform: translate3d(320px,480px,0px) rotate(90deg); -moz-transform: translate(320px,480px) rotate(90deg); -ms-transform: translate(320px,480px) rotate(90deg); transform: translate(320px,480px) rotate(90deg)' + assert transition.get((), mkref('value', lambda r: 320.1)) == '-webkit-transition: all 0.3201s' + kf = ((0, ('left: 0px', 'top: 0px')), (50, ('left: 10px', 'top: 10px')), (100, (("'left", '20px'), 'top: 20px'))) + assert frames.get((), mkref('msec', lambda r: 2000), mkref('loop', lambda r: True), mkref('content', lambda r: kf)) == 'position: absolute; -webkit-animation: {id} 2s ease 0 infinite normal; -moz-animation: {id} 2s ease 0 infinite normal; ' + return True + +def testEval(): + assert eval_.get((), mkref('py', lambda r: '1 + 2'), mkref('ref', lambda r: 4)) == 3 + assert eval_.get((), mkref('py', lambda r: 'ref.get(r) + 2'), mkref('ref', lambda r: 4)) == 6 + assert eval_.get((5,), mkref('py', lambda r: 'ref.get(r) + r[0] + 2'), mkref('ref', lambda r: 4)) == 11 + assert exec_.get((), mkref('py', lambda r: 'val = 1 + 2'), mkref('ref', lambda r: 4)) == 3 + assert exec_.get((), mkref('py', lambda r: 'val = ref.get(r) + 2'), mkref('ref', lambda r: 4)) == 6 + assert exec_.get((5,), mkref('py', lambda r: 'val = ref.get(r) + r[0] + 2'), mkref('ref', lambda r: 4)) == 11 + return True + +if __name__ == '__main__': + print 'Testing...' + testValues() + testLogic() + testLists() + testSelect() + testMath() + testHTTP() + testText() + testAnimation() + testEval() + print 'OK' + -- cgit v1.2.3