MCPcopy Index your code
hub / github.com/clips/pattern / xml_format

Function xml_format

pattern/db/__init__.py:1374–1390  ·  view source on GitHub ↗

Returns the given attribute (string, int, float, bool, None) as a quoted unicode string.

(a)

Source from the content-addressed store, hash-verified

1372 return u
1373
1374def xml_format(a):
1375 """ Returns the given attribute (string, int, float, bool, None) as a quoted unicode string.
1376 """
1377 if isinstance(a, basestring):
1378 return "\"%s\"" % encode_entities(a)
1379 if isinstance(a, bool):
1380 return "\"%s\"" % ("no","yes")[int(a)]
1381 if isinstance(a, (int, long)):
1382 return "\"%s\"" % a
1383 if isinstance(a, float):
1384 return "\"%s\"" % round(a, 5)
1385 if isinstance(a, type(None)):
1386 return "\"\""
1387 if isinstance(a, Date):
1388 return "\"%s\"" % str(a)
1389 if isinstance(a, datetime.datetime):
1390 return "\"%s\"" % str(date(mktime(a.timetuple())))
1391
1392def xml(rows):
1393 """ Returns the rows in the given Table or Query as an XML-string, for example:

Callers 1

xmlFunction · 0.85

Calls 3

strFunction · 0.85
dateFunction · 0.85
encode_entitiesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…