예제 #1
0
def scheduler_task():
    start_date, end_date = data.get_dates()
    for salesman in c.config.SALESMEN:
        delete_pdfs()
        report_pdf = run_ninja(start_date, end_date, salesman)
        send_email('Weekly Sales Report', [salesman['email']],
                   ['*****@*****.**'], [report_pdf])
예제 #2
0
파일: views.py 프로젝트: dedaluz/jamiecurle
def blog_post(slug):
    if slug.startswith('draft') and config.SHOW_DRAFTS == False:
        return render_template('404.html'), 404
    key = str('post_%s' % slug)
    post = get_post('%s.md' % slug )
    tags = get_tags()
    dates = get_dates()
    return render_template('blog/post.html', post=post, tags=tags,
        dates=dates)
예제 #3
0
파일: views.py 프로젝트: dedaluz/jamiecurle
def blog_archive(year, month):
    key = 'blog_archive_%s_%s' % (year, month)
    posts = get_posts()
    tags = get_tags()
    dates = get_dates()
    archive_posts = []
    for post in posts:
        if post['created'].month == month and post['created'].year == year:
            archive_posts.append(post)
    return render_template('blog/archive.html', posts=archive_posts, tags=tags,
        dates=dates)
예제 #4
0
파일: app.py 프로젝트: hakbailey/portfolio
def timeline():
	dates = get_dates('static/dms_portfolio.json')
	time_data = process_timeline('static/dms_portfolio.json')
	write_to_json('static/data_time.json', time_data)
	return render_template("timeline.html", data=time_data, dates=dates)
예제 #5
0
파일: views.py 프로젝트: dedaluz/jamiecurle
def blog_index():
    posts = get_posts()[:20]
    tags = get_tags()
    dates = get_dates()
    return render_template( 'blog/index.html', posts=posts, tags=tags,
        dates=dates)
예제 #6
0
파일: views.py 프로젝트: dedaluz/jamiecurle
def blog_tagged(tag):
    tags = get_tags()
    dates = get_dates()
    tagged_posts = [post for post in get_posts() if tag in post['tags']]
    return render_template('blog/tagged.html', tagged_posts=tagged_posts,
        tag=tag, tags=tags, dates=dates)
예제 #7
0
파일: views.py 프로젝트: dedaluz/jamiecurle
def blog_tags():
    tags = get_tags()
    dates = get_dates()
    return render_template('blog/tags.html',tags=tags, dates=dates)
예제 #8
0
def grid(df: pd.DataFrame, locs, column: Column,
         width, height, out_name,
         increment=False, average=1):

    fig: plt.Figure = plt.figure(figsize=(width, height), facecolor='papayawhip')
    gs = fig.add_gridspec(math.ceil(len(locs)/4), 4)  # , wspace=0.05, hspace=0.1)

    for i, location in enumerate(locs):
        ax: plt.Axes = fig.add_subplot(gs[i])
        series: pd.Series = get_series(df, location, column.label, increment, average)
        series.plot(ax=ax)

        ax.xaxis.set_visible(False)
        ax.set_facecolor('whitesmoke')

        # Annotate maximum
        max_x = series.idxmax()
        max_y = series.loc[max_x]
        ax.plot(max_x, max_y, 'rx', markersize=8)
        ax.set_ylim(bottom=0)
        # ax.annotate('peak={}\n{}'.format(int(max_y), time_repr(max_x)),
        #             xy=(max_x, max_y), xycoords='data',
        #             xytext=(-50, -0),
        #             textcoords='offset pixels', ha='right', va='top',
        #             arrowprops=dict(arrowstyle='->'),
        #             fontsize='small', fontweight='bold')

        # add month markers
        month = pd.Timestamp(year=series.index.min().year, month=series.index.min().month+1, day=1)
        while month < series.index.max():
            ax.axvline(month, ls=':', color='silver', linewidth=1)
            ax.text(month, -0.01, month.month_name(), va='top', transform=ax.get_xaxis_transform(), color='grey')
            month = month + pd.DateOffset(months=1)

        # add a text box with additional information. To automatically place it in the best place, create
        # a fake legend (legends have a loc='best' feature), as in:
        # https://stackoverflow.com/questions/7045729/automatically-position-text-box-in-matplotlib
        # 3 fake handles, one per line in the fake legend

        handles = [mpl_patches.Rectangle((0, 0), 1, 1, fc="white", ec="white", lw=0, alpha=0)] * 2
        labels = [
            # 'confirmed={}'.format(get_outbreak(df, location)),
            # 'active={}'.format(get_active(df, location)),
            # 'deaths={}'.format(get_deaths(df, location)),
            'last={} on {}'.format(int(series.iloc[-1]), time_repr(max_x)),
            'peak={} on {}'.format(int(max_y), time_repr(max_x))

        ]
        legend: plt.legend = ax.legend(handles, labels, fontsize='10',
                                       title=location, facecolor=ax.get_facecolor(),
                                       handlelength=0, handletextpad=0, frameon=False,
                                       loc='upper left' if location != 'China' else 'best')
        legend_title: plt.Text = legend.get_title()
        legend_title.set_fontweight('bold')
        legend_title.set_fontsize(12)
        legend._legend_box.align = "left"

    dates = [time_repr(dt) for dt in get_dates(df)]
    fig.suptitle('{}{}{}, from {} to {}'.format(
        'Daily ' if increment else '',
        column.label,
        ', {} days average'.format(average) if average > 1 else '',
        dates[0],
        dates[-1]),
        fontsize=14, fontweight='bold')

    fig.tight_layout(h_pad=0.1, w_pad=0.8, rect=(0, 0.01, 1, 0.965))
    fig.text(1, 0, 'https://github.com/rivasjm/covid19 ', va='bottom', ha='right')
    fig.savefig(out_name, facecolor=fig.get_facecolor())
    print('![{}]({})'.format(out_name, out_name))