def project_as_list(self): """R2 project file(s) as a list. When the R2 project file is not set, the empty list is returned. When there is only a single R2 project file, a singleton list is returned. When there are multiple files, the list is returned directly. """ return as_list(self.project)
def arch_as_list(self): """Architecture(s) as a list. When the architecture is not set, the empty list is returned. When there is only a single architecture, a singleton list is returned. When the architecture is a list, it is returned directly. """ return as_list(self.arch)
def idb_as_list(self): """IDA database file(s) as a list. When the IDA database file is not set, the empty list is returned. When there is only a single IDA database file, a singleton list is returned. When there are multiple files, the list is returned directly. """ return as_list(self.idb)
def format_as_list(self): """File format(s) as a list. When the file format is not set, the empty list is returned. When there is only a single file format, a singleton list is returned. When the format is a list, it is returned directly. """ return as_list(self.format)
def input_as_list(self): """Input file(s) as a list. When the input is not set, the empty list is returned. When there is only a single input, a singleton list is returned. When the input is a list, it is returned directly. """ return as_list(self.input)
def pdb_as_list(self): """PDB file(s) as a list. When the PDB file is not set, the empty list is returned. When there is only a single PDB file, a singleton list is returned. When there are multiple files, the list is returned directly. """ return as_list(self.pdb)
def static_code_archive_as_list(self): """Archive file(s) as a list. When the archive file is not set, the empty list is returned. When there is only a single archive file, a singleton list is returned. When there are multiple files, the list is returned directly. """ return as_list(self.static_code_archive)
def ar_index_as_list(self): """Index(es) of file(s) in the input archive as a list. When the index is not set, the empty list is returned. When there is only a single index, a singleton list is returned. When the index is a list, it is returned directly. """ return as_list(self.ar_index)
def ar_name_as_list(self): """Name(s) of file(s) in the input archive as a list. When the name is not set, the empty list is returned. When there is only a single name, a singleton list is returned. When the name is a list, it is returned directly. """ return as_list(self.ar_name)
def mode_as_list(self): """Mode(s) as a list. When the mode is not set, the empty list is returned. When there is only a single mode, a singleton list is returned. When the mode is a list, it is returned directly. """ return as_list(self.mode)
def hll_as_list(self): """High-level language(s) as a list. When the high-level language (HLL) is not set, the empty list is returned. When there is only a single HLL, a singleton list is returned. When the HLL is a list, it is returned directly. """ return as_list(self.hll)
def args_as_list(self): """Arguments passed directly to the tool as a list. When there are no arguments, the empty list is returned. When there are only a single arguments, a singleton list is returned. When there are multiple arguments, a list of them is returned. """ return as_list(self.args)
def config_as_list(self): """Configuration file(s) as a list. When the configuration file is not set, the empty list is returned. When there is only a single configuration file, a singleton list is returned. When there are multiple files, the list is returned directly. """ return as_list(self.config)
def commands_as_list(self): """R2 project file(s) as a list. When the R2 commands are not set, the empty list is returned. When there is only a single R2 command, a singleton list is returned. When there are multiple commands, the list is returned directly. """ return as_list(self.commands)
def _merge_duplicates(self, setting): """Merges duplicates from the given setting.""" # Duplicates can be removed only from lists. This prevents removal of # "duplicates" from strings or tuples. if not isinstance(setting, list): return setting # Do NOT use `if not setting:` because False can be a valid value for # some settings. if setting is None or setting == []: return setting no_duplicates = merge_duplicates(as_list(setting)) return no_duplicates if len(no_duplicates) != 1 else no_duplicates[0]
def test_for_none_empty_list_is_returned(self): self.assertEqual(as_list(None), [])
def test_for_list_same_list_is_returned(self): self.assertEqual(as_list(['a', 'b']), ['a', 'b'])
def test_for_int_singleton_list_is_returned(self): self.assertEqual(as_list(1), [1])
def test_for_tuple_singleton_list_is_returned(self): self.assertEqual(as_list((1, 2)), [(1, 2)])
def test_for_string_singleton_list_is_returned(self): self.assertEqual(as_list('test'), ['test'])