~ubuntu-branches/ubuntu/utopic/exabgp/utopic

« back to all changes in this revision

Viewing changes to lib/exabgp/util/enumeration.py

  • Committer: Package Import Robot
  • Author(s): Henry-Nicolas Tourneur
  • Date: 2014-03-08 19:07:00 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140308190700-xjbibpg1g6001c9x
Tags: 3.3.1-1
* New upstream release
* Bump python minimal required version (2.7)
* Closes: #726066 Debian packaging improvements proposed by Vincent Bernat
* Closes: #703774 not existent rundir (/var/run/exabgp) after reboot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# encoding: utf-8
 
2
'''
 
3
Enumeration.py
 
4
 
 
5
Created by Thomas Mangin on 2013-03-18.
 
6
Copyright (c) 2009-2013 Exa Networks. All rights reserved.
 
7
'''
 
8
 
 
9
# int are immutable once created: can not set ._str in __init__
 
10
class _integer (int):
 
11
        def __str__ (self):
 
12
                return self._str
 
13
 
 
14
class Enumeration (object):
 
15
        def __init__(self, *names):
 
16
                for number, name in enumerate(names):
 
17
                        # doing the .parent thing here instead
 
18
                        number = _integer(pow(2,number))
 
19
                        number._str = name
 
20
                        setattr(self, name, number)