-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Removed github workflows (not very useful, and since i'm no longer using the online editor for this i can test this on my pc) - Update license - Code rewrite, of course - Updated readme - Removed setup.py
- Loading branch information
1 parent
ee11bf6
commit b7db1b5
Showing
5 changed files
with
16 additions
and
157 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,19 @@ | ||
# MineTest Log Data Extractor | ||
MT log data extractor is a python module that extracts data from Minetest logs. You can track almost anything like block changes and players getting hurted and transform them into anything you want. | ||
MT log data extractor is a python module that extracts data from Minetest logs. | ||
# License | ||
Minetest log data extractor is a Open Source project under the MIT License (see [LICENSE](./LICENSE) file for details). | ||
# Installing | ||
Currently, there is no pip package for this module, so you will need to istall it manually (Steps valid for Linux, MacOS and Windows): | ||
- Download this module from [here](https://github.com/Miner34dev/Minetest-log-data-extractor/releases) or, for the latest development version, [here](https://github.com/Miner34dev/Minetest-log-data-extractor/archive/refs/heads/main.zip) | ||
Currently, there is no pip package for this module, so you will need to install it manually: | ||
- Download this module from [here](https://github.com/Miner34dev/Minetest-log-data-extractor/archive/refs/heads/main.zip) | ||
- Extract the archive | ||
- go into the extracted folder using ```cd``` | ||
- Run ```python setup.py install --user``` (Without ```--user``` to install globally) | ||
- copy mt_log_data_extractor.py into your python installation's site-packages folder | ||
# Getting started | ||
Import this module: | ||
```python3 | ||
from mt_log_data_extractor import import_mt_log | ||
``` | ||
Now, to get your data, use: | ||
```python3 | ||
import_mt_log(file) #with a path such as /home/username/.minetest/debug.txt (linux example) instead of file | ||
``` | ||
example: | ||
```python3 | ||
mt_actions = import_mt_log("/home/hugo/.minetest/debug.txt") | ||
``` | ||
What does this module output? Well, the answer is not that simple. | ||
Here is the tree of an example output: | ||
``` | ||
{"2023": | ||
| {"07": | ||
| | {"20": | ||
| | | {"13": | ||
| | | | {"01": | ||
| | | | | {"24": | ||
| | | | | | [ | ||
| | | | | | | "player1" | ||
| | | | | | | "joins game" | ||
| | | | | | ] | ||
| | | | | } | ||
| | | | | {"36": | ||
| | | | | | [ | ||
| | | | | | | "player1" | ||
| | | | | | | "digs" | ||
| | | | | | | "(12, 4, 105)" | ||
| | | | | | ] | ||
| | | | | } | ||
| | | | } | ||
| | | | {"02": | ||
| | | | | {"12": | ||
| | | | | | [ | ||
| | | | | | | "Server:" | ||
| | | | | | | "Shutting down" | ||
| | | | | | ] | ||
| | | | | } | ||
| | | | } | ||
| | | } | ||
| | } | ||
| } | ||
} | ||
``` | ||
# Contributing | ||
If you would like to contribute to this project you can do so through GitHub by forking the repository and sending a pull request (PR). You can also simply report bugs. | ||
|
||
**We also need a icon for this project.** | ||
import_mt_log(mt_log_path) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,9 @@ | ||
def import_mt_log(file): | ||
'''Read Minetest's log at file and return a dictionary containing the elaburated and sorted data''' | ||
from pathlib import Path | ||
input_path = Path(file) | ||
input_file = open(input_path, mode = "rt") | ||
input_read = input_file.read() | ||
input_read = input_read.split(sep="\n") | ||
data = list() | ||
for x in input_read: | ||
if x.find("ACTION") != -1: | ||
y = x.split(":") | ||
if y[4].find(".") == -1 and y[4].find("[") == -1 and y[4].find("MOD") == -1: | ||
data.append(x) | ||
elif y[4].find("joins game") != -1: | ||
data.append(x) | ||
f_data = dict() | ||
for x in data: | ||
year = x[:4] | ||
month = x[5:7] | ||
day = x[8:10] | ||
hour = x[11:13] | ||
minute = x[14:16] | ||
second = x[17:19] | ||
try: | ||
f_data[year] | ||
except: | ||
f_data[year] = dict() | ||
try: | ||
f_data[year][month] | ||
except: | ||
f_data[year][month] = dict() | ||
try: | ||
f_data[year][month][day] | ||
except: | ||
f_data[year][month][day] = dict() | ||
try: | ||
f_data[year][month][day][hour] | ||
except: | ||
f_data[year][month][day][hour] = dict() | ||
try: | ||
f_data[year][month][day][hour][minute] | ||
except: | ||
f_data[year][month][day][hour][minute] = dict() | ||
try: | ||
f_data[year][month][day][hour][minute][second] | ||
except: | ||
f_data[year][month][day][hour][minute][second] = list() | ||
if x[35:].find("Server:") == -1: | ||
y = x[37:] | ||
else: | ||
y = x[35:] | ||
y = y.split(" ") | ||
if y[2] == "node": | ||
y.remove("node") | ||
y.remove("at") | ||
elif y[1] == "digs": | ||
y.remove("at") | ||
elif y[1] == "Shutting": | ||
y.remove("down") | ||
y[1] = "Shutting down" | ||
elif y[2] == "joins": | ||
z = y[0] | ||
y.clear() | ||
y.append(z) | ||
y.append("joins game") | ||
f_data[x[:4]][x[5:7]][x[8:10]][x[11:13]][x[14:16]][x[17:19]].append(y) | ||
return f_data | ||
def import_mt_log(file_path): | ||
from datetime import datetime | ||
input_data = open(file_path, mode = "rt").read().split(sep="\n") | ||
result = list() | ||
for x in input_data: | ||
if x[21:36]=="ACTION[Server]:": | ||
date = datetime(int(x[:4]), int(x[5:7]), int(x[8:10]), int(x[11:13]), int(x[14:16]), int(x[17:19])) | ||
result.append({"when":date, "what":x[37:]}) | ||
return result |