Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 4
0
# mpl.use('TkAgg')
import matplotlib.pyplot as plt

if __name__ == "__main__":
    hv = Hive()
    price = Amount(hv.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 = hv._calc_resulting_vote()
    last_hp = 0
    hp_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_hp = hv.vests_to_hp(needed_vests)
        hp_list.append(needed_hp / 1000)
        # print("| %.1f | %.2f | %.2f  | " % (score, needed_hp / 1000, needed_hp / 1000 - last_hp / 1000))
        last_hp = needed_hp

    plt.figure(figsize=(12, 6))
    opts = {'linestyle': '-', 'marker': '.'}
    plt.semilogx(hp_list, rep_score_list, label="Reputation", **opts)
    plt.grid()
    plt.legend()
    plt.title("Required number of 1k HP upvotes to reach certain reputation")
    plt.xlabel("1k HP votes")