def main(): if len(sys.argv) != 2: usage() sys.exit() if sys.argv[1] == 'plain': text_builder = TextBuilder() director = Director(text_builder) director.construct() result = text_builder.get_result() print(result) elif sys.argv[1] == 'html': html_builder = HTMLBuilder() director = Director(html_builder) director.construct() filename = html_builder.get_result() print(filename + 'が作成されました。') else: usage() sys.exit()
def get_builder(regulation, version, inline_applier, p_applier, s_applier): """ Returns an HTML builder with the appliers, and the regulation tree. """ builder = HTMLBuilder(inline_applier, p_applier, s_applier) builder.tree = get_regulation(regulation, version) return builder
def usage(): print 'Usage: python Main plain プレーンテキストで文書作成' print 'Usage: python Main html HTMLファイルで文書作成' if __name__ == '__main__': # print sys.argv # 引数の数 check if len(sys.argv) != 2: usage() exit() if sys.argv[1] == 'plain': textbuilder = TextBuilder() director = Director(textbuilder) director.construct() result = textbuilder.get_result() print result elif sys.argv[1] == 'html': htmlbuilder = HTMLBuilder() director = Director(htmlbuilder) director.construct() filename = htmlbuilder.get_result() print filename + 'が作成されました。' else: usage() exit()
# -*- encoding: utf-8 -*- from html_form_parser import HTMLFormParser from html_builder import HTMLBuilder from db_client import DBClient from flask import Flask, request, render_template, redirect, url_for import json app = Flask(__name__) d = DBClient() hfp = HTMLFormParser() hb = HTMLBuilder() @app.route('/', methods=['GET', 'POST']) def list_of_verbs(): if request.method == 'POST': v_id = request.form["delete"] d.delete(v_id) return '{"result":"success"}' words = d.all_words() return render_template('index.html', words=words, results=False) @app.route('/add', methods=['GET', 'POST']) def add(): if request.method == 'POST': for_db = hfp.parse_form(dict(request.form)) d.add(for_db) return '{"result":"success"}' page = hb.create_html(d.empty_form_fields(), mode='add')