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_whiteutils.html | 217 +++++++++++++++++---------------- 1 file changed, 111 insertions(+), 106 deletions(-) (limited to 'doc/sample_html/cogapp_whiteutils.html') diff --git a/doc/sample_html/cogapp_whiteutils.html b/doc/sample_html/cogapp_whiteutils.html index b2aaf865..3fbdc300 100644 --- a/doc/sample_html/cogapp_whiteutils.html +++ b/doc/sample_html/cogapp_whiteutils.html @@ -1,19 +1,21 @@ - + + Coverage for cogapp\whiteutils - - + @@ -26,9 +28,12 @@ function toggle_lines(btn, cls) {

37 statements - 34 run + 34 run 0 excluded 3 missing + + 2 partial +

@@ -43,129 +48,129 @@ function toggle_lines(btn, cls) {

4

5

6

-

7

+

7

8

-

9

+

9

10

11

12

13

-

14

+

14

15

-

16

+

16

17

18

19

-

20

+

20

21

22

23

-

24

-

25

-

26

+

24

+

25

+

26

27

28

-

29

+

29

30

-

31

+

31

32

33

34

35

-

36

-

37

-

38

-

39

-

40

-

41

-

42

-

43

-

44

-

45

-

46

+

36

+

37

+

38

+

39

+

40

+

41

+

42

+

43

+

44

+

45

+

46

47

-

48

+

48

49

50

-

51

+

51

52

-

53

-

54

-

55

-

56

-

57

-

58

-

59

-

60

-

61

-

62

-

63

+

53

+

54

+

55

+

56

+

57

+

58

+

59

+

60

+

61

+

62

+

63

-

""" Indentation utilities for Cog. 

-

    http://nedbatchelder.com/code/cog 

-

     

-

    Copyright 2004-2009, Ned Batchelder. 

-

""" 

-

 

-

import re 

-

 

-

def whitePrefix(strings): 

-

    """ Determine the whitespace prefix common to all non-blank lines 

-

        in the argument list. 

-

    """ 

-

    # Remove all blank lines from the list 

-

    strings = [s for s in strings if s.strip() != ''] 

-

 

-

    if not strings: return '' 

-

 

-

    # Find initial whitespace chunk in the first line. 

-

    # This is the best prefix we can hope for. 

-

    prefix = re.match(r'\s*', strings[0]).group(0) 

-

 

-

    # Loop over the other strings, keeping only as much of 

-

    # the prefix as matches each string. 

-

    for s in strings: 

-

        for i in range(len(prefix)): 

-

            if prefix[i] != s[i]: 

-

                prefix = prefix[:i] 

-

                break 

-

    return prefix 

-

 

-

def reindentBlock(lines, newIndent=''): 

-

    """ Take a block of text as a string or list of lines. 

-

        Remove any common whitespace indentation. 

-

        Re-indent using newIndent, and return it as a single string. 

-

    """ 

-

    if isinstance(lines, basestring): 

-

        lines = lines.split('\n') 

-

    oldIndent = whitePrefix(lines) 

-

    outLines = [] 

-

    for l in lines: 

-

        if oldIndent: 

-

            l = l.replace(oldIndent, '', 1) 

-

        if l and newIndent: 

-

            l = newIndent + l 

-

        outLines.append(l) 

-

    return '\n'.join(outLines) 

-

 

-

def commonPrefix(strings): 

-

    """ Find the longest string that is a prefix of all the strings. 

-

    """ 

-

    if not strings: 

-

        return '' 

-

    prefix = strings[0] 

-

    for s in strings: 

-

        if len(s) < len(prefix): 

-

            prefix = prefix[:len(s)] 

-

        if not prefix: 

-

            return '' 

-

        for i in range(len(prefix)): 

-

            if prefix[i] != s[i]: 

-

                prefix = prefix[:i] 

-

                break 

-

    return prefix 

+

""" Indentation utilities for Cog. 

+

    http://nedbatchelder.com/code/cog 

+

     

+

    Copyright 2004-2009, Ned Batchelder. 

+

""" 

+

 

+

import re 

+

 

+

def whitePrefix(strings): 

+

    """ Determine the whitespace prefix common to all non-blank lines 

+

        in the argument list. 

+

    """ 

+

    # Remove all blank lines from the list 

+

    strings = [s for s in strings if s.strip() != ''] 

+

 

+

    if not strings: return '' 

+

 

+

    # Find initial whitespace chunk in the first line. 

+

    # This is the best prefix we can hope for. 

+

    prefix = re.match(r'\s*', strings[0]).group(0) 

+

 

+

    # Loop over the other strings, keeping only as much of 

+

    # the prefix as matches each string. 

+

    for s in strings: 

+

        for i in range(len(prefix)): 

+

27            if prefix[i] != s[i]: 

+

                prefix = prefix[:i] 

+

                break 

+

    return prefix 

+

 

+

def reindentBlock(lines, newIndent=''): 

+

    """ Take a block of text as a string or list of lines. 

+

        Remove any common whitespace indentation. 

+

        Re-indent using newIndent, and return it as a single string. 

+

    """ 

+

    if isinstance(lines, basestring): 

+

        lines = lines.split('\n') 

+

    oldIndent = whitePrefix(lines) 

+

    outLines = [] 

+

    for l in lines: 

+

        if oldIndent: 

+

            l = l.replace(oldIndent, '', 1) 

+

        if l and newIndent: 

+

            l = newIndent + l 

+

        outLines.append(l) 

+

    return '\n'.join(outLines) 

+

 

+

def commonPrefix(strings): 

+

    """ Find the longest string that is a prefix of all the strings. 

+

    """ 

+

52    if not strings: 

+

        return '' 

+

    prefix = strings[0] 

+

    for s in strings: 

+

        if len(s) < len(prefix): 

+

            prefix = prefix[:len(s)] 

+

        if not prefix: 

+

            return '' 

+

        for i in range(len(prefix)): 

+

            if prefix[i] != s[i]: 

+

                prefix = prefix[:i] 

+

                break 

+

    return prefix 

-- cgit v1.2.1