Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit ab1fbd5

Browse files
committed
Find and read personal commands recursively, allowing dirs
This simplifies organization and for example adding multiple upstream sources of commands as different directories.
1 parent 81375b5 commit ab1fbd5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mapadroid/utils/updater.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import glob
21
import json
32
import os
43
import re
54
import time
65
from datetime import datetime, timedelta
76
from enum import Enum
87
from multiprocessing import Event, Queue
8+
from pathlib import Path
99
from queue import Empty
1010
from threading import RLock, Thread
1111

@@ -91,16 +91,16 @@ def init_jobs(self):
9191

9292
# load personal commands
9393

94-
for command_file in glob.glob(os.path.join("personal_commands", "*.json")):
94+
for command_file in Path("personal_commands").rglob("*.json"):
9595
try:
9696
with open(command_file) as personal_command:
97-
peronal_cmd = json.loads(personal_command.read())
98-
for command in peronal_cmd:
97+
personal_cmd = json.load(personal_command)
98+
for command in personal_cmd:
9999
if command in self._commands:
100100
logger.error("Command {} already exist - skipping", command)
101101
else:
102102
logger.info('Loading personal command: {}', command)
103-
self._commands[command] = peronal_cmd[command]
103+
self._commands[command] = personal_cmd[command]
104104
except Exception as e:
105105
logger.error('Cannot add job {} - Reason: {}', command_file, e)
106106

0 commit comments

Comments
 (0)