From a694fa1a052736c3d30e1c266dd62fd237509ecb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 5 Dec 2009 16:29:33 -0500 Subject: Last touches for 3.2 final. --HG-- branch : 3.2_branch --- doc/sample_html/cogapp_makefiles.html | 165 +++++++++++++++++----------------- 1 file changed, 85 insertions(+), 80 deletions(-) (limited to 'doc/sample_html/cogapp_makefiles.html') diff --git a/doc/sample_html/cogapp_makefiles.html b/doc/sample_html/cogapp_makefiles.html index 4d50521a..8dfb26b2 100644 --- a/doc/sample_html/cogapp_makefiles.html +++ b/doc/sample_html/cogapp_makefiles.html @@ -1,19 +1,21 @@ - + + Coverage for cogapp\makefiles - - + @@ -22,13 +24,16 @@ function toggle_lines(btn, cls) { @@ -43,13 +48,13 @@ function toggle_lines(btn, cls) {

4

5

6

-

7

-

8

+

7

+

8

9

-

10

-

11

+

10

+

11

12

-

13

+

13

14

15

16

@@ -69,7 +74,7 @@ function toggle_lines(btn, cls) {

30

31

32

-

33

+

33

34

35

36

@@ -104,70 +109,70 @@ function toggle_lines(btn, cls) { -

""" Dictionary-to-filetree functions, to create test files for testing. 

-

    http://nedbatchelder.com/code/cog 

-

     

-

    Copyright 2004-2009, Ned Batchelder. 

-

""" 

-

 

-

import path     # Non-standard, from http://www.jorendorff.com/articles/python/path 

-

from whiteutils import reindentBlock 

-

 

-

__version__ = '1.0.20040126' 

-

__all__ = ['makeFiles', 'removeFiles'] 

-

 

-

def makeFiles(d, basedir='.', raw=False): 

-

    """ Create files from the dictionary d, in the directory named by dirpath. 

-

    """ 

-

    dirpath = path.path(basedir) 

-

    for name, contents in d.items(): 

-

        child = dirpath / name 

-

        if isinstance(contents, basestring): 

-

            mode = 'w' 

-

            if raw: 

-

                mode = 'wb' 

-

            f = open(child, mode) 

-

            if not raw: 

-

                contents = reindentBlock(contents) 

-

            f.write(contents) 

-

            f.close() 

-

        else: 

-

            if not child.exists(): 

-

                child.mkdir() 

-

            makeFiles(contents, child, raw=raw) 

-

 

-

def removeFiles(d, basedir='.'): 

-

    """ Remove the files created by makeFiles. 

-

        Directories are removed if they are empty. 

-

    """ 

-

    dirpath = path.path(basedir) 

-

    for name, contents in d.items(): 

-

        child = dirpath / name 

-

        if isinstance(contents, basestring): 

-

            child.remove() 

-

        else: 

-

            removeFiles(contents, child) 

-

            if not child.files() and not child.dirs(): 

-

                child.rmdir() 

-

 

-

if __name__ == '__main__':      #pragma: no cover 

-

    # Try it a little. 

-

    d = { 

-

        'test_makefiles': { 

-

            'hey.txt': """\ 

-

                        This is hey.txt. 

-

                        It's very simple. 

-

                        """, 

-

            'subdir': { 

-

                'fooey': """\ 

-

                            # Fooey 

-

                                Kablooey 

-

                            Ew. 

-

                            """ 

-

            } 

-

        } 

-

    } 

-

    makeFiles(d) 

+

""" Dictionary-to-filetree functions, to create test files for testing. 

+

    http://nedbatchelder.com/code/cog 

+

     

+

    Copyright 2004-2009, Ned Batchelder. 

+

""" 

+

 

+

import path     # Non-standard, from http://www.jorendorff.com/articles/python/path 

+

from whiteutils import reindentBlock 

+

 

+

__version__ = '1.0.20040126' 

+

__all__ = ['makeFiles', 'removeFiles'] 

+

 

+

def makeFiles(d, basedir='.', raw=False): 

+

    """ Create files from the dictionary d, in the directory named by dirpath. 

+

    """ 

+

    dirpath = path.path(basedir) 

+

    for name, contents in d.items(): 

+

        child = dirpath / name 

+

        if isinstance(contents, basestring): 

+

            mode = 'w' 

+

            if raw: 

+

                mode = 'wb' 

+

            f = open(child, mode) 

+

            if not raw: 

+

                contents = reindentBlock(contents) 

+

            f.write(contents) 

+

            f.close() 

+

        else: 

+

            if not child.exists(): 

+

                child.mkdir() 

+

            makeFiles(contents, child, raw=raw) 

+

 

+

def removeFiles(d, basedir='.'): 

+

    """ Remove the files created by makeFiles. 

+

        Directories are removed if they are empty. 

+

    """ 

+

    dirpath = path.path(basedir) 

+

    for name, contents in d.items(): 

+

        child = dirpath / name 

+

        if isinstance(contents, basestring): 

+

            child.remove() 

+

        else: 

+

            removeFiles(contents, child) 

+

            if not child.files() and not child.dirs(): 

+

                child.rmdir() 

+

 

+

if __name__ == '__main__':      #pragma: no cover 

+

    # Try it a little. 

+

    d = { 

+

        'test_makefiles': { 

+

            'hey.txt': """\ 

+

                        This is hey.txt. 

+

                        It's very simple. 

+

                        """, 

+

            'subdir': { 

+

                'fooey': """\ 

+

                            # Fooey 

+

                                Kablooey 

+

                            Ew. 

+

                            """ 

+

            } 

+

        } 

+

    } 

+

    makeFiles(d) 

-- cgit v1.2.1