Utils Text
inyoka.utils.text
Various text realated tools.
- copyright:
2007-2024 by the Inyoka Team, see AUTHORS for more details.
- license:
BSD, see LICENSE for more details.
- inyoka.utils.text.get_pagetitle(name, full=True)
Get the title for a page by name. Per default it just returns the title for the full page, not just the last part. If you just want the part after the last slash set full to False.
- inyoka.utils.text.human_number(value, gender=None)
- inyoka.utils.text.increment_string(s)
Increment a number in a string or add a number.
- inyoka.utils.text.join_pagename(name1, name2)
Join a page with another one. This works similar to a normal filesystem path join but with different rules. Here some examples:
>>> join_pagename('Foo', 'Bar') 'Foo/Bar' >>> join_pagename('Foo', '/Bar') 'Bar' >>> join_pagename('Foo', 'Bar/Baz') 'Bar/Baz' >>> join_pagename('Foo', './Bar/Baz') 'Foo/Bar/Baz'
- inyoka.utils.text.normalize_pagename(name, strip_location_markers=True)
Normalize a pagename. Strip unsupported characters. You have to call this function whenever you get a pagename from user input. The models itself never check for normalized names and passing unnormalized page names to the models can cause serious breakage.
If the second parameter is set to False the leading slashes or slash like path location markers are not removed. That way the pagename is left unnormalized to a part but will be fully normalized after a join_pagename call.
- inyoka.utils.text.slugify(string, convert_lowercase=True)
Slugify a string.
- inyoka.utils.text.wiki_slugify(name)
A special variant of slugify() used in our wiki. It tries to generate an internal representation of a wiki pagename, helpful if someone links a wiki pages with little differences like accents.