• Login
Community
  • Login

View>Function List python functions showing up outside of tree

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 805 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    MegMM
    last edited by Dec 18, 2019, 8:33 PM

    Hello, I’m on NPP 7.8.1 and writing Python code. I’m having a problem when using View>Function List. When adding functions to a class in files I’ve been working on over a period of days and weeks, the functions are showing up outside of the class tree instead of in the class. At first I thought it was indentation issues, but that wasn’t the case. How can I figure out what the problem is and fix this?
    Thank you!

    A 1 Reply Last reply Dec 18, 2019, 8:53 PM Reply Quote 0
    • A
      Alan Kilborn @MegMM
      last edited by Dec 18, 2019, 8:53 PM

      @MegMM

      Perhaps showing some examples of the abnormal behavior would be a great place to start?

      1 Reply Last reply Reply Quote 1
      • M
        MegMM
        last edited by Dec 19, 2019, 9:56 PM

        Hi, hope the img below is what you mean. Every function between the Catalog class and main() should be showing up as a method in the Catalog class.

        Annotation 2019-12-19 134605.png

        If you’re asking for code, here’s a snippet of where the functions suddenly show outside of the Class. Thanks for any ideas!

            def convert_raw_title_to_standard(self, raw_title: str) -> str:
                tt = self.cleanup_raw_title(raw_title)
                tt = uutil.change_chars_to_space(tt, '-')
                tt = tt.title()
                return tt
                
            def make_links_from_soup(self, src_url: str, soup: BeautifulSoup) -> list:
                stories = []
                story = {}
         
                if bool(soup.find_all('div', class_='ftr')):
                    div_rows = soup.find_all('div', class_='ftr')
                else:
                    return stories
                
                for row in div_rows:
                    self.entries_count = self.entries_count + 1
                    if 'dir' in row.find('div').text.lower():
                        dir_type = 'dir'
                        story_dir = row.a['href']+'/'
                        story_dir = story_dir.replace(r'//', r'/')           
                    else:
                        dir_type = 'text'
                        story_dir = row.a['href']
                    story_dir = Path(self.src_url).joinpath(story_dir)
                    title = self.convert_raw_title_to_standard(\
                                row.a['href'])
                    story = CatEntry(**{
                        'id': str(self.entries_count),
                        'title': title,
                        'dir_type': dir_type,
                        'dir_name': Path(row.a['href']),
                        'url': story_dir, # local or web
                        })           
                    stories.append(story)   
                return stories                
                                            
            ### KEEP        
            def save_catalog_to_file(self, stories: list, file=WindowsPath):
                if not file.exists():
                    uutil.make_parent_dir(file)
                with open(file, 'w+', encoding='utf-8') as cat:
                    for story in stories:
                        cat.write('{0}, {1}, {2}, {3}, {4}\n'.format(
                            str(story.id), story.title, story.dir_type, story.dir_name, story.url))
                cat.close()
        
        
        1 Reply Last reply Reply Quote 2
        • M
          MegMM
          last edited by MegMM Dec 19, 2019, 10:04 PM Dec 19, 2019, 10:03 PM

          Wow, so I just tried deleting all the comments that were left and when I deleted

          ### Keep
          

          and saved, it repositioned the methods correctly. So I’m not sure if that’s a bug or intentional. Can anyone explain? Thank you!

          1 Reply Last reply Reply Quote 0
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors