This commit is contained in:
2026-01-05 14:47:49 -01:00
5 changed files with 53 additions and 18 deletions

43
ev2.py
View File

@@ -1,11 +1,9 @@
import logging
import os
from enum import Enum
import time
from utilsv2 import mongo, stats
from utilsv2 import mongo, parser, stats, utils
from utilsv2.log import logger
from utilsv2.parser import parse
from utilsv2.utils import toDateTime, toFloat, toInt
OS = os.name
@@ -55,8 +53,8 @@ def filter_menu(old_fiters):
d1, d2 = aux.split(",", maxsplit=1)
d1 = toDateTime(d1)
d2 = toDateTime(d2)
d1 = utils.toDateTime(d1)
d2 = utils.toDateTime(d2)
filters["DateTime"] = {}
if d1 != -1:
@@ -73,8 +71,8 @@ def filter_menu(old_fiters):
d1, d2 = aux.split(",", maxsplit=1)
d1 = toFloat(d1)
d2 = toFloat(d2)
d1 = utils.toFloat(d1)
d2 = utils.toFloat(d2)
filters["Magnitudes.L.Magnitude"] = {}
if d1 != -1:
@@ -82,15 +80,17 @@ def filter_menu(old_fiters):
if d2 != -1:
filters["Magnitudes.L.Magnitude"]["$lte"] = d2
case "2":
# Profundidades
case "3":
clear_screen()
print("Inserir profundidades de corte, separadas por uma vírgula(,)")
aux = input()
d1, d2 = aux.split(",", maxsplit=1)
d1 = toFloat(d1)
d2 = toFloat(d2)
d1 = utils.toFloat(d1)
d2 = utils.toFloat(d2)
filters["Depth"] = {}
if d1 != -1:
@@ -99,12 +99,14 @@ def filter_menu(old_fiters):
if d2 != -1:
filters["Depth"]["$lte"] = d2
# GAP
case "4":
clear_screen()
print("Inserir GAP")
aux = input()
gap = toInt(aux)
gap = utils.toInt(aux)
filters["GAP"] = {}
if aux:
filters["GAP"]["$lte"] = gap
@@ -113,6 +115,7 @@ def filter_menu(old_fiters):
case "7":
print(filters)
time.sleep(2.0)
case "q":
return filters
@@ -133,14 +136,26 @@ def main():
match usrIn:
case "1":
parse("falsos.txt")
aux = input("Ficheiro a ler:")
if utils.fileExists(aux):
logger.info(f"Parsing the file {aux}")
ev, st = parser.parse(aux)
mongo.add_events(cli, "quakes", ev, "main")
mongo.add_stations(cli, "stations", st, "main")
else:
print(f"Could not open the file {aux}")
logger.error(f"Could not open the file {aux}")
time.sleep(2.0)
case "2":
filters = filter_menu(filters)
case "3":
print(filters)
v = mongo.filter_query(cli, "quakes", filters, "test")
stats.stats(v)
input()
time.sleep(2.0)
case "q":
break