[vlc-commits] commit: python-vlc: define hex version for libvlc/python module ( Jean Brouwers )

git at videolan.org git at videolan.org
Tue Dec 7 21:41:51 CET 2010


vlc/python | branch: master | Jean Brouwers <MrJean1 at EarthLink.net> | Tue Dec  7 18:17:55 2010 +0100| [6262a3dcca01b87ef74c2015c6bc6b321d7c40d4] | committer: Olivier Aubert 

python-vlc: define hex version for libvlc/python module

Signed-off-by: Olivier Aubert <olivier.aubert at liris.cnrs.fr>

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=6262a3dcca01b87ef74c2015c6bc6b321d7c40d4
---

 footer.py |   42 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/footer.py b/footer.py
index 43e1127..4823f8d 100644
--- a/footer.py
+++ b/footer.py
@@ -1,11 +1,43 @@
-### Start of footer.py ###
 
-def callbackmethod(f):
-    """Backward compatibility with the now useless @callbackmethod decorator.
+# Start of footer.py #
+
+# Backward compatibility
+def callbackmethod(callback):
+    """Now obsolete @callbackmethod decorator."""
+    return callback
+
+# Version functions
+def _dot2int(v):
+    '''(INTERNAL) Convert 'i.i.i[.i]' str to int.
+    '''
+    t = [int(i) for i in v.split('.')]
+    if len(t) == 3:
+        t.append(0)
+    elif len(t) != 4:
+        raise ValueError('"i.i.i[.i]": %r' % (v,))
+    if min(t) < 0 or max(t) > 255:
+        raise ValueError('[0..255]: %r' % (v,))
+    i = t.pop(0)
+    while t:
+        i = (i << 8) + t.pop(0)
+    return i
+
+def hex_version():
+    """Return the version of these bindings in hex or 0 if unavailable.
+    """
+    try:
+        return _dot2int(__version__.split('-')[-1])
+    except (NameError, ValueError):
+        return 0
 
-    This method will be removed after a transition period.
+def libvlc_hex_version():
+    """Return the libvlc version in hex or 0 if unavailable.
     """
-    return f
+    try:
+        return _dot2int(libvlc_get_version().split()[0])
+    except ValueError:
+        return 0
+
 
 # Example callback, useful for debugging
 def debug_callback(event, *args, **kwds):



More information about the vlc-commits mailing list