Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _install_dependency(self, dependency):
if 'zip_url' in dependency:
self.logger.info('Deploying unmanaged metadata from /{} of {}'.format(
dependency['subfolder'],
dependency['zip_url'],
))
package_zip = download_extract_zip(
dependency['zip_url'],
subfolder=dependency.get('subfolder')
)
if dependency.get('namespace_tokenize'):
self.logger.info('Replacing namespace prefix {}__ in files and filenames with namespace token strings'.format(
'{}__'.format(dependency['namespace_tokenize']),
))
package_zip = zip_tokenize_namespace(
package_zip,
namespace = dependency['namespace_tokenize'],
logger = self.logger,
)
if dependency.get('namespace_inject'):
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,
)
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
def _install_dependency(self, dependency):
if 'zip_url' in dependency:
self.logger.info('Deploying unmanaged metadata from /{} of {}'.format(
dependency['subfolder'],
dependency['zip_url'],
))
package_zip = download_extract_zip(
dependency['zip_url'],
subfolder=dependency.get('subfolder')
)
if dependency.get('namespace_tokenize'):
self.logger.info('Replacing namespace prefix {}__ in files and filenames with namespace token strings'.format(
'{}__'.format(dependency['namespace_tokenize']),
))
package_zip = zip_tokenize_namespace(
package_zip,
namespace = dependency['namespace_tokenize'],
logger = self.logger,
)
if dependency.get('namespace_inject'):
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,
)
def _process_namespace(self, zipf):
if self.options.get('namespace_tokenize'):
self.logger.info(
'Tokenizing namespace prefix {}__'.format(
self.options['namespace_tokenize'],
)
)
zipf = zip_tokenize_namespace(zipf, self.options['namespace_tokenize'], logger=self.logger)
if self.options.get('namespace_inject'):
kwargs = {}
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)
def _process_namespace(self, zipf):
if self.options.get('namespace_tokenize'):
self.logger.info(
'Tokenizing namespace prefix {}__'.format(
self.options['namespace_tokenize'],
)
)
zipf = zip_tokenize_namespace(zipf, self.options['namespace_tokenize'], logger=self.logger)
if self.options.get('namespace_inject'):
kwargs = {}
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)