nodes: 0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, comment:# `cid` is the only required argument; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, comment:# When the downloads directory exists along with its parent directory,; 22, comment:# the receiver directory, its parent's count (receiver directory's; 23, comment:# count) does not include the downloads directory. This behavior is; 24, comment:# similar to its parent's parent (root), the count of which does not; 25, comment:# include the receiver directory.; 26, comment:# The following code fixed this behavior so that a directory's; 27, comment:# count correctly reflects the actual number of entries in it; 28, comment:# The side-effect that this code may ensure that downloads directory; 29, comment:# exists, causing the system to create the receiver directory and; 30, comment:# downloads directory, if they do not exist.; 31, if_statement; 32, if_statement; 33, try_statement; 34, expression_statement; 35, for_statement; 36, return_statement; 37, identifier:count; 38, integer:30; 39, identifier:order; 40, string; 41, identifier:asc; 42, False; 43, identifier:show_dir; 44, True; 45, identifier:natsort; 46, True; 47, comment:"""
          List directory contents
  
          :param int count: number of entries to be listed
          :param str order: order of entries, originally named `o`. This value
              may be one of `user_ptime` (default), `file_size` and `file_name`
          :param bool asc: whether in ascending order
          :param bool show_dir: whether to show directories
          :param bool natsort: whether to use natural sort
  
          Return a list of :class:`.File` or :class:`.Directory` objects
          """; 48, comparison_operator:self.cid is None; 49, block; 50, call; 51, assignment; 52, assignment; 53, assignment; 54, assignment; 55, assignment; 56, assignment; 57, boolean_operator; 58, block; 59, comparison_operator:self.count <= count; 60, comment:# count should never be greater than self.count; 61, block; 62, block; 63, comment:# When natsort=1 and order='file_name', API access will fail; 64, except_clause; 65, assignment; 66, identifier:entry; 67, identifier:entries; 68, block; 69, identifier:res; 70, string_content:user_ptime; 71, attribute; 72, None; 73, return_statement; 74, attribute; 75, argument_list; 76, identifier:kwargs; 77, dictionary; 78, subscript; 79, attribute; 80, subscript; 81, conditional_expression:1 if asc is True else 0; 82, subscript; 83, conditional_expression:1 if show_dir is True else 0; 84, subscript; 85, conditional_expression:1 if natsort is True else 0; 86, subscript; 87, identifier:order; 88, attribute; 89, comparison_operator:self == self.api.receiver_directory; 90, expression_statement; 91, attribute; 92, identifier:count; 93, expression_statement; 94, expression_statement; 95, as_pattern; 96, block; 97, identifier:res; 98, list; 99, if_statement; 100, identifier:self; 101, identifier:cid; 102, False; 103, identifier:self; 104, identifier:reload; 105, identifier:kwargs; 106, string; 107, identifier:self; 108, identifier:cid; 109, identifier:kwargs; 110, string; 111, integer:1; 112, comparison_operator:asc is True; 113, integer:0; 114, identifier:kwargs; 115, string; 116, integer:1; 117, comparison_operator:show_dir is True; 118, integer:0; 119, identifier:kwargs; 120, string; 121, integer:1; 122, comparison_operator:natsort is True; 123, integer:0; 124, identifier:kwargs; 125, string; 126, identifier:self; 127, identifier:is_root; 128, identifier:self; 129, attribute; 130, augmented_assignment; 131, identifier:self; 132, identifier:count; 133, assignment; 134, assignment; 135, identifier:RequestFailure; 136, as_pattern_target; 137, if_statement; 138, comparison_operator:'pid' in entry; 139, block; 140, else_clause; 141, string_content:cid; 142, string_content:asc; 143, identifier:asc; 144, True; 145, string_content:show_dir; 146, identifier:show_dir; 147, True; 148, string_content:natsort; 149, identifier:natsort; 150, True; 151, string_content:o; 152, attribute; 153, identifier:receiver_directory; 154, attribute; 155, integer:1; 156, identifier:count; 157, attribute; 158, identifier:entries; 159, call; 160, identifier:e; 161, boolean_operator; 162, block; 163, else_clause; 164, string; 165, identifier:entry; 166, expression_statement; 167, block; 168, identifier:self; 169, identifier:api; 170, identifier:self; 171, identifier:_count; 172, identifier:self; 173, identifier:count; 174, attribute; 175, argument_list; 176, comparison_operator:natsort is True; 177, comparison_operator:order == 'file_name'; 178, expression_statement; 179, block; 180, string_content:pid; 181, call; 182, expression_statement; 183, identifier:self; 184, identifier:_load_entries; 185, keyword_argument; 186, keyword_argument; 187, keyword_argument; 188, dictionary_splat; 189, identifier:natsort; 190, True; 191, identifier:order; 192, string; 193, assignment; 194, raise_statement; 195, attribute; 196, argument_list; 197, call; 198, identifier:func; 199, attribute; 200, identifier:count; 201, identifier:count; 202, identifier:page; 203, integer:1; 204, identifier:kwargs; 205, string_content:file_name; 206, identifier:entries; 207, line_continuation:\; 208, call; 209, identifier:e; 210, identifier:res; 211, identifier:append; 212, call; 213, attribute; 214, argument_list; 215, attribute; 216, identifier:_req_files; 217, attribute; 218, argument_list; 219, identifier:_instantiate_directory; 220, argument_list; 221, identifier:res; 222, identifier:append; 223, call; 224, identifier:self; 225, identifier:api; 226, identifier:self; 227, identifier:_load_entries; 228, keyword_argument; 229, keyword_argument; 230, keyword_argument; 231, dictionary_splat; 232, attribute; 233, identifier:entry; 234, identifier:_instantiate_file; 235, argument_list; 236, identifier:func; 237, attribute; 238, identifier:count; 239, identifier:count; 240, identifier:page; 241, integer:1; 242, identifier:kwargs; 243, identifier:self; 244, identifier:api; 245, attribute; 246, identifier:entry; 247, attribute; 248, identifier:_req_aps_natsort_files; 249, identifier:self; 250, identifier:api; 251, identifier:self; 252, identifier:api
code: def list(self, count=30, order='user_ptime', asc=False, show_dir=True,
               natsort=True):
          """
          List directory contents
  
          :param int count: number of entries to be listed
          :param str order: order of entries, originally named `o`. This value
              may be one of `user_ptime` (default), `file_size` and `file_name`
          :param bool asc: whether in ascending order
          :param bool show_dir: whether to show directories
          :param bool natsort: whether to use natural sort
  
          Return a list of :class:`.File` or :class:`.Directory` objects
          """
          if self.cid is None:
              return False
          self.reload()
          kwargs = {}
          # `cid` is the only required argument
          kwargs['cid'] = self.cid
          kwargs['asc'] = 1 if asc is True else 0
          kwargs['show_dir'] = 1 if show_dir is True else 0
          kwargs['natsort'] = 1 if natsort is True else 0
          kwargs['o'] = order
  
          # When the downloads directory exists along with its parent directory,
          # the receiver directory, its parent's count (receiver directory's
          # count) does not include the downloads directory. This behavior is
          # similar to its parent's parent (root), the count of which does not
          # include the receiver directory.
          # The following code fixed this behavior so that a directory's
          # count correctly reflects the actual number of entries in it
          # The side-effect that this code may ensure that downloads directory
          # exists, causing the system to create the receiver directory and
          # downloads directory, if they do not exist.
  
          if self.is_root or self == self.api.receiver_directory:
              self._count += 1
  
          if self.count <= count:
              # count should never be greater than self.count
              count = self.count
          try:
              entries = self._load_entries(func=self.api._req_files,
                                           count=count, page=1, **kwargs)
          # When natsort=1 and order='file_name', API access will fail
          except RequestFailure as e:
              if natsort is True and order == 'file_name':
                  entries = \
                      self._load_entries(func=self.api._req_aps_natsort_files,
                                         count=count, page=1, **kwargs)
              else:
                  raise e
          res = []
          for entry in entries:
              if 'pid' in entry:
                  res.append(_instantiate_directory(self.api, entry))
              else:
                  res.append(_instantiate_file(self.api, entry))
          return res