Factor Sevice and Host classes into `data' module

portnov [2009-02-24 19:01:41]
Factor Sevice and Host classes into `data' module
Filename
data.py
test.py
diff --git a/data.py b/data.py
new file mode 100644
index 0000000..cdbf532
--- /dev/null
+++ b/data.py
@@ -0,0 +1,28 @@
+#####################################
+# Some classes
+
+class Service(object):
+    def __init__(self):
+        self.ip = ''
+        self.port = 0
+        self.proto = ''
+        self.stype = ''
+        self.name = ''
+
+    def __str__(self):
+        if self.port:
+            return "%s:%s" % (self.ip, self.port)
+        else:
+            return self.ip
+
+    def __repr__(self):
+        return "<Service %s on %s:%s>" % (self.name,self.ip,self.port)
+
+class Host(object):
+    def __init__(self):
+        self.ip = ''
+        self.hostname = ''
+
+    def __repr__(self):
+        return "<Host %s>" % self.hostname
+
diff --git a/test.py b/test.py
index e0c896a..7869850 100755
--- a/test.py
+++ b/test.py
@@ -8,6 +8,7 @@ import discovery
 import templates
 import configs
 import configsets
+from data import Service, Host

 # import xmlserialize as XML

@@ -21,34 +22,6 @@ def on_sigint(signum, frame):

 signal.signal(signal.SIGINT, on_sigint)

-#####################################
-# Some classes
-
-class Service(object):
-    def __init__(self):
-        self.ip = ''
-        self.port = 0
-        self.proto = ''
-        self.stype = ''
-        self.name = ''
-
-    def __str__(self):
-        if self.port:
-            return "%s:%s" % (self.ip, self.port)
-        else:
-            return self.ip
-
-    def __repr__(self):
-        return "<Service %s on %s:%s>" % (self.name,self.ip,self.port)
-
-class Host(object):
-    def __init__(self):
-        self.ip = ''
-        self.hostname = ''
-
-    def __repr__(self):
-        return "<Host %s>" % self.hostname
-
 class ZeroconfListener(object):
     def new_service(self, iface,proto,name,stype,domain, host, aproto,addr, port, txt,flags):
         global services
ViewGit