OSDN Git Service

change json attribute 'type' to 'device_type', 'port_type'
authort.moriyama <t.moriyama@users.sourceforge.jp>
Sun, 1 Sep 2013 08:26:14 +0000 (17:26 +0900)
committert.moriyama <t.moriyama@users.sourceforge.jp>
Sun, 1 Sep 2013 08:26:14 +0000 (17:26 +0900)
linkpair/collect/agent/base_agent.py
linkpair/device.py
linkpair/linkobject.py
linkpair/linkpair.py
linkpair/port.py

index 11594e8..622f7bc 100755 (executable)
@@ -2,8 +2,6 @@
 # -*- coding: utf-8 -*-
 #
 
-__version__ = '1.1'
-
 import sys
 import os
 import re
index 4f1ecd5..0c4a876 100755 (executable)
@@ -2,8 +2,6 @@
 # -*- coding: utf-8 -*-
 #
 
-__version__ = '1.1'
-
 from linkobject import LinkObject
 
 
@@ -16,7 +14,13 @@ class Device(LinkObject):
     NAMESPACE_TYPE = 6
     NOT_CONNECTED_TYPE = 7
 
-    def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+    def __init__(self, label, device_type=DEFAULT_TYPE, metadata={}):
         self.label = label
-        self.type = type
+        self.device_type = device_type
         self.metadata = metadata
+
+    def __repr__(self):
+        return "{\"label\":\"" + self.label + \
+            "\",\"device_type\":\"" + repr(self.device_type) + \
+            "\",\"meta\":" + self._blank_dict(self.metadata) + "}"
+
index 951b0ca..0d0e511 100755 (executable)
@@ -2,13 +2,11 @@
 # -*- coding: utf-8 -*-
 #
 
-
 class LinkObject(object):
     DEFAULT_TYPE = 1
 
-    def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+    def __init__(self, label, metadata={}):
         self.label = label
-        self.type = type
         self.metadata = metadata
 
     @apply
@@ -35,20 +33,11 @@ class LinkObject(object):
         def set(self, attr, attr_value):
             self.metadata[attr] = attr_value
 
-    @apply
-    def type():
-        def get(self):
-            return self.type
-
-        def set(self, type):
-            self.type = type
-
     def __str__(self):
         return self.label
 
     def __repr__(self):
         return "{\"label\":\"" + self.label + \
-            "\",\"type\":\"" + repr(self.type) + \
             "\",\"meta\":" + self._blank_dict(self.metadata) + "}"
 
     def _blank_dict(self, dict_object):
index ab11a26..f537460 100755 (executable)
@@ -65,7 +65,13 @@ class LinkPair(object):
             repr(format_name)
         else:
             return "\"\""
-            
+    
+    def get_linkpair_linkid(self):
+        return str(self.device1).replace(" ", "_") + "__" + \
+               str(self.device2).replace(" ", "_") + "__" + \
+               str(self.port1).replace(" ", "_") + "__" + \
+               str(self.port2).replace(" ", "_")
+    
     def to_json(self):
         return "{\"device1\":" + repr(self.device1) + "," + \
                "\"device2\":" + repr(self.device2) + "," + \
index 35e5db3..264a370 100755 (executable)
@@ -2,15 +2,20 @@
 # -*- coding: utf-8 -*-
 #
 
-__version__ = '1.1'
-
 from linkobject import LinkObject
 
 
 class Port(LinkObject):
     DEFAULT_TYPE = 1
 
-    def __init__(self, label, type=DEFAULT_TYPE, metadata={}):
+    def __init__(self, label, port_type=DEFAULT_TYPE, metadata={}):
         self.label = label
-        self.type = type
+        self.port_type = port_type
         self.metadata = metadata
+        
+
+    def __repr__(self):
+        return "{\"label\":\"" + self.label + \
+            "\",\"port_type\":\"" + repr(self.port_type) + \
+            "\",\"meta\":" + self._blank_dict(self.metadata) + "}"
+