pvl/dhcp/config.py
changeset 695 c60924eca185
parent 685 668f934bb958
child 699 d34567c1b21a
--- a/pvl/dhcp/config.py	Mon Mar 02 19:36:10 2015 +0200
+++ b/pvl/dhcp/config.py	Mon Mar 02 19:36:39 2015 +0200
@@ -68,6 +68,17 @@
 
         yield item
 
+class Field (object):
+    """
+        Pre-quoted fields for use in DHCP confs.
+    """
+
+    def __init__(self, token):
+        self.token = token
+
+    def __str__(self):
+        return self.token
+
 def quote (value, context=None):
     """
         Build a single field as part of a dhcp.conf line.
@@ -90,9 +101,13 @@
         192.0.2.1
         >>> print quote('00:11:22:33:44:55', context=('hardware', 'ethernet'))
         00:11:22:33:44:55
+        >>> print quote(Field('1:00:11:22:33:44:55'))
+        1:00:11:22:33:44:55
     """
 
-    if isinstance(value, int):
+    if isinstance(value, Field):
+        return str(value)
+    elif isinstance(value, int):
         return str(value)
     elif context in UNQUOTED_CONTEXT:
         return str(value)