adds over.file.context_dir

This commit is contained in:
Martinez 2017-05-02 02:39:33 +02:00
parent 2c99c441ca
commit e6652b6783
2 changed files with 19 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#! /usr/bin/env python3
# encoding: utf-8
from contextlib import contextmanager
import os
# --------------------------------------------------
@ -37,3 +38,18 @@ def count_lines(path):
lines += buffer.count(b"\n")
return lines
# --------------------------------------------------
@contextmanager
def context_dir(path):
"""
A directory context manager.
"""
previous = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(previous)

View file

@ -2,7 +2,7 @@
# encoding: utf-8
major = 1 # VERSION_MAJOR_IDENTIFIER
minor = 100 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 1.100
minor = 101 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 1.101
patch = 0 # VERSION_PATCH_IDENTIFIER
str = "1.100.0" # VERSION_STRING_IDENTIFIER
str = "1.101.0" # VERSION_STRING_IDENTIFIER