pythonNameToXmlTag(pythonName)
Convert a bumpyCase name to a hyphenated-tag name.
Each word in the Python name should begin with a capital letter. The
first word may be either lowercase or uppercase:
>>> pythonNameToXmlTag('attributeName')
'attribute-name'
>>> pythonNameToXmlTag('ClassName')
'class-name'
Words with all capital letters (i.e.: acronyms) will be properly
separated:
>>> pythonNameToXmlTag('IPAddress')
'ip-address'
>>> pythonNameToXmlTag('aURL')
'a-url'
>>> pythonNameToXmlTag('thisURLAndStuff')
'this-url-and-stuff'
Single words will not be transformed:
>>> pythonNameToXmlTag('attribute')
'attribute'
Unless they are entirely in uppercase, in which case they will be
converted to lowercase:
>>> pythonNameToXmlTag('URL')
'url'
Multiple acronyms are properly handled:
>>> pythonNameToXmlTag('oneURLAndAnotherURLAndAnother')
'one-url-and-another-url-and-another'
Single-letter words at the end of the string are O.K. as well:
>>> pythonNameToXmlTag('exhibitA')
'exhibit-a'
-
|