2018-06-13 12:44:36 +03:00
|
|
|
import os
|
|
|
|
import sys
|
2013-07-25 20:25:18 +04:00
|
|
|
|
2018-04-20 02:19:13 +03:00
|
|
|
py3 = sys.version_info.major >= 3
|
2019-01-29 03:45:53 +03:00
|
|
|
py36 = sys.version_info[0:2] >= (3, 6)
|
2018-04-20 02:19:13 +03:00
|
|
|
|
|
|
|
if py3:
|
2013-06-30 22:50:38 +04:00
|
|
|
def isStringType(t):
|
2018-04-20 02:19:13 +03:00
|
|
|
return isinstance(t, str)
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2019-01-28 20:14:42 +03:00
|
|
|
if py36:
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
def isPath(f):
|
|
|
|
return isinstance(f, (bytes, str, Path))
|
|
|
|
else:
|
|
|
|
def isPath(f):
|
|
|
|
return isinstance(f, (bytes, str))
|
2013-06-30 22:50:38 +04:00
|
|
|
else:
|
|
|
|
def isStringType(t):
|
2018-11-13 15:01:09 +03:00
|
|
|
return isinstance(t, basestring) # noqa: F821
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2013-06-30 22:50:38 +04:00
|
|
|
def isPath(f):
|
2018-11-13 15:01:09 +03:00
|
|
|
return isinstance(f, basestring) # noqa: F821
|
2013-06-30 22:50:38 +04:00
|
|
|
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2013-06-30 22:50:38 +04:00
|
|
|
# Checks if an object is a string, and that it points to a directory.
|
|
|
|
def isDirectory(f):
|
|
|
|
return isPath(f) and os.path.isdir(f)
|
2014-04-03 07:09:04 +04:00
|
|
|
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2014-04-09 10:42:34 +04:00
|
|
|
class deferred_error(object):
|
2014-04-04 03:05:02 +04:00
|
|
|
def __init__(self, ex):
|
|
|
|
self.ex = ex
|
2014-07-06 02:50:24 +04:00
|
|
|
|
2014-04-03 07:09:04 +04:00
|
|
|
def __getattr__(self, elt):
|
2014-04-04 03:05:02 +04:00
|
|
|
raise self.ex
|