def get_pack_ref_from_metadata(metadata, pack_directory_name=None):
 pack_ref = None
 if metadata.get('ref', None):
  pack_ref = metadata['ref']
 elif (pack_directory_name and re.match(PACK_REF_WHITELIST_REGEX, pack_directory_name)):
  pack_ref = pack_directory_name
 elif re.match(PACK_REF_WHITELIST_REGEX, metadata['name']):
  pack_ref = metadata['name']
 else:
  msg = 'Pack name "%s" contains invalid characters and "ref" attribute is not available. You either need to add "ref" attribute which contains only word characters to the pack metadata file or update name attribute to contain onlyword characters.'
  raise ValueError((msg % metadata['name']))
 return pack_ref

def get_pack_ref_from_metadata ( metadata , pack_directory_name = None ) : pack_ref = None if metadata . get ( 'ref' , None ) : pack_ref = metadata [ 'ref' ] elif ( pack_directory_name and re . match ( PACK_REF_WHITELIST_REGEX , pack_directory_name ) ) : pack_ref = pack_directory_name elif re . match ( PACK_REF_WHITELIST_REGEX , metadata [ 'name' ] ) : pack_ref = metadata [ 'name' ] else : msg = 'Pack name "%s" contains invalid characters and "ref" attribute is not available. You either need to add "ref" attribute which contains only word characters to the pack metadata file or update name attribute to contain onlyword characters.' raise ValueError ( ( msg % metadata [ 'name' ] ) ) return pack_ref
utility function which retrieves pack "ref" attribute from the pack metadata file .