Example #1
0
def __handle_flag_value(manager, value, ps):
    result = []

    if get_grist(value):
        f = feature.get(value)
        values = ps.get(f)

        for value in values:

            if f.dependency():
                # the value of a dependency feature is a target
                # and must be actualized
                result.append(value.actualize())

            elif f.path() or f.free():

                # Treat features with && in the value
                # specially -- each &&-separated element is considered
                # separate value. This is needed to handle searched
                # libraries, which must be in specific order.
                if not __re_two_ampersands.search(value):
                    result.append(value)

                else:
                    result.extend(value.split("&&"))
            else:
                result.append(ungristed)
    else:
        result.append(value)

    return result
Example #2
0
def response_chain(api, status):
    db = DBconnect.Database()
    recent = api.home_timeline(count=5)
    dic = {}
    for t in recent:
        tmpdic = feature.get(t.text)
        dic = merge_dict_add_values(dic, tmpdic)
    words = []
    weights = []
    for word, weight in dic.items():
        words.append(word)
        weights.append(weight)
    keyword = random.choices(words, weights=weights)[0]
    first_rawchain = db.read_single(keyword, "second")
    if first_rawchain:
        first_ring = weighted_choice(first_rawchain)
        chain = first_ring[1:4]
        while (chain[-1] != "ENDKEY"):
            rawchain = db.read_double(chain[-2], chain[-1])
            ring = weighted_choice(rawchain)
            chain.append(ring[3])
        while (chain[0] != "STARTKEY"):
            rawchain = db.read_double_back(chain[0], chain[1])
            ring = weighted_choice(rawchain)
            chain.insert(0, ring[1])
        chain.pop()
        text = "".join(chain[1:])
        api.update_status(text,
                          in_reply_to_status_id=status.id,
                          auto_populate_reply_metadata=True)
    else:
        double_chain(api, status)
        return
Example #3
0
def __handle_flag_value(manager, value, ps):
    result = []

    if get_grist(value):
        f = feature.get(value)
        values = ps.get(f)

        for value in values:

            if f.dependency():
                # the value of a dependency feature is a target
                # and must be actualized
                result.append(value.actualize())

            elif f.path() or f.free():

                # Treat features with && in the value
                # specially -- each &&-separated element is considered
                # separate value. This is needed to handle searched
                # libraries, which must be in specific order.
                if not __re_two_ampersands.search(value):
                    result.append(value)

                else:
                    result.extend(value.split('&&'))
            else:
                result.append(ungristed)
    else:
        result.append(value)

    return result
Example #4
0
def __handle_flag_value (manager, value, ps):
    assert isinstance(value, basestring)
    assert isinstance(ps, property_set.PropertySet)
    result = []

    if get_grist (value):
        f = feature.get(value)
        values = ps.get(f)

        for value in values:

            if f.dependency:
                # the value of a dependency feature is a target
                # and must be actualized
                result.append(value.actualize())

            elif f.path or f.free:

                # Treat features with && in the value
                # specially -- each &&-separated element is considered
                # separate value. This is needed to handle searched
                # libraries, which must be in specific order.
                if not __re_two_ampersands.search(value):
                    result.append(value)

                else:
                    result.extend(value.split ('&&'))
            else:
                result.append (value)
    else:
        result.append (value)

    return sequence.unique(result, stable=True)
Example #5
0
def __handle_flag_value(manager, value, ps):
    assert isinstance(value, basestring)
    assert isinstance(ps, property_set.PropertySet)
    result = []

    if get_grist(value):
        f = feature.get(value)
        values = ps.get(f)

        for value in values:

            if f.dependency:
                # the value of a dependency feature is a target
                # and must be actualized
                result.append(value.actualize())

            elif f.path or f.free:

                # Treat features with && in the value
                # specially -- each &&-separated element is considered
                # separate value. This is needed to handle searched
                # libraries, which must be in specific order.
                if not __re_two_ampersands.search(value):
                    result.append(value)

                else:
                    result.extend(value.split('&&'))
            else:
                result.append(value)
    else:
        result.append(value)

    return sequence.unique(result, stable=True)
Example #6
0
 def gettweets(self, tag):
     searchtag = '#' + tag
     jikkyos = self.api.search(searchtag + " -RT -@", count=10)
     dic = {}
     for j in jikkyos:
         tmpdic = feature.get(self.filter(j.text), profile.YAHOO_APPID)
         dic = self.merge_dict_add_values(dic, tmpdic)
     counter = Counter(dic)
     self.posttweet(counter.most_common(5))