Exemplo n.º 1
0
 def build_rep_arrays(self):
     """ Build reputation arrays """
     self.rep_timestamp = [self.timestamps[1]]
     self.rep = [reputation_to_score(0)]
     current_reputation = 0
     for (ts, rshares, rep) in zip(self.in_vote_timestamp,
                                   self.in_vote_rshares, self.in_vote_rep):
         if rep > 0:
             if rshares > 0 or (rshares < 0 and rep > current_reputation):
                 current_reputation += rshares >> 6
         self.rep.append(reputation_to_score(current_reputation))
         self.rep_timestamp.append(ts)
Exemplo n.º 2
0
def main(args=None):
    args = parse_args(args)
    authorperm = args.authorperm
    comment = Comment(authorperm)
    title = comment["title"]
    author = comment["author"]
    rep = reputation_to_score(comment["author_reputation"])
    time_created = comment["created"]
    utc = pytz.timezone('UTC')
    td_created = utc.localize(datetime.utcnow()) - time_created
    md = '# ' + title + '\n' + author
    md += '(%.2f) ' % (rep)
    md += formatTimedelta(td_created) + '\n\n'
    md += comment["body"]
    extensions = ['extra', 'smarty']
    html = markdown.markdown(md, extensions=extensions, output_format='html5')
    doc = jinja2.Template(TEMPLATE).render(content=html, title=title)
    args.out.write(doc)
Exemplo n.º 3
0
def main(args=None):
    """pandoc -s test.md  --from markdown-blank_before_header-blank_before_blockquote+lists_without_preceding_blankline    -o test.pdf"""
    args = parse_args(args)
    authorperm = args.authorperm
    comment = Comment(authorperm)
    title = comment["title"]
    author = comment["author"]
    rep = reputation_to_score(comment["author_reputation"])
    time_created = comment["created"]
    if True:
        md = '% Title:\t ' + title + '\n'
        md += '% Author:\t' + author + '(%.2f) ' % (rep) + '\n'
        md += '% Date:\t' + time_created.strftime("%d.%m.%Y") + '\n'
        md += '% Comment:\n'
    else:
        md = '# ' + title + '\n'
        md += author + '(%.2f) ' % (rep) + ' ' + time_created.strftime(
            "%d.%m.%Y") + '\n\n'
    md += comment["body"]

    args.out.write(md)
import matplotlib.pyplot as plt


if __name__ == "__main__":
    stm = Steem()
    price = Amount(stm.get_current_median_history()["base"])
    reps = [0]
    for i in range(26, 91):
        reps.append(int(10**((i - 25) / 9 + 9)))
    # reps = np.logspace(9, 16, 60)
    used_power = stm._calc_resulting_vote()
    last_sp = 0
    sp_list = []
    rep_score_list = []
    for goal_rep in reps:
        score = reputation_to_score(goal_rep)
        rep_score_list.append(score)
        needed_rshares = int(goal_rep) << 6
        needed_vests = needed_rshares / used_power / 100
        needed_sp = stm.vests_to_sp(needed_vests)
        sp_list.append(needed_sp / 1000)
        # print("| %.1f | %.2f | %.2f  | " % (score, needed_sp / 1000, needed_sp / 1000 - last_sp / 1000))
        last_sp = needed_sp

    plt.figure(figsize=(12, 6))
    opts = {'linestyle': '-', 'marker': '.'}
    plt.semilogx(sp_list, rep_score_list, label="Reputation", **opts)
    plt.grid()
    plt.legend()
    plt.title("Required number of 1k SP upvotes to reach certain reputation")
    plt.xlabel("1k SP votes")
Exemplo n.º 5
0
        'allow_curation_rewards', 'allow_curation_rewards', 'beneficiaries',
        'promoted', 'depth'
    ]
    query = "SELECT %s from Comments WHERE " \
             "created BETWEEN '%s' AND '%s'" % \
            (", ".join(fields), start_date, stop_date)

    entries = []
    cursor.execute(query)
    for op in cursor:
        entry = {}
        for key, value in zip(fields, op):
            if key in ['active_votes', 'beneficiaries']:
                if not value:
                    entry[key] = {}
                else:
                    entry[key] = json.loads(value)
            elif key == 'author_reputation':
                entry[key] = reputation_to_score(int(value))
            else:
                entry[key] = value
        entries.append(entry)

    s = shelve.open("posts-%s.shelf" % (datestr(start_date)))
    s['posts'] = entries
    s.close()
    print(start_date, len(entries))
    start_date = stop_date

connection.close()