adds over.file.context_dir
This commit is contained in:
parent
2c99c441ca
commit
e6652b6783
2 changed files with 19 additions and 3 deletions
16
over/file.py
16
over/file.py
|
@ -1,6 +1,7 @@
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
|
from contextlib import contextmanager
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
@ -37,3 +38,18 @@ def count_lines(path):
|
||||||
lines += buffer.count(b"\n")
|
lines += buffer.count(b"\n")
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
# --------------------------------------------------
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def context_dir(path):
|
||||||
|
"""
|
||||||
|
A directory context manager.
|
||||||
|
"""
|
||||||
|
previous = os.getcwd()
|
||||||
|
os.chdir(path)
|
||||||
|
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
os.chdir(previous)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
major = 1 # VERSION_MAJOR_IDENTIFIER
|
major = 1 # VERSION_MAJOR_IDENTIFIER
|
||||||
minor = 100 # VERSION_MINOR_IDENTIFIER
|
minor = 101 # VERSION_MINOR_IDENTIFIER
|
||||||
# VERSION_LAST_MM 1.100
|
# VERSION_LAST_MM 1.101
|
||||||
patch = 0 # VERSION_PATCH_IDENTIFIER
|
patch = 0 # VERSION_PATCH_IDENTIFIER
|
||||||
str = "1.100.0" # VERSION_STRING_IDENTIFIER
|
str = "1.101.0" # VERSION_STRING_IDENTIFIER
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue