Passed
Pull Request — master (#57)
by Yoshihiro
04:03
created

neditor.mp.MainProcessingClass.initialize()   B

Complexity

Conditions 6

Size

Total Lines 30
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6.0073

Importance

Changes 0
Metric Value
cc 6
eloc 17
nop 1
dl 0
loc 30
ccs 16
cts 17
cp 0.9412
crap 6.0073
rs 8.6166
c 0
b 0
f 0
1
#!/usr/bin/env python3
2 1
import os
3 1
import shutil
4 1
import tkinter as tk
5
6 1
from . import cw
7 1
from . import ep
8 1
from . import sp
9 1
from . import hp
10 1
from . import fp
11 1
from . import cp
12 1
from . import fm
13 1
from . import em
14 1
from . import hm
15 1
from . import pm
16 1
from . import lm
17 1
from . import main
18
19
20 1
class MainProcessingClass(main.MainClass):
21
    """メインフレーム処理のクラス.
22
23
    ・初期設定をするプログラム群
24
25
    Args:
26
        tokenizer (instance): Tokenizer のインスタンス
27
        wiki_wiki (instance): wikipediaapi.Wikipedia のインスタンス
28
        locale_var (str): ロケーション
29
        master (instance): toplevel のインスタンス
30
    """
31
32 1
    def __init__(self, tokenizer, wiki_wiki, locale_var, master=None):
33 1
        super().__init__(locale_var, master)
34
        # 自作クラスの読み込み
35 1
        self.cwc = cw.CreateWindowClass(
36
            self,
37
            locale_var,
38
            master
39
        )
40 1
        self.epc = ep.EventProcessingClass(
41
            self,
42
            locale_var,
43
            master
44
        )
45 1
        self.spc = sp.SubfunctionProcessingClass(
46
            self,
47
            locale_var,
48
            master
49
        )
50 1
        self.hpc = hp.HighlightProcessingClass(
51
            self,
52
            tokenizer,
53
            locale_var,
54
            master
55
        )
56 1
        self.fpc = fp.FindProcessingClass(
57
            self,
58
            locale_var,
59
            master
60
        )
61 1
        self.cpc = cp.ComplementProcessingClass(
62
            self,
63
            tokenizer,
64
            locale_var,
65
            master
66
        )
67 1
        self.fmc = fm.FileMenuClass(
68
            self,
69
            locale_var,
70
            master
71
        )
72 1
        self.emc = em.EditMenuClass(
73
            self,
74
            locale_var,
75
            master
76
        )
77 1
        self.pmc = pm.ProcessingMenuClass(
78
            self,
79
            tokenizer,
80
            wiki_wiki,
81
            locale_var,
82
            master
83
        )
84 1
        self.lmc = lm.ListMenuClass(
85
            self,
86
            locale_var,
87
            master
88
        )
89 1
        self.hmc = hm.HelpMenuClass(
90
            self,
91
            locale_var,
92
            master
93
        )
94
        # メニューバーの作成
95 1
        self.menu_bar = tk.Menu(master)
96 1
        self.master.config(menu=self.menu_bar)
97
        # 初期化処理
98 1
        self.initialize()
99 1
        self.cwc.create_widgets()
100 1
        self.epc.create_event()
101
102 1
    def initialize(self):
103
        """初期化処理.
104
105
        ・変数の初期化及び起動準備をする。
106
        """
107
        # 今の処理ししているファイルのパス
108 1
        fm.FileMenuClass.now_path = ""
109
        # 現在開いているファイル
110 1
        fm.FileMenuClass.file_path = ""
111
        # 検索文字列
112 1
        fp.FindProcessingClass.find_text = ""
113
        # 現在入力中の初期テキスト
114 1
        lm.ListMenuClass.text_text = ""
115 1
        lm.ListMenuClass.select_list_item = ""
116
        # 文字の大きさ
117 1
        pm.ProcessingMenuClass.font_size = 16
118 1
        pm.ProcessingMenuClass.yahoo_appid = ""
119 1
        if os.path.isfile("./appid.txt"):
120 1
            with open("./appid.txt", encoding='utf-8') as f:
121 1
                pm.ProcessingMenuClass.yahoo_appid = f.read()
122
123 1
        if u"ここを消して、" in pm.ProcessingMenuClass.yahoo_appid:
124
            pm.ProcessingMenuClass.yahoo_appid = ""
125
126
        # dataフォルダがあるときは、削除する
127 1
        if os.path.isdir('./data'):
128 1
            shutil.rmtree('./data')
129
        # 新しくdataフォルダを作成する
130 1
        for val in self.TREE_FOLDER:
131
            os.makedirs('./{0}'.format(val[0]))
132