Beispiel #1
0
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()
Beispiel #2
0
def main():
    # 引数を解析
    parser = argparse.ArgumentParser()
    parser.add_argument("--t")
    args = parser.parse_args()

    # 引数を変数に設定
    file_type = args.t

    if file_type == "plain":
        textbuilder = TextBuilder()
        director = Director(textbuilder)
        director.construct()
        result = textbuilder.get_result()
        print(result)
    elif file_type == "html":
        htmlbuilder = HtmlBuilder()
        director = Director(htmlbuilder)
        director.construct()
        filename = htmlbuilder.get_result()
        print("{}が作成されました".format(filename))
    else:
        usage()
Beispiel #3
0
def main():
    concrete_builder = ConcreteBuilder()
    director = Director()
    director.construct(concrete_builder)
    product = concrete_builder.product
Beispiel #4
0
def doConstruct( builder ):
    director = Director( builder )
    for i in director.construct():
        print i
from concrete_builder import ConcreteBuilder
from director import Director

if __name__ == "__main__":
    print("***Demo: builder pattern")
    builder = ConcreteBuilder()
    director = Director(builder)
    product = director.construct()
Beispiel #6
0
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()


Beispiel #7
0
def doConstruct(builder):
    director = Director(builder)
    for i in director.construct():
        print i