Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tutorius/uam
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-07-11 21:39:46 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-07-11 22:00:30 (GMT)
commit0c3f127c86af818d260966d2292b199757087157 (patch)
tree62cf941aef5bde83641a17ec492e03d0ecb17386 /tutorius/uam
parent9fafb49af210e956d43d6a00106558d1a00d13df (diff)
repackage
Diffstat (limited to 'tutorius/uam')
-rw-r--r--tutorius/uam/Makefile.am5
-rw-r--r--tutorius/uam/__init__.py88
-rw-r--r--tutorius/uam/gobjectparser.py27
-rw-r--r--tutorius/uam/gtkparser.py44
4 files changed, 164 insertions, 0 deletions
diff --git a/tutorius/uam/Makefile.am b/tutorius/uam/Makefile.am
new file mode 100644
index 0000000..219291e
--- /dev/null
+++ b/tutorius/uam/Makefile.am
@@ -0,0 +1,5 @@
+sugardir = $(pythondir)/sugar/tutorius/uam
+sugar_PYTHON = \
+ gobjectparser.py \
+ gtkparser.py \
+ __init__.py
diff --git a/tutorius/uam/__init__.py b/tutorius/uam/__init__.py
new file mode 100644
index 0000000..7cf5671
--- /dev/null
+++ b/tutorius/uam/__init__.py
@@ -0,0 +1,88 @@
+# Copyright (C) 2009, Tutorius.org
+# Copyright (C) 2009, Vincent Vinet <vince.vinet@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+Universal Addressing Mechanism module
+
+Allows addressing Events, signals, widgets, etc for supported platforms
+"""
+
+from urllib2 import urlparse
+
+import gtkparser
+import gobjectparser
+
+
+SCHEME="tap" #Tutorius Adressing Protocol
+
+__parsers = {
+ gtkparser.SCHEME:gtkparser.parse_gtk,
+ gobjectparser.SCHEME:gobjectparser.parse_gobject,
+}
+
+def __add_to_urlparse(name):
+ #Add to uses_netloc
+ if not name in urlparse.uses_netloc:
+ urlparse.uses_netloc.append(name)
+
+ #Add to uses_relative
+ if not name in urlparse.uses_relative:
+ urlparse.uses_relative.append(name)
+
+# #Add to uses_params
+# if not name in urlparse.uses_params:
+# urlparse.uses_params.append(name)
+
+ #Add to uses_query
+ if not name in urlparse.uses_query:
+ urlparse.uses_query.append(name)
+
+ #Add to uses_frament
+ if not name in urlparse.uses_fragment:
+ urlparse.uses_fragment.append(name)
+
+
+#Add schemes to urlparse
+__add_to_urlparse(SCHEME)
+
+for subscheme in [".".join([SCHEME,s]) for s in __parsers]:
+ __add_to_urlparse(subscheme)
+
+
+class SchemeError(Exception):
+ def __init__(self, message):
+ Exception.__init__(self, message)
+ self.message = message
+
+
+def parse_uri(uri):
+ res = urlparse.urlparse(uri)
+
+ scheme = res.scheme.split(".")[0]
+ subscheme = ".".join(res.scheme.split(".")[1:])
+ if not scheme == SCHEME:
+ raise SchemeError("Scheme %s not supported" % scheme)
+
+ if subscheme != "" and not subscheme in __parsers:
+ raise SchemeError("SubScheme %s not supported" % subscheme)
+
+ if subscheme:
+ return __parsers[subscheme](res)
+
+ return res
+
+
+
diff --git a/tutorius/uam/gobjectparser.py b/tutorius/uam/gobjectparser.py
new file mode 100644
index 0000000..c1fba3d
--- /dev/null
+++ b/tutorius/uam/gobjectparser.py
@@ -0,0 +1,27 @@
+# Copyright (C) 2009, Tutorius.org
+# Copyright (C) 2009, Vincent Vinet <vince.vinet@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+UAM Parser for gobject subscheme
+
+To be completed
+"""
+
+SCHEME="gobject"
+
+def parse_gobject(parsed_uri):
+ """Do nothing for now"""
+ return parsed_uri
diff --git a/tutorius/uam/gtkparser.py b/tutorius/uam/gtkparser.py
new file mode 100644
index 0000000..ede2f03
--- /dev/null
+++ b/tutorius/uam/gtkparser.py
@@ -0,0 +1,44 @@
+# Copyright (C) 2009, Tutorius.org
+# Copyright (C) 2009, Vincent Vinet <vince.vinet@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+UAM Parser for gtk subscheme
+
+Allows addressing Gtk Events, signals, widgets
+
+The gtk subscheme for tutorius is
+
+<scheme>://<activity>/<path>[?<params>#<ptype>]
+
+where:
+
+<scheme> is the uam.SCHEME + "." + SCHEME
+
+<activity> is the activity's dns identifier, such as battleship.tutorius.org
+
+<path> is the Hierarchical path to the widget, where 0 is the activity, such as /0/0/1/0/1/0
+
+<params> can be used to specify additionnal parameters required for an event handler or action, such as event=clicked
+
+<ptype> must be used with params to specify which action or eventfilter to use, such as "DialogMessage"
+
+"""
+
+SCHEME="gtk"
+
+def parse_gtk(parsed_uri):
+ """Do nothing for now"""
+ return parsed_uri