Add global settings.yaml in USER_CONFIG_DIR (#125)
This commit is contained in:
parent
a9b9fe7618
commit
598f17a472
16 changed files with 127 additions and 45 deletions
|
|
@ -6,8 +6,6 @@ from datetime import datetime
|
|||
from pathlib import Path
|
||||
from zipfile import ZipFile
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
class WorkingDirectory(contextlib.ContextDecorator):
|
||||
# Usage: @WorkingDirectory(dir) decorator or 'with WorkingDirectory(dir):' context manager
|
||||
|
|
@ -57,18 +55,6 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
|
|||
return path
|
||||
|
||||
|
||||
def yaml_save(file='data.yaml', data=None):
|
||||
# Single-line safe yaml saving
|
||||
with open(file, 'w') as f:
|
||||
yaml.safe_dump({k: str(v) if isinstance(v, Path) else v for k, v in data.items()}, f, sort_keys=False)
|
||||
|
||||
|
||||
def yaml_load(file='data.yaml'):
|
||||
# Single-line safe yaml loading
|
||||
with open(file, errors='ignore') as f:
|
||||
return {**yaml.safe_load(f), 'yaml_file': file} # add YAML filename to dict and return
|
||||
|
||||
|
||||
def unzip_file(file, path=None, exclude=('.DS_Store', '__MACOSX')):
|
||||
# Unzip a *.zip file to path/, excluding files containing strings in exclude list
|
||||
if path is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue