Skip to content

Commit

Permalink
add new method in DevTools
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Jun 13, 2016
1 parent 2717f39 commit 3307f46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions doc/ChangeLog.txt
@@ -1,3 +1,10 @@


.. rubric:: 0.9.22

* NEWS:
* add a method in DevTools to check for the existence of a file

.. rubric:: 0.9.21

* BUGS:
Expand Down
15 changes: 14 additions & 1 deletion easydev/tools.py
Expand Up @@ -23,7 +23,8 @@
import sys

__all__ = ["shellcmd", "checkParam", "swapdict", "check_param_in_list",
"check_range", "precision", "AttrDict", "DevTools", "execute"]
"check_range", "precision", "AttrDict", "DevTools", "execute",
"touch"]


def precision(data, digit=2):
Expand Down Expand Up @@ -153,6 +154,9 @@ def execute(cmd, showcmd=True, verbose=True):
line = p.readline()


def touch(fname, times=None):
with open(fname, 'a'):
os.utime(fname, times)


def swapdict(dic, check_ambiguity=True):
Expand Down Expand Up @@ -297,6 +301,7 @@ def to_json(self, dictionary):
return json.dumps(dictionary)

def mkdir(self, dirname):
"""Create a directory if it does not exists; pass without error otherwise"""
try:
os.mkdir(dirname)
except OSError:
Expand All @@ -308,6 +313,14 @@ def shellcmd(self, cmd, show=False, verbose=False, ignore_errors=False):
"""See :func:`shellcmd`"""
return shellcmd(cmd, show=show, verbose=verbose, ignore_errors=ignore_errors)

def check_exists(self, filename):
"""Raise error message if the file does not exists"""
if os.path.exists(filename) is False:
raise ValueError("This file %s does not exists" % filename)







2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -7,7 +7,7 @@

_MAJOR = 0
_MINOR = 9
_MICRO = 21
_MICRO = 22
version = '%d.%d.%d' % (_MAJOR, _MINOR, _MICRO)
release = '%d.%d' % (_MAJOR, _MINOR)

Expand Down

0 comments on commit 3307f46

Please sign in to comment.