Jeffrey Gelens avatar Jeffrey Gelens committed c56a28d

Updated version

Comments (0)

Files changed (3)

-Copyright (c) 2012, Noppo (Jeffrey Gelens) <http://www.noppo.pro/>
+Copyright (c) 2011-2013, Noppo (Jeffrey Gelens) <http://www.noppo.pro/>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification,

geventwebsocket/__init__.py

-version_info = (0, 3, 6)
-__version__ = ".".join(map(str, version_info))
+VERSION = (0, 4, 0, 'alpha', 0)
 
-__all__ = ['WebSocketHandler', 'WebSocketError']
 
-from geventwebsocket.handler import WebSocketHandler
-from geventwebsocket.websocket import WebSocketError
+def get_version(*args, **kwargs):
+    from .utils import get_version
+    return get_version(*args, **kwargs)

geventwebsocket/utils.py

+import subprocess
+
+
+def get_version(version=None):
+    "Returns a PEP 386-compliant version number from VERSION."
+
+    if version is None:
+        from geventwebsocket import VERSION as version
+    else:
+        assert len(version) == 5
+        assert version[3] in ('alpha', 'beta', 'rc', 'final')
+
+    # Now build the two parts of the version number:
+    # main = X.Y[.Z]
+    # sub = .devN - for pre-alpha releases
+    #     | {a|b|c}N - for alpha, beta and rc releases
+
+    parts = 2 if version[2] == 0 else 3
+    main = '.'.join(str(x) for x in version[:parts])
+
+    sub = ''
+    if version[3] == 'alpha' and version[4] == 0:
+        hg_changeset = get_hg_changeset()
+        if hg_changeset:
+            sub = '.dev{0}'.format(hg_changeset)
+
+    elif version[3] != 'final':
+        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
+        sub = mapping[version[3]] + str(version[4])
+
+    return str(main + sub)
+
+
+def get_hg_changeset():
+    rev, err = subprocess.Popen(
+        'hg id -i',
+        shell=True,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE
+    ).communicate()
+
+    if err:
+        return None
+    else:
+        return rev.strip().replace('+', '')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.