Passed
Push — master ( 3731d5...59a60b )
by Yoshihiro
02:04
created

MP   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Test Coverage

Coverage 91.8%

Importance

Changes 0
Metric Value
eloc 68
dl 0
loc 103
ccs 56
cts 61
cp 0.918
rs 10
c 0
b 0
f 0
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
A MainProcessingClass.__init__() 0 29 1
B MainProcessingClass.initialize() 0 38 8
1
#!/usr/bin/env python3
2 1
import os
3 1
import shutil
4 1
import platform
5 1
import tkinter as tk
6 1
import tkinter.ttk as ttk
7
8 1
import CW
9 1
import EP
10 1
import SP
11 1
import HP
12 1
import FP
13 1
import CP
14 1
import FM
15 1
import EM
16 1
import HM
17 1
import PM
18 1
import LM
19
20
21 1
class MainProcessingClass(ttk.Frame):
22
    """メインフレーム処理のクラス.
23
24
    ・初期設定をするプログラム群
25
26
    Args:
27
        tree_folder (str): ツリーフォルダの配列
28
        tokenizer (instance): Tokenizerインスタンス
29
        wiki_wiki (instance): wikipediaapi.Wikipediaインスタンス
30
        title_binary (str): タイトルイメージファイルバイナリ
31
        master (instance): toplevelインスタンス
32
33
    """
34
35 1
    def __init__(
36
        self,
37
        tree_folder,
38
        tokenizer,
39
        wiki_wiki,
40
        title_binary,
41
        master=None
42
    ):
43 1
        super().__init__(master)
44 1
        self.TREE_FOLDER = tree_folder
45
        # 自作クラスの読み込み
46 1
        self.cwc = CW.CreateWindowClass(self)
47 1
        self.epc = EP.EventProcessingClass(self)
48 1
        self.sfc = SP.SubfunctionProcessingClass(self, self.TREE_FOLDER)
49 1
        self.hpc = HP.HighlightProcessingClass(self, tokenizer)
50 1
        self.fpc = FP.FindProcessingClass(self)
51 1
        self.cpc = CP.ComplementProcessingClass(self, tokenizer)
52 1
        self.fmc = FM.FileMenuClass(self, master, self.TREE_FOLDER)
53 1
        self.emc = EM.EditMenuClass(self)
54 1
        self.pmc = PM.ProcessingMenuClass(self, wiki_wiki, tokenizer)
55 1
        self.lmc = LM.ListMenuClass(self, master, self.TREE_FOLDER)
56 1
        self.hmc = HM.HelpMenuClass(self, title_binary)
57
        # メニューバーの作成
58 1
        self.menu_bar = tk.Menu(self.master)
59 1
        self.master.config(menu=self.menu_bar)
60
        # 初期化処理
61 1
        self.initialize()
62 1
        self.cwc.create_widgets()
63 1
        self.epc.create_event()
64
65 1
    def initialize(self):
66
        """初期化処理.
67
68
        ・変数の初期化及び起動準備をする。
69
70
        """
71
        # 今の処理ししているファイルのパス
72 1
        self.fmc.now_path = ""
73
        # 現在開いているファイル
74 1
        self.fmc.file_path = ""
75
        # 検索文字列
76 1
        self.fpc.find_text = ""
77
        # 現在入力中の初期テキスト
78 1
        self.lmc.text_text = ""
79 1
        self.lmc.select_list_item = ""
80
        # 文字の大きさ
81 1
        self.pmc.font_size = 16
82 1
        self.pmc.APPID = ""
83 1
        if os.path.isfile("./appid.txt"):
84 1
            f = open("./appid.txt", "r", encoding="utf-8")
85 1
            self.pmc.APPID = f.read()
86 1
            f.close()
87 1
        if u"ここを消して、" in self.pmc.APPID:
88
            self.pmc.APPID = ""
89
        # フォントをOSごとに変える
90 1
        pf = platform.system()
91 1
        if pf == 'Windows':
92 1
            self.font = "メイリオ"
93
        elif pf == 'Darwin':  # MacOS
94
            self.font = "Osaka-等幅"
95
        elif pf == 'Linux':
96
            self.font = "IPAゴシック"
97
        # dataフォルダがあるときは、削除する
98 1
        if os.path.isdir('./data'):
99 1
            shutil.rmtree('./data')
100
        # 新しくdataフォルダを作成する
101 1
        for val in self.TREE_FOLDER:
102
            os.makedirs('./{0}'.format(val[0]))
103