コード例 #1
0
def calculate_desired_collection_list(c, cc, sc):
    """Function that calculates the user desired collection list when sending a webalert e-mail"""

    if not cc[0]:
        cc = [CFG_SITE_NAME]

    # quickly create the reverse function of is_hosted_collection
    is_not_hosted_collection = lambda coll: not is_hosted_collection(coll)

    # calculate the list of non hosted, non restricted, regular sons of cc
    washed_cc_sons = filter(is_not_hosted_collection, get_coll_sons(cc[0]))
    # clean up c removing hosted collections
    washed_c = filter(is_not_hosted_collection, c)

    # try to simulate the wash_colls function behavior when calculating the collections to return
    if washed_cc_sons == washed_c:
        if sc == 0:
            return cc
        elif sc == 1:
            return washed_c
    else:
        if sc == 0:
            return washed_c
        elif sc == 1:
            washed_c_sons = []
            for coll in washed_c:
                if coll in washed_cc_sons:
                    washed_c_sons.extend(get_coll_sons(coll))
                else:
                    washed_c_sons.append(coll)
            return washed_c_sons
コード例 #2
0
def calculate_desired_collection_list(c, cc, sc):
    """Function that calculates the user desired collection list when sending a webalert e-mail"""

    if not cc[0]:
        cc = [CFG_SITE_NAME]

    # quickly create the reverse function of is_hosted_collection
    is_not_hosted_collection = lambda coll: not is_hosted_collection(coll)

    # calculate the list of non hosted, non restricted, regular sons of cc
    washed_cc_sons = filter(is_not_hosted_collection, get_coll_sons(cc[0]))
    # clean up c removing hosted collections
    washed_c = filter(is_not_hosted_collection, c)

    # try to simulate the wash_colls function behavior when calculating the collections to return
    if washed_cc_sons == washed_c:
        if sc == 0:
            return cc
        elif sc == 1:
            return washed_c
    else:
        if sc == 0:
            return washed_c
        elif sc == 1:
            washed_c_sons = []
            for coll in washed_c:
                if coll in washed_cc_sons:
                    washed_c_sons.extend(get_coll_sons(coll))
                else:
                    washed_c_sons.append(coll)
            return washed_c_sons
コード例 #3
0
 def tmpl_collection_stats_main_list(self, ln=CFG_SITE_LANG):
     """
     Generates a list of available collections statistics.
     """
     out = """<h3>Collections stats</h3>
              <ul>"""
     for coll in get_coll_sons(CFG_SITE_NAME):
         out += """<li><a href="%s/stats/collections?%s">%s</a></li>""" \
                     % (CFG_SITE_URL, urllib.urlencode({'collection': coll}) +
                        ((CFG_SITE_LANG != ln and '&ln=' + ln) or ''), coll)
     out += """<li><a href="%s/stats/collection_stats%s">Other collections</a></li>""" \
             % (CFG_SITE_URL, (CFG_SITE_LANG != ln and '?ln=' + ln) or '')
     return out + "</ul>"
コード例 #4
0
 def tmpl_collection_stats_main_list(self, ln=CFG_SITE_LANG):
     """
     Generates a list of available collections statistics.
     """
     out = """<h3>Collections stats</h3>
              <ul>"""
     for coll in get_coll_sons(CFG_SITE_NAME):
         out += """<li><a href="%s/stats/collections?%s">%s</a></li>""" \
                     % (CFG_SITE_URL, urllib.urlencode({'collection': coll}) +
                        ((CFG_SITE_LANG != ln and '&ln=' + ln) or ''), coll)
     out += """<li><a href="%s/stats/collection_stats%s">Other collections</a></li>""" \
             % (CFG_SITE_URL, (CFG_SITE_LANG != ln and '?ln=' + ln) or '')
     return out + "</ul>"