Skip to content

Commit

Permalink
Adjust touch_p
Browse files Browse the repository at this point in the history
  • Loading branch information
yesimon committed Mar 3, 2019
1 parent 58dc717 commit 157cd7b
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def tmp_dir(*args, **kwargs):
_args = inspect.getcallargs(tempfile.mkdtemp, *args, **kwargs)
length_margin = 6
for pfx_sfx in ('prefix', 'suffix'):
if _args[pfx_sfx]:
if _args[pfx_sfx]:
_args[pfx_sfx] = string_to_file_name(_args[pfx_sfx], file_system_path=_args['dir'], length_margin=length_margin)
length_margin += len(_args[pfx_sfx].encode('utf-8'))

Expand Down Expand Up @@ -321,11 +321,10 @@ def mkdir_p(dirpath):
else:
raise

def touch_p(path):
def touch_p(path, times=None):
'''Touch file, making parent directories if they don't exist.'''
mkdir_p(os.path.dirname(path))
open(path, 'a').close()

touch(path, times=times)

def open_or_gzopen(fname, *opts, **kwargs):
mode = 'r'
Expand Down Expand Up @@ -389,7 +388,7 @@ def read_tabfile_dict(inFile, header_prefix="#", skip_prefix=None, rowcount_limi
row = row[:len(header)] + [item for item in row[len(header):] if len(item)]
assert len(header) == len(row), "%s != %s" % (len(header), len(row))
yield dict((k, v) for k, v in zip(header, row) if v)

if rowcount_limit and lines_read==rowcount_limit:
break

Expand Down Expand Up @@ -858,14 +857,14 @@ def uncompressed_file_type(fname):
base, ext = os.path.splitext(base)
return ext

def repack_tarballs(out_compressed_tarball,
input_compressed_tarballs,
extract_to_disk_path=None,
extract_numeric_owner=False,
avoid_disk_roundtrip=True,
ignore_zeros=True,
pipe_hint_in=None,
pipe_hint_out=None,
def repack_tarballs(out_compressed_tarball,
input_compressed_tarballs,
extract_to_disk_path=None,
extract_numeric_owner=False,
avoid_disk_roundtrip=True,
ignore_zeros=True,
pipe_hint_in=None,
pipe_hint_out=None,
threads=None):
threads = util.misc.sanitize_thread_count(threads)

Expand Down Expand Up @@ -913,7 +912,7 @@ def __del__(self):

def read(self, size):
assert size is not None

buf = self.fileobj.read(size)
self.written_mirror_file.write(buf)
return buf
Expand Down Expand Up @@ -975,6 +974,6 @@ def read(self, size):
out_compress_ps.wait()
if out_compress_ps.returncode != 0:
raise subprocess.CalledProcessError(out_compress_ps.returncode, "Call error %s" % out_compress_ps.returncode)

if outfile is not None:
outfile.close()

0 comments on commit 157cd7b

Please sign in to comment.