Changeset 740:119f013c8e27 in hatta-dev


Ignore:
Timestamp:
01/24/10 13:28:09 (2 years ago)
Author:
sheep@…
Branch:
default
Message:

Add option and placeholder for the subdirectory storage

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • hatta.py

    r739 r740  
    185185            help='Use the STYLE pygments style for highlighting', 
    186186            metavar='STYLE') 
     187        add('-D', '--subdirectories', dest='subdirectories', 
     188            action="store_true", 
     189            help='Store subpages as subdirectories in the filesystem') 
    187190 
    188191        options, args = parser.parse_args() 
     
    662665            if filename.startswith(self.repo_prefix): 
    663666                yield self._file_to_title(filename) 
     667 
     668 
     669class WikiSubdirectoryStorage(WikiStorage): 
     670    """ 
     671    A version of WikiStorage that keeps the subpages in real subdirectories in 
     672    the filesystem. 
     673 
     674    """ 
     675 
     676    # XXX Override required methods here. 
     677 
    664678 
    665679class WikiParser(object): 
     
    24462460        self.icon_page = self.config.get('icon_page', None) 
    24472461        self.pygments_style = self.config.get('pygments_style', 'tango') 
    2448  
    2449         self.storage = self.storage_class(self.path, self.page_charset) 
     2462        self.subdirectories = self.config.get_bool('subdirectories', False) 
     2463        if self.subdirectories: 
     2464            self.storage = WikiSubdirectoryStorage(self.path, self.page_charset) 
     2465        else: 
     2466            self.storage = self.storage_class(self.path, self.page_charset) 
    24502467        if not os.path.isdir(self.cache): 
    24512468            os.makedirs(self.cache) 
  • tests/test_repo.py

    r739 r740  
    4848    return hatta.WikiStorage(repo_path) 
    4949 
     50def pytest_funcarg__subdir_repo(request): 
     51    """ 
     52    This function is executed whenever a test needs a "repo" parameter. 
     53    It creates a new WikiSubdirectoryStorage object with Hatta repository in a 
     54    temporary directory. 
     55    """ 
     56 
     57    repo_path = str(request.config.ensuretemp('repo')) 
     58    request.addfinalizer(lambda: clear_directory(repo_path)) 
     59    return hatta.WikiSubdirectoryStorage(repo_path) 
     60 
     61class TestSubdirectoryStorage(object): 
     62    """ 
     63    Tests for the WikiSubdirectoryStorage. 
     64    """ 
     65 
     66    # XXX Put your tests here. 
     67 
     68 
    5069class TestMercurialStorage(object): 
    5170    """ 
Note: See TracChangeset for help on using the changeset viewer.