nodes: 0, module; 1, function_definition; 2, function_name:get_posts; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, function_definition; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:include_draft; 15, False; 16, identifier:filter_functions; 17, None; 18, comment:"""
          Get all posts from filesystem.
  
          :param include_draft: return draft posts or not
          :param filter_functions: filter to apply BEFORE result being sorted
          :return: an iterable of Post objects (the first is the latest post)
          """; 19, function_name:posts_generator; 20, parameters; 21, block; 22, assignment; 23, assignment; 24, assignment; 25, call; 26, identifier:path; 27, expression_statement; 28, if_statement; 29, identifier:posts_path; 30, call; 31, identifier:result; 32, call; 33, identifier:result; 34, call; 35, identifier:sorted; 36, argument_list; 37, comment:"""Loads valid posts one by one in the given path."""; 38, call; 39, block; 40, attribute; 41, argument_list; 42, identifier:filter; 43, argument_list; 44, attribute; 45, argument_list; 46, identifier:result; 47, keyword_argument; 48, keyword_argument; 49, attribute; 50, argument_list; 51, for_statement; 52, attribute; 53, identifier:join; 54, attribute; 55, string; 56, lambda; 57, call; 58, identifier:self; 59, identifier:_filter_result; 60, identifier:result; 61, identifier:filter_functions; 62, identifier:key; 63, lambda; 64, identifier:reverse; 65, True; 66, attribute; 67, identifier:isdir; 68, identifier:path; 69, identifier:file; 70, call; 71, block; 72, identifier:os; 73, identifier:path; 74, identifier:current_app; 75, identifier:instance_path; 76, string_content:posts; 77, lambda_parameters; 78, boolean_operator; 79, identifier:posts_generator; 80, argument_list; 81, lambda_parameters; 82, attribute; 83, identifier:os; 84, identifier:path; 85, attribute; 86, argument_list; 87, expression_statement; 88, expression_statement; 89, if_statement; 90, identifier:p; 91, identifier:include_draft; 92, not_operator; 93, identifier:posts_path; 94, identifier:p; 95, identifier:p; 96, identifier:created; 97, identifier:os; 98, identifier:listdir; 99, identifier:path; 100, assignment; 101, assignment; 102, boolean_operator; 103, comment:# the format is supported and the filename is valid,; 104, comment:# so load this post; 105, block; 106, attribute; 107, pattern_list; 108, call; 109, identifier:format_name; 110, call; 111, comparison_operator:format_name is not None; 112, call; 113, expression_statement; 114, expression_statement; 115, expression_statement; 116, expression_statement; 117, expression_statement; 118, expression_statement; 119, identifier:p; 120, identifier:is_draft; 121, identifier:filename; 122, identifier:ext; 123, attribute; 124, argument_list; 125, identifier:get_standard_format_name; 126, argument_list; 127, identifier:format_name; 128, None; 129, attribute; 130, argument_list; 131, assignment; 132, assignment; 133, assignment; 134, assignment; 135, assignment; 136, yield; 137, attribute; 138, identifier:splitext; 139, identifier:file; 140, subscript; 141, identifier:re; 142, identifier:match; 143, string; 144, identifier:filename; 145, identifier:post; 146, call; 147, attribute; 148, identifier:format_name; 149, pattern_list; 150, call; 151, attribute; 152, binary_operator:filename.replace('-', '/', 3) + '/'; 153, attribute; 154, binary_operator:'/post/' + post.rel_url; 155, identifier:post; 156, identifier:os; 157, identifier:path; 158, identifier:ext; 159, slice; 160, string_content:\d{4}-\d{2}-\d{2}-.+; 161, identifier:Post; 162, argument_list; 163, identifier:post; 164, identifier:format; 165, attribute; 166, attribute; 167, attribute; 168, argument_list; 169, identifier:post; 170, identifier:rel_url; 171, call; 172, string; 173, identifier:post; 174, identifier:unique_key; 175, string; 176, attribute; 177, integer:1; 178, identifier:post; 179, identifier:meta; 180, identifier:post; 181, identifier:raw_content; 182, identifier:FileStorage; 183, identifier:read_file; 184, call; 185, attribute; 186, argument_list; 187, string_content:/; 188, string_content:/post/; 189, identifier:post; 190, identifier:rel_url; 191, attribute; 192, argument_list; 193, identifier:filename; 194, identifier:replace; 195, string; 196, string; 197, integer:3; 198, attribute; 199, identifier:join; 200, identifier:path; 201, identifier:file; 202, string_content:-; 203, string_content:/; 204, identifier:os; 205, identifier:path
code: def get_posts(self, include_draft=False, filter_functions=None):
          """
          Get all posts from filesystem.
  
          :param include_draft: return draft posts or not
          :param filter_functions: filter to apply BEFORE result being sorted
          :return: an iterable of Post objects (the first is the latest post)
          """
  
          def posts_generator(path):
              """Loads valid posts one by one in the given path."""
              if os.path.isdir(path):
                  for file in os.listdir(path):
                      filename, ext = os.path.splitext(file)
                      format_name = get_standard_format_name(ext[1:])
                      if format_name is not None and re.match(
                              r'\d{4}-\d{2}-\d{2}-.+', filename):
                          # the format is supported and the filename is valid,
                          # so load this post
                          post = Post()
                          post.format = format_name
                          post.meta, post.raw_content = FileStorage.read_file(
                              os.path.join(path, file))
                          post.rel_url = filename.replace('-', '/', 3) + '/'
                          post.unique_key = '/post/' + post.rel_url
                          yield post
  
          posts_path = os.path.join(current_app.instance_path, 'posts')
          result = filter(lambda p: include_draft or not p.is_draft,
                          posts_generator(posts_path))
          result = self._filter_result(result, filter_functions)
  
          return sorted(result, key=lambda p: p.created, reverse=True)