~ubuntu-branches/ubuntu/trusty/exabgp/trusty

« back to all changes in this revision

Viewing changes to build/lib.linux-x86_64-2.7/exabgp/message/update/attribute/origin.py

  • Committer: Package Import Robot
  • Author(s): Henry-Nicolas Tourneur
  • Date: 2012-03-22 12:00:00 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120322120000-v4aj8h69mhpmgbjq
Tags: 2.0.7-1

* New upstream release
* Fix bad clean target for build/ directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# encoding: utf-8
3
 
"""
4
 
attributes.py
5
 
 
6
 
Created by Thomas Mangin on 2009-11-05.
7
 
Copyright (c) 2009-2011 Exa Networks. All rights reserved.
8
 
"""
9
 
 
10
 
from exabgp.message.update.attribute import AttributeID,Flag,Attribute
11
 
 
12
 
# =================================================================== Origin (1)
13
 
 
14
 
class Origin (Attribute):
15
 
        ID = AttributeID.ORIGIN
16
 
        FLAG = Flag.TRANSITIVE
17
 
        MULTIPLE = False
18
 
 
19
 
        IGP        = 0x00
20
 
        EGP        = 0x01
21
 
        INCOMPLETE = 0x02
22
 
 
23
 
        def __init__ (self,origin):
24
 
                self.origin = origin
25
 
 
26
 
        def pack (self):
27
 
                return self._attribute(chr(self.origin))
28
 
 
29
 
        def __len__ (self):
30
 
                return len(self.pack())
31
 
 
32
 
        def __str__ (self):
33
 
                if self.origin == 0x00: return 'IGP'
34
 
                if self.origin == 0x01: return 'EGP'
35
 
                if self.origin == 0x02: return 'INCOMPLETE'
36
 
                return 'INVALID'
37
 
 
38
 
        def __repr__ (self):
39
 
                return str(self)