Remove unused utility functions.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 22 Nov 2010 21:26:50 +0000 (22:26 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 22 Nov 2010 21:26:50 +0000 (22:26 +0100)
buildfarm/tests/test_util.py
buildfarm/util.py
buildfarm/web/__init__.py

index 79a311d908cb3b211598ee55eb660eb24deb4b08..17bb1615c1c904790cabe52676f0ceb001525162 100755 (executable)
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-import os
-import tempfile
 import testtools
-import unittest
 
 from buildfarm import util
 
-class ChangeExtensionTests(unittest.TestCase):
-
-    def test_simple(self):
-        self.assertEquals("foo.bar", util.ChangeExtension("foo.old", "bar"))
-        self.assertEquals("foo.png", util.ChangeExtension("foo.png", "png"))
-        self.assertEquals("foobar.png", util.ChangeExtension("foobar", "png"))
-
-
-class DhmTimeTests(unittest.TestCase):
+class DhmTimeTests(testtools.TestCase):
 
     def test_simple(self):
         self.assertEquals("0s", util.dhm_time(0))
@@ -38,32 +27,3 @@ class DhmTimeTests(unittest.TestCase):
         self.assertEquals("-", util.dhm_time(-20))
         self.assertEquals("1d 3h 1m", util.dhm_time(97265))
         self.assertEquals("3h 1m", util.dhm_time(10865))
-
-
-class LoadTests(testtools.TestCase):
-
-    def test_simple(self):
-        fd, name = tempfile.mkstemp()
-        self.addCleanup(os.remove, name)
-        f = os.fdopen(fd, 'w')
-        f.write("""one
-two
-three\r
-
-for
-""")
-        f.close()
-        l = util.load_list(name)
-        self.assertEquals(4, len(l))
-        self.assertEquals("three", l[2])
-
-
-class StripHtmlTests(unittest.TestCase):
-
-    def test_simple(self):
-        self.assertEquals("", util.strip_html("<!--foo-->"))
-        self.assertEquals("bar ", util.strip_html("<!--foo-->bar <!--bloe-->"))
-        self.assertEquals("bar <bloe>", util.strip_html("<bar>bar <bloe></bar>"))
-        self.assertEquals("", util.strip_html("<bar><bloe></bloe></bar>"))
-
-        self.assertEquals("bla", util.strip_html("<a href=\"foo\">bla</a>"))
index 3739ebaaf56572f708b4326a8501db41fea077d7..70989a1fba166a00a0ad18244713207d3c934353 100644 (file)
@@ -17,8 +17,6 @@
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-import re
-
 def load_list(fname):
     """load a list from a file, using : to separate"""
     ret = []
@@ -34,34 +32,6 @@ def load_list(fname):
     return ret
 
 
-def FileLoad(filename):
-    """read a file into a string"""
-    f = open(filename, 'r')
-    try:
-        return f.read()
-    finally:
-        f.close()
-
-
-def FileSave(filename, contents):
-    """write a string into a file"""
-    f = open(filename, 'w')
-    try:
-        f.write(contents)
-    finally:
-        f.close()
-
-
-def ChangeExtension(fname, ext):
-    """return a filename with a changed extension"""
-    try:
-        (base, oldext) = fname.rsplit(".", 1)
-    except ValueError:
-        return "%s.%s" % (fname, ext)
-    else:
-        return "%s.%s" % (base, ext)
-
-
 def dhm_time(sec):
     """display a time as days, hours, minutes"""
     days = int(sec / (60*60*24));
@@ -78,16 +48,3 @@ def dhm_time(sec):
     if min != 0:
         return "%dm" % min
     return "%ds" % sec
-
-
-def strip_html(string):
-    """simple html markup stripper"""
-    # get rid of comments
-    string = re.sub("<!\-\-(.*?)\-\->", "", string)
-
-    # and remove tags.
-    count = True
-    while count:
-        (string, count) = re.subn("<(\w+).*?>(.*?)</\\1>", "\\2", string)
-
-    return string
index d0500af0051468c65999c778088faeb514b16775..97b544b1cf6d964b5218c9574ab9dca3329dc091 100755 (executable)
@@ -128,18 +128,6 @@ def build_link(myself, build):
     return "<a href='%s?function=View+Build;%s'>%s</a>" % (myself, ";".join(["%s=%s" % k for k in params.iteritems()]), html_build_status(build.status()))
 
 
-def build_status_vals(status):
-    """translate a status into a set of int representing status"""
-    status = util.strip_html(status)
-
-    status = status.replace("ok", "0")
-    status = status.replace("-", "0")
-    status = status.replace("?", "0.1")
-    status = status.replace("PANIC", "1")
-
-    return status.split("/")
-
-
 def host_link(myself, host):
     return "<a href='%s?function=View+Host;host=%s'>%s</a>" % (
         myself, host, host)