* wpylib.file.file_utils: added file_exists_nonempty() function.
This commit is contained in:
@@ -24,6 +24,7 @@ import bz2
|
|||||||
import glob
|
import glob
|
||||||
import gzip
|
import gzip
|
||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
try:
|
try:
|
||||||
import subprocess
|
import subprocess
|
||||||
has_subprocess = True
|
has_subprocess = True
|
||||||
@@ -80,6 +81,11 @@ def open_input_file(fname, superize=0):
|
|||||||
|
|
||||||
# Miscellaneous functions
|
# Miscellaneous functions
|
||||||
|
|
||||||
|
def file_exists_nonempty(fn):
|
||||||
|
return os.path.isfile(fn) and os.stat(fn).st_size > 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def glob_files(filespec):
|
def glob_files(filespec):
|
||||||
'''Processes a glob string, or does nothing (pass-on only) if an iterable object
|
'''Processes a glob string, or does nothing (pass-on only) if an iterable object
|
||||||
(e.g. list or tuple) is already given.
|
(e.g. list or tuple) is already given.
|
||||||
@@ -101,8 +107,9 @@ def path_search(*specs, **opts):
|
|||||||
* pathsep="/" -- path separator
|
* pathsep="/" -- path separator
|
||||||
* filetest=os.path.isfile -- filetest operator to be used
|
* filetest=os.path.isfile -- filetest operator to be used
|
||||||
* raise_error=False -- do we want to raise an exception if the file
|
* raise_error=False -- do we want to raise an exception if the file
|
||||||
is not found?
|
is not found after all possible searches?
|
||||||
'''
|
'''
|
||||||
|
path_join = os.path.join
|
||||||
# FIXME: this can be extremely expensive!
|
# FIXME: this can be extremely expensive!
|
||||||
xspecs = []
|
xspecs = []
|
||||||
xlen = []
|
xlen = []
|
||||||
|
|||||||
Reference in New Issue
Block a user