[Telepathy-commits] [telepathy-spec/master] Report Access for properties

Davyd Madeley davyd at madeley.id.au
Mon Mar 23 12:29:25 PDT 2009


---
 doc/spec/style.css           |    5 +++++
 doc/templates/interface.html |    1 +
 tools/specparser.py          |   12 ++++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/spec/style.css b/doc/spec/style.css
index 12effb4..d237b6e 100644
--- a/doc/spec/style.css
+++ b/doc/spec/style.css
@@ -92,6 +92,11 @@ div.error {
 	border: 1px solid #cc0000;
 }
 
+div.access {
+	font-weight: bold;
+	margin-left: 1ex;
+}
+
 div.docstring {
 	margin: 1ex;
 }
diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index ee95243..f4f1d18 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -138,6 +138,7 @@
       $property.short_name — $property.dbus_type
       #if $property.type: (<a href="$property.get_url()" title="$property.get_title()">$property.get_type().short_name</a>)
      </h2>
+      <div class="access">$property.get_access()</div>
 
      $property.get_added_html()
      $property.get_deprecated_html()
diff --git a/tools/specparser.py b/tools/specparser.py
index 26509ef..469382b 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -251,8 +251,8 @@ class Typed (base):
         return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.dbus_type)
 
 class Property (Typed):
-    ACCESS_READ     = 0x01
-    ACCESS_WRITE    = 0x10
+    ACCESS_READ     = 1
+    ACCESS_WRITE    = 2
     
     ACCESS_READWRITE = ACCESS_READ | ACCESS_WRITE
 
@@ -271,6 +271,14 @@ class Property (Typed):
             raise UnknownAccess ("Unknown access `%s' on %s" % (
                                     access, self))
 
+    def get_access (self):
+        if self.access & self.ACCESS_READ and self.access & self.ACCESS_WRITE:
+            return 'Read/Write'
+        elif self.access & self.ACCESS_READ:
+            return 'Read only'
+        elif self.access & self.ACCESS_WRITE:
+            return 'Write only'
+
 class Arg (Typed):
     DIRECTION_IN, DIRECTION_OUT = range (2)
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list