Esempio n. 1
0
    def render(self, data, field):
        if field in data.keys():
            ##multilangs
            if isinstance(data[field], dict):
                resstr = ""
                if "currentlanguage" in conf.keys():
                    if conf["currentlanguage"] in data[field].keys():
                        resstr = data[field][conf["currentlanguage"]].replace(
                            """, "'").replace(";", " ").replace('"', "'")
                    else:
                        if len(data[field].keys()) > 0:
                            resstr = data[field][
                                data[field].keys()[0]].replace(
                                    """,
                                    "'").replace(";", " ").replace('"', "'")
                return '"%s"' % resstr
            elif isinstance(data[field], list):
                return ", ".join([
                    item.replace(""", "").replace(";",
                                                       " ").replace('"', "'")
                    for item in data[field]
                ])
            elif data[field] is not None:
                return str('"%s"' % str(data[field]).replace(
                    """, "").replace(";", " ").replace('"', "'"))

        return conf["empty_value"]
Esempio n. 2
0
def do_fixups():
    for template in \
     glob.glob(os.path.join("poller", "for-testing", "*.TEMPLATE")) + \
     glob.glob(os.path.join("poller", "for-release", "*.TEMPLATE")) + \
     glob.glob(os.path.join("pov", "*.TEMPLATE")) + \
     glob.glob(os.path.join("lib", "*.TEMPLATE")):

        fp = open(template, "r")
        buf = fp.read()
        fp.close()

        for key in conf.keys():
            buf = buf.replace(key, conf[key])

        fp = open(template[:-len(".TEMPLATE")], "w")
        fp.write(buf)
        fp.close()
Esempio n. 3
0
def do_fixups():
	for template in \
		glob.glob(os.path.join("poller", "for-testing", "*.TEMPLATE")) + \
		glob.glob(os.path.join("poller", "for-release", "*.TEMPLATE")) + \
		glob.glob(os.path.join("pov", "*.TEMPLATE")) + \
		glob.glob(os.path.join("lib", "*.TEMPLATE")):
		
		fp = open(template, "r")
		buf = fp.read()
		fp.close()

		for key in conf.keys():
			buf = buf.replace(key, conf[key])

		fp = open(template[:-len(".TEMPLATE")], "w")
		fp.write(buf)
		fp.close()
Esempio n. 4
0
	def render(self, data, field):
		if field in data.keys():
			##multilangs
			if isinstance(data[field], dict):
				resstr = ""
				if "currentlanguage" in conf.keys():
					if conf["currentlanguage"] in data[field].keys():
						resstr = data[field][conf["currentlanguage"]].replace(""", "").replace(";", " ").replace(
							'"', "'")
					else:
						if data[field].keys().length > 0:
							resstr = data[field][data[field].keys()[0]].replace(""", "").replace(";", " ").replace(
								'"', "'")
				return '"%s"' % resstr
			else:
				# no langobject
				return str('"%s"' % data[field].replace(""", "").replace(";", " ").replace('"', "'"))
		return conf["empty_value"]
Esempio n. 5
0
	def render(self, data, field):
		if field in data.keys():
			##multilangs
			if isinstance(data[field], dict):
				resstr = ""
				if "currentlanguage" in conf.keys():
					if conf["currentlanguage"] in data[field].keys():
						resstr = data[field][conf["currentlanguage"]]
					else:
						if data[field].keys().length > 0:
							resstr = data[field][data[field].keys()[0]]
				aspan = html5.Span()
				aspan.appendChild(html5.TextNode(resstr))
				aspan["Title"] = str(data[field])
				return (aspan)
			else:
				# no langobject
				return html5.Label(str(data[field]))
		return html5.Label(conf["empty_value"])
Esempio n. 6
0
	def render( self, data, field ):
		if field in data.keys():
			##multilangs
			if isinstance(data[field],dict):
				resstr=""
				if "currentlanguage" in conf.keys():
					if conf["currentlanguage"] in data[field].keys():
						resstr=data[field][conf["currentlanguage"]]
					else:
						if len(data[field].keys())>0:
							resstr=data[field][data[field].keys()[0]]
				return (self.getViewElement(resstr,data[field]))


			else:
				#no langobject
				if isinstance( data[field], list ):
					output = ", ".join( data[field] )
				else:
					output=str( data[field] )

				return self.getViewElement( output,False )

		return self.getViewElement( conf[ "empty_value" ], False )