def __init__(self, artifacts_path: str, zip: bool, packs: bool, content_version: str, suffix: str, cpus: int, id_set_path: str = '', pack_names: str = 'all', signature_key: str = '', sign_directory: Path = None, remove_test_playbooks: bool = True): """ Content artifacts configuration Args: artifacts_path: existing destination directory for creating artifacts. zip: True for zip all content artifacts to 3 different zip files in same structure else False. packs: create only content_packs artifacts if True. content_version: release content version. suffix: suffix to add all file we creates. cpus: available cpus in the computer. id_set_path: the full path of id_set.json. pack_names: Packs to create artifacts for. signature_key: Base64 encoded signature key used for signing packs. sign_directory: Path to the signDirectory executable file. remove_test_playbooks: Should remove test playbooks from content packs or not. """ # options arguments self.artifacts_path = Path(artifacts_path) self.zip_artifacts = zip self.only_content_packs = packs self.content_version = content_version self.suffix = suffix self.cpus = cpus self.id_set_path = id_set_path self.pack_names = arg_to_list(pack_names) self.signature_key = signature_key self.signDirectory = sign_directory self.remove_test_playbooks = remove_test_playbooks # run related arguments self.content_new_path = self.artifacts_path / 'content_new' self.content_test_path = self.artifacts_path / 'content_test' self.content_packs_path = self.artifacts_path / 'content_packs' self.content_all_path = self.artifacts_path / 'all_content' self.content_uploadable_zips_path = self.artifacts_path / 'uploadable_packs' # inits self.content = Content.from_cwd() self.execution_start = time.time() self.exit_code = EX_SUCCESS
def test_arg_to_list(arg: Union[List[str], str], expected_result: List[str]): """ Given - String or list of strings. Case a: comma-separated string. Case b: a string representing a list. Case c: python list. Case d: empty string. Case e: empty list. When - Convert given string to list of strings, for example at unify.add_contributors_support. Then: - Ensure a Python list is returned with the relevant values. """ func_result = arg_to_list(arg=arg, separator=",") assert func_result == expected_result
def add_contributors_support(self, unified_yml: Dict, contributor_type: str, contributor_email: Union[str, List[str]], contributor_url: str, author: str = '') -> Dict: """Add contributor support to the unified file - text in the display name and detailed description. Args: unified_yml (dict): The unified yaml file. contributor_type (str): The contributor type - partner / developer / community contributor_email (str): The contributor email. contributor_url (str): The contributor url. author (str): The packs author. Returns: The unified yaml file (dict). """ if ' Contribution)' not in unified_yml['display']: unified_yml['display'] += CONTRIBUTOR_DISPLAY_NAME.format( contributor_type.capitalize()) existing_detailed_description = unified_yml.get( 'detaileddescription', '') if contributor_type == COMMUNITY_CONTRIBUTOR: contributor_description = CONTRIBUTOR_COMMUNITY_DETAILED_DESC.format( author) else: contributor_description = CONTRIBUTOR_DETAILED_DESC.format( contributor_type.capitalize(), author) if contributor_email: email_list: List[str] = arg_to_list(contributor_email, ",") for email in email_list: contributor_description += f'\n- **Email**: [{email}](mailto:{email})' if contributor_url: contributor_description += f'\n- **URL**: [{contributor_url}]({contributor_url})' contrib_details = re.findall(r'### .* Contributed Integration', existing_detailed_description) if not contrib_details: unified_yml[ 'detaileddescription'] = contributor_description + '\n***\n' + existing_detailed_description return unified_yml
def init_packs(self, pack_paths): """Init dict that map pack name to Pack object and init also the pack_names property. Args: pack_paths (str): CSV str with the pack paths. """ self.packs = {} for path_str in arg_to_list(pack_paths): path = Path(path_str) if len(path.parts) == 2 and path.parts[ 0] == PACKS_DIR: # relative path from Packs/... path = self.content.path / path if not os.path.exists(path): click.secho( f'Error: Given input path: {path} does not exist, ignored', fg='bright_red') continue self.packs.update({path.name: Pack(path)}) self.pack_names = [*self.packs]