Beispiel #1
0
def build_comments(url):
    if url[-1] != '/':
        url += '/'
    page = requests.get(url)
    content_type = page.headers['Content-Type']
    if 'application/rss' in content_type:
        from rss import rss
        return rss(page)
    return walk(page)
Beispiel #2
0
    def plantreg(X, y, num):
        """
        Input:
        X - macierz z przykladami budujacymi drzewo
        y - wektor z decyzjami
        num - liczba cech, sposrod ktorych gini wybiera wartosc podzialu

        Rekurencyjna funkcja budujaca drzewo. Wybiera wartosc podzialu na podstawie
        wartosci RSS. 
        """

        rss_tup = rss.rss(X,y,num)

        set1, set2, y1, y2 = Tree.divideset(X, rss_tup[0], rss_tup[1], y)
        
        if rss_tup[2] == 100000000000000000:
            if len(y1) == 0:
                y1 = y2
            if len(y2) == 0:
                y2 = y1

            y1avg = float(sum(y1))/len(y1)
            y2avg = float(sum(y2))/len(y2)

            return node.Node(tb = leaf.Leaf(y1avg), fb = leaf.Leaf(y2avg), value = rss_tup[1], index=rss_tup[0], gn = rss_tup[2])

        if len(set1) > 3 and len(set2) > 3:
            trueBranch = Tree.plantreg(set1, y1, num)
            falseBranch = Tree.plantreg(set2, y2, num)
            return node.Node(tb=trueBranch, fb=falseBranch, value=rss_tup[1], index=rss_tup[0], gn = rss_tup[2])

        elif len(set1) > 3 and len(set2) <= 3:
            trueBranch = Tree.plantreg(set1, y1, num)
            y2avg = float(sum(y2))/len(y2)
            falseBranch = leaf.Leaf(y2avg)
            return node.Node(tb=trueBranch, fb=falseBranch, value=rss_tup[1], index=rss_tup[0], gn = rss_tup[2])
                
        elif len(set2) > 3 and len(set1) <= 3:
            y1avg = float(sum(y1))/len(y1)
            trueBranch = leaf.Leaf(y1avg)
            falseBranch = Tree.plantreg(set2, y2, num)
            return node.Node(tb=trueBranch, fb=falseBranch, value=rss_tup[1], index=rss_tup[0], gn = rss_tup[2])

        else:
            if len(y1) == 0:
                y1 = y2
            if len(y2) == 0:
                y2 = y1

            y1avg = float(sum(y1))/len(y1)
            y2avg = float(sum(y2))/len(y2)

            return node.Node(tb = leaf.Leaf(y1avg), fb = leaf.Leaf(y2avg), value = rss_tup[1], index=rss_tup[0], gn = rss_tup[2])
Beispiel #3
0
async def _():
    none.logger.info("Running scheduled Job")
    loadConfig()

    bot = none.get_bot()
    tmp = rss("db").query(URLS)
    for i, post in enumerate(tmp):
        text = []
        text.append({"type": "text", "data": {"text": f'{post.title}\n'}})
        text.append({"type": "text", "data": {"text": f'发布于 {post.author}\n'}})
        text.append({"type": "text", "data": {"text": f'{post.link}'}})
        none.logger.info(text)
        try:
            for num in QQGroup:
                await bot.send_group_msg(group_id=num, message=text)
        except CQHttpError:
            pass
Beispiel #4
0
 def test_rss(self):
     
     X_list = []
     f = open("regd.txt", "r")
     for i in f:
         X_list.append(i.strip().split("\t"))
     f.close()
     
     y_list = []
     g = open("regkl.txt", "r")
     for j in g:
         y_list.append(float(j.strip()))
     g.close()
     
     rss_val = 1926.0449999999996
     rss_test = rss.rss(X_list,y_list,4)[2]
     
     self.assertEqual(rss_val, rss_test)
Beispiel #5
0
 def do_rss(self):
     from rss import rss
     return rss()
Beispiel #6
0
 def do_rss(self):
   from rss import rss
   return rss()
Beispiel #7
0
from rss import rss
"""
Simple tester for the rss module which connects to rasdproc.
Data is read and output in the rtl_power format.
"""

