Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.logger.info('Replacing namespace tokens with {}'.format(
'{}__'.format(dependency['namespace_inject']),
))
package_zip = zip_inject_namespace(
package_zip,
namespace = dependency['namespace_inject'],
managed = not dependency.get('unmanaged'),
namespaced_org = self.options['namespaced_org'],
logger = self.logger,
)
if dependency.get('namespace_strip'):
self.logger.info('Removing namespace prefix {}__ from all files and filenames'.format(
'{}__'.format(dependency['namespace_strip']),
))
package_zip = zip_strip_namespace(
package_zip,
namespace = dependency['namespace_strip'],
logger = self.logger,
)
package_zip = ZipfilePackageZipBuilder(package_zip)()
elif 'namespace' in dependency:
self.logger.info('Installing {} version {}'.format(
dependency['namespace'],
dependency['version'],
))
package_zip = InstallPackageZipBuilder(dependency['namespace'], dependency['version'])()
api = self.api_class(self, package_zip, purge_on_delete=self.options['purge_on_delete'])
return api()
def _process_namespace(self, src_zip):
if self.options.get('namespace_tokenize'):
src_zip = zip_tokenize_namespace(src_zip, self.options['namespace_tokenize'], logger=self.logger)
if self.options.get('namespace_inject'):
kwargs = {}
kwargs['unmanaged'] = process_bool_arg(self.options.get('unmanaged', True))
kwargs['namespaced_org'] = process_bool_arg(self.options.get('namespaced_org', False))
kwargs['logger'] = self.logger
src_zip = zip_inject_namespace(src_zip, self.options['namespace_inject'], **kwargs)
if self.options.get('namespace_strip'):
src_zip = zip_strip_namespace(src_zip, self.options['namespace_strip'], logger=self.logger)
return src_zip
)
package_zip = zip_inject_namespace(
package_zip,
namespace=dependency["namespace_inject"],
managed=not dependency.get("unmanaged"),
namespaced_org=self.options["namespaced_org"],
logger=self.logger,
)
if dependency.get("namespace_strip"):
self.logger.info(
"Removing namespace prefix {}__ from all files and filenames".format(
"{}__".format(dependency["namespace_strip"])
)
)
package_zip = zip_strip_namespace(
package_zip, namespace=dependency["namespace_strip"], logger=self.logger
)
with temporary_dir() as path:
with cd(path):
package_zip.extractall(path)
package_config = {
"name": "{repo_owner}/{repo_name} {subfolder}".format(**dependency),
"version_name": "{repo_owner}/{repo_name} {subfolder} - ".format(
**dependency
)
+ "{{ version }}",
"package_type": "unlocked",
"path": os.path.join(path),
# FIXME: Ideally we'd do this without a namespace but that causes package creation errors
"namespace": self.package_config.get("namespace"),
kwargs['managed'] = not process_bool_arg(self.options.get('unmanaged', True))
kwargs['namespaced_org'] = process_bool_arg(self.options.get('namespaced_org', False))
kwargs['logger'] = self.logger
if kwargs['managed']:
self.logger.info(
'Replacing namespace tokens from metadata with namespace prefix {}__'.format(
self.options['namespace_inject'],
)
)
else:
self.logger.info(
'Stripping namespace tokens from metadata for unmanaged deployment'
)
zipf = zip_inject_namespace(zipf, self.options['namespace_inject'], **kwargs)
if self.options.get('namespace_strip'):
zipf = zip_strip_namespace(zipf, self.options['namespace_strip'], logger=self.logger)
return zipf
def _process_namespace(self, src_zip):
if self.options.get('namespace_tokenize'):
src_zip = zip_tokenize_namespace(src_zip, self.options['namespace_tokenize'], logger=self.logger)
if self.options.get('namespace_inject'):
kwargs = {}
kwargs['unmanaged'] = process_bool_arg(self.options.get('unmanaged', True))
kwargs['namespaced_org'] = process_bool_arg(self.options.get('namespaced_org', False))
kwargs['logger'] = self.logger
src_zip = zip_inject_namespace(src_zip, self.options['namespace_inject'], **kwargs)
if self.options.get('namespace_strip'):
src_zip = zip_strip_namespace(src_zip, self.options['namespace_strip'], logger=self.logger)
return src_zip
self.logger.info('Replacing namespace tokens with {}'.format(
'{}__'.format(dependency['namespace_inject']),
))
package_zip = zip_inject_namespace(
package_zip,
namespace = dependency['namespace_inject'],
managed = not dependency.get('unmanaged'),
namespaced_org = self.options['namespaced_org'],
logger = self.logger,
)
if dependency.get('namespace_strip'):
self.logger.info('Removing namespace prefix {}__ from all files and filenames'.format(
'{}__'.format(dependency['namespace_strip']),
))
package_zip = zip_strip_namespace(
package_zip,
namespace = dependency['namespace_strip'],
logger = self.logger,
)
package_zip = ZipfilePackageZipBuilder(package_zip)()
elif 'namespace' in dependency:
self.logger.info('Installing {} version {}'.format(
dependency['namespace'],
dependency['version'],
))
package_zip = InstallPackageZipBuilder(dependency['namespace'], dependency['version'])()
api = self.api_class(self, package_zip, purge_on_delete=self.options['purge_on_delete'])
return api()