Skip to content

Commit

Permalink
Environment: Do not generate directories when simulating build
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Oct 24, 2019
1 parent 5eb414e commit 8e014ef
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lbuild/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def _copyfile(sourcepath, destpath, fn_copy=None):
if fn_copy is None:
fn_copy = default_fn_copy
if not SIMULATE:
if not os.path.exists(os.path.dirname(destpath)):
os.makedirs(os.path.dirname(destpath), exist_ok=True)
fn_copy(sourcepath, destpath)


Expand Down Expand Up @@ -76,8 +78,6 @@ def _copytree(logger, src, dst, ignore=None,
_copytree(logger, sourcepath, destpath, ignore, fn_listdir, fn_isdir, fn_copy)
else:
starttime = time.time()
if not os.path.exists(dst):
os.makedirs(dst, exist_ok=True)
_copyfile(sourcepath, destpath, fn_copy)
endtime = time.time()
total = endtime - starttime
Expand Down Expand Up @@ -176,8 +176,6 @@ def log_copy(src, dest, operation_time):
_copytree(log_copy, src, destpath, wrap_ignore,
fn_listdir, fn_isdir, fn_copy)
else:
if not os.path.exists(os.path.dirname(destpath)):
os.makedirs(os.path.dirname(destpath), exist_ok=True)
_copyfile(src, destpath, fn_copy)

endtime = time.time()
Expand Down Expand Up @@ -227,8 +225,6 @@ def log_copy(src, dest, operation_time):
destpath,
wrap_ignore)
else:
if not os.path.exists(os.path.dirname(destpath)):
os.makedirs(os.path.dirname(destpath), exist_ok=True)
_copyfile(srcpath, destpath)

endtime = time.time()
Expand Down Expand Up @@ -284,11 +280,11 @@ def template(self, src, dest=None, substitutions=None, filters=None, metadata=No

outfile_name = self.outpath(dest)

# Create folder structure if it doesn't exists
if not SIMULATE:
# Create folder structure if it doesn't exists
if not os.path.exists(os.path.dirname(outfile_name)):
os.makedirs(os.path.dirname(outfile_name), exist_ok=True)

# Write template output to file
with open(outfile_name, 'w', encoding="utf-8") as outfile:
outfile.write(output)

Expand Down

0 comments on commit 8e014ef

Please sign in to comment.