r = rss()

print('rasdproc state:')
keys = r.parameters.keys()
values = [str(value) for value in r.parameters.values()]
print(' '.join(keys))
print(' '.join(values))
while True:
    rtl_power_lines = r.read_data()
    for line in rtl_power_lines:
        print(line)
Beispiel #8
0
def convert_localfile_to_jpg(local_image_file,local_jpg_file):
  debug('converting to jpeg')
  debug("  "+local_image_file)
  debug("  "+local_jpg_file)
  im=Image.open(local_image_file)
  if im.mode != "RGB":
    im = im.convert("RGB")
    im.save(local_jpg_file)

frameconfig=yaml.load(open('/home/matt/framer/frameconfig.yaml','r').read())
feed=frameconfig['feedinfo']
resources=frameconfig['resources']

local_dir=feed['localdir']+"/"
rss=rss.rss(feed['localdir']+"/"+feed['filename'],feed['title'],feed['description'])

#download each image, convert it to jpg if nessesary, move to folder and build rss
for item in resources:
    # use a hash for the file name as some urls are horrendous looking filenames
    md5= hashlib.sha224(item['uri']).hexdigest()
    localfsp=local_dir+md5

    # type can be file or web
    if item['type']=='file':
      debug('file')
      debug('copying '+item['uri']+' to '+localfsp)
      copyfile(item['uri'], localfsp)
    else:
      debug('web')
      download_web_image(item['uri'],localfsp)
Beispiel #9
0
    def plantreg(X, y, num):
        """
        Input:
        X - macierz z przykladami budujacymi drzewo
        y - wektor z decyzjami
        num - liczba cech, sposrod ktorych gini wybiera wartosc podzialu

        Rekurencyjna funkcja budujaca drzewo. Wybiera wartosc podzialu na podstawie
        wartosci RSS. 
        """

        rss_tup = rss.rss(X, y, num)

        set1, set2, y1, y2 = Tree.divideset(X, rss_tup[0], rss_tup[1], y)

        if rss_tup[2] == 100000000000000000:
            if len(y1) == 0:
                y1 = y2
            if len(y2) == 0:
                y2 = y1

            y1avg = float(sum(y1)) / len(y1)
            y2avg = float(sum(y2)) / len(y2)

            return node.Node(tb=leaf.Leaf(y1avg),
                             fb=leaf.Leaf(y2avg),
                             value=rss_tup[1],
                             index=rss_tup[0],
                             gn=rss_tup[2])

        if len(set1) > 3 and len(set2) > 3:
            trueBranch = Tree.plantreg(set1, y1, num)
            falseBranch = Tree.plantreg(set2, y2, num)
            return node.Node(tb=trueBranch,
                             fb=falseBranch,
                             value=rss_tup[1],
                             index=rss_tup[0],
                             gn=rss_tup[2])

        elif len(set1) > 3 and len(set2) <= 3:
            trueBranch = Tree.plantreg(set1, y1, num)
            y2avg = float(sum(y2)) / len(y2)
            falseBranch = leaf.Leaf(y2avg)
            return node.Node(tb=trueBranch,
                             fb=falseBranch,
                             value=rss_tup[1],
                             index=rss_tup[0],
                             gn=rss_tup[2])

        elif len(set2) > 3 and len(set1) <= 3:
            y1avg = float(sum(y1)) / len(y1)
            trueBranch = leaf.Leaf(y1avg)
            falseBranch = Tree.plantreg(set2, y2, num)
            return node.Node(tb=trueBranch,
                             fb=falseBranch,
                             value=rss_tup[1],
                             index=rss_tup[0],
                             gn=rss_tup[2])

        else:
            if len(y1) == 0:
                y1 = y2
            if len(y2) == 0:
                y2 = y1

            y1avg = float(sum(y1)) / len(y1)
            y2avg = float(sum(y2)) / len(y2)

            return node.Node(tb=leaf.Leaf(y1avg),
                             fb=leaf.Leaf(y2avg),
                             value=rss_tup[1],
                             index=rss_tup[0],
                             gn=rss_tup[2])