-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMockDataGen.py
74 lines (64 loc) · 3.3 KB
/
MockDataGen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# MIT License
#
# Copyright (C) 2021 <FacuFalcone - CaidevOficial>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import datetime
import os
import FileHandle_Mod.FileHandle as FH
import SearchIfExist_Mod.Search as SF
from CreateRegisters_Mod.DataCreation import CreateRegisterForCSV as CSV
from CreateRegisters_Mod.DataCreation import CreateRegisterForSQL as SQL
from FileHandle_Mod.FileHandle import DoubleMessage as PMD
from FileHandle_Mod.FileHandle import SingleMessage as PMS
from GetConfigs_Mod.GetConfigsPython import ScriptConfigurator as GCP
from Statistics_Mod.Statistics import CountRegisters as CR
from Statistics_Mod.Statistics import FormatAmountRegisters as FAR
from Statistics_Mod.Statistics import TimeFormatted as TF
################################ SETUP AREA ################################
configurator = GCP(os.path.dirname(os.path.realpath(__file__)))
################################ SETUP AREA ################################
def MockDataGenerator() -> None:
"""[summary]
Creates Files in csv with the data generated and a Json with the tables and its pk values inside.
"""
jsonRecord = {}
try:
jsonRecord = SF.SearchIfExist(jsonRecord, configurator.getCurrentDir(), configurator.getDatasetName(), configurator.getJSONDirectory(), configurator.getJSONFileName())
JSON_ALL_TABLES = FH.OpenFile(configurator.getAbsolutePathOfConfigFile())
if(configurator.isSql()):
SQL(JSON_ALL_TABLES, jsonRecord, configurator.getDatasetName(), configurator.isSql())
else:
CSV(JSON_ALL_TABLES, jsonRecord, configurator.getDatasetName(), configurator.isSql())
PMS(f"Creating JSON file for {configurator.getDatasetName()}")
################
totalRecords = CR(jsonRecord)
amountRegisters = FAR(totalRecords)
##############
FH.WriteJSON(jsonRecord, configurator.getDatasetName(), configurator.getJSONFileName())
PMS("Moving Files...")
FH.SortFiles(configurator.getNameConfigOfDataset(), configurator.getDatasetName(), configurator.getCSVDirectory(), configurator.getJSONDirectory(), configurator.getSQLDirectory(),configurator.getCurrentDir())
PMD(f'{configurator.getScriptName()} - {configurator.getScriptVersion()}','Finished Successfully!.')
PMS(f'Total Records Created: {amountRegisters}')
except Exception as e:
PMS("Error: Try to run again.")
PMS(f"Exception: {e}")
################################# TEST AREA ################################
if __name__ == "__main__":
start_time = datetime.datetime.now()
MockDataGenerator()
elapsed_time = TF(start_time)
PMS(f"Elapsed Time: {elapsed_time}")
PMS("Success! All task done. Press a key to close the app")
end = input()