Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove redudant use of os.walk and check pageTitles are actually created properly #12

Open
WolfgangFahl opened this issue Jul 13, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@WolfgangFahl
Copy link
Collaborator

check an example for a pageTitle with a "/" or other directory separating characters depending on os

make sure the two methods:
cmdline.py:

 @staticmethod
    def getPageTitlesForWikiTextPath(backup_path:str)->list:
        '''
        get the page titles for the given backupPath
        
        Args: 
            backup_path(str): the path to the WikiText Files (e.g. created by wikibackup)
            
        Returns:
            list: a list of PageTitles
        '''       
        page_titles = []
        if backup_path:
            for path, _subdirs, files in os.walk(backup_path):
                for name in files:
                    filename = os.path.join(path, name)[len(backup_path) + 1:]
                    if filename.endswith(".wiki"):
                        page_titles.append(filename[:-len(".wiki")])
        return page_titles;

wikiFileManager.py

def getAllWikiFiles(self,wikiTextPath:str=None):
        '''
        get all wiki Files for the given wikiTextPath

        Args:
            wikiTextPath(str): the root of the wikiText directory (e.g. a wikiBackup target or staging area for generating or fixing/restoring wikiMarkup)

        Returns:
            dict: a lookup for WikiFiles by pageTitle
        '''
        allWikiFiles = {}
        if wikiTextPath is None:
            wikiTextPath=self.wikiTextPath
        for root, _dirnames, filenames in os.walk(wikiTextPath):
            for filename in filenames:
                if filename.endswith('.wiki'):
                    wikiFile=WikiFile(filename, wikiFileManager=self)
                    allWikiFiles[wikiFile.getPageTitle()]=wikiFile
        return allWikiFiles

are integrated

@WolfgangFahl WolfgangFahl added the enhancement New feature or request label Jul 13, 2021
@WolfgangFahl WolfgangFahl changed the title remove redudant use of os.walk and check pagetTitles are actually created properly remove redudant use of os.walk and check pageTitles are actually created properly Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants