From aec665434043f4cad34a1efddb21b6fa9dc89430 Mon Sep 17 00:00:00 2001 From: Aleksandr Slobodeniuk Date: Tue, 11 Jan 2022 23:47:09 +0100 Subject: [PATCH] Simplify all the os.makedirs around the project Since Python 3.2 it can be written in one line --- cerbero/bootstrap/android.py | 3 +-- cerbero/bootstrap/build_tools.py | 10 ++++------ cerbero/bootstrap/windows.py | 9 +++------ cerbero/build/build.py | 3 +-- cerbero/build/cookbook.py | 3 +-- cerbero/build/fridge.py | 3 +-- cerbero/build/recipe.py | 3 +-- cerbero/build/source.py | 6 ++---- cerbero/commands/genlibfiles.py | 4 ++-- cerbero/commands/genvsprops.py | 3 +-- cerbero/commands/genxcconfig.py | 3 +-- cerbero/config.py | 9 ++++----- cerbero/packages/__init__.py | 3 +-- cerbero/packages/disttarball.py | 3 +-- cerbero/packages/osx/bundles.py | 3 +-- cerbero/packages/osx/packager.py | 18 ++++++------------ cerbero/packages/wix_packager.py | 3 +-- cerbero/tools/osxuniversalgenerator.py | 9 +++------ cerbero/utils/__init__.py | 3 +-- cerbero/utils/shell.py | 9 +++------ config/android.config | 8 ++++---- config/darwin.config | 3 +-- recipes/build-tools/gas-preprocessor.recipe | 3 +-- recipes/build-tools/gtk-doc-lite.recipe | 9 +++------ recipes/build-tools/vala-m4.recipe | 3 +-- recipes/ca-certificates.recipe | 3 +-- recipes/docbook-xml.recipe | 3 +-- recipes/docbook-xsl.recipe | 3 +-- recipes/glib.recipe | 3 +-- recipes/gmp.recipe | 3 +-- recipes/gnustl.recipe | 9 +++------ recipes/graphene.recipe | 3 +-- recipes/gst-android-1.0.recipe | 3 +-- recipes/ladspa.recipe | 3 +-- recipes/mingw-runtime.recipe | 6 ++---- recipes/tinyalsa.recipe | 3 +-- recipes/vsintegration-1.0.recipe | 9 +++------ 37 files changed, 66 insertions(+), 121 deletions(-) diff --git a/cerbero/bootstrap/android.py b/cerbero/bootstrap/android.py index 6875b2adc..645a7a719 100644 --- a/cerbero/bootstrap/android.py +++ b/cerbero/bootstrap/android.py @@ -43,8 +43,7 @@ def __init__(self, config, offline, assume_yes): self.extract_steps.append((url, True, self.prefix)) def start(self): - if not os.path.exists(self.prefix): - os.makedirs(self.prefix) + os.makedirs(self.prefix, exist_ok = True) ndkdir = os.path.join(self.prefix, 'android-ndk-' + NDK_VERSION) if not os.path.isdir(ndkdir): return diff --git a/cerbero/bootstrap/build_tools.py b/cerbero/bootstrap/build_tools.py index f318409dc..16e144065 100644 --- a/cerbero/bootstrap/build_tools.py +++ b/cerbero/bootstrap/build_tools.py @@ -108,12 +108,10 @@ def _setup_env(self): config.binaries_local = self.config.binaries_local config.binaries_remote = self.config.binaries_remote - if config.toolchain_prefix and not os.path.exists(config.toolchain_prefix): - os.makedirs(config.toolchain_prefix) - if not os.path.exists(config.prefix): - os.makedirs(config.prefix) - if not os.path.exists(config.sources): - os.makedirs(config.sources) + if config.toolchain_prefix: + os.makedirs(config.toolchain_prefix, exist_ok = True) + os.makedirs(config.prefix, exist_ok = True) + os.makedirs(config.sources, exist_ok = True) config.do_setup_env() self.cookbook = CookBook(config, offline=self.offline) diff --git a/cerbero/bootstrap/windows.py b/cerbero/bootstrap/windows.py index 4cdda82d3..8ea26fd20 100644 --- a/cerbero/bootstrap/windows.py +++ b/cerbero/bootstrap/windows.py @@ -112,13 +112,10 @@ def start(self): self.fix_mingw_unused() def check_dirs(self): - if not os.path.exists(self.perl_prefix): - os.makedirs(self.perl_prefix) - if not os.path.exists(self.prefix): - os.makedirs(self.prefix) + os.makedirs(self.perl_prefix, exist_ok = True) + os.makedirs(self.prefix, exist_ok = True) etc_path = os.path.join(self.config.prefix, 'etc') - if not os.path.exists(etc_path): - os.makedirs(etc_path) + os.makedirs(etc_path, exist_ok = True) def fix_mingw(self): if self.arch == Architecture.X86: diff --git a/cerbero/build/build.py b/cerbero/build/build.py index 615d7cdea..817c7740c 100644 --- a/cerbero/build/build.py +++ b/cerbero/build/build.py @@ -394,8 +394,7 @@ async def configure(self): When called from a method in derived class, that method has to be decorated with modify_environment decorator. ''' - if not os.path.exists(self.make_dir): - os.makedirs(self.make_dir) + os.makedirs(self.make_dir, exist_ok = True) if self.requires_non_src_build: self.config_sh = os.path.join('../', self.config_sh) diff --git a/cerbero/build/cookbook.py b/cerbero/build/cookbook.py index 2b38e3fa5..289e528d8 100644 --- a/cerbero/build/cookbook.py +++ b/cerbero/build/cookbook.py @@ -346,8 +346,7 @@ def list_recipe_reverse_deps(self, recipe_name): def save(self): try: cache_file = self._cache_file(self.get_config()) - if not os.path.exists(os.path.dirname(cache_file)): - os.makedirs(os.path.dirname(cache_file)) + os.makedirs(os.path.dirname(cache_file), exist_ok = True) with open(cache_file, 'wb') as f: pickle.dump(self.status, f) except IOError as ex: diff --git a/cerbero/build/fridge.py b/cerbero/build/fridge.py index 544187b30..06a053d2b 100644 --- a/cerbero/build/fridge.py +++ b/cerbero/build/fridge.py @@ -283,8 +283,7 @@ def _ensure_ready(self, recipe): self.binaries_local = os.path.join(self.config.binaries_local, self.env_checksum) if not self.binaries_remote: raise FatalError(_('Configuration without binaries remote')) - if not os.path.exists(self.binaries_local): - os.makedirs(self.binaries_local) + os.makedirs(self.binaries_local, exist_ok = True) self.env_file = os.path.join(self.binaries_local, 'ENVIRONMENT') if not os.path.exists(self.env_file): with open(self.env_file, 'w') as f: diff --git a/cerbero/build/recipe.py b/cerbero/build/recipe.py index 01eb2f360..0ba03882b 100644 --- a/cerbero/build/recipe.py +++ b/cerbero/build/recipe.py @@ -1005,6 +1005,5 @@ def not_in_prefix(src): dest = os.path.join(self._config.prefix, recipe.config.target_arch, f) - if not os.path.exists(os.path.dirname(dest)): - os.makedirs(os.path.dirname(dest)) + os.makedirs(os.path.dirname(dest), exist_ok = True) shutil.move(src, dest) diff --git a/cerbero/build/source.py b/cerbero/build/source.py index e639cd3d1..c21d34a1c 100644 --- a/cerbero/build/source.py +++ b/cerbero/build/source.py @@ -178,8 +178,7 @@ async def fetch_impl(self, redownload=False): self.verify() m.action(_('Found %s at %s') % (self.url, self.download_path)) return - if not os.path.exists(self.download_dir): - os.makedirs(self.download_dir) + os.makedirs(self.download_dir, exist_ok = True) # Enable certificate checking only on Linux for now # FIXME: Add more platforms here after testing cc = self.config.platform == Platform.LINUX and self.config.distro_version != DistroVersion.REDHAT_6 @@ -244,8 +243,7 @@ def __init__(self): BaseTarball.__init__(self) async def fetch_impl(self, redownload=False): - if not os.path.exists(self.download_dir): - os.makedirs(self.download_dir) + os.makedirs(self.download_dir, exist_ok = True) cached_file = os.path.join(self.config.cached_sources, self.package_name, self.tarball_name) diff --git a/cerbero/commands/genlibfiles.py b/cerbero/commands/genlibfiles.py index 810e5ba80..d7e05919e 100644 --- a/cerbero/commands/genlibfiles.py +++ b/cerbero/commands/genlibfiles.py @@ -43,8 +43,8 @@ def run(self, config, args): raise UsageError(_('%s command can only be used targetting ' 'Windows platforms') % self.name) - if args.output_dir is not None and not os.path.exists(args.output_dir): - os.makedirs(args.output_dir) + if args.output_dir is not None: + os.makedirs(args.output_dir, exist_ok = True) cookbook = CookBook(config) recipes = cookbook.get_recipes_list() diff --git a/cerbero/commands/genvsprops.py b/cerbero/commands/genvsprops.py index d67c23d45..c1989608a 100644 --- a/cerbero/commands/genvsprops.py +++ b/cerbero/commands/genvsprops.py @@ -45,8 +45,7 @@ def run(self, config, args): self.runargs(config, args.output_dir, args.prefix) def runargs(self, config, output_dir, prefix=DEFAULT_PREFIX_MACRO): - if not os.path.exists(output_dir): - os.makedirs(output_dir) + os.makedirs(output_dir, exist_ok = True) for pc in PkgConfig.list_all(): p2v = PkgConfig2VSProps(pc, prefix=config.prefix, diff --git a/cerbero/commands/genxcconfig.py b/cerbero/commands/genxcconfig.py index 0c8828759..c329c6759 100644 --- a/cerbero/commands/genxcconfig.py +++ b/cerbero/commands/genxcconfig.py @@ -43,8 +43,7 @@ def run(self, config, args): self.runargs(config, args.output_dir, args.filename, args.libraries) def runargs(self, config, output_dir, filename, libraries): - if not os.path.exists(output_dir): - os.makedirs(output_dir) + os.makedirs(output_dir, exist_ok = True) if len(libraries) == 0: raise UsageError("You need to specify at least one library name") diff --git a/cerbero/config.py b/cerbero/config.py index 4b22d4ea5..108b7622e 100644 --- a/cerbero/config.py +++ b/cerbero/config.py @@ -607,11 +607,10 @@ def _check_uninstalled(self): self.uninstalled = int(os.environ.get(CERBERO_UNINSTALLED, 0)) == 1 def _create_path(self, path): - if not os.path.exists(path): - try: - os.makedirs(path) - except: - raise FatalError(_('directory (%s) can not be created') % path) + try: + os.makedirs(path, exist_ok = True) + except: + raise FatalError(_('directory (%s) can not be created') % path) def _join_path(self, path1, path2): if len(path1) == 0: diff --git a/cerbero/packages/__init__.py b/cerbero/packages/__init__.py index 47a4e78b9..bba47b1ba 100644 --- a/cerbero/packages/__init__.py +++ b/cerbero/packages/__init__.py @@ -62,8 +62,7 @@ def pack(self, output_dir, devel=True, force=False, keep_temp=False, split=True) @rtype: list ''' self.output_dir = os.path.realpath(output_dir) - if not os.path.exists(self.output_dir): - os.makedirs(self.output_dir) + os.makedirs(self.output_dir, exist_ok = True) self.devel = devel self.force = force self.keep_temp = keep_temp diff --git a/cerbero/packages/disttarball.py b/cerbero/packages/disttarball.py index dd071b1dd..7e50984af 100644 --- a/cerbero/packages/disttarball.py +++ b/cerbero/packages/disttarball.py @@ -136,8 +136,7 @@ def _create_tarball_stripped(self, output_dir, package_type, files, force, orig_file = os.path.join(self.prefix, f) tmp_file = os.path.join(tmpdir, f) tmp_file_dir = os.path.dirname(tmp_file) - if not os.path.exists(tmp_file_dir): - os.makedirs(tmp_file_dir) + os.makedirs(tmp_file_dir, exist_ok = True) shutil.copy(orig_file, tmp_file, follow_symlinks=False) s.strip_file(tmp_file) diff --git a/cerbero/packages/osx/bundles.py b/cerbero/packages/osx/bundles.py index e62455e26..51b57d50d 100644 --- a/cerbero/packages/osx/bundles.py +++ b/cerbero/packages/osx/bundles.py @@ -188,8 +188,7 @@ def create_bundle(self, tmp=None): macos = os.path.join(contents, 'MacOS') resources = os.path.join(contents, 'Resources') for p in [contents, macos, resources]: - if not os.path.exists(p): - os.makedirs(p) + os.makedirs(p, exist_ok = True) # Create Contents/Info.plist # Use the template if provided in the package diff --git a/cerbero/packages/osx/packager.py b/cerbero/packages/osx/packager.py index 714ba884d..12a8a6601 100644 --- a/cerbero/packages/osx/packager.py +++ b/cerbero/packages/osx/packager.py @@ -73,8 +73,7 @@ def _copy_versioned_headers(self, headers, include_dirs): for p in os.listdir(inc_dir): src = os.path.join(inc_dir, p) dest = os.path.join(headers, p) - if not os.path.exists(os.path.dirname(dest)): - os.makedirs(os.path.dirname(dest)) + os.makedirs(os.path.dirname(dest), exist_ok = True) # include/cairo/cairo.h -> Headers/cairo.h if os.path.isfile(src): shutil.copy(src, dest) @@ -94,8 +93,7 @@ def _copy_unversioned_headers(self, dirname, include, headers, if os.path.isfile(path): p = os.path.join(headers, rel_path) d = os.path.dirname(p) - if not os.path.exists(d): - os.makedirs(d) + os.makedirs(d, exist_ok = True) shutil.copy(path, p) # scan sub-directories elif os.path.isdir(path): @@ -192,8 +190,7 @@ def _create_bundle(self, files, package_type): continue out_path = os.path.join(root, f) out_dir = os.path.split(out_path)[0] - if not os.path.exists(out_dir): - os.makedirs(out_dir) + os.makedirs(out_dir, exist_ok = True) shutil.copy(in_path, out_path, follow_symlinks=False) if package_type == PackageType.DEVEL or not self.split: self._create_framework_headers(self.config.prefix, self.include_dirs, root) @@ -425,8 +422,7 @@ def _create_bundle(self): continue out_path = os.path.join(out_dir, f) odir = os.path.split(out_path)[0] - if not os.path.exists(odir): - os.makedirs(odir) + os.makedirs(odir, exist_ok = True) shutil.copy(in_path, out_path) def _create_app_bundle(self): @@ -558,8 +554,7 @@ def _copy_files(self, files, root): for f in files: out_path = f.replace(self.config.prefix, root) out_dir = os.path.split(out_path)[0] - if not os.path.exists(out_dir): - os.makedirs(out_dir) + os.makedirs(out_dir, exist_ok = True) shutil.copy(f, out_path) def _copy_templates(self, files): @@ -570,8 +565,7 @@ def _copy_templates(self, files): os.path.join(self.tmp, 'Templates')) out_path = out_path.replace(templates_prefix, '') out_dir = os.path.split(out_path)[0] - if not os.path.exists(out_dir): - os.makedirs(out_dir) + os.makedirs(out_dir, exist_ok = True) shutil.copy(f, out_path) def _copy_headers(self, files, version_dir): diff --git a/cerbero/packages/wix_packager.py b/cerbero/packages/wix_packager.py index f325f3b64..1b8deb514 100644 --- a/cerbero/packages/wix_packager.py +++ b/cerbero/packages/wix_packager.py @@ -74,8 +74,7 @@ def _create_merge_module(self, package_type, keep_strip_temp_dir=False): for f in files_list: src = os.path.join(self.config.prefix, f) dst = os.path.join(tmpdir, f) - if not os.path.exists(os.path.dirname(dst)): - os.makedirs(os.path.dirname(dst)) + os.makedirs(os.path.dirname(dst), exist_ok = True) shutil.copy(src, dst) if self.package.strip: diff --git a/cerbero/tools/osxuniversalgenerator.py b/cerbero/tools/osxuniversalgenerator.py index b56fc06c3..489265b61 100644 --- a/cerbero/tools/osxuniversalgenerator.py +++ b/cerbero/tools/osxuniversalgenerator.py @@ -171,8 +171,7 @@ def do_merge(self, filepath, dirs): elif action == 'link': self._link(current_file, output_file, filepath) elif action == 'merge': - if not os.path.exists(output_dir): - os.makedirs(output_dir) + os.makedirs(output_dir, exist_ok = True) self.create_universal_file(output_file, full_filepaths, dirs) elif action == 'skip': pass #just pass @@ -200,8 +199,7 @@ def parse_dirs(self, dirs, filters=None): self.do_merge(current_file, dirs) def _copy(self, src, dest): - if not os.path.exists(os.path.dirname(dest)): - os.makedirs(os.path.dirname(dest)) + os.makedirs(os.path.dirname(dest), exist_ok = True) shutil.copy(src, dest) def _copy_and_replace_paths(self, src, dest, dirs): @@ -212,8 +210,7 @@ def _copy_and_replace_paths(self, src, dest, dirs): shell.replace(dest, replacements) def _link(self, src, dest, filepath): - if not os.path.exists(os.path.dirname(dest)): - os.makedirs(os.path.dirname(dest)) + os.makedirs(os.path.dirname(dest), exist_ok = True) if os.path.lexists(dest): return #link exists, skip it diff --git a/cerbero/utils/__init__.py b/cerbero/utils/__init__.py index a03a5558c..22bc43ccd 100644 --- a/cerbero/utils/__init__.py +++ b/cerbero/utils/__init__.py @@ -382,8 +382,7 @@ def copy_files(origdir, destdir, files, extensions, target_platform): for f in files: f = f % extensions install_dir = os.path.dirname(os.path.join(destdir, f)) - if not os.path.exists(install_dir): - os.makedirs(install_dir) + os.makedirs(install_dir, exist_ok = True) if destdir[1] == ':': # windows path relprefix = to_unixpath(destdir)[2:] diff --git a/cerbero/utils/shell.py b/cerbero/utils/shell.py index 476747925..01cdf336c 100644 --- a/cerbero/utils/shell.py +++ b/cerbero/utils/shell.py @@ -328,8 +328,7 @@ async def unpack(filepath, output_dir, logfile=None): # can't use tar on Windows because MSYS tar is ancient and buggy. if filepath.endswith(TARBALL_SUFFIXES): if PLATFORM != Platform.WINDOWS: - if not os.path.exists(output_dir): - os.makedirs(output_dir) + os.makedirs(output_dir, exist_ok = True) await async_call(['tar', '-C', output_dir, '-xf', filepath]) else: cmode = 'bz2' if filepath.endswith('bz2') else filepath[-2:] @@ -461,8 +460,7 @@ async def download(url, destination=None, check_cert=True, overwrite=False, logf logging.info("File %s already downloaded." % destination) return else: - if not os.path.exists(os.path.dirname(destination)): - os.makedirs(os.path.dirname(destination)) + os.makedirs(os.path.dirname(destination), exist_ok = True) log("Downloading {}".format(url), logfile) urls = [url] @@ -629,8 +627,7 @@ def copy_dir(src, dest, exclude_dirs=[]): continue s = os.path.join(src, path) d = os.path.join(dest, path) - if not os.path.exists(os.path.dirname(d)): - os.makedirs(os.path.dirname(d)) + os.makedirs(os.path.dirname(d), exist_ok = True) if os.path.isfile(s): shutil.copy(s, d) elif os.path.isdir(s): diff --git a/config/android.config b/config/android.config index 6675f3024..65f562f2f 100644 --- a/config/android.config +++ b/config/android.config @@ -116,10 +116,10 @@ if 'universal' in variants: else: incl_dir = os.path.join(prefix, 'include') lib_dir = os.path.join(prefix, 'lib') -if target_arch != Architecture.UNIVERSAL and not os.path.exists(incl_dir): - os.makedirs(incl_dir) -if target_arch != Architecture.UNIVERSAL and not os.path.exists(lib_dir): - os.makedirs(lib_dir) +if target_arch != Architecture.UNIVERSAL: + os.makedirs(incl_dir, exist_ok = True) +if target_arch != Architecture.UNIVERSAL: + os.makedirs(lib_dir, exist_ok = True) # Most of the compiler/linker specific flags are taken from # from android-ndk-r16/build/core/toolchains/$NAME-$VERSION/setup.mk diff --git a/config/darwin.config b/config/darwin.config index 26aed5e49..14332eb0a 100644 --- a/config/darwin.config +++ b/config/darwin.config @@ -60,8 +60,7 @@ arch_cflags += ' -Wno-error=format-nonliteral ' incl_dir = os.path.join(prefix, 'include') -if not os.path.exists(incl_dir): - os.makedirs(incl_dir) +os.makedirs(incl_dir, exist_ok = True) # Append to these flags if not already present for f in ['CFLAGS', 'CCASFLAGS', 'CXXFLAGS', 'OBJCFLAGS']: diff --git a/recipes/build-tools/gas-preprocessor.recipe b/recipes/build-tools/gas-preprocessor.recipe index e308abba8..0821bdb7f 100644 --- a/recipes/build-tools/gas-preprocessor.recipe +++ b/recipes/build-tools/gas-preprocessor.recipe @@ -12,8 +12,7 @@ class Recipe(recipe.Recipe): commit = 'f8a2d8c155bda8d925a7ee2ed8315c553a2b865f' def install(self): - if not os.path.exists(os.path.join(self.config.prefix, 'bin')): - os.makedirs(os.path.join(self.config.prefix, 'bin')) + os.makedirs(os.path.join(self.config.prefix, 'bin'), exist_ok = True) shutil.copy (os.path.join(self.build_dir, 'gas-preprocessor.pl'), os.path.join(self.config.prefix, 'bin')) shell.call ('chmod +x %s' % diff --git a/recipes/build-tools/gtk-doc-lite.recipe b/recipes/build-tools/gtk-doc-lite.recipe index b0b96e118..5ac761c4f 100644 --- a/recipes/build-tools/gtk-doc-lite.recipe +++ b/recipes/build-tools/gtk-doc-lite.recipe @@ -18,14 +18,11 @@ class Recipe(recipe.Recipe): from cerbero.utils import shell import shutil aclocal_dir = os.path.join(self.config.prefix, 'share', 'aclocal') - if not os.path.exists(aclocal_dir): - os.makedirs(aclocal_dir) + os.makedirs(aclocal_dir, exist_ok = True) data_dir = os.path.join(self.config.prefix, 'share', 'gtk-doc', 'data') - if not os.path.exists(data_dir): - os.makedirs(data_dir) + os.makedirs(data_dir, exist_ok = True) bin_dir = os.path.join(self.config.prefix, 'bin') - if not os.path.exists(bin_dir): - os.makedirs(bin_dir) + os.makedirs(bin_dir, exist_ok = True) autotools_dir = os.path.join(self.build_dir, 'buildsystems/autotools') shutil.copy(os.path.join(autotools_dir, 'gtk-doc.m4'), os.path.join(aclocal_dir, 'gtk-doc.m4')) diff --git a/recipes/build-tools/vala-m4.recipe b/recipes/build-tools/vala-m4.recipe index 53181f775..583c7d7f7 100644 --- a/recipes/build-tools/vala-m4.recipe +++ b/recipes/build-tools/vala-m4.recipe @@ -26,7 +26,6 @@ class Recipe(recipe.Recipe): os.path.join(self.config.prefix, 'share', 'aclocal', 'vala.m4')) destdir = os.path.join(self.config.prefix, 'share', 'vala') - if not os.path.exists(destdir): - os.makedirs(destdir) + os.makedirs(destdir, exist_ok = True) shutil.copy(os.path.join(self.build_dir, 'vapigen', 'Makefile.vapigen'), os.path.join(destdir, 'Makefile.vapigen')) diff --git a/recipes/ca-certificates.recipe b/recipes/ca-certificates.recipe index bd62a850e..1118ce68c 100644 --- a/recipes/ca-certificates.recipe +++ b/recipes/ca-certificates.recipe @@ -19,8 +19,7 @@ class Recipe(recipe.Recipe): def install(self): dst_dir = os.path.join(self.config.prefix, 'etc', 'ssl', 'certs') - if not os.path.exists(dst_dir): - os.makedirs(dst_dir) + os.makedirs(dst_dir, exist_ok = True) src_dir = os.path.join(self.config.recipes_dir, 'ca-certificates') for f in self.files_etc: fname = os.path.basename(f) diff --git a/recipes/docbook-xml.recipe b/recipes/docbook-xml.recipe index 65bba12a3..89156c00b 100644 --- a/recipes/docbook-xml.recipe +++ b/recipes/docbook-xml.recipe @@ -14,8 +14,7 @@ class Recipe(recipe.Recipe): def install(self): etc_path = os.path.join(self.config.prefix, 'etc') - if not os.path.exists(etc_path): - os.makedirs(etc_path) + os.makedirs(etc_path, exist_ok = True) etc_catalog_path = os.path.join(etc_path, 'catalog.xml') new_catalog_path = os.path.join(self.build_dir, 'catalog.xml') diff --git a/recipes/docbook-xsl.recipe b/recipes/docbook-xsl.recipe index d1a40fee3..80fa475f3 100644 --- a/recipes/docbook-xsl.recipe +++ b/recipes/docbook-xsl.recipe @@ -13,8 +13,7 @@ class Recipe(recipe.Recipe): def install(self): etc_path = os.path.join(self.config.prefix, 'etc') - if not os.path.exists(etc_path): - os.makedirs(etc_path) + os.makedirs(etc_path, exist_ok = True) etc_catalog_path = os.path.join(etc_path, 'catalog.xml') new_catalog_path = os.path.join(self.build_dir, 'catalog.xml') diff --git a/recipes/glib.recipe b/recipes/glib.recipe index 6de5af19a..6d6e7cfe5 100644 --- a/recipes/glib.recipe +++ b/recipes/glib.recipe @@ -220,8 +220,7 @@ class Recipe(recipe.Recipe): arch_dir = os.path.join(self.config.prefix, 'lib', 'glib-2.0', 'include', arch) - if not os.path.exists(arch_dir): - os.makedirs(arch_dir) + os.makedirs(arch_dir, exist_ok = True) shutil.copyfile(os.path.join(self.meson_dir, 'glib', 'glibconfig.h'), os.path.join(arch_dir, 'glibconfig.h')) with open(os.path.join(self.config.prefix, 'lib', 'glib-2.0', diff --git a/recipes/gmp.recipe b/recipes/gmp.recipe index c2948d763..636d6c82c 100644 --- a/recipes/gmp.recipe +++ b/recipes/gmp.recipe @@ -81,8 +81,7 @@ class Recipe(recipe.Recipe): arch = 'arm' arch_dir = os.path.join(self.config.prefix, 'include', arch) - if not os.path.exists(arch_dir): - os.makedirs(arch_dir) + os.makedirs(arch_dir, exist_ok = True) shutil.copyfile(os.path.join(self.build_dir, 'gmp.h'), os.path.join(arch_dir, 'gmp.h')) with open(os.path.join(self.config.prefix, 'include', 'gmp.h'), 'w+') as f: diff --git a/recipes/gnustl.recipe b/recipes/gnustl.recipe index 0ad59547b..629d8d253 100644 --- a/recipes/gnustl.recipe +++ b/recipes/gnustl.recipe @@ -28,8 +28,7 @@ class Recipe(recipe.Recipe): def compile(self): libdir = os.path.join(self.config.prefix, 'lib') - if not os.path.exists(libdir): - os.makedirs(libdir) + os.makedirs(libdir, exist_ok = True) # Generate libraries that aren't copied from the NDK v = DistroVersion.get_android_api_version(self.config.target_distro_version) @@ -55,8 +54,7 @@ class Recipe(recipe.Recipe): raise FatalError("Unsupported Android architecture %s" % self.config.target_arch) stl_libdir = os.path.join(stl_prefix, 'libs', libarch) libdir = os.path.join(self.config.prefix, 'lib') - if not os.path.exists(libdir): - os.makedirs(libdir) + os.makedirs(libdir, exist_ok = True) override_libname = 'libc++_shared%s.so' % self.config.libname_suffix output_libpath = os.path.join(libdir, override_libname) @@ -88,8 +86,7 @@ class Recipe(recipe.Recipe): # Create pkg-config file (gnustl.pc) pkgdir = os.path.join(self.config.prefix, 'lib', 'pkgconfig') - if not os.path.exists(pkgdir): - os.makedirs(pkgdir) + os.makedirs(pkgdir, exist_ok = True) stl_pc = PkgConfigWritter('gnustl', 'gnustl', '2.0', '', '-L${libdir} ${libdir}/%s' % override_libname + (' ${libdir}/libandroid_support.a ' if v < 21 else '') + diff --git a/recipes/graphene.recipe b/recipes/graphene.recipe index 7740adae8..76d9976bc 100644 --- a/recipes/graphene.recipe +++ b/recipes/graphene.recipe @@ -82,8 +82,7 @@ class Recipe(recipe.Recipe): arch_dir = os.path.join(self.config.prefix, 'lib', 'graphene-1.0', 'include', arch) - if not os.path.exists(arch_dir): - os.makedirs(arch_dir) + os.makedirs(arch_dir, exist_ok = True) shutil.copyfile(os.path.join(self.meson_dir, 'src', 'graphene-config.h'), os.path.join(arch_dir, 'graphene-config.h')) with open(os.path.join(self.config.prefix, 'lib', 'graphene-1.0', diff --git a/recipes/gst-android-1.0.recipe b/recipes/gst-android-1.0.recipe index b8abefeba..edfb076c2 100644 --- a/recipes/gst-android-1.0.recipe +++ b/recipes/gst-android-1.0.recipe @@ -24,8 +24,7 @@ class Recipe(recipe.Recipe): def install(self): ndk_build_dir_dst = os.path.join(self.config.prefix, 'share', 'gst-android', 'ndk-build') - if not os.path.exists(ndk_build_dir_dst): - os.makedirs(ndk_build_dir_dst) + os.makedirs(ndk_build_dir_dst, exist_ok = True) ndk_build_dir_src = os.path.join(self.config.data_dir, 'ndk-build') for f in self.files_devel: fname = os.path.basename(f) diff --git a/recipes/ladspa.recipe b/recipes/ladspa.recipe index e5f656844..209b78992 100644 --- a/recipes/ladspa.recipe +++ b/recipes/ladspa.recipe @@ -16,8 +16,7 @@ class Recipe(recipe.Recipe): def install(self): include_path = os.path.join(self.config.prefix, 'include') - if not os.path.exists(include_path): - os.makedirs(include_path) + os.makedirs(include_path, exist_ok = True) ladspa_h = os.path.join(self.build_dir, 'src', 'ladspa.h') shutil.copy(ladspa_h, include_path) diff --git a/recipes/mingw-runtime.recipe b/recipes/mingw-runtime.recipe index f5a96440a..de1425bf8 100644 --- a/recipes/mingw-runtime.recipe +++ b/recipes/mingw-runtime.recipe @@ -58,10 +58,8 @@ class Recipe(recipe.Recipe): libdir = os.path.join(hostroot, 'lib') # copy the dll - if not os.path.exists(os.path.join(self.config.prefix, 'bin')): - os.makedirs(os.path.join(self.config.prefix, 'bin')) - if not os.path.exists(os.path.join(self.config.prefix, 'lib')): - os.makedirs(os.path.join(self.config.prefix, 'lib')) + os.makedirs(os.path.join(self.config.prefix, 'bin'), exist_ok = True) + os.makedirs(os.path.join(self.config.prefix, 'lib'), exist_ok = True) for f in ['libwinpthread-1.dll']: shutil.copy( os.path.join(libmingw, f), diff --git a/recipes/tinyalsa.recipe b/recipes/tinyalsa.recipe index e755f3130..6e2b6e2eb 100644 --- a/recipes/tinyalsa.recipe +++ b/recipes/tinyalsa.recipe @@ -29,8 +29,7 @@ class Recipe(recipe.Recipe): tinyalsa_header = os.path.join(self.build_dir, 'include', 'tinyalsa', 'asoundlib.h') tinyalsa_lib = os.path.join(self.build_dir, 'src', 'libtinyalsa.a') - if not os.path.exists(include_path): - os.makedirs(include_path) + os.makedirs(include_path, exist_ok = True) shutil.copy(tinyalsa_header, include_path) shutil.copy(tinyalsa_lib, library_path) diff --git a/recipes/vsintegration-1.0.recipe b/recipes/vsintegration-1.0.recipe index c77960a87..15f2fe49e 100644 --- a/recipes/vsintegration-1.0.recipe +++ b/recipes/vsintegration-1.0.recipe @@ -15,22 +15,19 @@ class Recipe(recipe.Recipe): from cerbero.commands.genvsprops import GenVSProps env_var = ('GSTREAMER_1_0_ROOT_%s' % self.config.target_arch).upper() vspropsdir = os.path.join(self.config.prefix, self.files_devel[0], 'libs') - if not os.path.exists(vspropsdir): - os.makedirs(vspropsdir) + os.makedirs(vspropsdir, exist_ok = True) genvsprops = GenVSProps() genvsprops.runargs(self.config, vspropsdir, env_var) # Copy msvc propsdir = os.path.join(self.config.prefix, 'share/vs/2010/msvc') - if not os.path.exists(propsdir): - os.makedirs(propsdir) + os.makedirs(propsdir, exist_ok = True) datapropsdir = os.path.join(self.config.data_dir, 'vs-1.0', 'msvc') for f in os.listdir(datapropsdir): path = os.path.join(datapropsdir, f) shutil.copy(path, os.path.join(propsdir, f)) # Copy Wizard files propsdir = os.path.join(self.config.prefix, 'share/vs/2010/wizard') - if not os.path.exists(propsdir): - os.makedirs(propsdir) + os.makedirs(propsdir, exist_ok = True) datapropsdir = os.path.join(self.config.data_dir, 'vs-1.0', 'wizard') for f in os.listdir(datapropsdir): path = os.path.join(datapropsdir, f)