def testis_number(self):
        self.assertTrue(chart_encoding.is_number("1"))
        self.assertTrue(chart_encoding.is_number("0"))
        self.assertTrue(chart_encoding.is_number("-1"))

        self.assertFalse(chart_encoding.is_number(""))
        self.assertFalse(chart_encoding.is_number("a"))
        self.assertFalse(chart_encoding.is_number("4a"))
Ejemplo n.º 2
0
        for key in dir(self):
            if not key.startswith("__"):
                attr = getattr(self, key)
                if isinstance(attr, basestring) and len(attr) > 0:  # skip instance methods, etc.
                    s += "&" + key + "=" + attr
        return s

    def asUrl(self):
        url = chartImageUrl + self.str()
        return url

    def asImgElement(self):
        url = self.asUrl()
        width, height = self.getDimensions()
        imgElement = chartImageTemplate % {"url": url, "width": width, "height": height}
        return imgElement


if __name__ == "__main__":
    c = Chart()
    data = []
    for arg in sys.argv:
        if arg.startswith("ch") and string.find(arg, "=") > 0:
            (name, value) = string.split(arg, "=")
            setattr(c, name, value)
        elif chart_encoding.is_number(arg):
            data.append(float(arg))
    if len(data) > 0:
        c.addData(data)
    print(c.str())