You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-10 01:22:48 +03:00
42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
from contextlib import contextmanager
|
|
import os
|
|
|
|
|
|
@contextmanager
|
|
def change_directory(new_dir):
|
|
"""
|
|
Context manager for temporarily changing the current working directory.
|
|
|
|
Args:
|
|
new_dir: Directory to change to
|
|
|
|
Example:
|
|
with change_directory("/path/to/dir"):
|
|
# Code here runs with the working directory as "/path/to/dir"
|
|
# After the block, we return to the original directory
|
|
"""
|
|
old_dir = os.getcwd()
|
|
try:
|
|
os.chdir(new_dir)
|
|
yield
|
|
finally:
|
|
os.chdir(old_dir)
|
|
|
|
|
|
def drop_timestamp(data: dict) -> dict:
|
|
"""
|
|
Drop the timestamp from the data dictionary.
|
|
"""
|
|
if "timestamp" in data:
|
|
del data["timestamp"]
|
|
return data
|
|
|
|
|
|
def assert_dict_includes(this: dict, other: dict) -> None:
|
|
"""
|
|
Check if the current dictionary includes all keys and values from another dictionary.
|
|
"""
|
|
for key, value in other.items():
|
|
assert key in this
|
|
assert this[key] == value, f"Key '{key}' does not match: {this[key]} != {value}"
|