Example #1
0
def main():
    # 引数を解析
    parser = argparse.ArgumentParser()
    parser.add_argument("--f")
    args = parser.parse_args()

    # 引数を変数に設定
    factory_name = args.f

    # print(factory_name)
    factory = Factory.get_factory(factory_name)

    # print(type(factory))

    asahi = factory.create_link(caption="朝日新聞", url="http://www.asahi.com/")
    yomiuri = factory.create_link("読売新聞", "http://www.yomiuri.co.jp/")

    us_yahoo = factory.create_link("Yahoo!", "http://www.yahoo.com/")
    jp_yahoo = factory.create_link("Yahoo!Japan", "http://www.yahoo.co.jp/")

    excite = factory.create_link("Excite", "http://www.excite.com/")
    google = factory.create_link("Google", "http://www.google.com/")

    traynews = factory.create_tray("新聞")
    traynews.add(asahi)
    traynews.add(yomiuri)

    trayyahoo = factory.create_tray("Yahoo!")
    trayyahoo.add(us_yahoo)
    trayyahoo.add(jp_yahoo)

    traysearch = factory.create_tray("サーチエンジン")
    traysearch.add(trayyahoo)
    traysearch.add(excite)
    traysearch.add(google)

    page = factory.create_page("LinkPage", "結城 浩")
    page.add(traynews)
    page.add(traysearch)
    page.output()
Example #2
0
from typing import List
import argparse
import os
from factory.factory import Factory

if __name__ == '__main__':
    
    parser = argparse.ArgumentParser()
    parser.add_argument("class_name")
    args = parser.parse_args()

    class_name = args.class_name  # listfactory.listfactory.ListFactory
    factory = Factory.get_factory(class_name)
    print(factory)

    google_link = factory.create_link('Google', 'https://www.google.com/')
    jp_yahoo_link = factory.create_link('Yahoo! JAPAN', 'https://www.yahoo.co.jp/')
    us_yahoo_link = factory.create_link('Yahoo!', 'https://www.yahoo.com/')

    yahoo_tray = factory.create_tray('Yahoo!')
    yahoo_tray.add(jp_yahoo_link)
    yahoo_tray.add(us_yahoo_link)

    search_tray = factory.create_tray('サーチエンジン')
    search_tray.add(yahoo_tray)
    search_tray.add(google_link)

    page = factory.create_page('LinkPage', 'Sadistica')
    page.add(search_tray)
    page.output()