mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2026-10-10 09:12:05 +00:00
refactor: streamline file operations and enhance atomic read/write functions
This commit is contained in:
@@ -7,7 +7,7 @@ from datetime import datetime, timedelta, timezone
|
||||
import yaml
|
||||
|
||||
import module.config.server as server_
|
||||
from deploy.Windows.atomic import atomic_read, atomic_write
|
||||
from deploy.Windows.atomic import atomic_read_bytes, atomic_read_text, atomic_write
|
||||
|
||||
LANGUAGES = ['zh-CN', 'en-US']
|
||||
SERVER_TO_TIMEZONE = {
|
||||
@@ -68,12 +68,12 @@ def read_file(file):
|
||||
"""
|
||||
print(f'read: {file}')
|
||||
if file.endswith('.json'):
|
||||
content = atomic_read(file, mode='rb')
|
||||
content = atomic_read_bytes(file)
|
||||
if not content:
|
||||
return {}
|
||||
return json.loads(content)
|
||||
elif file.endswith('.yaml'):
|
||||
content = atomic_read(file, mode='r')
|
||||
content = atomic_read_text(file)
|
||||
data = list(yaml.safe_load_all(content))
|
||||
if len(data) == 1:
|
||||
data = data[0]
|
||||
|
||||
Reference in New Issue
Block a user