mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
20 lines
405 B
Python
20 lines
405 B
Python
|
from contextlib import contextmanager
|
||
|
import os
|
||
|
from typing import Union, Iterator
|
||
|
from pathlib import Path
|
||
|
|
||
|
|
||
|
class WithIter(type):
|
||
|
def __iter__(cls):
|
||
|
return (v for k, v in cls.__dict__.items() if not k.startswith("_"))
|
||
|
|
||
|
|
||
|
@contextmanager
|
||
|
def cd(path: Union[Path, str]) -> Iterator[None]:
|
||
|
oldpwd = os.getcwd()
|
||
|
os.chdir(path)
|
||
|
try:
|
||
|
yield
|
||
|
finally:
|
||
|
os.chdir(oldpwd)
|