def main(): """Create DataFrame from markdown files, split dataframes by habit name, create plots, and add plots to PDF """ config = configparser.ConfigParser() config.read('config.ini') # Directories need to exist habit_dir = config.get('Directories', 'md_dir') save_dir = config.get('Directories', 'pdf_save_dir') color_heatmap_border = config.get('Plots', 'color_heatmap_border') color_low = config.get('Plots', 'color_low') color_high = config.get('Plots', 'color_high') color = config.get('Plots', 'color') font = config.get('Plots', 'font') habitlist = md_file_list(habit_dir) df_list = get_df_list(habitlist, habit_dir) plotslist = get_plot_list(df_list, color, color_low, color_high, color_heatmap_border, font, save_dir) pdf.create_pdf(plotslist, save_dir, get_date()) delete_lists = [x[2] for x in plotslist] for delete_list in delete_lists: delete_files(delete_list)
def create_wishlist_pdf(): """Creates and downloads pdf of user wishlist""" if g.user: html = request.form['wished-html'] create_pdf(html, g.user.username) path = f"wishlists\\{g.user.username}.pdf" return send_file(path, as_attachment=True) else: return "no logged in user"
def get_reports(): """Route for reports.""" if 'Content-Type' in request.headers and request.headers[ 'Content-Type'] in app.config['SUPPORTED_CONTENT_TYPE']: if request.headers['Content-Type'] == 'application/pdf': ext = 'pdf' elif request.headers['Content-Type'] == 'text/xml': ext = 'xml' elif request.headers['Content-Type'] == 'application/json': ext = 'json' elif 'format' in request.args and request.args['format'] in app.config[ 'SUPPORTED_FORMAT']: ext = request.args['format'] else: ext = 'json' cmd = "SELECT * FROM reports;" # execut the cmd for fetch the correct data. cursor.execute(cmd) # fetch the data from the Database. data = cursor.fetchall() if not data: return not_found() # clean the data jdata = list(map(decode_data, data)) if ext == 'pdf': # Generate the pdf pdf, filename = create_pdf('all', jdata) # Set the pdf data as responce resp = make_response(pdf) # Set the header as pdf resp.headers["Content-Type"] = 'application/pdf' return resp if ext == 'xml': print('jData: ', jdata) # Create the xml xml = dicttoxml(jdata, custom_root='Reports', attr_type=False) # Set the xml data as responce resp = make_response(xml) # Set the header as xml resp.headers["Content-Type"] = 'text/xml' return resp if ext == 'json': # Create the json resp = make_response(json.dumps(jdata)) # Set the header as json resp.headers["Content-Type"] = 'application/json' return resp return "Nay!", 202
def main(cat_list,basic,etf,div): #generate portfolio on preferences portfolio = create_portfolio(cat_list=cat_list,basic=basic,etf=etf,div=div) #yields of portfolio yields = portfolio.iloc[:,3:8].sum().round(2) #plot history of this portfolio perf=plot_port_history(yields) perf = round(perf,4) * 100 #plot Pie Chart of portfolio allocation by Stocks weight = portfolio.loc[:,['Wertpapier','Weight']] create_pie(weight) #plot pie chart of portfolio allocation by cat cat_alloc= portfolio.loc[:,['Wertpapier','Weight','Kategorie']] create_pie_cat(cat_alloc) # sets up the parsing of arguments to the create pdf function stocks= portfolio['Wertpapier'].tolist() weights = portfolio['Weight'].tolist() yd=yields.values.reshape(-1, 1) yr =[2015,2016,2017,2018,2019] #create pdf create_pdf(stocks,weights,yd,yr,perf)
def create(albumData): pdf = create_pdf(html_doc(albumData)) return pdf
line_thickness=8, min_score_thresh=0.60) c += 1 if c >= 10: if (np.squeeze(scores)[0] > 0.5) & (np.squeeze(classes)[0] == 1): cv2.putText(frame, "Pass!", (100, 100), cv2.FONT_HERSHEY_SIMPLEX, 2, (0, 128, 0)) if flagjer == False: #cv2.imwrite('C:/Tensorflow/models/research/object_detection/zresult/image%d.jpg' % count, frame) cv2.imwrite( 'C:/Tensorflow/models/research/object_detection/zresult/image.jpg', frame) #count += 1 flagjer = True pdf.create_pdf() mailpdf.send_mail() elif np.squeeze(scores)[0] < 0.5: flagjer = False c = 0 #print(np.squeeze(classes)[0]) #print(np.squeeze(scores)[0]) #print(f"Classes: {classes}"+"is Found") #print(f"cate: {category_index}"+"is Found") # All the results have been drawn on the frame, so it's time to display it. cv2.imshow('Object detector', frame) # Press 'q' to quit
from spider import Spider from pdf import create_pdf url = sys.argv[1] spider = Spider(url) print('书名:', spider.book.name) print('作者:', spider.book.author) print('类型:', spider.book.bookType) print('简介:', spider.book.description) isExist = os.path.exists(spider.book.name) if not isExist: print('{0}文件夹不存在,自动创建...'.format(spider.book.name)) os.makedirs(spider.book.name) print('{0}文件夹创建成功!'.format(spider.book.name)) for p in spider.book.content: story = p['part'] + '\n' + '---------------' + '\n' print(story) for charpter in p['charpters']: story += charpter['title'] + '\n' + \ charpter['content'] + '\n' + '---------------' + '\n' filePath = '{0}/{1}.pdf'.format(spider.book.name.strip(), p['part'].strip()) create_pdf(story, filePath) print('pdf导出完成')