comparison MoinMoin/wikiutil.py @ 1866:0194beaf511e

reduce reduce, filter and map usage
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Mar 2007 19:20:19 +0100
parents b180f047d918
children 64507f46beb2
comparison
equal deleted inserted replaced
1865:05158c12c271 1866:0194beaf511e
705 @param pagelist: a list of pages 705 @param pagelist: a list of pages
706 @rtype: list 706 @rtype: list
707 @return: only the category pages of pagelist 707 @return: only the category pages of pagelist
708 """ 708 """
709 func = request.cfg.cache.page_category_regex.search 709 func = request.cfg.cache.page_category_regex.search
710 return filter(func, pagelist) 710 return [pn for pn in pagelist if func(pn)]
711 711
712 712
713 def getLocalizedPage(request, pagename): # was: getSysPage 713 def getLocalizedPage(request, pagename): # was: getSysPage
714 """ Get a system page according to user settings and available translations. 714 """ Get a system page according to user settings and available translations.
715 715
822 @param pagename: the (possibly relative) page name 822 @param pagename: the (possibly relative) page name
823 @rtype: string 823 @rtype: string
824 @return: the absolute page name 824 @return: the absolute page name
825 """ 825 """
826 if pagename.startswith(PARENT_PREFIX): 826 if pagename.startswith(PARENT_PREFIX):
827 pagename = '/'.join(filter(None, context.split('/')[:-1] + [pagename[PARENT_PREFIX_LEN:]])) 827 pagename = '/'.join([x for x in context.split('/')[:-1] + [pagename[PARENT_PREFIX_LEN:]] if x])
828 elif pagename.startswith(CHILD_PREFIX): 828 elif pagename.startswith(CHILD_PREFIX):
829 pagename = context + '/' + pagename[CHILD_PREFIX_LEN:] 829 pagename = context + '/' + pagename[CHILD_PREFIX_LEN:]
830 return pagename 830 return pagename
831 831
832 def pagelinkmarkup(pagename): 832 def pagelinkmarkup(pagename):