def list_files(self): """ Returns list of the files for the given path :rtype : list :return: list the files and directories in the current directory or list with the single HDFS object when applied to a regular file.. """ return [HDFS(path) for path in fs.list_files(self.path)]
def test_list_files_command_generator_negative(self): _stdout = ( "Found 5 items\n" "drwxr-xr-x - hbase supergroup 0 2014-09-18 23:38 /hbase\n" "drwxr-xr-x - solr solr 0 2014-07-31 10:38 /solr\n" "drwxrwxrwx - hdfs supergroup 0 2014-09-26 04:34 /tmp\n" "drwxr-xr-x - hdfs supergroup 0 2014-09-11 03:47 /user\n" "drwxr-xr-x - hdfs supergroup 0 2014-07-31 10:37 /var\n" ) files = hdfs_client.list_files( "/", executor=lambda cmd, *args: self._assert_command_generation("hadoop fs -ls /", stdout=_stdout)(cmd, *args), ) self.assertListEqual(files, ["/hbase"])
def test_list_files_command_generator_negative(self): _stdout = ( "Found 5 items\n" "drwxr-xr-x - hbase supergroup 0 2014-09-18 23:38 /hbase\n" "drwxr-xr-x - solr solr 0 2014-07-31 10:38 /solr\n" "drwxrwxrwx - hdfs supergroup 0 2014-09-26 04:34 /tmp\n" "drwxr-xr-x - hdfs supergroup 0 2014-09-11 03:47 /user\n" "drwxr-xr-x - hdfs supergroup 0 2014-07-31 10:37 /var\n" ) files = hdfs_client.list_files( "/", executor=lambda cmd, *args: self._assert_command_generation( "hadoop fs -ls /", stdout=_stdout)(cmd, *args)) self.assertListEqual(files, ["/hbase"])