From python-dev@python.org Sat Apr 1 05:26:00 2000 From: python-dev@python.org (Fred Drake) Date: Sat, 1 Apr 2000 00:26:00 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg.py,1.1,1.2 Message-ID: <200004010526.AAA14923@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test Modified Files: test_winreg.py Log Message: Mark Hammond: Uncomment call to delete test data when done. Index: test_winreg.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_winreg.py 2000/03/28 20:36:51 1.1 --- test_winreg.py 2000/04/01 05:25:57 1.2 *************** *** 123,127 **** WriteTestData(root_key) ReadTestData(root_key) ! # DeleteTestData(root_key) # Test on my local machine. --- 123,127 ---- WriteTestData(root_key) ReadTestData(root_key) ! DeleteTestData(root_key) # Test on my local machine. From python-dev@python.org Sun Apr 2 06:15:41 2000 From: python-dev@python.org (Andrew M. Kuchling) Date: Sun, 2 Apr 2000 00:15:41 -0500 (EST) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.1,1.2 Message-ID: <200004020515.AAA28389@amarok.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory amarok:/home/akuchlin/src/Python-1.5/Lib/test Modified Files: test_pyexpat.py Log Message: Untabified file to fix problems reported by tabnanny Index: test_pyexpat.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pyexpat.py 2000/03/31 15:44:52 1.1 --- test_pyexpat.py 2000/04/02 05:15:38 1.2 *************** *** 8,18 **** import pyexpat ! class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs ! def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 8,18 ---- import pyexpat ! class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs ! def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): *************** *** 23,46 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): ! print 'Start of CDATA section' def EndCdataSectionHandler(self): ! print 'End of CDATA section' def CommentHandler(self, text): ! print 'Comment:\n\t', repr(text) def NotationDeclHandler(self, *args): name, base, sysid, pubid = args ! print 'Notation declared:', args def UnparsedEntityDeclHandler(self, *args): --- 23,46 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): ! print 'Start of CDATA section' def EndCdataSectionHandler(self): ! print 'End of CDATA section' def CommentHandler(self, text): ! print 'Comment:\n\t', repr(text) def NotationDeclHandler(self, *args): name, base, sysid, pubid = args ! print 'Notation declared:', args def UnparsedEntityDeclHandler(self, *args): *************** *** 66,77 **** parser = pyexpat.ParserCreate(namespace_separator='!') for name in ['StartElementHandler', 'EndElementHandler', ! 'CharacterDataHandler', 'ProcessingInstructionHandler', ! 'UnparsedEntityDeclHandler', 'NotationDeclHandler', ! 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', ! 'CommentHandler', 'StartCdataSectionHandler', ! 'EndCdataSectionHandler', 'DefaultHandler', 'DefaultHandlerExpand', #'NotStandaloneHandler', ! 'ExternalEntityRefHandler' ]: setattr(parser, name, getattr(out, name) ) --- 66,77 ---- parser = pyexpat.ParserCreate(namespace_separator='!') for name in ['StartElementHandler', 'EndElementHandler', ! 'CharacterDataHandler', 'ProcessingInstructionHandler', ! 'UnparsedEntityDeclHandler', 'NotationDeclHandler', ! 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', ! 'CommentHandler', 'StartCdataSectionHandler', ! 'EndCdataSectionHandler', 'DefaultHandler', 'DefaultHandlerExpand', #'NotStandaloneHandler', ! 'ExternalEntityRefHandler' ]: setattr(parser, name, getattr(out, name) ) From python-dev@python.org Sun Apr 2 06:22:34 2000 From: python-dev@python.org (Andrew M. Kuchling) Date: Sun, 2 Apr 2000 00:22:34 -0500 (EST) Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.1,1.2 sre_compile.py,1.1,1.2 sre_constants.py,1.1,1.2 sre_parse.py,1.1,1.2 Message-ID: <200004020522.AAA28446@amarok.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory amarok:/home/akuchlin/src/Python-1.5/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: This patch looks large, but it just deletes the ^M characters and untabifies the files. No actual code changes were made. Index: sre.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre.py 2000/03/31 14:58:54 1.1 --- sre.py 2000/04/02 05:22:29 1.2 *************** *** 1,46 **** ! # -*- Mode: Python; tab-width: 4 -*- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # re-compatible interface for the sre matching engine ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! """ ! this is a long string ! """ ! ! import sre_compile ! ! # -------------------------------------------------------------------- ! # public interface ! ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) ! ! def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) ! ! def search(pattern, string, flags=0): ! assert flags == 0 ! return compile(pattern, _fixflags(flags)).search(string) ! ! # FIXME: etc ! ! # -------------------------------------------------------------------- ! # helpers ! ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert flags == 0 ! return () ! --- 1,46 ---- ! # -*- Mode: Python; tab-width: 4 -*- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.2 2000/04/02 05:22:29 akuchlin Exp $ ! # ! # re-compatible interface for the sre matching engine ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! """ ! this is a long string ! """ ! ! import sre_compile ! ! # -------------------------------------------------------------------- ! # public interface ! ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) ! ! def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) ! ! def search(pattern, string, flags=0): ! assert flags == 0 ! return compile(pattern, _fixflags(flags)).search(string) ! ! # FIXME: etc ! ! # -------------------------------------------------------------------- ! # helpers ! ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert flags == 0 ! return () ! Index: sre_compile.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_compile.py 2000/03/31 14:58:54 1.1 --- sre_compile.py 2000/04/02 05:22:30 1.2 *************** *** 1,187 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # convert template to internal format ! # ! # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: formalize (objectify?) and document the compiler code ! # format, so that other frontends can use this compiler ! ! import array, string, sys ! ! import _sre ! ! from sre_constants import * ! ! # find an array type code that matches the engine's code size ! for WORDSIZE in "BHil": ! if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break ! else: ! raise RuntimeError, "cannot find a useable array type" ! ! # FIXME: should move some optimizations from the parser to here! ! ! class Code: ! def __init__(self): ! self.data = [] ! def __len__(self): ! return len(self.data) ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def append(self, code): ! self.data.append(code) ! def todata(self): ! # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! ! def _compile(code, pattern, flags): ! append = code.append ! for op, av in pattern: ! if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! ! else: ! append(CODES[NOT_LITERAL]) ! append(10) ! elif op in (SUCCESS, FAILURE): ! append(CODES[op]) ! elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) ! elif op is BRANCH: ! append(CODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) ! code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) ! elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! else: ! append(CODES[op]) ! append(av) ! elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) ! else: ! append(CODES[op]) ! fixup = ord ! skip = len(code); append(0) ! for op, av in av: ! append(CODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! append(fixup(av)) ! elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) ! elif op is CATEGORY: ! append(CATEGORIES[av]) ! else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) ! else: ! append(CODES[op]) ! append(ord(av)) ! elif op is MARK: ! append(CODES[op]) ! append(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) ! else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) ! ! def compile(p, flags=()): ! # convert pattern list to internal format ! if type(p) is type(""): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) ! else: ! pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 1,187 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # convert template to internal format ! # ! # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: formalize (objectify?) and document the compiler code ! # format, so that other frontends can use this compiler ! ! import array, string, sys ! ! import _sre ! ! from sre_constants import * ! ! # find an array type code that matches the engine's code size ! for WORDSIZE in "BHil": ! if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break ! else: ! raise RuntimeError, "cannot find a useable array type" ! ! # FIXME: should move some optimizations from the parser to here! ! ! class Code: ! def __init__(self): ! self.data = [] ! def __len__(self): ! return len(self.data) ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def append(self, code): ! self.data.append(code) ! def todata(self): ! # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! ! def _compile(code, pattern, flags): ! append = code.append ! for op, av in pattern: ! if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! ! else: ! append(CODES[NOT_LITERAL]) ! append(10) ! elif op in (SUCCESS, FAILURE): ! append(CODES[op]) ! elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) ! elif op is BRANCH: ! append(CODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) ! code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) ! elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! else: ! append(CODES[op]) ! append(av) ! elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) ! else: ! append(CODES[op]) ! fixup = ord ! skip = len(code); append(0) ! for op, av in av: ! append(CODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! append(fixup(av)) ! elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) ! elif op is CATEGORY: ! append(CATEGORIES[av]) ! else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) ! else: ! append(CODES[op]) ! append(ord(av)) ! elif op is MARK: ! append(CODES[op]) ! append(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) ! else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) ! ! def compile(p, flags=()): ! # convert pattern list to internal format ! if type(p) is type(""): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) ! else: ! pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) Index: sre_constants.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_constants.py 2000/03/31 14:58:54 1.1 --- sre_constants.py 2000/04/02 05:22:30 1.2 *************** *** 1,131 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # various symbols used by the regular expression engine. ! # run this script to update the _sre include files! ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # operators ! ! FAILURE = "failure" ! SUCCESS = "success" ! ! ANY = "any" ! ASSERT = "assert" ! AT = "at" ! BRANCH = "branch" ! CALL = "call" ! CATEGORY = "category" ! GROUP = "group" ! GROUP_IGNORE = "group_ignore" ! IN = "in" ! IN_IGNORE = "in_ignore" ! JUMP = "jump" ! LITERAL = "literal" ! LITERAL_IGNORE = "literal_ignore" ! MARK = "mark" ! MAX_REPEAT = "max_repeat" ! MAX_REPEAT_ONE = "max_repeat_one" ! MAX_UNTIL = "max_until" ! MIN_REPEAT = "min_repeat" ! MIN_UNTIL = "min_until" ! NEGATE = "negate" ! NOT_LITERAL = "not_literal" ! NOT_LITERAL_IGNORE = "not_literal_ignore" ! RANGE = "range" ! REPEAT = "repeat" ! SUBPATTERN = "subpattern" ! ! # positions ! AT_BEGINNING = "at_beginning" ! AT_BOUNDARY = "at_boundary" ! AT_NON_BOUNDARY = "at_non_boundary" ! AT_END = "at_end" ! ! # categories ! ! CATEGORY_DIGIT = "category_digit" ! CATEGORY_NOT_DIGIT = "category_not_digit" ! CATEGORY_SPACE = "category_space" ! CATEGORY_NOT_SPACE = "category_not_space" ! CATEGORY_WORD = "category_word" ! CATEGORY_NOT_WORD = "category_not_word" ! ! CODES = [ ! ! # failure=0 success=1 (just because it looks better that way :-) ! FAILURE, SUCCESS, ! ! ANY, ! ASSERT, ! AT, ! BRANCH, ! CALL, ! CATEGORY, ! GROUP, GROUP_IGNORE, ! IN, IN_IGNORE, ! JUMP, ! LITERAL, LITERAL_IGNORE, ! MARK, ! MAX_REPEAT, MAX_UNTIL, ! MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, ! NOT_LITERAL, NOT_LITERAL_IGNORE, ! NEGATE, ! RANGE, ! REPEAT ! ! ] ! ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c ! ! # replacement operations for "ignore case" mode ! MAP_IGNORE = { ! GROUP: GROUP_IGNORE, ! IN: IN_IGNORE, ! LITERAL: LITERAL_IGNORE, ! NOT_LITERAL: NOT_LITERAL_IGNORE ! } ! ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), ! } ! ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), ! } ! ! if __name__ == "__main__": ! import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") ! f.close() ! print "done" --- 1,131 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # various symbols used by the regular expression engine. ! # run this script to update the _sre include files! ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # operators ! ! FAILURE = "failure" ! SUCCESS = "success" ! ! ANY = "any" ! ASSERT = "assert" ! AT = "at" ! BRANCH = "branch" ! CALL = "call" ! CATEGORY = "category" ! GROUP = "group" ! GROUP_IGNORE = "group_ignore" ! IN = "in" ! IN_IGNORE = "in_ignore" ! JUMP = "jump" ! LITERAL = "literal" ! LITERAL_IGNORE = "literal_ignore" ! MARK = "mark" ! MAX_REPEAT = "max_repeat" ! MAX_REPEAT_ONE = "max_repeat_one" ! MAX_UNTIL = "max_until" ! MIN_REPEAT = "min_repeat" ! MIN_UNTIL = "min_until" ! NEGATE = "negate" ! NOT_LITERAL = "not_literal" ! NOT_LITERAL_IGNORE = "not_literal_ignore" ! RANGE = "range" ! REPEAT = "repeat" ! SUBPATTERN = "subpattern" ! ! # positions ! AT_BEGINNING = "at_beginning" ! AT_BOUNDARY = "at_boundary" ! AT_NON_BOUNDARY = "at_non_boundary" ! AT_END = "at_end" ! ! # categories ! ! CATEGORY_DIGIT = "category_digit" ! CATEGORY_NOT_DIGIT = "category_not_digit" ! CATEGORY_SPACE = "category_space" ! CATEGORY_NOT_SPACE = "category_not_space" ! CATEGORY_WORD = "category_word" ! CATEGORY_NOT_WORD = "category_not_word" ! ! CODES = [ ! ! # failure=0 success=1 (just because it looks better that way :-) ! FAILURE, SUCCESS, ! ! ANY, ! ASSERT, ! AT, ! BRANCH, ! CALL, ! CATEGORY, ! GROUP, GROUP_IGNORE, ! IN, IN_IGNORE, ! JUMP, ! LITERAL, LITERAL_IGNORE, ! MARK, ! MAX_REPEAT, MAX_UNTIL, ! MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, ! NOT_LITERAL, NOT_LITERAL_IGNORE, ! NEGATE, ! RANGE, ! REPEAT ! ! ] ! ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c ! ! # replacement operations for "ignore case" mode ! MAP_IGNORE = { ! GROUP: GROUP_IGNORE, ! IN: IN_IGNORE, ! LITERAL: LITERAL_IGNORE, ! NOT_LITERAL: NOT_LITERAL_IGNORE ! } ! ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), ! } ! ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), ! } ! ! if __name__ == "__main__": ! import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") ! f.close() ! print "done" Index: sre_parse.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_parse.py 2000/03/31 14:58:54 1.1 --- sre_parse.py 2000/04/02 05:22:30 1.2 *************** *** 1,492 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_parse.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: comments marked with the FIXME tag are open issues. all such ! # issues should be closed before the final beta. ! ! import string, sys ! ! from sre_constants import * ! ! SPECIAL_CHARS = ".\\[{()*+?^$|" ! REPEAT_CHARS = "*+?{" ! ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! ! ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) ! } ! ! CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string ! } ! ! class Pattern: ! # FIXME: rename class, and store flags in here too! ! def __init__(self): ! self.flags = [] ! self.groups = 1 ! self.groupdict = {} ! def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid ! return gid ! def setflag(self, flag): ! if flag not in self.flags: ! self.flags.append(flag) ! ! class SubPattern: ! # a subpattern, in intermediate form ! def __init__(self, pattern, data=None): ! self.pattern = pattern ! if not data: ! data = [] ! self.data = data ! self.flags = [] ! self.width = None ! def __repr__(self): ! return repr(self.data) ! def __len__(self): ! return len(self.data) ! def __delitem__(self, index): ! del self.data[index] ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def __getslice__(self, start, stop): ! return SubPattern(self.pattern, self.data[start:stop]) ! def insert(self, index, code): ! self.data.insert(index, code) ! def append(self, code): ! self.data.append(code) ! def getwidth(self): ! # determine the width (min, max) for this subpattern ! if self.width: ! return self.width ! lo = hi = 0L ! for op, av in self.data: ! if op is BRANCH: ! l = sys.maxint ! h = 0 ! for av in av[1]: ! i, j = av.getwidth() ! l = min(l, i) ! h = min(h, j) ! lo = lo + i ! hi = hi + j ! elif op is CALL: ! i, j = av.getwidth() ! lo = lo + i ! hi = hi + j ! elif op is SUBPATTERN: ! i, j = av[1].getwidth() ! lo = lo + i ! hi = hi + j ! elif op in (MIN_REPEAT, MAX_REPEAT): ! i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] ! elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): ! lo = lo + 1 ! hi = hi + 1 ! elif op == SUCCESS: ! break ! self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) ! return self.width ! def set(self, flag): ! if not flag in self.flags: ! self.flags.append(flag) ! def reset(self, flag): ! if flag in self.flags: ! self.flags.remove(flag) ! ! class Tokenizer: ! def __init__(self, string): ! self.string = list(string) ! self.next = self.__next() ! def __next(self): ! if not self.string: ! return None ! char = self.string[0] ! if char[0] == "\\": ! try: ! c = self.string[1] ! except IndexError: ! raise SyntaxError, "bogus escape" ! char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if c not in HEXDIGITS: ! break ! char = char + c ! elif c in string.digits: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if c not in string.digits: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] ! return char ! def match(self, char): ! if char == self.next: ! self.next = self.__next() ! return 1 ! return 0 ! def match_set(self, set): ! if self.next in set: ! self.next = self.__next() ! return 1 ! return 0 ! def get(self): ! this = self.next ! self.next = self.__next() ! return this ! ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass ! try: ! if escape[1:2] == "x": ! escape = escape[2:] ! return LITERAL, chr(string.atoi(escape[-2:], 16) & 0xff) ! elif escape[1:2] in string.digits: ! return LITERAL, chr(string.atoi(escape[1:], 8) & 0xff) ! elif len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _branch(subpattern, items): ! ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) ! ! # check if all items share a common prefix ! while 1: ! prefix = None ! for item in items: ! if not item: ! break ! if prefix is None: ! prefix = item[0] ! elif item[0] != prefix: ! break ! else: ! # all subitems start with a common "prefix". ! # move it out of the branch ! for item in items: ! del item[0] ! subpattern.append(prefix) ! continue # check next one ! break ! ! # check if the branch can be replaced by a character set ! for item in items: ! if len(item) != 1 or item[0][0] != LITERAL: ! break ! else: ! # we can store this as a character set instead of a ! # branch (FIXME: use a range if possible) ! set = [] ! for item in items: ! set.append(item[0]) ! subpattern.append((IN, set)) ! return ! ! subpattern.append((BRANCH, (None, items))) ! ! def _parse(source, pattern, flags=()): ! ! # parse regular expression pattern into an operator list. ! ! subpattern = SubPattern(pattern) ! ! this = None ! ! while 1: ! ! if source.next in ("|", ")"): ! break # end of subpattern ! this = source.get() ! if this is None: ! break # end of pattern ! ! if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) ! ! elif this == "[": ! # character set ! set = [] ! ## if source.match(":"): ! ## pass # handle character classes ! if source.match("^"): ! set.append((NEGATE, None)) ! # check remaining characters ! start = set[:] ! while 1: ! this = source.get() ! if this == "]" and set != start: ! break ! elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) ! elif this: ! code1 = LITERAL, this ! else: ! raise SyntaxError, "unexpected end of regular expression" ! if source.match("-"): ! # potential range ! this = source.get() ! if this == "]": ! set.append(code1) ! set.append((LITERAL, "-")) ! break ! else: ! if this[0] == "\\": ! code2 = _fixescape(this, 1) ! else: ! code2 = LITERAL, this ! if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" ! if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" ! set.append((RANGE, (code1[1], code2[1]))) ! else: ! if code1[0] is IN: ! code1 = code1[1][0] ! set.append(code1) ! ! # FIXME: move set optimization to support function ! if len(set)==1 and set[0][0] is LITERAL: ! subpattern.append(set[0]) # optimization ! elif len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: ! subpattern.append((NOT_LITERAL, set[1][1])) # optimization ! else: ! # FIXME: add charmap optimization ! subpattern.append((IN, set)) ! ! elif this and this[0] in REPEAT_CHARS: ! # repeat previous item ! if this == "?": ! min, max = 0, 1 ! elif this == "*": ! min, max = 0, sys.maxint ! elif this == "+": ! min, max = 1, sys.maxint ! elif this == "{": ! min, max = 0, sys.maxint ! lo = hi = "" ! while source.next in string.digits: ! lo = lo + source.get() ! if source.match(","): ! while source.next in string.digits: ! hi = hi + source.get() ! else: ! hi = lo ! if not source.match("}"): ! raise SyntaxError, "bogus range" ! if lo: ! min = int(lo) ! if hi: ! max = int(hi) ! # FIXME: check that hi >= lo! ! else: ! raise SyntaxError, "not supported" ! # figure out which item to repeat ! # FIXME: should back up to the right mark, right? ! if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] ! else: ! raise SyntaxError, "nothing to repeat" ! if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) ! else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": ! subpattern.append((ANY, None)) ! elif this == "(": ! group = 1 ! name = None ! if source.match("?"): ! group = 0 ! # options ! if source.match("P"): ! # named group: skip forward to end of name ! if source.match("<"): ! name = "" ! while 1: ! char = source.get() ! if char in (">", None): ! break ! name = name + char ! group = 1 ! elif source.match(":"): ! # non-capturing group ! group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") ! if group: ! # parse group contents ! b = [] ! if group == 2: ! # anonymous group ! group = None ! else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) ! while 1: ! p = _parse(source, pattern, flags) ! if source.match(")"): ! if b: ! b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) ! break ! elif source.match("|"): ! b.append(p) ! else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) ! else: ! # FIXME: should this really be a while loop? ! while source.get() not in (")", None): ! pass ! ! elif this == "^": ! subpattern.append((AT, AT_BEGINNING)) ! ! elif this == "$": ! subpattern.append((AT, AT_END)) ! ! elif this and this[0] == "\\": ! code =_fixescape(this) ! subpattern.append(code) ! ! else: ! raise SyntaxError, "parser error" ! ! return subpattern ! ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() ! b = [] ! while 1: ! p = _parse(s, g, flags) ! tail = s.get() ! if tail == "|": ! b.append(p) ! elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" ! elif tail is None: ! if b: ! b.append(p) ! p = SubPattern(g) ! _branch(p, b) ! break ! else: ! raise SyntaxError, "bogus characters at end of regular expression" ! return p ! ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" ! --- 1,492 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_parse.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: comments marked with the FIXME tag are open issues. all such ! # issues should be closed before the final beta. ! ! import string, sys ! ! from sre_constants import * ! ! SPECIAL_CHARS = ".\\[{()*+?^$|" ! REPEAT_CHARS = "*+?{" ! ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! ! ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) ! } ! ! CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string ! } ! ! class Pattern: ! # FIXME: rename class, and store flags in here too! ! def __init__(self): ! self.flags = [] ! self.groups = 1 ! self.groupdict = {} ! def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid ! return gid ! def setflag(self, flag): ! if flag not in self.flags: ! self.flags.append(flag) ! ! class SubPattern: ! # a subpattern, in intermediate form ! def __init__(self, pattern, data=None): ! self.pattern = pattern ! if not data: ! data = [] ! self.data = data ! self.flags = [] ! self.width = None ! def __repr__(self): ! return repr(self.data) ! def __len__(self): ! return len(self.data) ! def __delitem__(self, index): ! del self.data[index] ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def __getslice__(self, start, stop): ! return SubPattern(self.pattern, self.data[start:stop]) ! def insert(self, index, code): ! self.data.insert(index, code) ! def append(self, code): ! self.data.append(code) ! def getwidth(self): ! # determine the width (min, max) for this subpattern ! if self.width: ! return self.width ! lo = hi = 0L ! for op, av in self.data: ! if op is BRANCH: ! l = sys.maxint ! h = 0 ! for av in av[1]: ! i, j = av.getwidth() ! l = min(l, i) ! h = min(h, j) ! lo = lo + i ! hi = hi + j ! elif op is CALL: ! i, j = av.getwidth() ! lo = lo + i ! hi = hi + j ! elif op is SUBPATTERN: ! i, j = av[1].getwidth() ! lo = lo + i ! hi = hi + j ! elif op in (MIN_REPEAT, MAX_REPEAT): ! i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] ! elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): ! lo = lo + 1 ! hi = hi + 1 ! elif op == SUCCESS: ! break ! self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) ! return self.width ! def set(self, flag): ! if not flag in self.flags: ! self.flags.append(flag) ! def reset(self, flag): ! if flag in self.flags: ! self.flags.remove(flag) ! ! class Tokenizer: ! def __init__(self, string): ! self.string = list(string) ! self.next = self.__next() ! def __next(self): ! if not self.string: ! return None ! char = self.string[0] ! if char[0] == "\\": ! try: ! c = self.string[1] ! except IndexError: ! raise SyntaxError, "bogus escape" ! char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if c not in HEXDIGITS: ! break ! char = char + c ! elif c in string.digits: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if c not in string.digits: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] ! return char ! def match(self, char): ! if char == self.next: ! self.next = self.__next() ! return 1 ! return 0 ! def match_set(self, set): ! if self.next in set: ! self.next = self.__next() ! return 1 ! return 0 ! def get(self): ! this = self.next ! self.next = self.__next() ! return this ! ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass ! try: ! if escape[1:2] == "x": ! escape = escape[2:] ! return LITERAL, chr(string.atoi(escape[-2:], 16) & 0xff) ! elif escape[1:2] in string.digits: ! return LITERAL, chr(string.atoi(escape[1:], 8) & 0xff) ! elif len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _branch(subpattern, items): ! ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) ! ! # check if all items share a common prefix ! while 1: ! prefix = None ! for item in items: ! if not item: ! break ! if prefix is None: ! prefix = item[0] ! elif item[0] != prefix: ! break ! else: ! # all subitems start with a common "prefix". ! # move it out of the branch ! for item in items: ! del item[0] ! subpattern.append(prefix) ! continue # check next one ! break ! ! # check if the branch can be replaced by a character set ! for item in items: ! if len(item) != 1 or item[0][0] != LITERAL: ! break ! else: ! # we can store this as a character set instead of a ! # branch (FIXME: use a range if possible) ! set = [] ! for item in items: ! set.append(item[0]) ! subpattern.append((IN, set)) ! return ! ! subpattern.append((BRANCH, (None, items))) ! ! def _parse(source, pattern, flags=()): ! ! # parse regular expression pattern into an operator list. ! ! subpattern = SubPattern(pattern) ! ! this = None ! ! while 1: ! ! if source.next in ("|", ")"): ! break # end of subpattern ! this = source.get() ! if this is None: ! break # end of pattern ! ! if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) ! ! elif this == "[": ! # character set ! set = [] ! ## if source.match(":"): ! ## pass # handle character classes ! if source.match("^"): ! set.append((NEGATE, None)) ! # check remaining characters ! start = set[:] ! while 1: ! this = source.get() ! if this == "]" and set != start: ! break ! elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) ! elif this: ! code1 = LITERAL, this ! else: ! raise SyntaxError, "unexpected end of regular expression" ! if source.match("-"): ! # potential range ! this = source.get() ! if this == "]": ! set.append(code1) ! set.append((LITERAL, "-")) ! break ! else: ! if this[0] == "\\": ! code2 = _fixescape(this, 1) ! else: ! code2 = LITERAL, this ! if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" ! if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" ! set.append((RANGE, (code1[1], code2[1]))) ! else: ! if code1[0] is IN: ! code1 = code1[1][0] ! set.append(code1) ! ! # FIXME: move set optimization to support function ! if len(set)==1 and set[0][0] is LITERAL: ! subpattern.append(set[0]) # optimization ! elif len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: ! subpattern.append((NOT_LITERAL, set[1][1])) # optimization ! else: ! # FIXME: add charmap optimization ! subpattern.append((IN, set)) ! ! elif this and this[0] in REPEAT_CHARS: ! # repeat previous item ! if this == "?": ! min, max = 0, 1 ! elif this == "*": ! min, max = 0, sys.maxint ! elif this == "+": ! min, max = 1, sys.maxint ! elif this == "{": ! min, max = 0, sys.maxint ! lo = hi = "" ! while source.next in string.digits: ! lo = lo + source.get() ! if source.match(","): ! while source.next in string.digits: ! hi = hi + source.get() ! else: ! hi = lo ! if not source.match("}"): ! raise SyntaxError, "bogus range" ! if lo: ! min = int(lo) ! if hi: ! max = int(hi) ! # FIXME: check that hi >= lo! ! else: ! raise SyntaxError, "not supported" ! # figure out which item to repeat ! # FIXME: should back up to the right mark, right? ! if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] ! else: ! raise SyntaxError, "nothing to repeat" ! if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) ! else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": ! subpattern.append((ANY, None)) ! elif this == "(": ! group = 1 ! name = None ! if source.match("?"): ! group = 0 ! # options ! if source.match("P"): ! # named group: skip forward to end of name ! if source.match("<"): ! name = "" ! while 1: ! char = source.get() ! if char in (">", None): ! break ! name = name + char ! group = 1 ! elif source.match(":"): ! # non-capturing group ! group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") ! if group: ! # parse group contents ! b = [] ! if group == 2: ! # anonymous group ! group = None ! else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) ! while 1: ! p = _parse(source, pattern, flags) ! if source.match(")"): ! if b: ! b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) ! break ! elif source.match("|"): ! b.append(p) ! else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) ! else: ! # FIXME: should this really be a while loop? ! while source.get() not in (")", None): ! pass ! ! elif this == "^": ! subpattern.append((AT, AT_BEGINNING)) ! ! elif this == "$": ! subpattern.append((AT, AT_END)) ! ! elif this and this[0] == "\\": ! code =_fixescape(this) ! subpattern.append(code) ! ! else: ! raise SyntaxError, "parser error" ! ! return subpattern ! ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() ! b = [] ! while 1: ! p = _parse(s, g, flags) ! tail = s.get() ! if tail == "|": ! b.append(p) ! elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" ! elif tail is None: ! if b: ! b.append(p) ! p = SubPattern(g) ! _branch(p, b) ! break ! else: ! raise SyntaxError, "bogus characters at end of regular expression" ! return p ! ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" ! From python-dev@python.org Mon Apr 3 04:51:52 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:52 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib UserString.py,NONE,1.1 Message-ID: <200004030351.XAA07636@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib Added Files: UserString.py Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:52 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:52 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_userstring.py,NONE,1.1 Message-ID: <200004030351.XAA07640@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test Added Files: test_userstring.py Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:53 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:53 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_userstring,NONE,1.1 Message-ID: <200004030351.XAA07648@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test/output In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test/output Added Files: test_userstring Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:53 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:53 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libuserdict.tex,1.12,1.13 Message-ID: <200004030351.XAA07654@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: libuserdict.tex Log Message: UserString class from Peter Funk . Index: libuserdict.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** libuserdict.tex 1999/07/26 15:45:52 1.12 --- libuserdict.tex 2000/04/03 03:51:50 1.13 *************** *** 64,65 **** --- 64,114 ---- \class{UserList} class. \end{memberdesc} + + + \section{\module{UserString} --- + Class wrapper for string objects} + + \declaremodule{standard}{UserString} + \modulesynopsis{Class wrapper for string objects.} + \moduleauthor{Peter Funk}{pf@artcom-gmbh.de} + \sectionauthor{Peter Funk}{pf@artcom-gmbh.de} + + This module defines a class that acts as a wrapper around + string objects. It is a useful base class for + your own string-like classes, which can inherit from + them and override existing methods or add new ones. In this way one + can add new behaviours to strings. + + The \module{UserString} module defines the \class{UserString} class: + + \begin{classdesc}{UserString}{\optional{sequence}} + Return a class instance that simulates a string or an unicode string object. + The instance's content is kept in a regular string or unicode string + object, which is accessible via the + \member{data} attribute of \class{UserString} instances. The instance's + contents are initially set to a copy of \var{sequence}. + \var{sequence} can be either a regular Python string or unicode string, + an instance of \class{UserString} (or a subclass) or an arbitrary sequence + which can be converted into a string. + supporting. + \end{classdesc} + + In addition to supporting the methods and operations of string or + unicode objects (see section \ref{typesseq}), \class{UserString} instances + provide the following attribute: + + \begin{memberdesc}{data} + A real Python string or unicode object used to store the content of the + \class{UserString} class. + \end{memberdesc} + + \begin{classdesc}{MutableString}{\optional{sequence}} + This class is derived from the \class{UserString} above and redefines + strings to be \emph{mutable}. Mutable strings can't be used as + dictionary keys, because dictionaries require \emph{immutable} objects as + keys. The main intention of this class is to serve as an educational + example for inheritance and necessity to remove (override) the + \function{__hash__} method in order to trap attempts to use a + mutable object as dictionary key, which would be otherwise very + errorprone and hard to track down. + \end{classdesc} From python-dev@python.org Mon Apr 3 05:13:51 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:13:51 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.39,1.40 ltxmarkup.sty,1.3,1.4 python.sty,1.54,1.55 Message-ID: <200004030413.AAA08320@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/texinputs In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/texinputs Modified Files: boilerplate.tex ltxmarkup.sty python.sty Log Message: Merged changes from the 1.5.2p2 release. Index: boilerplate.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** boilerplate.tex 2000/02/22 18:20:03 1.39 --- boilerplate.tex 2000/04/03 04:13:48 1.40 *************** *** 2,7 **** \authoraddress{ ! Corporation for National Research Initiatives (CNRI) \\ ! 1895 Preston White Drive, Reston, Va 20191, USA \\ E-mail: \email{guido@python.org} } --- 2,7 ---- \authoraddress{ ! Corporation for National Research Initiatives \\ ! 1895 Preston White Drive, Reston, VA 20191, USA \\ E-mail: \email{guido@python.org} } Index: ltxmarkup.sty =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/ltxmarkup.sty,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ltxmarkup.sty 1999/04/23 14:44:53 1.3 --- ltxmarkup.sty 2000/04/03 04:13:48 1.4 *************** *** 19,23 **** \let\p=\py@ltx@param% #2}}] ! %\item[\code{\e end\{{\bfseries #1}\}}] \index{#1 environment@\idxcode{#1} environment} \index{environments!#1@\idxcode{#1}} --- 19,23 ---- \let\p=\py@ltx@param% #2}}] ! \item[\code{\e end\{{\bfseries #1}\}}] \index{#1 environment@\idxcode{#1} environment} \index{environments!#1@\idxcode{#1}} Index: python.sty =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** python.sty 1999/11/09 17:02:11 1.54 --- python.sty 2000/04/03 04:13:48 1.55 *************** *** 278,288 **** % Additional string for an index entry ! \newcommand{\index@subitem}{} ! \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} ! \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}} ! \newcommand{\withsubitem}[2]{% \begingroup% ! \def\index@subitem{#1}#2% \endgroup% } --- 278,300 ---- % Additional string for an index entry ! \newif\ifpy@usingsubitem\py@usingsubitemfalse ! \newcommand{\py@indexsubitem}{} ! \newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}% ! \py@usingsubitemtrue} ! \newcommand{\ttindex}[1]{% ! \ifpy@usingsubitem ! \index{#1@{\py@idxcode{#1}}\py@indexsubitem}% ! \else% ! \index{#1@{\py@idxcode{#1}}}% ! \fi% ! } \newcommand{\withsubitem}[2]{% \begingroup% ! \ifpy@usingsubitem% ! \def\index@subitem{#1}#2% ! \else% ! \def\index@subitem{#1}#2% ! \py@usingsubitemfalse% ! \fi \endgroup% } *************** *** 422,425 **** --- 434,438 ---- \newcommand{\py@reset}{ + \py@usingsubitemfalse \py@ProcessModSynopsis \renewcommand{\py@thisclass}{} *************** *** 511,522 **** % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} % \newcommand{\optional}[1]{% {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} % C functions ------------------------------------------------------------ ! % \begin{cfuncdesc}{type}{name}{arglist} ! \newenvironment{cfuncdesc}[3]{ ! \begin{fulllineitems} ! \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}] }{\end{fulllineitems}} --- 524,551 ---- % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} % + \let\py@badkey=\@undefined + \newcommand{\optional}[1]{% {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} + % This can be used when a function or method accepts an varying number + % of arguments, such as by using the *args syntax in the parameter list. + \newcommand{\py@moreargs}{...} + + % This can be used when you don't want to document the parameters to a + % function or method, but simply state that it's an alias for + % something else. + \newcommand{\py@unspecified}{...} + % C functions ------------------------------------------------------------ ! % \begin{cfuncdesc}[refcount]{type}{name}{arglist} ! % Note that the [refcount] slot should only be filled in by ! % tools/anno-api.py; it pulls the value from the refcounts database. ! \newenvironment{cfuncdesc}[4][\py@badkey]{ ! \begin{fulllineitems} ! \item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}] ! \ifx#1\@undefined\else% ! \emph{Return value: \textbf{#1 reference}.}\\ ! \fi }{\end{fulllineitems}} *************** *** 529,536 **** % C data types ----------------------------------------------------------- ! % \begin{ctypedesc}{typedef name} ! \newenvironment{ctypedesc}[1]{ \begin{fulllineitems} ! \item[\bfcode{#1}\ttindex{#1}] }{\end{fulllineitems}} --- 558,578 ---- % C data types ----------------------------------------------------------- ! % \begin{ctypedesc}[index name]{typedef name} ! \newenvironment{ctypedesc}[2][\py@badkey]{ \begin{fulllineitems} ! \item[\bfcode{#2}% ! \ifx#1\@undefined% ! \withsubitem{(C type)}{\ttindex{#2}}% ! \else% ! \withsubitem{(C type)}{\ttindex{#1}}% ! \fi] ! }{\end{fulllineitems}} ! ! % Funky macros ----------------------------------------------------------- ! % \begin{csimplemacro}{name} ! % -- "simple" because it has no args; NOT for constant definitions! ! \newenvironment{csimplemacrodesc}[1]{ ! \begin{fulllineitems} ! \item[\bfcode{#1}\withsubitem{(macro)}{\ttindex{#1}}] }{\end{fulllineitems}} *************** *** 709,713 **** \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} ! \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} % let's see if this breaks anything now; we may be able to simplify... \renewcommand{\py@varvars}[1]{\var{#1}} --- 751,759 ---- \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} ! %\newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} ! \newcommand{\py@varvars}[1]{% ! {\let\unspecified=\py@unspecified% ! \let\moreargs=\py@moreargs% ! \def\,{\/{\char`\,}}\var{#1}}} % let's see if this breaks anything now; we may be able to simplify... \renewcommand{\py@varvars}[1]{\var{#1}} From python-dev@python.org Mon Apr 3 05:15:48 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:15:48 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools node2label.pl,1.9,1.10 Message-ID: <200004030415.AAA08371@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tools In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tools Modified Files: node2label.pl Log Message: Merged changes from the 1.5.2p2 release. Index: node2label.pl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/node2label.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** node2label.pl 1999/02/10 17:08:00 1.9 --- node2label.pl 2000/04/03 04:15:46 1.10 *************** *** 33,46 **** # don't want to do one s/// per line per node # so look for lines with hrefs, then do s/// on nodes present ! if (/(HREF|href)=\"([^\#\"]*)html[\#\"]/) { ! @parts = split(/(HREF|href)\=\"/); shift @parts; for $node (@parts) { ! $node =~ s/[\#\"].*$//g; chop($node); if (defined($nodes{$node})) { $label = $nodes{$node}; ! if (s/(HREF|href)=\"$node([\#\"])/$1=\"$label.html$2/g) { ! s/(HREF|href)=\"$label.html#(l2h-)?SECTION\d+/$1=\"$label.html/g; $newnames{$node} = "$label.html"; } --- 33,46 ---- # don't want to do one s/// per line per node # so look for lines with hrefs, then do s/// on nodes present ! if (/(HREF|href)=[\"\']([^\#\"\']*)html[\#\"\']/) { ! @parts = split(/(HREF|href)\=[\"\']/); shift @parts; for $node (@parts) { ! $node =~ s/[\#\"\'].*$//g; chop($node); if (defined($nodes{$node})) { $label = $nodes{$node}; ! if (s/(HREF|href)=([\"\'])$node([\#\"\'])/href=$2$label.html$3/g) { ! s/(HREF|href)=([\"\'])$label.html/href=$2$label.html/g; $newnames{$node} = "$label.html"; } From python-dev@python.org Mon Apr 3 05:19:17 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:19:17 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools buildindex.py,1.10,1.11 getpagecounts,1.5,1.6 mkdvi.sh,1.7,1.8 mkhowto,1.7,1.8 mkhtml.sh,1.11,1.12 mkmodindex,1.4,1.5 mksourcepkg,1.1,1.2 Message-ID: <200004030419.AAA08465@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tools In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tools Modified Files: buildindex.py getpagecounts mkdvi.sh mkhowto mkhtml.sh mkmodindex mksourcepkg Log Message: Merged changes from the 1.5.2p2 release. Index: buildindex.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/buildindex.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** buildindex.py 1999/02/24 16:36:48 1.10 --- buildindex.py 2000/04/03 04:19:14 1.11 *************** *** 1,5 **** #! /usr/bin/env python ! __version__ = '$Revision: 1.10 $' import os --- 1,5 ---- #! /usr/bin/env python ! __version__ = '$Revision: 1.11 $' import os *************** *** 12,15 **** --- 12,17 ---- __rmjunk = re.compile("<#\d+#>") + continuation = 0 + def __init__(self, link, str, seqno): self.links = [link] *************** *** 78,82 **** ! _rmtt = re.compile(r"(.*)(.*)(.*)$", re.IGNORECASE) _rmparens = re.compile(r"\(\)") --- 80,84 ---- ! _rmtt = re.compile(r"""(.*)(.*)(.*)$""", re.IGNORECASE) _rmparens = re.compile(r"\(\)") *************** *** 176,179 **** --- 178,197 ---- end = start + colheight cols.append(nodes[start:end]) + # + # If items continue across columns, make sure they are marked + # as continuations so the user knows to look at the previous column. + # + for i in range(len(cols) - 1): + try: + prev = cols[i][-1] + next = cols[i + 1][0] + except IndexError: + return cols + else: + n = min(len(prev.key), len(next.key)) + for j in range(n): + if prev.key[j] != next.key[j]: + break + next.continuation = j + 1 return cols *************** *** 205,210 **** term = node.text[i] level = level + 1 ! append("\n
%s\n
\n%s
" ! % (term, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" % (level * DL_LEVEL_INDENT, node.links[0], node.text[-1])) --- 223,232 ---- term = node.text[i] level = level + 1 ! if node.continuation > i: ! extra = " (continued)" ! else: ! extra = "" ! append("\n
%s%s\n
\n%s
" ! % (term, extra, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" % (level * DL_LEVEL_INDENT, node.links[0], node.text[-1])) Index: getpagecounts =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/getpagecounts,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** getpagecounts 1999/08/03 17:54:39 1.5 --- getpagecounts 2000/04/03 04:19:14 1.6 *************** *** 4,8 **** """Generate a page count report of the PostScript version of the manuals.""" ! __version__ = '$Revision: 1.5 $' --- 4,8 ---- """Generate a page count report of the PostScript version of the manuals.""" ! __version__ = '$Revision: 1.6 $' *************** *** 44,48 **** This is the PostScript version of the standard Python documentation. If you plan to print this, be aware that some of the documents are ! long. The following manuals are included: """ SUFFIX = """\ --- 44,55 ---- This is the PostScript version of the standard Python documentation. If you plan to print this, be aware that some of the documents are ! long. It is formatted for printing on two-sided paper; if you do plan ! to print this, *please* print two-sided if you have a printer capable ! of it! To locate published copies of the larger manuals, or other ! Python reference material, consult the PSA Online Bookstore at: ! ! http://www.python.org/psa/bookstore/ ! ! The following manuals are included: """ SUFFIX = """\ *************** *** 51,54 **** --- 58,67 ---- If you have any questions, comments, or suggestions regarding these documents, please send them via email to python-docs@python.org. + + If you would like to support the development and maintenance of + documentation for Python, please consider joining the Python Software + Activity (PSA; see http://www.python.org/psa/), or urging your + organization to join the PSA or the Python Consortium (see + http://www.python.org/consortium/). """ Index: mkdvi.sh =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkdvi.sh,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mkdvi.sh 1999/04/14 13:13:32 1.7 --- mkdvi.sh 2000/04/03 04:19:14 1.8 *************** *** 35,39 **** part=$1; shift 1 ! TEXINPUTS=$srcdir/$part:$TEXINPUTS export TEXINPUTS --- 35,39 ---- part=$1; shift 1 ! TEXINPUTS=.:$srcdir/$part:$TEXINPUTS export TEXINPUTS Index: mkhowto =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mkhowto 2000/03/31 20:27:36 1.7 --- mkhowto 2000/04/03 04:19:14 1.8 *************** *** 331,334 **** --- 331,336 ---- texfile = texfile[2:] # build the command line and run LaTeX2HTML: + if not os.path.isdir(builddir): + os.mkdir(builddir) args = [LATEX2HTML_BINARY, "-init_file", L2H_INIT_FILE, Index: mkhtml.sh =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkhtml.sh,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** mkhtml.sh 1999/10/29 20:51:43 1.11 --- mkhtml.sh 2000/04/03 04:19:14 1.12 *************** *** 28,31 **** --- 28,33 ---- if [ -d $part ] ; then rm -f $part/*.html + else + mkdir $part fi *************** *** 34,37 **** --- 36,41 ---- latex2html \ -no_auto_link \ + -up_url '../index.html' \ + -up_title 'Documentation Index' \ -init_file $srcdir/perl/l2hinit.perl \ -address '
See About this document... for information on suggesting changes.' \ Index: mkmodindex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkmodindex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mkmodindex 1999/03/04 21:33:55 1.4 --- mkmodindex 2000/04/03 04:19:14 1.5 *************** *** 48,53 **** _rx = re.compile( ! '
' ! '([a-zA-Z_][a-zA-Z0-9_.]*(\s*\(.*\))?)') def main(): --- 48,54 ---- _rx = re.compile( ! "
" ! "([a-zA-Z_][a-zA-Z0-9_.]*(\s*" ! "\(.*\))?)") def main(): Index: mksourcepkg =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mksourcepkg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** mksourcepkg 1999/08/02 20:19:17 1.1 --- mksourcepkg 2000/04/03 04:19:14 1.2 *************** *** 17,21 **** # from the Makefile or someplace. ! __version__ = "$Revision: 1.1 $" import getopt --- 17,21 ---- # from the Makefile or someplace. ! __version__ = "$Revision: 1.2 $" import getopt *************** *** 106,110 **** % (release, archive)) elif format == "zip": ! run("zip -r9 %s.zip Python-%s" % (archive, release)) --- 106,112 ---- % (release, archive)) elif format == "zip": ! if os.path.exists(archive + ".zip"): ! os.unlink(archive + ".zip") ! run("zip -q -r9 %s.zip Python-%s" % (archive, release)) From python-dev@python.org Mon Apr 3 05:27:01 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:27:01 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.103,1.104 Message-ID: <200004030427.AAA08553@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tut In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tut Modified Files: tut.tex Log Message: Merge in changes from the 1.5.2p2 release. Index: tut.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -r1.103 -r1.104 *** tut.tex 1999/11/10 16:17:10 1.103 --- tut.tex 2000/04/03 04:26:58 1.104 *************** *** 4,8 **** % Add a section on file I/O % Write a chapter entitled ``Some Useful Modules'' ! % --regex, math+cmath % Should really move the Python startup file info to an appendix --- 4,8 ---- % Add a section on file I/O % Write a chapter entitled ``Some Useful Modules'' ! % --re, math+cmath % Should really move the Python startup file info to an appendix [...1461 lines suppressed...] \begin{verbatim} *************** *** 3740,3747 **** Automatic completion of variable and module names is optionally available. To enable it in the interpreter's interactive mode, add ! the following to your \file{\$HOME/.pythonrc.py} file:% $ <- bow to font-lock \indexii{.pythonrc.py}{file} ! \refstmodindex{rlcompleter} ! \refbimodindex{readline} \begin{verbatim} --- 3884,3890 ---- Automatic completion of variable and module names is optionally available. To enable it in the interpreter's interactive mode, add ! the following to your \file{\$HOME/.pythonrc.py} file:% \indexii{.pythonrc.py}{file} ! \refstmodindex{rlcompleter}\refbimodindex{readline} \begin{verbatim} From python-dev@python.org Mon Apr 3 05:41:20 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:41:20 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl SynopsisTable.pm,1.4,1.5 l2hinit.perl,1.41,1.42 ltxmarkup.perl,1.3,1.4 python.perl,1.68,1.69 Message-ID: <200004030441.AAA08829@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/perl In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/perl Modified Files: SynopsisTable.pm l2hinit.perl ltxmarkup.perl python.perl Log Message: Merged changes from the 1.5.2p2 release. Index: SynopsisTable.pm =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/SynopsisTable.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** SynopsisTable.pm 1999/07/12 16:28:50 1.4 --- SynopsisTable.pm 2000/04/03 04:41:17 1.5 *************** *** 39,50 **** sub tohtml{ my $self = shift; ! my $data = "\n"; my $name; foreach $name (split /,/, $self->{names}) { my($key,$type,$synopsis) = $self->get($name); ! my $link = ""; ! $data .= (" " ! . "\n" ! . " \n"); } $data .= "
$link$name$synopsis
\n"; --- 39,50 ---- sub tohtml{ my $self = shift; ! my $data = "\n"; my $name; foreach $name (split /,/, $self->{names}) { my($key,$type,$synopsis) = $self->get($name); ! my $link = ""; ! $data .= (' ' ! . "\n" ! . " \n"); } $data .= "
$link$name$synopsis
\n"; Index: l2hinit.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** l2hinit.perl 1999/09/23 16:53:09 1.41 --- l2hinit.perl 2000/04/03 04:41:18 1.42 *************** *** 17,20 **** --- 17,21 ---- $MAX_LINK_DEPTH = 2; + $MAX_SPLIT_DEPTH = 5; # split at subsections but not sub-subsections $ADDRESS = ''; *************** *** 144,147 **** --- 145,149 ---- $NAV_BGCOLOR = " bgcolor=\"#99CCFF\""; } + adjust_icon_information(); *************** *** 150,156 **** my($label,$title) = @_; if ($title) { ! $title =~ s/$label: " ! . "$title\n"); } return ''; --- 152,157 ---- my($label,$title) = @_; if ($title) { ! return ("$label: " ! . "$title\n"); } return ''; *************** *** 159,163 **** sub make_nav_panel{ my $s; ! $s = "" . "\n" . "\n" --- 160,164 ---- sub make_nav_panel{ my $s; ! $s = "
$NEXT
" . "\n" . "\n" *************** *** 185,189 **** sub top_navigation_panel { ! "'; --- 186,190 ---- sub top_navigation_panel { ! "'; *************** *** 191,195 **** sub bot_navigation_panel { ! "

\n

'; --- 192,196 ---- sub bot_navigation_panel { ! "

\n

'; *************** *** 335,345 **** $key =~ s/([a-zA-Z0-9._]*)<\/tt>/\1/; if ($ModulePlatforms{$key} && !$allthesame) { ! $plat = (" ($ModulePlatforms{$key}" . ')'); } ! print MODIDXFILE ! $moditem ! . $IDXFILE_FIELD_SEP ! . "$key$plat###\n"; } close(MODIDXFILE); --- 336,344 ---- $key =~ s/([a-zA-Z0-9._]*)<\/tt>/\1/; if ($ModulePlatforms{$key} && !$allthesame) { ! $plat = (" ($ModulePlatforms{$key}" . ')'); } ! print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP ! . "$key$plat###\n"; } close(MODIDXFILE); *************** *** 557,564 **** # Note that this *must* be done in the init file, not the python.perl # style support file. The %declarations must be set before initialize() ! # is called in the main script. # ! %declarations = ('preform' => '
', %declarations); 1; # This must be the last line --- 556,609 ---- # Note that this *must* be done in the init file, not the python.perl # style support file. The %declarations must be set before initialize() ! # is called in the main LaTeX2HTML script (which happens before style files ! # are loaded). # ! %declarations = ('preform' => '
', %declarations); + + + # This is added to get rid of the long comment that follows the doctype + # declaration; MSIE5 on NT4 SP4 barfs on it and drops the content of the + # page. + sub make_head_and_body { + local($title,$body) = @_; + local($DTDcomment) = ''; + local($version,$isolanguage) = ($HTML_VERSION, 'EN'); + local(%isolanguages) = ( 'english', 'EN' , 'USenglish', 'EN.US' + , 'original', 'EN' , 'german' , 'DE' + , 'austrian', 'DE.AT', 'french' , 'FR' + , 'spanish', 'ES' + , %isolanguages ); + $isolanguage = $isolanguages{$default_language}; + $isolanguage = 'EN' unless $isolanguage; + $title = &purify($title,1); + eval("\$title = ". $default_title ) unless ($title); + + # allow user-modification of the tag; thanks Dan Young + if (defined &custom_TITLE_hook) { + $title = &custom_TITLE_hook($title, $toc_sec_title); + } + + if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included + $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n"; + } else { + $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//" + . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n"; + } + + $STYLESHEET = $FILE.".css" unless $STYLESHEET; + if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; } + + join('', ($DOCTYPE ? $DTDcomment : '' ) + ,"<html>\n<head>\n<title>", $title, "\n" + , &meta_information($title) + , ($CHARSET && $HTML_VERSION ge "2.1" ? + "\n" + : "" ) + , ($BASE ? "\n" : "" ) + , "" + , $more_links_mark + , "\n\n\n"); + } 1; # This must be the last line Index: ltxmarkup.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/ltxmarkup.perl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ltxmarkup.perl 1999/04/28 16:42:29 1.3 --- ltxmarkup.perl 2000/04/03 04:41:18 1.4 *************** *** 16,20 **** local($_) = @_; my $macro = ltx_next_argument(); ! return "\$macro" . $_; } --- 16,20 ---- local($_) = @_; my $macro = ltx_next_argument(); ! return "\$macro" . $_; } *************** *** 22,26 **** local($_) = @_; my $env = ltx_next_argument(); ! return "\$env" . $_; } --- 22,26 ---- local($_) = @_; my $env = ltx_next_argument(); ! return "\$env" . $_; } *************** *** 44,49 **** my $macro = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\$macro" . "\n $params" . "\n
" --- 44,49 ---- my $macro = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\$macro" . "\n $params" . "\n
" *************** *** 56,62 **** my $env = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\begin{$env}" . "\n $params" . "\n
" . $_ --- 56,63 ---- my $env = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\begin{$env}" . "\n $params" + . "\n
\end{$env}" . "\n
" . $_ Index: python.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** python.perl 1999/11/09 16:59:42 1.68 --- python.perl 2000/04/03 04:41:18 1.69 *************** *** 62,66 **** sub do_cmd_Cpp{ 'C++' . @_[0]; } sub do_cmd_EOF{ 'EOF' . @_[0]; } ! sub do_cmd_NULL{ 'NULL' . @_[0]; } sub do_cmd_e{ '\' . @_[0]; } --- 62,66 ---- sub do_cmd_Cpp{ 'C++' . @_[0]; } sub do_cmd_EOF{ 'EOF' . @_[0]; } ! sub do_cmd_NULL{ 'NULL' . @_[0]; } sub do_cmd_e{ '\' . @_[0]; } *************** *** 120,170 **** sub do_cmd_makevar{ return @_[0]; } sub do_cmd_code{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_module{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_keyword{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_exception{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_class{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_function{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_constant{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_member{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_method{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cfunction{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cdata{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_ctype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_regexp{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_character{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_program{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_programopt{ return use_wrappers(@_[0], '', ''); } sub do_cmd_email{ ! return use_wrappers(@_[0], ''); } sub do_cmd_mimetype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_var{ return use_wrappers(@_[0], "", ""); } sub do_cmd_dfn{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_emph{ return use_italics(@_); } sub do_cmd_file{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_filenq{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_samp{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_kbd{ return use_wrappers(@_[0], '', ''); } --- 120,172 ---- sub do_cmd_makevar{ return @_[0]; } sub do_cmd_code{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_module{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_keyword{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_exception{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_class{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_function{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_constant{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_member{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_method{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cfunction{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cdata{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_ctype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_regexp{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_character{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_program{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_programopt{ return use_wrappers(@_[0], '', ''); } sub do_cmd_email{ ! return use_wrappers(@_[0], ''); } sub do_cmd_mimetype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_var{ return use_wrappers(@_[0], "", ""); } sub do_cmd_dfn{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_emph{ return use_italics(@_); } sub do_cmd_file{ ! return use_wrappers(@_[0], ! '', ! ''); } sub do_cmd_filenq{ ! return do_cmd_file(@_[0]); } sub do_cmd_samp{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_kbd{ return use_wrappers(@_[0], '', ''); } *************** *** 184,188 **** $key = $module unless $key; ! return "$module" . $_; } --- 186,191 ---- $key = $module unless $key; ! return "$module" ! . $_; } *************** *** 190,194 **** local($_) = @_; my $newsgroup = next_argument(); ! my $stuff = "$newsgroup"; return $stuff . $_; } --- 193,198 ---- local($_) = @_; my $newsgroup = next_argument(); ! my $stuff = "" ! . "$newsgroup"; return $stuff . $_; } *************** *** 203,207 **** $ahref); add_index_entry("$envvar@\$$envvar", $ahref); ! $aname =~ s/" . $_; } --- 207,211 ---- $ahref); add_index_entry("$envvar@\$$envvar", $ahref); ! $aname =~ s/" . $_; } *************** *** 212,216 **** my $url = next_argument(); $url =~ s/~/~/g; ! return "$url" . $_; } --- 216,220 ---- my $url = next_argument(); $url =~ s/~/~/g; ! return "$url" . $_; } *************** *** 220,224 **** my $page = next_argument(); my $section = next_argument(); ! return "$page($section)" . $_; } --- 224,228 ---- my $page = next_argument(); my $section = next_argument(); ! return "$page($section)" . $_; } *************** *** 232,236 **** my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("RFC $rfcnumber" . $_); } --- 236,240 ---- my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("RFC $rfcnumber" . $_); } *************** *** 281,289 **** local($_) = @_; my $platform = next_argument(); ! $ModulePlatforms{$THIS_MODULE} = $platform; $platform = "Macintosh" if $platform eq 'Mac'; ! return "\n

Availability: $platform.

\n" . $_; } --- 285,293 ---- local($_) = @_; my $platform = next_argument(); ! $ModulePlatforms{"$THIS_MODULE"} = $platform; $platform = "Macintosh" if $platform eq 'Mac'; ! return "\n

Availability: $platform.

\n" . $_; } *************** *** 354,358 **** my($node,$target) = @_; print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; ! return ""; } --- 358,362 ---- my($node,$target) = @_; print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; ! return ""; } *************** *** 367,371 **** sub new_link_info{ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ''; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $aname, $ahref); --- 371,375 ---- sub new_link_info{ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ""; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $aname, $ahref); *************** *** 484,488 **** sub idx_cmd_bifuncindex{ my $str = next_argument(); ! add_index_entry("$str() (built-in function)", @_[0]); } --- 488,493 ---- sub idx_cmd_bifuncindex{ my $str = next_argument(); ! add_index_entry("$str() (built-in function)", ! @_[0]); } *************** *** 500,504 **** if ($define eq 'DEF') { # add to the module index ! my($nstr,$garbage) = split / /, $str, 2; $Modules{$nstr} .= $ahref; } --- 505,510 ---- if ($define eq 'DEF') { # add to the module index ! $str =~ /()/; ! my $nstr = $1; $Modules{$nstr} .= $ahref; } *************** *** 523,527 **** $INDEX_SUBITEM = "(in $name)"; print "[$name]"; ! return make_mod_index_entry("$name (${word}module)", 'DEF'); } --- 529,534 ---- $INDEX_SUBITEM = "(in $name)"; print "[$name]"; ! return make_mod_index_entry( ! "$name (${word}module)", 'DEF'); } *************** *** 541,545 **** my $str = next_argument(); $word = "$word " if $word; ! $str = "$str (${word}module)"; # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; # just inline it all here --- 548,552 ---- my $str = next_argument(); $word = "$word " if $word; ! $str = "$str (${word}module)"; # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; # just inline it all here *************** *** 576,579 **** --- 583,619 ---- } + $REFCOUNTS_LOADED = 0; + + sub load_refcounts{ + $REFCOUNTS_LOADED = 1; + + use File::Basename; + my $myname, $mydir, $myext; + ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); + chop $mydir; # remove trailing '/' + ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); + chop $mydir; # remove trailing '/' + $mydir = getcwd() . "$dd$mydir" + unless $mydir =~ s|^/|/|; + local $_; + my $filename = "$mydir${dd}api${dd}refcounts.dat"; + open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; + print "[loading API refcount data]"; + while () { + if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1):(.*)$/) { + my($func, $param, $count, $comment) = ($1, $2, $3, $4); + #print "\n$func($param) --> $count"; + $REFCOUNTS{"$func:$param"} = $count; + } + } + } + + sub get_refcount{ + my ($func, $param) = @_; + load_refcounts() + unless $REFCOUNTS_LOADED; + return $REFCOUNTS{"$func:$param"}; + } + sub do_env_cfuncdesc{ local($_) = @_; *************** *** 581,600 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" ! . get_indexsubitem()); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; # ???? return "
$return_type $idx ($arg_list)\n
" . $_ . '
'; } sub do_env_ctypedesc{ local($_) = @_; my $type_name = next_argument(); ! my $idx = make_str_index_entry("$type_name" ! . get_indexsubitem()); ! $idx =~ s/ \(.*\)//; ! return "
$idx\n
" . $_ . '
' --- 621,665 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry( ! "$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; # ???? + my $result_rc = get_refcount($function_name, ''); + my $rcinfo = ''; + if ($result_rc eq '+1') { + $rcinfo = 'Return value:' + . "\n New reference."; + } + elsif ($result_rc eq '0') { + $rcinfo = 'Return value:' + . "\n Borrowed reference."; + } + if ($rcinfo ne '') { + $rcinfo = "\n
\n $rcinfo\n
"; + } return "
$return_type $idx ($arg_list)\n
" + . $rcinfo . $_ . '
'; } + sub do_env_csimplemacrodesc{ + local($_) = @_; + my $name = next_argument(); + my $idx = make_str_index_entry("$name"); + return "
$idx\n
" + . $_ + . '
' + } + sub do_env_ctypedesc{ local($_) = @_; + my $index_name = next_optional_argument(); my $type_name = next_argument(); ! $index_name = $type_name ! unless $index_name; ! my($name,$aname,$ahref) = new_link_info(); ! add_index_entry("$index_name (C type)", $ahref); ! return "
$aname$type_name\n
" . $_ . '
' *************** *** 605,609 **** my $var_type = next_argument(); my $var_name = next_argument(); ! my $idx = make_str_index_entry("$var_name" . get_indexsubitem()); $idx =~ s/ \(.*\)//; --- 670,674 ---- my $var_type = next_argument(); my $var_name = next_argument(); ! my $idx = make_str_index_entry("$var_name" . get_indexsubitem()); $idx =~ s/ \(.*\)//; *************** *** 618,622 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; --- 683,687 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; *************** *** 629,633 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! return "
$function_name" . " ($arg_list)\n" . '
' --- 694,698 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! return "
$function_name" . " ($arg_list)\n" . '
' *************** *** 640,644 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name()"; my $idx = make_str_index_entry($prefix . get_indexsubitem()); $prefix =~ s/\(\)//; --- 705,709 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name()"; my $idx = make_str_index_entry($prefix . get_indexsubitem()); $prefix =~ s/\(\)//; *************** *** 651,655 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name"; return "
$prefix ($arg_list)\n
" . $_; --- 716,720 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name"; return "
$prefix ($arg_list)\n
" . $_; *************** *** 668,677 **** my $idx; if ($INDEX_OPCODES) { ! $idx = make_str_index_entry( ! "$opcode_name (byte code instruction)"); $idx =~ s/ \(byte code instruction\)//; } else { ! $idx = "$opcode_name"; } my $stuff = "
$idx"; --- 733,742 ---- my $idx; if ($INDEX_OPCODES) { ! $idx = make_str_index_entry("$opcode_name" ! . " (byte code instruction)"); $idx =~ s/ \(byte code instruction\)//; } else { ! $idx = "$opcode_name"; } my $stuff = "
$idx"; *************** *** 712,716 **** local($_) = @_; my $excname = next_argument(); ! my $idx = make_str_index_entry("$excname"); return "
$idx\n
" . $_ . '
' } --- 777,781 ---- local($_) = @_; my $excname = next_argument(); ! my $idx = make_str_index_entry("$excname"); return "
$idx\n
" . $_ . '
' } *************** *** 724,728 **** my $arg_list = next_argument(); $idx = make_str_index_entry( ! "$THIS_CLASS (class in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; return "
$idx ($arg_list)\n
" . $_ . '
'; --- 789,793 ---- my $arg_list = next_argument(); $idx = make_str_index_entry( ! "$THIS_CLASS (class in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; return "
$idx ($arg_list)\n
" . $_ . '
'; *************** *** 741,745 **** $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 806,810 ---- $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 759,763 **** $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 824,828 ---- $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 796,800 **** $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 861,865 ---- $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 812,816 **** $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 877,881 ---- $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 822,826 **** next_optional_argument(); my $member = next_argument(); ! return "
$member\n
" . $_ . '
'; } --- 887,893 ---- next_optional_argument(); my $member = next_argument(); ! return "
$member\n
" ! . $_ ! . '
'; } *************** *** 830,852 **** next_optional_argument(); my $member = next_argument(); ! return "
$member
" . $_; } ! @col_aligns = ("
" . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " . "\n " ! . "\n " ! . $_ . "\n " . "\n
$NEXT", "", "", ""); $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR; - sub get_th{ - my $a = @_[0]; - my $r = ''; - if ($a eq 'l') - { $r = ''; } - elsif (substr($a, 0, 1) eq 'p') - { $r = ''; } - elsif ($a eq 'r') - { $r = ''; } - return $r; - } - sub fix_font{ # do a little magic on a font name to get the right behavior in the first --- 897,907 ---- next_optional_argument(); my $member = next_argument(); ! return "
$member
" . $_; } ! @col_aligns = ('
', '', '', ''); $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR; sub fix_font{ # do a little magic on a font name to get the right behavior in the first *************** *** 857,878 **** } elsif ($font eq 'file' || $font eq 'filenq') { ! $font = 'tt class=file'; } return $font; } sub setup_column_alignments{ local($_) = @_; ! my($a1,$a2,$a3,$a4) = split(/[|]/,$_); ! my($th1,$th2,$th3,$th4) = ('', '', '', ''); ! $col_aligns[0] = (($a1 eq 'c') ? '' ! : ''); ! $col_aligns[1] = (($a2 eq 'c') ? '' : ''); ! $col_aligns[2] = (($a3 eq 'c') ? '' : ''); ! $col_aligns[3] = (($a4 eq 'c') ? '' : ''); # return the aligned header start tags ! return (get_th($a1), get_th($a2), get_th($a3), get_th($a4)); } sub do_env_tableii{ local($_) = @_; --- 912,964 ---- } elsif ($font eq 'file' || $font eq 'filenq') { ! $font = 'tt class="file"'; } + elsif ($font eq 'member') { + $font = 'tt class="member"'; + } return $font; } + sub figure_column_alignment{ + my $a = @_[0]; + my $mark = substr($a, 0, 1); + my $r = ''; + if ($mark eq 'c') + { $r = ' align="center"'; } + elsif ($mark eq 'r') + { $r = ' align="right"'; } + elsif ($mark eq 'l') + { $r = ' align="left"'; } + elsif ($mark eq 'p') + { $r = ' align="left"'; } + return $r; + } + sub setup_column_alignments{ local($_) = @_; ! my($s1,$s2,$s3,$s4) = split(/[|]/,$_); ! my $a1 = figure_column_alignment($s1); ! my $a2 = figure_column_alignment($s2); ! my $a3 = figure_column_alignment($s3); ! my $a4 = figure_column_alignment($s4); ! $col_aligns[0] = ""; ! $col_aligns[1] = ""; ! $col_aligns[2] = ""; ! $col_aligns[3] = ""; # return the aligned header start tags ! return ("", "", "", ""); } + sub get_table_col1_fonts{ + my $font = $globals{'lineifont'}; + my ($sfont,$efont) = ('', ''); + if ($font) { + $sfont = "<$font>"; + $efont = ""; + $efont =~ s/ .*>/>/; + } + return ($font, $sfont, $efont); + } + sub do_env_tableii{ local($_) = @_; *************** *** 883,894 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " . "\n " ! . "\n " ! . $_ . "\n " . "\n
"; --- 969,983 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! s/\\lineii' . "\n
"; *************** *** 897,912 **** sub do_cmd_lineii{ local($_) = @_; my $c1 = next_argument(); my $c2 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; ! } ! my($c1align,$c2align) = @col_aligns[0,1]; ! return "\n $c1align$sfont$c1$efont\n" ! . " $c2align$c2\ " . $_; } --- 986,1002 ---- sub do_cmd_lineii{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c2 = ' ' if ($c2 eq ''); ! my($c1align,$c2align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; ! } ! return "\n $c1align$sfont$c1$efont$padding\n" ! . " $c2align$c2" . $_; } *************** *** 921,932 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " ! . "\n $th3$h3\ \ " . "\n " ! . "\n " . $_ . "\n " --- 1011,1026 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! my $a3 = $col_aligns[2]; ! s/\\lineiii' . "\n " . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " ! . "\n $th3$h3\ " . "\n " ! . "\n " . $_ . "\n " *************** *** 936,953 **** sub do_cmd_lineiii{ local($_) = @_; my $c1 = next_argument(); my $c2 = next_argument(); my $c3 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; } ! my($c1align,$c2align,$c3align) = @col_aligns[0,1,2]; ! return "\n $c1align$sfont$c1$efont\n" . " $c2align$c2\n" ! . " $c3align$c3\ " . $_; } --- 1030,1048 ---- sub do_cmd_lineiii{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); my $c3 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c3 = ' ' if ($c3 eq ''); ! my($c1align,$c2align,$c3align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; } ! return "\n $c1align$sfont$c1$efont$padding\n" . " $c2align$c2\n" ! . " $c3align$c3" . $_; } *************** *** 963,975 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '
' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " ! . "\n $th3$h3\ \ " ! . "\n $th4$h4\ \ " . "\n " ! . "\n " . $_ . "\n " --- 1058,1075 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! my $a3 = $col_aligns[2]; ! my $a4 = $col_aligns[3]; ! s/\\lineiv' . "\n " . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " ! . "\n $th3$h3\ " ! . "\n $th4$h4\ " . "\n " ! . "\n " . $_ . "\n " *************** *** 979,982 **** --- 1079,1083 ---- sub do_cmd_lineiv{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); *************** *** 984,998 **** my $c4 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; } ! my($c1align,$c2align,$c3align,$c4align) = @col_aligns; ! return "\n $c1align$sfont$c1$efont\n" . " $c2align$c2\n" . " $c3align$c3\n" ! . " $c4align$c4\ " . $_; } --- 1085,1099 ---- my $c4 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c4 = ' ' if ($c4 eq ''); ! my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; } ! return "\n $c1align$sfont$c1$efont$padding\n" . " $c2align$c2\n" . " $c3align$c3\n" ! . " $c4align$c4" . $_; } *************** *** 1000,1004 **** sub do_cmd_maketitle { local($_) = @_; ! my $the_title = "\n
"; if ($t_title) { $the_title .= "\n

$t_title

"; --- 1101,1105 ---- sub do_cmd_maketitle { local($_) = @_; ! my $the_title = "\n
"; if ($t_title) { $the_title .= "\n

$t_title

"; *************** *** 1126,1131 **** sub do_env_seealso{ ! return "
\n " ! . "

See Also:

\n" . @_[0] . '
'; --- 1227,1232 ---- sub do_env_seealso{ ! return "
\n " ! . "

See Also:

\n" . @_[0] . '
'; *************** *** 1145,1150 **** $period = ''; } ! return '
' ! . "\n
Module " . "$module:" . "\n
$text$period\n
" --- 1246,1251 ---- $period = ''; } ! return '
' ! . "\n
Module " . "$module:" . "\n
$text$period\n
" *************** *** 1155,1159 **** local($_) = @_; my $content = next_argument(); ! return '

' . $content . '

' . $_; } --- 1256,1260 ---- local($_) = @_; my $content = next_argument(); ! return '

' . $content . '

' . $_; } *************** *** 1165,1169 **** sub do_env_definitions{ local($_) = @_; ! return "
$_
\n"; } --- 1266,1270 ---- sub do_env_definitions{ local($_) = @_; ! return "
$_
\n"; } From python-dev@python.org Mon Apr 3 05:41:21 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:41:21 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref2.tex,1.17,1.18 ref3.tex,1.39,1.40 ref4.tex,1.21,1.22 ref5.tex,1.27,1.28 ref7.tex,1.18,1.19 Message-ID: <200004030441.AAA08839@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/ref In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/ref Modified Files: ref2.tex ref3.tex ref4.tex ref5.tex ref7.tex Log Message: Merged changes from the 1.5.2p2 release. Index: ref2.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** ref2.tex 1999/03/05 18:30:21 1.17 --- ref2.tex 2000/04/03 04:41:18 1.18 *************** *** 149,153 **** A formfeed character may be present at the start of the line; it will ! be ignored for the indentation calculations above. A formfeed characters occurring elsewhere in the leading whitespace have an undefined effect (for instance, they may reset the space count to --- 149,153 ---- A formfeed character may be present at the start of the line; it will ! be ignored for the indentation calculations above. Formfeed characters occurring elsewhere in the leading whitespace have an undefined effect (for instance, they may reset the space count to *************** *** 370,374 **** backslashes). Specifically, \emph{a raw string cannot end in a single backslash} (since the backslash would escape the following quote ! character). \subsection{String literal concatenation\label{string-catenation}} --- 370,376 ---- backslashes). Specifically, \emph{a raw string cannot end in a single backslash} (since the backslash would escape the following quote ! character). Note also that a single backslash followed by a newline ! is interpreted as those two characters as part of the string, ! \emph{not} as a line continuation. \subsection{String literal concatenation\label{string-catenation}} *************** *** 465,469 **** Note that the integer part of a floating point number cannot look like ! an octal integer. The allowed range of floating point literals is implementation-dependent. --- 467,473 ---- Note that the integer part of a floating point number cannot look like ! an octal integer, though the exponent may look like an octal literal ! but will always be interpreted using radix 10. For example, ! \samp{1e010} is legal, while \samp{07.1} is a syntax error. The allowed range of floating point literals is implementation-dependent. *************** *** 486,490 **** \end{verbatim} ! An imaginary literals yields a complex number with a real part of 0.0. Complex numbers are represented as a pair of floating point numbers and have the same restrictions on their range. To create a --- 490,494 ---- \end{verbatim} ! An imaginary literal yields a complex number with a real part of 0.0. Complex numbers are represented as a pair of floating point numbers and have the same restrictions on their range. To create a *************** *** 523,527 **** The period can also occur in floating-point and imaginary literals. A ! sequence of three periods has a special meaning as ellipses in slices. The following printing ASCII characters have special meaning as part --- 527,531 ---- The period can also occur in floating-point and imaginary literals. A ! sequence of three periods has a special meaning as an ellipsis in slices. The following printing ASCII characters have special meaning as part Index: ref3.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** ref3.tex 1999/11/10 16:13:25 1.39 --- ref3.tex 2000/04/03 04:41:18 1.40 *************** *** 145,149 **** numbers are of course strongly related to mathematical numbers, but subject to the limitations of numerical representation in computers. - \obindex{number} \obindex{numeric} --- 145,148 ---- *************** *** 163,167 **** (The range may be larger on machines with a larger natural word size, but not smaller.) ! When the result of an operation falls outside this range, the exception \exception{OverflowError} is raised. For the purpose of shift and mask operations, integers are assumed to --- 162,166 ---- (The range may be larger on machines with a larger natural word size, but not smaller.) ! When the result of an operation would fall outside this range, the exception \exception{OverflowError} is raised. For the purpose of shift and mask operations, integers are assumed to *************** *** 222,226 **** index set contains the numbers 0, 1, \ldots, \var{n}-1. Item \var{i} of sequence \var{a} is selected by \code{\var{a}[\var{i}]}. ! \obindex{seqence} \index{index operation} \index{item selection} --- 221,225 ---- index set contains the numbers 0, 1, \ldots, \var{n}-1. Item \var{i} of sequence \var{a} is selected by \code{\var{a}[\var{i}]}. ! \obindex{sequence} \index{index operation} \index{item selection} *************** *** 619,623 **** they have methods with certain special names. See section \ref{specialnames}, ``Special method names.'' ! \obindex{number} \obindex{sequence} \obindex{mapping} --- 618,622 ---- they have methods with certain special names. See section \ref{specialnames}, ``Special method names.'' ! \obindex{numeric} \obindex{sequence} \obindex{mapping} *************** *** 703,715 **** \ttindex{co_varnames}} ! The following flag bits are defined for \member{co_flags}: bit 2 is set ! if the function uses the \samp{*arguments} syntax to accept an ! arbitrary number of positional arguments; bit 3 is set if the function ! uses the \samp{**keywords} syntax to accept arbitrary keyword ! arguments; other bits are used internally or reserved for future use. ! If a code object represents a function, the first item in ! \member{co_consts} is the documentation string of the ! function, or \code{None} if undefined. ! \index{documentation string} \item[Frame objects] --- 702,713 ---- \ttindex{co_varnames}} ! The following flag bits are defined for \member{co_flags}: bit ! \code{0x04} is set if the function uses the \samp{*arguments} syntax ! to accept an arbitrary number of positional arguments; bit ! \code{0x08} is set if the function uses the \samp{**keywords} syntax ! to accept arbitrary keyword arguments; other bits are used internally ! or reserved for future use. If\index{documentation string} a code ! object represents a function, the first item in \member{co_consts} is ! the documentation string of the function, or \code{None} if undefined. \item[Frame objects] *************** *** 1099,1106 **** The returned object should be of the same type as \var{self}. Note that missing \var{i} or \var{j} in the slice expression are replaced ! by zero or \code{sys.maxint}, respectively, and no further ! transformations on the indices is performed. The interpretation of ! negative indices and indices larger than the length of the sequence is ! up to the method. \end{methoddesc} --- 1097,1107 ---- The returned object should be of the same type as \var{self}. Note that missing \var{i} or \var{j} in the slice expression are replaced ! by zero or \code{sys.maxint}, respectively. If negative indexes are ! used in the slice, the length of the sequence is added to that index. ! If the instance does not implement the \method{__len__()} method, an ! \exception{AttributeError} is raised. ! No guarantee is made that indexes adjusted this way are not still ! negative. Indexes which are greater than the length of the sequence ! are not modified. \end{methoddesc} Index: ref4.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** ref4.tex 1999/05/13 18:38:11 1.21 --- ref4.tex 2000/04/03 04:41:18 1.22 *************** *** 184,192 **** executed whether an exception occurred or not in the preceding code. ! Python uses the ``termination'' model of error handling: an exception ! handler can find out what happened and continue execution at an outer ! level, but it cannot repair the cause of the error and retry the ! failing operation (except by re-entering the offending piece of ! code from the top). When an exception is not handled at all, the interpreter terminates --- 184,192 ---- executed whether an exception occurred or not in the preceding code. ! Python uses the ``termination'' \index{termination model}model of ! error handling: an exception handler can find out what happened and ! continue execution at an outer level, but it cannot repair the cause ! of the error and retry the failing operation (except by re-entering ! the offending piece of code from the top). When an exception is not handled at all, the interpreter terminates *************** *** 211,214 **** being raised. ! See also the description of the \keyword{try} and \keyword{raise} ! statements in chapter \ref{compound}. --- 211,214 ---- being raised. ! See also the description of the \keyword{try} statement in section ! \ref{try} and \keyword{raise} statement in section \ref{raise}. Index: ref5.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** ref5.tex 1999/05/06 14:46:35 1.27 --- ref5.tex 2000/04/03 04:41:18 1.28 *************** *** 116,120 **** the same object or a different object with the same value. \indexiii{immutable}{data}{type} ! \indexii{immutable}{objects} \subsection{Parenthesized forms\label{parenthesized}} --- 116,120 ---- the same object or a different object with the same value. \indexiii{immutable}{data}{type} ! \indexii{immutable}{object} \subsection{Parenthesized forms\label{parenthesized}} *************** *** 190,194 **** are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. ! \indexii{immutable}{objects} \subsection{String conversions\label{string-conversions}} --- 190,194 ---- are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. ! \indexii{immutable}{object} \subsection{String conversions\label{string-conversions}} *************** *** 339,343 **** evaluate to a sequence object. The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the ! sequence's length, respectively. If either bound is negative, the sequence's length is added to it. The slicing now selects all items with index \var{k} such that --- 339,343 ---- evaluate to a sequence object. The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the ! \code{sys.maxint}, respectively. If either bound is negative, the sequence's length is added to it. The slicing now selects all items with index \var{k} such that *************** *** 508,512 **** ! \section{Unary arithmetic operations\label{unary}} \indexiii{unary}{arithmetic}{operation} \indexiii{unary}{bit-wise}{operation} --- 508,512 ---- ! \section{Unary arithmetic operations \label{unary}} \indexiii{unary}{arithmetic}{operation} \indexiii{unary}{bit-wise}{operation} *************** *** 527,531 **** \index{plus} ! The unary \code{~} (invert) operator yields the bit-wise inversion of its plain or long integer argument. The bit-wise inversion of \code{x} is defined as \code{-(x+1)}. It only applies to integral --- 527,531 ---- \index{plus} ! The unary \code{\~} (invert) operator yields the bit-wise inversion of its plain or long integer argument. The bit-wise inversion of \code{x} is defined as \code{-(x+1)}. It only applies to integral Index: ref7.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** ref7.tex 1999/08/24 22:14:01 1.18 --- ref7.tex 2000/04/03 04:41:18 1.19 *************** *** 307,313 **** parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not ! expressed by the grammar.\footnote{ ! Currently this is not checked; instead, \code{def f(a=1, b)} is ! interpreted as \code{def f(a=1, b=None)}.} \indexiii{default}{parameter}{value} --- 307,311 ---- parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not ! expressed by the grammar. \indexiii{default}{parameter}{value} From python-dev@python.org Mon Apr 3 05:43:08 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:43:08 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/paper-letter .cvsignore,1.7,1.8 Makefile,1.13,1.14 Message-ID: <200004030443.AAA08922@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/paper-letter In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/paper-letter Modified Files: .cvsignore Makefile Log Message: Merged changes from the 1.5.2p2 release. Index: .cvsignore =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/paper-letter/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/03/16 16:14:50 1.7 --- .cvsignore 2000/04/03 04:43:05 1.8 *************** *** 14,15 **** --- 14,16 ---- *.how README + api.tex Index: Makefile =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/paper-letter/Makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** Makefile 1999/10/29 20:49:23 1.13 --- Makefile 2000/04/03 04:43:05 1.14 *************** *** 59,73 **** ! README: $(PSFILES) $(TOOLSDIR)/getpagecounts >$@ # Python/C API Reference Manual ! api.dvi: $(APIFILES) $(MKDVI) api ! api.pdf: $(APIFILES) $(MKPDF) api # Documenting Python doc.dvi: $(DOCFILES) --- 59,76 ---- ! README: $(PSFILES) $(TOOLSDIR)/getpagecounts $(TOOLSDIR)/getpagecounts >$@ # Python/C API Reference Manual ! api.dvi: api.tex $(APIFILES) $(MKDVI) api ! api.pdf: api.tex $(APIFILES) $(MKPDF) api + api.tex: ../api/api.tex ../api/refcounts.dat ../tools/anno-api.py + $(PYTHON) ../tools/anno-api.py -o $@ ../api/api.tex + # Documenting Python doc.dvi: $(DOCFILES) *************** *** 114,118 **** clean: ! rm -f *~ *.aux *.idx *.ilg *.ind *.log *.toc *.bkm *.syn *.pla clobber: clean --- 117,121 ---- clean: ! rm -f *~ *.aux *.idx *.ilg *.ind *.log *.toc *.bkm *.syn *.pla api.tex clobber: clean From python-dev@python.org Mon Apr 3 05:47:19 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:47:19 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.15,1.16 Message-ID: <200004030447.AAA08994@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/doc In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/doc Modified Files: doc.tex Log Message: Merged changes from the 1.5.2p2 release. Index: doc.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** doc.tex 1999/11/10 22:51:18 1.15 --- doc.tex 2000/04/03 04:47:16 1.16 *************** *** 227,230 **** --- 227,243 ---- facilities. + \subsection{Meta-information Markup \label{meta-info}} + + \begin{macrodesc}{sectionauthor}{\p{author}\p{email}} + Identifies the author of the current section. \var{author} + should be the author's name such that it can be used for + presentation (though it isn't), and \var{email} should be the + author's email address. The domain name portion of + the address should be lower case. + + No presentation is generated from this markup, but it is used to + help keep track of contributions. + \end{macrodesc} + \subsection{Information Units \label{info-units}} *************** *** 413,417 **** \begin{macrodesc}{email}{\p{address}} An email address. Note that this is \emph{not} hyperlinked in ! any of the possible output formats. \end{macrodesc} --- 426,431 ---- \begin{macrodesc}{email}{\p{address}} An email address. Note that this is \emph{not} hyperlinked in ! any of the possible output formats. The domain name portion of ! the address should be lower case. \end{macrodesc} *************** *** 690,695 **** table generated by this environment contains two columns, and each row is defined by an alternate definition of ! \macro{modulesynopsis}. This environment is not normally use by ! the user, but is created by the \macro{localmoduletable} macro. --- 704,709 ---- table generated by this environment contains two columns, and each row is defined by an alternate definition of ! \macro{modulesynopsis}. This environment is not normally used by ! authors, but is created by the \macro{localmoduletable} macro. *************** *** 727,731 **** Effective index generation for technical documents can be very ! difficult, especially for someone familliar with the topic but not the creation of indexes. Much of the difficulty arises in the area of terminology: including the terms an expert would use for a --- 741,745 ---- Effective index generation for technical documents can be very ! difficult, especially for someone familiar with the topic but not the creation of indexes. Much of the difficulty arises in the area of terminology: including the terms an expert would use for a *************** *** 736,740 **** The truly difficult aspects of index generation are not areas with which the documentation tools can help. However, ease ! of producing the index once content decisions are make is within the scope of the tools. Markup is provided which the processing software is able to use to generate a variety of kinds of index --- 750,754 ---- The truly difficult aspects of index generation are not areas with which the documentation tools can help. However, ease ! of producing the index once content decisions are made is within the scope of the tools. Markup is provided which the processing software is able to use to generate a variety of kinds of index From python-dev@python.org Mon Apr 3 05:51:15 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:51:15 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/html Makefile,1.30,1.31 index.html.in,1.4,1.5 Message-ID: <200004030451.AAA09076@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/html In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/html Modified Files: Makefile index.html.in Log Message: Merged changes from the 1.5.2p2 release. Index: Makefile =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/Makefile,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** Makefile 1999/11/18 20:56:29 1.30 --- Makefile 2000/04/03 04:51:13 1.31 *************** *** 54,58 **** tut: tut/tut.html ! $(INDEXFILES): $(COMMONPERL) $(TOPDIR)/html/about.dat # The index.html target is at the end since it screws up font-lock. --- 54,60 ---- tut: tut/tut.html ! $(INDEXFILES): $(COMMONPERL) \ ! $(TOPDIR)/html/about.dat \ ! $(TOPDIR)/tools/node2label.pl # The index.html target is at the end since it screws up font-lock. Index: index.html.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** index.html.in 1999/05/27 21:56:11 1.4 --- index.html.in 2000/04/03 04:51:13 1.5 *************** *** 1,5 **** ! Python 1.5.2 Documentation ! !
! ! ! ! ! ! ! --- 2,28 ---- Python @RELEASE@ Documentation - @DATE@ ! ! !
! Python DocumentationModule Index
! ! ! ! ! ! ! *************** *** 29,33 ****
!

Python Documentation

--- 30,34 ----
!

Python Documentation

*************** *** 43,74 ****
--- 44,83 ---- From python-dev@python.org Fri Apr 28 18:45:30 2000 From: python-dev@python.org (Fred Drake) Date: Fri, 28 Apr 2000 13:45:30 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/html .cvsignore,1.7,1.8 Message-ID: <200004281745.NAA18694@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/html In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/html Modified Files: .cvsignore Log Message: Don't worry about the output dirs for the distutils manuals. Index: .cvsignore =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/09/24 13:48:38 1.7 --- .cvsignore 2000/04/28 17:45:27 1.8 *************** *** 6,9 **** --- 6,11 ---- ref tut + dist + inst index.html modindex.html From python-dev@python.org Fri Apr 28 19:17:26 2000 From: python-dev@python.org (Fred Drake) Date: Fri, 28 Apr 2000 14:17:26 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librobotparser.tex,1.1,1.2 Message-ID: <200004281817.OAA18950@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: librobotparser.tex Log Message: \file and \filenq should not be used in section titles; they are not sufficiently robust to survive the creation of bookmarks in the PDF format. Index: librobotparser.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/librobotparser.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** librobotparser.tex 2000/03/31 17:51:10 1.1 --- librobotparser.tex 2000/04/28 18:17:23 1.2 *************** *** 1,4 **** \section{\module{robotparser} --- ! Parser for \filenq{robots.txt}} \declaremodule{standard}{robotparser} --- 1,4 ---- \section{\module{robotparser} --- ! Parser for robots.txt} \declaremodule{standard}{robotparser} From python-dev@python.org Fri Apr 28 20:03:57 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 28 Apr 2000 15:03:57 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.130,2.131 Message-ID: <200004281903.PAA17701@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: import.c Log Message: As Marc-Andre Lemburg points out, the magic number needs to change because we've added Unicode marshalling to the repertoire. Index: import.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v retrieving revision 2.130 retrieving revision 2.131 diff -C2 -r2.130 -r2.131 *** import.c 2000/04/24 15:08:18 2.130 --- import.c 2000/04/28 19:03:54 2.131 *************** *** 85,89 **** added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (20121 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* See _PyImport_FixupExtension() below */ --- 85,89 ---- added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (50428 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* See _PyImport_FixupExtension() below */ From python-dev@python.org Fri Apr 28 21:40:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 28 Apr 2000 16:40:00 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.9,1.10 Message-ID: <200004282040.QAA18998@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory eric:/projects/python/develop/guido/src/Lib/test Modified Files: test_unicode.py Log Message: Get rid of memory leak caused by assingning sys.exc_info() to a local. Store sys.exc_info()[:2] instead. Index: test_unicode.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_unicode.py 2000/04/13 14:11:56 1.9 --- test_unicode.py 2000/04/28 20:39:58 1.10 *************** *** 17,21 **** except: value = sys.exc_type ! exc = sys.exc_info() else: exc = None --- 17,21 ---- except: value = sys.exc_type ! exc = sys.exc_info()[:2] else: exc = None *************** *** 25,29 **** print '*',f, `input`, `output`, `value` if exc: ! print ' value == %s: %s' % (exc[:2]) else: if verbose: --- 25,29 ---- print '*',f, `input`, `output`, `value` if exc: ! print ' value == %s: %s' % (exc) else: if verbose: From python-dev@python.org Sat Apr 1 05:26:00 2000 From: python-dev@python.org (Fred Drake) Date: Sat, 1 Apr 2000 00:26:00 -0500 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg.py,1.1,1.2 Message-ID: <200004010526.AAA14923@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test Modified Files: test_winreg.py Log Message: Mark Hammond: Uncomment call to delete test data when done. Index: test_winreg.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_winreg.py 2000/03/28 20:36:51 1.1 --- test_winreg.py 2000/04/01 05:25:57 1.2 *************** *** 123,127 **** WriteTestData(root_key) ReadTestData(root_key) ! # DeleteTestData(root_key) # Test on my local machine. --- 123,127 ---- WriteTestData(root_key) ReadTestData(root_key) ! DeleteTestData(root_key) # Test on my local machine. From python-dev@python.org Sun Apr 2 06:15:41 2000 From: python-dev@python.org (Andrew M. Kuchling) Date: Sun, 2 Apr 2000 00:15:41 -0500 (EST) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.1,1.2 Message-ID: <200004020515.AAA28389@amarok.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory amarok:/home/akuchlin/src/Python-1.5/Lib/test Modified Files: test_pyexpat.py Log Message: Untabified file to fix problems reported by tabnanny Index: test_pyexpat.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pyexpat.py 2000/03/31 15:44:52 1.1 --- test_pyexpat.py 2000/04/02 05:15:38 1.2 *************** *** 8,18 **** import pyexpat ! class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs ! def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 8,18 ---- import pyexpat ! class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs ! def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): *************** *** 23,46 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): ! print 'Start of CDATA section' def EndCdataSectionHandler(self): ! print 'End of CDATA section' def CommentHandler(self, text): ! print 'Comment:\n\t', repr(text) def NotationDeclHandler(self, *args): name, base, sysid, pubid = args ! print 'Notation declared:', args def UnparsedEntityDeclHandler(self, *args): --- 23,46 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): ! print 'Start of CDATA section' def EndCdataSectionHandler(self): ! print 'End of CDATA section' def CommentHandler(self, text): ! print 'Comment:\n\t', repr(text) def NotationDeclHandler(self, *args): name, base, sysid, pubid = args ! print 'Notation declared:', args def UnparsedEntityDeclHandler(self, *args): *************** *** 66,77 **** parser = pyexpat.ParserCreate(namespace_separator='!') for name in ['StartElementHandler', 'EndElementHandler', ! 'CharacterDataHandler', 'ProcessingInstructionHandler', ! 'UnparsedEntityDeclHandler', 'NotationDeclHandler', ! 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', ! 'CommentHandler', 'StartCdataSectionHandler', ! 'EndCdataSectionHandler', 'DefaultHandler', 'DefaultHandlerExpand', #'NotStandaloneHandler', ! 'ExternalEntityRefHandler' ]: setattr(parser, name, getattr(out, name) ) --- 66,77 ---- parser = pyexpat.ParserCreate(namespace_separator='!') for name in ['StartElementHandler', 'EndElementHandler', ! 'CharacterDataHandler', 'ProcessingInstructionHandler', ! 'UnparsedEntityDeclHandler', 'NotationDeclHandler', ! 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', ! 'CommentHandler', 'StartCdataSectionHandler', ! 'EndCdataSectionHandler', 'DefaultHandler', 'DefaultHandlerExpand', #'NotStandaloneHandler', ! 'ExternalEntityRefHandler' ]: setattr(parser, name, getattr(out, name) ) From python-dev@python.org Sun Apr 2 06:22:34 2000 From: python-dev@python.org (Andrew M. Kuchling) Date: Sun, 2 Apr 2000 00:22:34 -0500 (EST) Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.1,1.2 sre_compile.py,1.1,1.2 sre_constants.py,1.1,1.2 sre_parse.py,1.1,1.2 Message-ID: <200004020522.AAA28446@amarok.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory amarok:/home/akuchlin/src/Python-1.5/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: This patch looks large, but it just deletes the ^M characters and untabifies the files. No actual code changes were made. Index: sre.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre.py 2000/03/31 14:58:54 1.1 --- sre.py 2000/04/02 05:22:29 1.2 *************** *** 1,46 **** ! # -*- Mode: Python; tab-width: 4 -*- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # re-compatible interface for the sre matching engine ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! """ ! this is a long string ! """ ! ! import sre_compile ! ! # -------------------------------------------------------------------- ! # public interface ! ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) ! ! def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) ! ! def search(pattern, string, flags=0): ! assert flags == 0 ! return compile(pattern, _fixflags(flags)).search(string) ! ! # FIXME: etc ! ! # -------------------------------------------------------------------- ! # helpers ! ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert flags == 0 ! return () ! --- 1,46 ---- ! # -*- Mode: Python; tab-width: 4 -*- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.2 2000/04/02 05:22:29 akuchlin Exp $ ! # ! # re-compatible interface for the sre matching engine ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! """ ! this is a long string ! """ ! ! import sre_compile ! ! # -------------------------------------------------------------------- ! # public interface ! ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) ! ! def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) ! ! def search(pattern, string, flags=0): ! assert flags == 0 ! return compile(pattern, _fixflags(flags)).search(string) ! ! # FIXME: etc ! ! # -------------------------------------------------------------------- ! # helpers ! ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert flags == 0 ! return () ! Index: sre_compile.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_compile.py 2000/03/31 14:58:54 1.1 --- sre_compile.py 2000/04/02 05:22:30 1.2 *************** *** 1,187 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # convert template to internal format ! # ! # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: formalize (objectify?) and document the compiler code ! # format, so that other frontends can use this compiler ! ! import array, string, sys ! ! import _sre ! ! from sre_constants import * ! ! # find an array type code that matches the engine's code size ! for WORDSIZE in "BHil": ! if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break ! else: ! raise RuntimeError, "cannot find a useable array type" ! ! # FIXME: should move some optimizations from the parser to here! ! ! class Code: ! def __init__(self): ! self.data = [] ! def __len__(self): ! return len(self.data) ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def append(self, code): ! self.data.append(code) ! def todata(self): ! # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! ! def _compile(code, pattern, flags): ! append = code.append ! for op, av in pattern: ! if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! ! else: ! append(CODES[NOT_LITERAL]) ! append(10) ! elif op in (SUCCESS, FAILURE): ! append(CODES[op]) ! elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) ! elif op is BRANCH: ! append(CODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) ! code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) ! elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! else: ! append(CODES[op]) ! append(av) ! elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) ! else: ! append(CODES[op]) ! fixup = ord ! skip = len(code); append(0) ! for op, av in av: ! append(CODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! append(fixup(av)) ! elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) ! elif op is CATEGORY: ! append(CATEGORIES[av]) ! else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) ! else: ! append(CODES[op]) ! append(ord(av)) ! elif op is MARK: ! append(CODES[op]) ! append(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) ! else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) ! ! def compile(p, flags=()): ! # convert pattern list to internal format ! if type(p) is type(""): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) ! else: ! pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 1,187 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # convert template to internal format ! # ! # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: formalize (objectify?) and document the compiler code ! # format, so that other frontends can use this compiler ! ! import array, string, sys ! ! import _sre ! ! from sre_constants import * ! ! # find an array type code that matches the engine's code size ! for WORDSIZE in "BHil": ! if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break ! else: ! raise RuntimeError, "cannot find a useable array type" ! ! # FIXME: should move some optimizations from the parser to here! ! ! class Code: ! def __init__(self): ! self.data = [] ! def __len__(self): ! return len(self.data) ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def append(self, code): ! self.data.append(code) ! def todata(self): ! # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! ! def _compile(code, pattern, flags): ! append = code.append ! for op, av in pattern: ! if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! ! else: ! append(CODES[NOT_LITERAL]) ! append(10) ! elif op in (SUCCESS, FAILURE): ! append(CODES[op]) ! elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) ! elif op is BRANCH: ! append(CODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) ! code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) ! elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! else: ! append(CODES[op]) ! append(av) ! elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) ! else: ! append(CODES[op]) ! fixup = ord ! skip = len(code); append(0) ! for op, av in av: ! append(CODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! append(fixup(av)) ! elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) ! elif op is CATEGORY: ! append(CATEGORIES[av]) ! else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) ! else: ! append(CODES[op]) ! append(ord(av)) ! elif op is MARK: ! append(CODES[op]) ! append(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) ! else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) ! ! def compile(p, flags=()): ! # convert pattern list to internal format ! if type(p) is type(""): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) ! else: ! pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) Index: sre_constants.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_constants.py 2000/03/31 14:58:54 1.1 --- sre_constants.py 2000/04/02 05:22:30 1.2 *************** *** 1,131 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # various symbols used by the regular expression engine. ! # run this script to update the _sre include files! ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # operators ! ! FAILURE = "failure" ! SUCCESS = "success" ! ! ANY = "any" ! ASSERT = "assert" ! AT = "at" ! BRANCH = "branch" ! CALL = "call" ! CATEGORY = "category" ! GROUP = "group" ! GROUP_IGNORE = "group_ignore" ! IN = "in" ! IN_IGNORE = "in_ignore" ! JUMP = "jump" ! LITERAL = "literal" ! LITERAL_IGNORE = "literal_ignore" ! MARK = "mark" ! MAX_REPEAT = "max_repeat" ! MAX_REPEAT_ONE = "max_repeat_one" ! MAX_UNTIL = "max_until" ! MIN_REPEAT = "min_repeat" ! MIN_UNTIL = "min_until" ! NEGATE = "negate" ! NOT_LITERAL = "not_literal" ! NOT_LITERAL_IGNORE = "not_literal_ignore" ! RANGE = "range" ! REPEAT = "repeat" ! SUBPATTERN = "subpattern" ! ! # positions ! AT_BEGINNING = "at_beginning" ! AT_BOUNDARY = "at_boundary" ! AT_NON_BOUNDARY = "at_non_boundary" ! AT_END = "at_end" ! ! # categories ! ! CATEGORY_DIGIT = "category_digit" ! CATEGORY_NOT_DIGIT = "category_not_digit" ! CATEGORY_SPACE = "category_space" ! CATEGORY_NOT_SPACE = "category_not_space" ! CATEGORY_WORD = "category_word" ! CATEGORY_NOT_WORD = "category_not_word" ! ! CODES = [ ! ! # failure=0 success=1 (just because it looks better that way :-) ! FAILURE, SUCCESS, ! ! ANY, ! ASSERT, ! AT, ! BRANCH, ! CALL, ! CATEGORY, ! GROUP, GROUP_IGNORE, ! IN, IN_IGNORE, ! JUMP, ! LITERAL, LITERAL_IGNORE, ! MARK, ! MAX_REPEAT, MAX_UNTIL, ! MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, ! NOT_LITERAL, NOT_LITERAL_IGNORE, ! NEGATE, ! RANGE, ! REPEAT ! ! ] ! ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c ! ! # replacement operations for "ignore case" mode ! MAP_IGNORE = { ! GROUP: GROUP_IGNORE, ! IN: IN_IGNORE, ! LITERAL: LITERAL_IGNORE, ! NOT_LITERAL: NOT_LITERAL_IGNORE ! } ! ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), ! } ! ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), ! } ! ! if __name__ == "__main__": ! import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") ! f.close() ! print "done" --- 1,131 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # various symbols used by the regular expression engine. ! # run this script to update the _sre include files! ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # operators ! ! FAILURE = "failure" ! SUCCESS = "success" ! ! ANY = "any" ! ASSERT = "assert" ! AT = "at" ! BRANCH = "branch" ! CALL = "call" ! CATEGORY = "category" ! GROUP = "group" ! GROUP_IGNORE = "group_ignore" ! IN = "in" ! IN_IGNORE = "in_ignore" ! JUMP = "jump" ! LITERAL = "literal" ! LITERAL_IGNORE = "literal_ignore" ! MARK = "mark" ! MAX_REPEAT = "max_repeat" ! MAX_REPEAT_ONE = "max_repeat_one" ! MAX_UNTIL = "max_until" ! MIN_REPEAT = "min_repeat" ! MIN_UNTIL = "min_until" ! NEGATE = "negate" ! NOT_LITERAL = "not_literal" ! NOT_LITERAL_IGNORE = "not_literal_ignore" ! RANGE = "range" ! REPEAT = "repeat" ! SUBPATTERN = "subpattern" ! ! # positions ! AT_BEGINNING = "at_beginning" ! AT_BOUNDARY = "at_boundary" ! AT_NON_BOUNDARY = "at_non_boundary" ! AT_END = "at_end" ! ! # categories ! ! CATEGORY_DIGIT = "category_digit" ! CATEGORY_NOT_DIGIT = "category_not_digit" ! CATEGORY_SPACE = "category_space" ! CATEGORY_NOT_SPACE = "category_not_space" ! CATEGORY_WORD = "category_word" ! CATEGORY_NOT_WORD = "category_not_word" ! ! CODES = [ ! ! # failure=0 success=1 (just because it looks better that way :-) ! FAILURE, SUCCESS, ! ! ANY, ! ASSERT, ! AT, ! BRANCH, ! CALL, ! CATEGORY, ! GROUP, GROUP_IGNORE, ! IN, IN_IGNORE, ! JUMP, ! LITERAL, LITERAL_IGNORE, ! MARK, ! MAX_REPEAT, MAX_UNTIL, ! MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, ! NOT_LITERAL, NOT_LITERAL_IGNORE, ! NEGATE, ! RANGE, ! REPEAT ! ! ] ! ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c ! ! # replacement operations for "ignore case" mode ! MAP_IGNORE = { ! GROUP: GROUP_IGNORE, ! IN: IN_IGNORE, ! LITERAL: LITERAL_IGNORE, ! NOT_LITERAL: NOT_LITERAL_IGNORE ! } ! ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), ! } ! ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), ! } ! ! if __name__ == "__main__": ! import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") ! f.close() ! print "done" Index: sre_parse.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_parse.py 2000/03/31 14:58:54 1.1 --- sre_parse.py 2000/04/02 05:22:30 1.2 *************** *** 1,492 **** ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_parse.py,v 1.1 2000/03/31 14:58:54 guido Exp $ ! # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: comments marked with the FIXME tag are open issues. all such ! # issues should be closed before the final beta. ! ! import string, sys ! ! from sre_constants import * ! ! SPECIAL_CHARS = ".\\[{()*+?^$|" ! REPEAT_CHARS = "*+?{" ! ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! ! ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) ! } ! ! CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string ! } ! ! class Pattern: ! # FIXME: rename class, and store flags in here too! ! def __init__(self): ! self.flags = [] ! self.groups = 1 ! self.groupdict = {} ! def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid ! return gid ! def setflag(self, flag): ! if flag not in self.flags: ! self.flags.append(flag) ! ! class SubPattern: ! # a subpattern, in intermediate form ! def __init__(self, pattern, data=None): ! self.pattern = pattern ! if not data: ! data = [] ! self.data = data ! self.flags = [] ! self.width = None ! def __repr__(self): ! return repr(self.data) ! def __len__(self): ! return len(self.data) ! def __delitem__(self, index): ! del self.data[index] ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def __getslice__(self, start, stop): ! return SubPattern(self.pattern, self.data[start:stop]) ! def insert(self, index, code): ! self.data.insert(index, code) ! def append(self, code): ! self.data.append(code) ! def getwidth(self): ! # determine the width (min, max) for this subpattern ! if self.width: ! return self.width ! lo = hi = 0L ! for op, av in self.data: ! if op is BRANCH: ! l = sys.maxint ! h = 0 ! for av in av[1]: ! i, j = av.getwidth() ! l = min(l, i) ! h = min(h, j) ! lo = lo + i ! hi = hi + j ! elif op is CALL: ! i, j = av.getwidth() ! lo = lo + i ! hi = hi + j ! elif op is SUBPATTERN: ! i, j = av[1].getwidth() ! lo = lo + i ! hi = hi + j ! elif op in (MIN_REPEAT, MAX_REPEAT): ! i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] ! elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): ! lo = lo + 1 ! hi = hi + 1 ! elif op == SUCCESS: ! break ! self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) ! return self.width ! def set(self, flag): ! if not flag in self.flags: ! self.flags.append(flag) ! def reset(self, flag): ! if flag in self.flags: ! self.flags.remove(flag) ! ! class Tokenizer: ! def __init__(self, string): ! self.string = list(string) ! self.next = self.__next() ! def __next(self): ! if not self.string: ! return None ! char = self.string[0] ! if char[0] == "\\": ! try: ! c = self.string[1] ! except IndexError: ! raise SyntaxError, "bogus escape" ! char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if c not in HEXDIGITS: ! break ! char = char + c ! elif c in string.digits: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if c not in string.digits: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] ! return char ! def match(self, char): ! if char == self.next: ! self.next = self.__next() ! return 1 ! return 0 ! def match_set(self, set): ! if self.next in set: ! self.next = self.__next() ! return 1 ! return 0 ! def get(self): ! this = self.next ! self.next = self.__next() ! return this ! ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass ! try: ! if escape[1:2] == "x": ! escape = escape[2:] ! return LITERAL, chr(string.atoi(escape[-2:], 16) & 0xff) ! elif escape[1:2] in string.digits: ! return LITERAL, chr(string.atoi(escape[1:], 8) & 0xff) ! elif len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _branch(subpattern, items): ! ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) ! ! # check if all items share a common prefix ! while 1: ! prefix = None ! for item in items: ! if not item: ! break ! if prefix is None: ! prefix = item[0] ! elif item[0] != prefix: ! break ! else: ! # all subitems start with a common "prefix". ! # move it out of the branch ! for item in items: ! del item[0] ! subpattern.append(prefix) ! continue # check next one ! break ! ! # check if the branch can be replaced by a character set ! for item in items: ! if len(item) != 1 or item[0][0] != LITERAL: ! break ! else: ! # we can store this as a character set instead of a ! # branch (FIXME: use a range if possible) ! set = [] ! for item in items: ! set.append(item[0]) ! subpattern.append((IN, set)) ! return ! ! subpattern.append((BRANCH, (None, items))) ! ! def _parse(source, pattern, flags=()): ! ! # parse regular expression pattern into an operator list. ! ! subpattern = SubPattern(pattern) ! ! this = None ! ! while 1: ! ! if source.next in ("|", ")"): ! break # end of subpattern ! this = source.get() ! if this is None: ! break # end of pattern ! ! if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) ! ! elif this == "[": ! # character set ! set = [] ! ## if source.match(":"): ! ## pass # handle character classes ! if source.match("^"): ! set.append((NEGATE, None)) ! # check remaining characters ! start = set[:] ! while 1: ! this = source.get() ! if this == "]" and set != start: ! break ! elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) ! elif this: ! code1 = LITERAL, this ! else: ! raise SyntaxError, "unexpected end of regular expression" ! if source.match("-"): ! # potential range ! this = source.get() ! if this == "]": ! set.append(code1) ! set.append((LITERAL, "-")) ! break ! else: ! if this[0] == "\\": ! code2 = _fixescape(this, 1) ! else: ! code2 = LITERAL, this ! if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" ! if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" ! set.append((RANGE, (code1[1], code2[1]))) ! else: ! if code1[0] is IN: ! code1 = code1[1][0] ! set.append(code1) ! ! # FIXME: move set optimization to support function ! if len(set)==1 and set[0][0] is LITERAL: ! subpattern.append(set[0]) # optimization ! elif len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: ! subpattern.append((NOT_LITERAL, set[1][1])) # optimization ! else: ! # FIXME: add charmap optimization ! subpattern.append((IN, set)) ! ! elif this and this[0] in REPEAT_CHARS: ! # repeat previous item ! if this == "?": ! min, max = 0, 1 ! elif this == "*": ! min, max = 0, sys.maxint ! elif this == "+": ! min, max = 1, sys.maxint ! elif this == "{": ! min, max = 0, sys.maxint ! lo = hi = "" ! while source.next in string.digits: ! lo = lo + source.get() ! if source.match(","): ! while source.next in string.digits: ! hi = hi + source.get() ! else: ! hi = lo ! if not source.match("}"): ! raise SyntaxError, "bogus range" ! if lo: ! min = int(lo) ! if hi: ! max = int(hi) ! # FIXME: check that hi >= lo! ! else: ! raise SyntaxError, "not supported" ! # figure out which item to repeat ! # FIXME: should back up to the right mark, right? ! if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] ! else: ! raise SyntaxError, "nothing to repeat" ! if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) ! else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": ! subpattern.append((ANY, None)) ! elif this == "(": ! group = 1 ! name = None ! if source.match("?"): ! group = 0 ! # options ! if source.match("P"): ! # named group: skip forward to end of name ! if source.match("<"): ! name = "" ! while 1: ! char = source.get() ! if char in (">", None): ! break ! name = name + char ! group = 1 ! elif source.match(":"): ! # non-capturing group ! group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") ! if group: ! # parse group contents ! b = [] ! if group == 2: ! # anonymous group ! group = None ! else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) ! while 1: ! p = _parse(source, pattern, flags) ! if source.match(")"): ! if b: ! b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) ! break ! elif source.match("|"): ! b.append(p) ! else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) ! else: ! # FIXME: should this really be a while loop? ! while source.get() not in (")", None): ! pass ! ! elif this == "^": ! subpattern.append((AT, AT_BEGINNING)) ! ! elif this == "$": ! subpattern.append((AT, AT_END)) ! ! elif this and this[0] == "\\": ! code =_fixescape(this) ! subpattern.append(code) ! ! else: ! raise SyntaxError, "parser error" ! ! return subpattern ! ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() ! b = [] ! while 1: ! p = _parse(s, g, flags) ! tail = s.get() ! if tail == "|": ! b.append(p) ! elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" ! elif tail is None: ! if b: ! b.append(p) ! p = SubPattern(g) ! _branch(p, b) ! break ! else: ! raise SyntaxError, "bogus characters at end of regular expression" ! return p ! ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" ! --- 1,492 ---- ! # ! # Secret Labs' Regular Expression Engine ! # $Id: sre_parse.py,v 1.2 2000/04/02 05:22:30 akuchlin Exp $ ! # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. ! # ! # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. ! # ! # This code can only be used for 1.6 alpha testing. All other use ! # require explicit permission from Secret Labs AB. ! # ! # Portions of this engine have been developed in cooperation with ! # CNRI. Hewlett-Packard provided funding for 1.6 integration and ! # other compatibility work. ! # ! ! # FIXME: comments marked with the FIXME tag are open issues. all such ! # issues should be closed before the final beta. ! ! import string, sys ! ! from sre_constants import * ! ! SPECIAL_CHARS = ".\\[{()*+?^$|" ! REPEAT_CHARS = "*+?{" ! ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! ! ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) ! } ! ! CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string ! } ! ! class Pattern: ! # FIXME: rename class, and store flags in here too! ! def __init__(self): ! self.flags = [] ! self.groups = 1 ! self.groupdict = {} ! def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid ! return gid ! def setflag(self, flag): ! if flag not in self.flags: ! self.flags.append(flag) ! ! class SubPattern: ! # a subpattern, in intermediate form ! def __init__(self, pattern, data=None): ! self.pattern = pattern ! if not data: ! data = [] ! self.data = data ! self.flags = [] ! self.width = None ! def __repr__(self): ! return repr(self.data) ! def __len__(self): ! return len(self.data) ! def __delitem__(self, index): ! del self.data[index] ! def __getitem__(self, index): ! return self.data[index] ! def __setitem__(self, index, code): ! self.data[index] = code ! def __getslice__(self, start, stop): ! return SubPattern(self.pattern, self.data[start:stop]) ! def insert(self, index, code): ! self.data.insert(index, code) ! def append(self, code): ! self.data.append(code) ! def getwidth(self): ! # determine the width (min, max) for this subpattern ! if self.width: ! return self.width ! lo = hi = 0L ! for op, av in self.data: ! if op is BRANCH: ! l = sys.maxint ! h = 0 ! for av in av[1]: ! i, j = av.getwidth() ! l = min(l, i) ! h = min(h, j) ! lo = lo + i ! hi = hi + j ! elif op is CALL: ! i, j = av.getwidth() ! lo = lo + i ! hi = hi + j ! elif op is SUBPATTERN: ! i, j = av[1].getwidth() ! lo = lo + i ! hi = hi + j ! elif op in (MIN_REPEAT, MAX_REPEAT): ! i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] ! elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): ! lo = lo + 1 ! hi = hi + 1 ! elif op == SUCCESS: ! break ! self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) ! return self.width ! def set(self, flag): ! if not flag in self.flags: ! self.flags.append(flag) ! def reset(self, flag): ! if flag in self.flags: ! self.flags.remove(flag) ! ! class Tokenizer: ! def __init__(self, string): ! self.string = list(string) ! self.next = self.__next() ! def __next(self): ! if not self.string: ! return None ! char = self.string[0] ! if char[0] == "\\": ! try: ! c = self.string[1] ! except IndexError: ! raise SyntaxError, "bogus escape" ! char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if c not in HEXDIGITS: ! break ! char = char + c ! elif c in string.digits: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if c not in string.digits: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] ! return char ! def match(self, char): ! if char == self.next: ! self.next = self.__next() ! return 1 ! return 0 ! def match_set(self, set): ! if self.next in set: ! self.next = self.__next() ! return 1 ! return 0 ! def get(self): ! this = self.next ! self.next = self.__next() ! return this ! ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass ! try: ! if escape[1:2] == "x": ! escape = escape[2:] ! return LITERAL, chr(string.atoi(escape[-2:], 16) & 0xff) ! elif escape[1:2] in string.digits: ! return LITERAL, chr(string.atoi(escape[1:], 8) & 0xff) ! elif len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _branch(subpattern, items): ! ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) ! ! # check if all items share a common prefix ! while 1: ! prefix = None ! for item in items: ! if not item: ! break ! if prefix is None: ! prefix = item[0] ! elif item[0] != prefix: ! break ! else: ! # all subitems start with a common "prefix". ! # move it out of the branch ! for item in items: ! del item[0] ! subpattern.append(prefix) ! continue # check next one ! break ! ! # check if the branch can be replaced by a character set ! for item in items: ! if len(item) != 1 or item[0][0] != LITERAL: ! break ! else: ! # we can store this as a character set instead of a ! # branch (FIXME: use a range if possible) ! set = [] ! for item in items: ! set.append(item[0]) ! subpattern.append((IN, set)) ! return ! ! subpattern.append((BRANCH, (None, items))) ! ! def _parse(source, pattern, flags=()): ! ! # parse regular expression pattern into an operator list. ! ! subpattern = SubPattern(pattern) ! ! this = None ! ! while 1: ! ! if source.next in ("|", ")"): ! break # end of subpattern ! this = source.get() ! if this is None: ! break # end of pattern ! ! if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) ! ! elif this == "[": ! # character set ! set = [] ! ## if source.match(":"): ! ## pass # handle character classes ! if source.match("^"): ! set.append((NEGATE, None)) ! # check remaining characters ! start = set[:] ! while 1: ! this = source.get() ! if this == "]" and set != start: ! break ! elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) ! elif this: ! code1 = LITERAL, this ! else: ! raise SyntaxError, "unexpected end of regular expression" ! if source.match("-"): ! # potential range ! this = source.get() ! if this == "]": ! set.append(code1) ! set.append((LITERAL, "-")) ! break ! else: ! if this[0] == "\\": ! code2 = _fixescape(this, 1) ! else: ! code2 = LITERAL, this ! if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" ! if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" ! set.append((RANGE, (code1[1], code2[1]))) ! else: ! if code1[0] is IN: ! code1 = code1[1][0] ! set.append(code1) ! ! # FIXME: move set optimization to support function ! if len(set)==1 and set[0][0] is LITERAL: ! subpattern.append(set[0]) # optimization ! elif len(set)==2 and set[0][0] is NEGATE and set[1][0] is LITERAL: ! subpattern.append((NOT_LITERAL, set[1][1])) # optimization ! else: ! # FIXME: add charmap optimization ! subpattern.append((IN, set)) ! ! elif this and this[0] in REPEAT_CHARS: ! # repeat previous item ! if this == "?": ! min, max = 0, 1 ! elif this == "*": ! min, max = 0, sys.maxint ! elif this == "+": ! min, max = 1, sys.maxint ! elif this == "{": ! min, max = 0, sys.maxint ! lo = hi = "" ! while source.next in string.digits: ! lo = lo + source.get() ! if source.match(","): ! while source.next in string.digits: ! hi = hi + source.get() ! else: ! hi = lo ! if not source.match("}"): ! raise SyntaxError, "bogus range" ! if lo: ! min = int(lo) ! if hi: ! max = int(hi) ! # FIXME: check that hi >= lo! ! else: ! raise SyntaxError, "not supported" ! # figure out which item to repeat ! # FIXME: should back up to the right mark, right? ! if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] ! else: ! raise SyntaxError, "nothing to repeat" ! if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) ! else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": ! subpattern.append((ANY, None)) ! elif this == "(": ! group = 1 ! name = None ! if source.match("?"): ! group = 0 ! # options ! if source.match("P"): ! # named group: skip forward to end of name ! if source.match("<"): ! name = "" ! while 1: ! char = source.get() ! if char in (">", None): ! break ! name = name + char ! group = 1 ! elif source.match(":"): ! # non-capturing group ! group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") ! if group: ! # parse group contents ! b = [] ! if group == 2: ! # anonymous group ! group = None ! else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) ! while 1: ! p = _parse(source, pattern, flags) ! if source.match(")"): ! if b: ! b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) ! break ! elif source.match("|"): ! b.append(p) ! else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) ! else: ! # FIXME: should this really be a while loop? ! while source.get() not in (")", None): ! pass ! ! elif this == "^": ! subpattern.append((AT, AT_BEGINNING)) ! ! elif this == "$": ! subpattern.append((AT, AT_END)) ! ! elif this and this[0] == "\\": ! code =_fixescape(this) ! subpattern.append(code) ! ! else: ! raise SyntaxError, "parser error" ! ! return subpattern ! ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() ! b = [] ! while 1: ! p = _parse(s, g, flags) ! tail = s.get() ! if tail == "|": ! b.append(p) ! elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" ! elif tail is None: ! if b: ! b.append(p) ! p = SubPattern(g) ! _branch(p, b) ! break ! else: ! raise SyntaxError, "bogus characters at end of regular expression" ! return p ! ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" ! From python-dev@python.org Mon Apr 3 04:51:52 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:52 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib UserString.py,NONE,1.1 Message-ID: <200004030351.XAA07636@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib Added Files: UserString.py Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:52 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:52 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_userstring.py,NONE,1.1 Message-ID: <200004030351.XAA07640@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test Added Files: test_userstring.py Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:53 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:53 -0400 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_userstring,NONE,1.1 Message-ID: <200004030351.XAA07648@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test/output In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Lib/test/output Added Files: test_userstring Log Message: UserString class from Peter Funk . From python-dev@python.org Mon Apr 3 04:51:53 2000 From: python-dev@python.org (Fred Drake) Date: Sun, 2 Apr 2000 23:51:53 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libuserdict.tex,1.12,1.13 Message-ID: <200004030351.XAA07654@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: libuserdict.tex Log Message: UserString class from Peter Funk . Index: libuserdict.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** libuserdict.tex 1999/07/26 15:45:52 1.12 --- libuserdict.tex 2000/04/03 03:51:50 1.13 *************** *** 64,65 **** --- 64,114 ---- \class{UserList} class. \end{memberdesc} + + + \section{\module{UserString} --- + Class wrapper for string objects} + + \declaremodule{standard}{UserString} + \modulesynopsis{Class wrapper for string objects.} + \moduleauthor{Peter Funk}{pf@artcom-gmbh.de} + \sectionauthor{Peter Funk}{pf@artcom-gmbh.de} + + This module defines a class that acts as a wrapper around + string objects. It is a useful base class for + your own string-like classes, which can inherit from + them and override existing methods or add new ones. In this way one + can add new behaviours to strings. + + The \module{UserString} module defines the \class{UserString} class: + + \begin{classdesc}{UserString}{\optional{sequence}} + Return a class instance that simulates a string or an unicode string object. + The instance's content is kept in a regular string or unicode string + object, which is accessible via the + \member{data} attribute of \class{UserString} instances. The instance's + contents are initially set to a copy of \var{sequence}. + \var{sequence} can be either a regular Python string or unicode string, + an instance of \class{UserString} (or a subclass) or an arbitrary sequence + which can be converted into a string. + supporting. + \end{classdesc} + + In addition to supporting the methods and operations of string or + unicode objects (see section \ref{typesseq}), \class{UserString} instances + provide the following attribute: + + \begin{memberdesc}{data} + A real Python string or unicode object used to store the content of the + \class{UserString} class. + \end{memberdesc} + + \begin{classdesc}{MutableString}{\optional{sequence}} + This class is derived from the \class{UserString} above and redefines + strings to be \emph{mutable}. Mutable strings can't be used as + dictionary keys, because dictionaries require \emph{immutable} objects as + keys. The main intention of this class is to serve as an educational + example for inheritance and necessity to remove (override) the + \function{__hash__} method in order to trap attempts to use a + mutable object as dictionary key, which would be otherwise very + errorprone and hard to track down. + \end{classdesc} From python-dev@python.org Mon Apr 3 05:13:51 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:13:51 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.39,1.40 ltxmarkup.sty,1.3,1.4 python.sty,1.54,1.55 Message-ID: <200004030413.AAA08320@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/texinputs In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/texinputs Modified Files: boilerplate.tex ltxmarkup.sty python.sty Log Message: Merged changes from the 1.5.2p2 release. Index: boilerplate.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** boilerplate.tex 2000/02/22 18:20:03 1.39 --- boilerplate.tex 2000/04/03 04:13:48 1.40 *************** *** 2,7 **** \authoraddress{ ! Corporation for National Research Initiatives (CNRI) \\ ! 1895 Preston White Drive, Reston, Va 20191, USA \\ E-mail: \email{guido@python.org} } --- 2,7 ---- \authoraddress{ ! Corporation for National Research Initiatives \\ ! 1895 Preston White Drive, Reston, VA 20191, USA \\ E-mail: \email{guido@python.org} } Index: ltxmarkup.sty =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/ltxmarkup.sty,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ltxmarkup.sty 1999/04/23 14:44:53 1.3 --- ltxmarkup.sty 2000/04/03 04:13:48 1.4 *************** *** 19,23 **** \let\p=\py@ltx@param% #2}}] ! %\item[\code{\e end\{{\bfseries #1}\}}] \index{#1 environment@\idxcode{#1} environment} \index{environments!#1@\idxcode{#1}} --- 19,23 ---- \let\p=\py@ltx@param% #2}}] ! \item[\code{\e end\{{\bfseries #1}\}}] \index{#1 environment@\idxcode{#1} environment} \index{environments!#1@\idxcode{#1}} Index: python.sty =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** python.sty 1999/11/09 17:02:11 1.54 --- python.sty 2000/04/03 04:13:48 1.55 *************** *** 278,288 **** % Additional string for an index entry ! \newcommand{\index@subitem}{} ! \newcommand{\setindexsubitem}[1]{\renewcommand{\index@subitem}{#1}} ! \newcommand{\ttindex}[1]{\index{#1@{\py@idxcode{#1}} \index@subitem}} ! \newcommand{\withsubitem}[2]{% \begingroup% ! \def\index@subitem{#1}#2% \endgroup% } --- 278,300 ---- % Additional string for an index entry ! \newif\ifpy@usingsubitem\py@usingsubitemfalse ! \newcommand{\py@indexsubitem}{} ! \newcommand{\setindexsubitem}[1]{\renewcommand{\py@indexsubitem}{ #1}% ! \py@usingsubitemtrue} ! \newcommand{\ttindex}[1]{% ! \ifpy@usingsubitem ! \index{#1@{\py@idxcode{#1}}\py@indexsubitem}% ! \else% ! \index{#1@{\py@idxcode{#1}}}% ! \fi% ! } \newcommand{\withsubitem}[2]{% \begingroup% ! \ifpy@usingsubitem% ! \def\index@subitem{#1}#2% ! \else% ! \def\index@subitem{#1}#2% ! \py@usingsubitemfalse% ! \fi \endgroup% } *************** *** 422,425 **** --- 434,438 ---- \newcommand{\py@reset}{ + \py@usingsubitemfalse \py@ProcessModSynopsis \renewcommand{\py@thisclass}{} *************** *** 511,522 **** % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} % \newcommand{\optional}[1]{% {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} % C functions ------------------------------------------------------------ ! % \begin{cfuncdesc}{type}{name}{arglist} ! \newenvironment{cfuncdesc}[3]{ ! \begin{fulllineitems} ! \item[\code{#1 \bfcode{#2}(\py@varvars{#3})}\index{#2@{\py@idxcode{#2()}}}] }{\end{fulllineitems}} --- 524,551 ---- % \begin{funcdesc}{myfunc}{\optional{parm1\optional{, parm2}}} % + \let\py@badkey=\@undefined + \newcommand{\optional}[1]{% {\textnormal{\Large[}}{#1}\hspace{0.5mm}{\textnormal{\Large]}}} + % This can be used when a function or method accepts an varying number + % of arguments, such as by using the *args syntax in the parameter list. + \newcommand{\py@moreargs}{...} + + % This can be used when you don't want to document the parameters to a + % function or method, but simply state that it's an alias for + % something else. + \newcommand{\py@unspecified}{...} + % C functions ------------------------------------------------------------ ! % \begin{cfuncdesc}[refcount]{type}{name}{arglist} ! % Note that the [refcount] slot should only be filled in by ! % tools/anno-api.py; it pulls the value from the refcounts database. ! \newenvironment{cfuncdesc}[4][\py@badkey]{ ! \begin{fulllineitems} ! \item[\code{#2 \bfcode{#3}(\py@varvars{#4})}\index{#3@{\py@idxcode{#3()}}}] ! \ifx#1\@undefined\else% ! \emph{Return value: \textbf{#1 reference}.}\\ ! \fi }{\end{fulllineitems}} *************** *** 529,536 **** % C data types ----------------------------------------------------------- ! % \begin{ctypedesc}{typedef name} ! \newenvironment{ctypedesc}[1]{ \begin{fulllineitems} ! \item[\bfcode{#1}\ttindex{#1}] }{\end{fulllineitems}} --- 558,578 ---- % C data types ----------------------------------------------------------- ! % \begin{ctypedesc}[index name]{typedef name} ! \newenvironment{ctypedesc}[2][\py@badkey]{ \begin{fulllineitems} ! \item[\bfcode{#2}% ! \ifx#1\@undefined% ! \withsubitem{(C type)}{\ttindex{#2}}% ! \else% ! \withsubitem{(C type)}{\ttindex{#1}}% ! \fi] ! }{\end{fulllineitems}} ! ! % Funky macros ----------------------------------------------------------- ! % \begin{csimplemacro}{name} ! % -- "simple" because it has no args; NOT for constant definitions! ! \newenvironment{csimplemacrodesc}[1]{ ! \begin{fulllineitems} ! \item[\bfcode{#1}\withsubitem{(macro)}{\ttindex{#1}}] }{\end{fulllineitems}} *************** *** 709,713 **** \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} ! \newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} % let's see if this breaks anything now; we may be able to simplify... \renewcommand{\py@varvars}[1]{\var{#1}} --- 751,759 ---- \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} ! %\newcommand{\py@varvars}[1]{{\def\,{\/{\char`\,}}\var{#1}}} ! \newcommand{\py@varvars}[1]{% ! {\let\unspecified=\py@unspecified% ! \let\moreargs=\py@moreargs% ! \def\,{\/{\char`\,}}\var{#1}}} % let's see if this breaks anything now; we may be able to simplify... \renewcommand{\py@varvars}[1]{\var{#1}} From python-dev@python.org Mon Apr 3 05:15:48 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:15:48 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools node2label.pl,1.9,1.10 Message-ID: <200004030415.AAA08371@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tools In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tools Modified Files: node2label.pl Log Message: Merged changes from the 1.5.2p2 release. Index: node2label.pl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/node2label.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** node2label.pl 1999/02/10 17:08:00 1.9 --- node2label.pl 2000/04/03 04:15:46 1.10 *************** *** 33,46 **** # don't want to do one s/// per line per node # so look for lines with hrefs, then do s/// on nodes present ! if (/(HREF|href)=\"([^\#\"]*)html[\#\"]/) { ! @parts = split(/(HREF|href)\=\"/); shift @parts; for $node (@parts) { ! $node =~ s/[\#\"].*$//g; chop($node); if (defined($nodes{$node})) { $label = $nodes{$node}; ! if (s/(HREF|href)=\"$node([\#\"])/$1=\"$label.html$2/g) { ! s/(HREF|href)=\"$label.html#(l2h-)?SECTION\d+/$1=\"$label.html/g; $newnames{$node} = "$label.html"; } --- 33,46 ---- # don't want to do one s/// per line per node # so look for lines with hrefs, then do s/// on nodes present ! if (/(HREF|href)=[\"\']([^\#\"\']*)html[\#\"\']/) { ! @parts = split(/(HREF|href)\=[\"\']/); shift @parts; for $node (@parts) { ! $node =~ s/[\#\"\'].*$//g; chop($node); if (defined($nodes{$node})) { $label = $nodes{$node}; ! if (s/(HREF|href)=([\"\'])$node([\#\"\'])/href=$2$label.html$3/g) { ! s/(HREF|href)=([\"\'])$label.html/href=$2$label.html/g; $newnames{$node} = "$label.html"; } From python-dev@python.org Mon Apr 3 05:19:17 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:19:17 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools buildindex.py,1.10,1.11 getpagecounts,1.5,1.6 mkdvi.sh,1.7,1.8 mkhowto,1.7,1.8 mkhtml.sh,1.11,1.12 mkmodindex,1.4,1.5 mksourcepkg,1.1,1.2 Message-ID: <200004030419.AAA08465@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tools In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tools Modified Files: buildindex.py getpagecounts mkdvi.sh mkhowto mkhtml.sh mkmodindex mksourcepkg Log Message: Merged changes from the 1.5.2p2 release. Index: buildindex.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/buildindex.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** buildindex.py 1999/02/24 16:36:48 1.10 --- buildindex.py 2000/04/03 04:19:14 1.11 *************** *** 1,5 **** #! /usr/bin/env python ! __version__ = '$Revision: 1.10 $' import os --- 1,5 ---- #! /usr/bin/env python ! __version__ = '$Revision: 1.11 $' import os *************** *** 12,15 **** --- 12,17 ---- __rmjunk = re.compile("<#\d+#>") + continuation = 0 + def __init__(self, link, str, seqno): self.links = [link] *************** *** 78,82 **** ! _rmtt = re.compile(r"(.*)(.*)(.*)$", re.IGNORECASE) _rmparens = re.compile(r"\(\)") --- 80,84 ---- ! _rmtt = re.compile(r"""(.*)(.*)(.*)$""", re.IGNORECASE) _rmparens = re.compile(r"\(\)") *************** *** 176,179 **** --- 178,197 ---- end = start + colheight cols.append(nodes[start:end]) + # + # If items continue across columns, make sure they are marked + # as continuations so the user knows to look at the previous column. + # + for i in range(len(cols) - 1): + try: + prev = cols[i][-1] + next = cols[i + 1][0] + except IndexError: + return cols + else: + n = min(len(prev.key), len(next.key)) + for j in range(n): + if prev.key[j] != next.key[j]: + break + next.continuation = j + 1 return cols *************** *** 205,210 **** term = node.text[i] level = level + 1 ! append("\n
%s\n
\n%s
" ! % (term, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" % (level * DL_LEVEL_INDENT, node.links[0], node.text[-1])) --- 223,232 ---- term = node.text[i] level = level + 1 ! if node.continuation > i: ! extra = " (continued)" ! else: ! extra = "" ! append("\n
%s%s\n
\n%s
" ! % (term, extra, level * DL_LEVEL_INDENT)) append("\n%s
%s%s" % (level * DL_LEVEL_INDENT, node.links[0], node.text[-1])) Index: getpagecounts =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/getpagecounts,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** getpagecounts 1999/08/03 17:54:39 1.5 --- getpagecounts 2000/04/03 04:19:14 1.6 *************** *** 4,8 **** """Generate a page count report of the PostScript version of the manuals.""" ! __version__ = '$Revision: 1.5 $' --- 4,8 ---- """Generate a page count report of the PostScript version of the manuals.""" ! __version__ = '$Revision: 1.6 $' *************** *** 44,48 **** This is the PostScript version of the standard Python documentation. If you plan to print this, be aware that some of the documents are ! long. The following manuals are included: """ SUFFIX = """\ --- 44,55 ---- This is the PostScript version of the standard Python documentation. If you plan to print this, be aware that some of the documents are ! long. It is formatted for printing on two-sided paper; if you do plan ! to print this, *please* print two-sided if you have a printer capable ! of it! To locate published copies of the larger manuals, or other ! Python reference material, consult the PSA Online Bookstore at: ! ! http://www.python.org/psa/bookstore/ ! ! The following manuals are included: """ SUFFIX = """\ *************** *** 51,54 **** --- 58,67 ---- If you have any questions, comments, or suggestions regarding these documents, please send them via email to python-docs@python.org. + + If you would like to support the development and maintenance of + documentation for Python, please consider joining the Python Software + Activity (PSA; see http://www.python.org/psa/), or urging your + organization to join the PSA or the Python Consortium (see + http://www.python.org/consortium/). """ Index: mkdvi.sh =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkdvi.sh,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mkdvi.sh 1999/04/14 13:13:32 1.7 --- mkdvi.sh 2000/04/03 04:19:14 1.8 *************** *** 35,39 **** part=$1; shift 1 ! TEXINPUTS=$srcdir/$part:$TEXINPUTS export TEXINPUTS --- 35,39 ---- part=$1; shift 1 ! TEXINPUTS=.:$srcdir/$part:$TEXINPUTS export TEXINPUTS Index: mkhowto =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mkhowto 2000/03/31 20:27:36 1.7 --- mkhowto 2000/04/03 04:19:14 1.8 *************** *** 331,334 **** --- 331,336 ---- texfile = texfile[2:] # build the command line and run LaTeX2HTML: + if not os.path.isdir(builddir): + os.mkdir(builddir) args = [LATEX2HTML_BINARY, "-init_file", L2H_INIT_FILE, Index: mkhtml.sh =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkhtml.sh,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** mkhtml.sh 1999/10/29 20:51:43 1.11 --- mkhtml.sh 2000/04/03 04:19:14 1.12 *************** *** 28,31 **** --- 28,33 ---- if [ -d $part ] ; then rm -f $part/*.html + else + mkdir $part fi *************** *** 34,37 **** --- 36,41 ---- latex2html \ -no_auto_link \ + -up_url '../index.html' \ + -up_title 'Documentation Index' \ -init_file $srcdir/perl/l2hinit.perl \ -address '
See About this document... for information on suggesting changes.' \ Index: mkmodindex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mkmodindex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mkmodindex 1999/03/04 21:33:55 1.4 --- mkmodindex 2000/04/03 04:19:14 1.5 *************** *** 48,53 **** _rx = re.compile( ! '
' ! '([a-zA-Z_][a-zA-Z0-9_.]*(\s*\(.*\))?)') def main(): --- 48,54 ---- _rx = re.compile( ! "
" ! "([a-zA-Z_][a-zA-Z0-9_.]*(\s*" ! "\(.*\))?)") def main(): Index: mksourcepkg =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tools/mksourcepkg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** mksourcepkg 1999/08/02 20:19:17 1.1 --- mksourcepkg 2000/04/03 04:19:14 1.2 *************** *** 17,21 **** # from the Makefile or someplace. ! __version__ = "$Revision: 1.1 $" import getopt --- 17,21 ---- # from the Makefile or someplace. ! __version__ = "$Revision: 1.2 $" import getopt *************** *** 106,110 **** % (release, archive)) elif format == "zip": ! run("zip -r9 %s.zip Python-%s" % (archive, release)) --- 106,112 ---- % (release, archive)) elif format == "zip": ! if os.path.exists(archive + ".zip"): ! os.unlink(archive + ".zip") ! run("zip -q -r9 %s.zip Python-%s" % (archive, release)) From python-dev@python.org Mon Apr 3 05:27:01 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:27:01 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.103,1.104 Message-ID: <200004030427.AAA08553@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/tut In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/tut Modified Files: tut.tex Log Message: Merge in changes from the 1.5.2p2 release. Index: tut.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -r1.103 -r1.104 *** tut.tex 1999/11/10 16:17:10 1.103 --- tut.tex 2000/04/03 04:26:58 1.104 *************** *** 4,8 **** % Add a section on file I/O % Write a chapter entitled ``Some Useful Modules'' ! % --regex, math+cmath % Should really move the Python startup file info to an appendix --- 4,8 ---- % Add a section on file I/O % Write a chapter entitled ``Some Useful Modules'' ! % --re, math+cmath % Should really move the Python startup file info to an appendix [...1461 lines suppressed...] \begin{verbatim} *************** *** 3740,3747 **** Automatic completion of variable and module names is optionally available. To enable it in the interpreter's interactive mode, add ! the following to your \file{\$HOME/.pythonrc.py} file:% $ <- bow to font-lock \indexii{.pythonrc.py}{file} ! \refstmodindex{rlcompleter} ! \refbimodindex{readline} \begin{verbatim} --- 3884,3890 ---- Automatic completion of variable and module names is optionally available. To enable it in the interpreter's interactive mode, add ! the following to your \file{\$HOME/.pythonrc.py} file:% \indexii{.pythonrc.py}{file} ! \refstmodindex{rlcompleter}\refbimodindex{readline} \begin{verbatim} From python-dev@python.org Mon Apr 3 05:41:20 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:41:20 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl SynopsisTable.pm,1.4,1.5 l2hinit.perl,1.41,1.42 ltxmarkup.perl,1.3,1.4 python.perl,1.68,1.69 Message-ID: <200004030441.AAA08829@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/perl In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/perl Modified Files: SynopsisTable.pm l2hinit.perl ltxmarkup.perl python.perl Log Message: Merged changes from the 1.5.2p2 release. Index: SynopsisTable.pm =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/SynopsisTable.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** SynopsisTable.pm 1999/07/12 16:28:50 1.4 --- SynopsisTable.pm 2000/04/03 04:41:17 1.5 *************** *** 39,50 **** sub tohtml{ my $self = shift; ! my $data = "
! Python DocumentationModule Index
\n"; my $name; foreach $name (split /,/, $self->{names}) { my($key,$type,$synopsis) = $self->get($name); ! my $link = ""; ! $data .= (" " ! . "\n" ! . " \n"); } $data .= "
$link$name$synopsis
\n"; --- 39,50 ---- sub tohtml{ my $self = shift; ! my $data = "\n"; my $name; foreach $name (split /,/, $self->{names}) { my($key,$type,$synopsis) = $self->get($name); ! my $link = ""; ! $data .= (' ' ! . "\n" ! . " \n"); } $data .= "
$link$name$synopsis
\n"; Index: l2hinit.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/l2hinit.perl,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** l2hinit.perl 1999/09/23 16:53:09 1.41 --- l2hinit.perl 2000/04/03 04:41:18 1.42 *************** *** 17,20 **** --- 17,21 ---- $MAX_LINK_DEPTH = 2; + $MAX_SPLIT_DEPTH = 5; # split at subsections but not sub-subsections $ADDRESS = ''; *************** *** 144,147 **** --- 145,149 ---- $NAV_BGCOLOR = " bgcolor=\"#99CCFF\""; } + adjust_icon_information(); *************** *** 150,156 **** my($label,$title) = @_; if ($title) { ! $title =~ s/$label: " ! . "$title\n"); } return ''; --- 152,157 ---- my($label,$title) = @_; if ($title) { ! return ("$label: " ! . "$title\n"); } return ''; *************** *** 159,163 **** sub make_nav_panel{ my $s; ! $s = "" . "\n" . "\n" --- 160,164 ---- sub make_nav_panel{ my $s; ! $s = "
$NEXT
" . "\n" . "\n" *************** *** 185,189 **** sub top_navigation_panel { ! "'; --- 186,190 ---- sub top_navigation_panel { ! "'; *************** *** 191,195 **** sub bot_navigation_panel { ! "

\n

'; --- 192,196 ---- sub bot_navigation_panel { ! "

\n

'; *************** *** 335,345 **** $key =~ s/([a-zA-Z0-9._]*)<\/tt>/\1/; if ($ModulePlatforms{$key} && !$allthesame) { ! $plat = (" ($ModulePlatforms{$key}" . ')'); } ! print MODIDXFILE ! $moditem ! . $IDXFILE_FIELD_SEP ! . "$key$plat###\n"; } close(MODIDXFILE); --- 336,344 ---- $key =~ s/([a-zA-Z0-9._]*)<\/tt>/\1/; if ($ModulePlatforms{$key} && !$allthesame) { ! $plat = (" ($ModulePlatforms{$key}" . ')'); } ! print MODIDXFILE $moditem . $IDXFILE_FIELD_SEP ! . "$key$plat###\n"; } close(MODIDXFILE); *************** *** 557,564 **** # Note that this *must* be done in the init file, not the python.perl # style support file. The %declarations must be set before initialize() ! # is called in the main script. # ! %declarations = ('preform' => '
', %declarations); 1; # This must be the last line --- 556,609 ---- # Note that this *must* be done in the init file, not the python.perl # style support file. The %declarations must be set before initialize() ! # is called in the main LaTeX2HTML script (which happens before style files ! # are loaded). # ! %declarations = ('preform' => '
', %declarations); + + + # This is added to get rid of the long comment that follows the doctype + # declaration; MSIE5 on NT4 SP4 barfs on it and drops the content of the + # page. + sub make_head_and_body { + local($title,$body) = @_; + local($DTDcomment) = ''; + local($version,$isolanguage) = ($HTML_VERSION, 'EN'); + local(%isolanguages) = ( 'english', 'EN' , 'USenglish', 'EN.US' + , 'original', 'EN' , 'german' , 'DE' + , 'austrian', 'DE.AT', 'french' , 'FR' + , 'spanish', 'ES' + , %isolanguages ); + $isolanguage = $isolanguages{$default_language}; + $isolanguage = 'EN' unless $isolanguage; + $title = &purify($title,1); + eval("\$title = ". $default_title ) unless ($title); + + # allow user-modification of the tag; thanks Dan Young + if (defined &custom_TITLE_hook) { + $title = &custom_TITLE_hook($title, $toc_sec_title); + } + + if ($DOCTYPE =~ /\/\/[\w\.]+\s*$/) { # language spec included + $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE\">\n"; + } else { + $DTDcomment = "<!DOCTYPE html PUBLIC \"$DOCTYPE//" + . ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage) . "\">\n"; + } + + $STYLESHEET = $FILE.".css" unless $STYLESHEET; + if (!$charset && $CHARSET) { $charset = $CHARSET; $charset =~ s/_/\-/go; } + + join('', ($DOCTYPE ? $DTDcomment : '' ) + ,"<html>\n<head>\n<title>", $title, "\n" + , &meta_information($title) + , ($CHARSET && $HTML_VERSION ge "2.1" ? + "\n" + : "" ) + , ($BASE ? "\n" : "" ) + , "" + , $more_links_mark + , "\n\n\n"); + } 1; # This must be the last line Index: ltxmarkup.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/ltxmarkup.perl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** ltxmarkup.perl 1999/04/28 16:42:29 1.3 --- ltxmarkup.perl 2000/04/03 04:41:18 1.4 *************** *** 16,20 **** local($_) = @_; my $macro = ltx_next_argument(); ! return "\$macro" . $_; } --- 16,20 ---- local($_) = @_; my $macro = ltx_next_argument(); ! return "\$macro" . $_; } *************** *** 22,26 **** local($_) = @_; my $env = ltx_next_argument(); ! return "\$env" . $_; } --- 22,26 ---- local($_) = @_; my $env = ltx_next_argument(); ! return "\$env" . $_; } *************** *** 44,49 **** my $macro = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\$macro" . "\n $params" . "\n
" --- 44,49 ---- my $macro = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\$macro" . "\n $params" . "\n
" *************** *** 56,62 **** my $env = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\begin{$env}" . "\n $params" . "\n
" . $_ --- 56,63 ---- my $env = ltx_next_argument(); my $params = ltx_process_params(ltx_next_argument()); ! return "\n
" ! . "\n
\begin{$env}" . "\n $params" + . "\n
\end{$env}" . "\n
" . $_ Index: python.perl =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** python.perl 1999/11/09 16:59:42 1.68 --- python.perl 2000/04/03 04:41:18 1.69 *************** *** 62,66 **** sub do_cmd_Cpp{ 'C++' . @_[0]; } sub do_cmd_EOF{ 'EOF' . @_[0]; } ! sub do_cmd_NULL{ 'NULL' . @_[0]; } sub do_cmd_e{ '\' . @_[0]; } --- 62,66 ---- sub do_cmd_Cpp{ 'C++' . @_[0]; } sub do_cmd_EOF{ 'EOF' . @_[0]; } ! sub do_cmd_NULL{ 'NULL' . @_[0]; } sub do_cmd_e{ '\' . @_[0]; } *************** *** 120,170 **** sub do_cmd_makevar{ return @_[0]; } sub do_cmd_code{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_module{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_keyword{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_exception{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_class{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_function{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_constant{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_member{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_method{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cfunction{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cdata{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_ctype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_regexp{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_character{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_program{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_programopt{ return use_wrappers(@_[0], '', ''); } sub do_cmd_email{ ! return use_wrappers(@_[0], ''); } sub do_cmd_mimetype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_var{ return use_wrappers(@_[0], "", ""); } sub do_cmd_dfn{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_emph{ return use_italics(@_); } sub do_cmd_file{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_filenq{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_samp{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_kbd{ return use_wrappers(@_[0], '', ''); } --- 120,172 ---- sub do_cmd_makevar{ return @_[0]; } sub do_cmd_code{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_module{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_keyword{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_exception{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_class{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_function{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_constant{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_member{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_method{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cfunction{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_cdata{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_ctype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_regexp{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_character{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_program{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_programopt{ return use_wrappers(@_[0], '', ''); } sub do_cmd_email{ ! return use_wrappers(@_[0], ''); } sub do_cmd_mimetype{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_var{ return use_wrappers(@_[0], "", ""); } sub do_cmd_dfn{ ! return use_wrappers(@_[0], '', ''); } sub do_cmd_emph{ return use_italics(@_); } sub do_cmd_file{ ! return use_wrappers(@_[0], ! '', ! ''); } sub do_cmd_filenq{ ! return do_cmd_file(@_[0]); } sub do_cmd_samp{ ! return use_wrappers(@_[0], '"', '"'); } sub do_cmd_kbd{ return use_wrappers(@_[0], '', ''); } *************** *** 184,188 **** $key = $module unless $key; ! return "$module" . $_; } --- 186,191 ---- $key = $module unless $key; ! return "$module" ! . $_; } *************** *** 190,194 **** local($_) = @_; my $newsgroup = next_argument(); ! my $stuff = "$newsgroup"; return $stuff . $_; } --- 193,198 ---- local($_) = @_; my $newsgroup = next_argument(); ! my $stuff = "" ! . "$newsgroup"; return $stuff . $_; } *************** *** 203,207 **** $ahref); add_index_entry("$envvar@\$$envvar", $ahref); ! $aname =~ s/" . $_; } --- 207,211 ---- $ahref); add_index_entry("$envvar@\$$envvar", $ahref); ! $aname =~ s/" . $_; } *************** *** 212,216 **** my $url = next_argument(); $url =~ s/~/~/g; ! return "$url" . $_; } --- 216,220 ---- my $url = next_argument(); $url =~ s/~/~/g; ! return "$url" . $_; } *************** *** 220,224 **** my $page = next_argument(); my $section = next_argument(); ! return "$page($section)" . $_; } --- 224,228 ---- my $page = next_argument(); my $section = next_argument(); ! return "$page($section)" . $_; } *************** *** 232,236 **** my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("RFC $rfcnumber" . $_); } --- 236,240 ---- my $nstr = gen_index_id("RFC!RFC $rfcnumber", ''); $index{$nstr} .= make_half_href("$CURRENT_FILE#$id"); ! return ("RFC $rfcnumber" . $_); } *************** *** 281,289 **** local($_) = @_; my $platform = next_argument(); ! $ModulePlatforms{$THIS_MODULE} = $platform; $platform = "Macintosh" if $platform eq 'Mac'; ! return "\n

Availability: $platform.

\n" . $_; } --- 285,293 ---- local($_) = @_; my $platform = next_argument(); ! $ModulePlatforms{"$THIS_MODULE"} = $platform; $platform = "Macintosh" if $platform eq 'Mac'; ! return "\n

Availability: $platform.

\n" . $_; } *************** *** 354,358 **** my($node,$target) = @_; print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; ! return ""; } --- 358,362 ---- my($node,$target) = @_; print INTLABELS "\$internal_labels{\"$target\"} = \"$URL/$node\";\n"; ! return ""; } *************** *** 367,371 **** sub new_link_info{ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ''; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $aname, $ahref); --- 371,375 ---- sub new_link_info{ my $name = "l2h-" . ++$globals{'max_id'}; ! my $aname = ""; my $ahref = gen_link($CURRENT_FILE, $name); return ($name, $aname, $ahref); *************** *** 484,488 **** sub idx_cmd_bifuncindex{ my $str = next_argument(); ! add_index_entry("$str() (built-in function)", @_[0]); } --- 488,493 ---- sub idx_cmd_bifuncindex{ my $str = next_argument(); ! add_index_entry("$str() (built-in function)", ! @_[0]); } *************** *** 500,504 **** if ($define eq 'DEF') { # add to the module index ! my($nstr,$garbage) = split / /, $str, 2; $Modules{$nstr} .= $ahref; } --- 505,510 ---- if ($define eq 'DEF') { # add to the module index ! $str =~ /()/; ! my $nstr = $1; $Modules{$nstr} .= $ahref; } *************** *** 523,527 **** $INDEX_SUBITEM = "(in $name)"; print "[$name]"; ! return make_mod_index_entry("$name (${word}module)", 'DEF'); } --- 529,534 ---- $INDEX_SUBITEM = "(in $name)"; print "[$name]"; ! return make_mod_index_entry( ! "$name (${word}module)", 'DEF'); } *************** *** 541,545 **** my $str = next_argument(); $word = "$word " if $word; ! $str = "$str (${word}module)"; # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; # just inline it all here --- 548,552 ---- my $str = next_argument(); $word = "$word " if $word; ! $str = "$str (${word}module)"; # can't use add_index_entry() since the 2nd arg to gen_index_id() is used; # just inline it all here *************** *** 576,579 **** --- 583,619 ---- } + $REFCOUNTS_LOADED = 0; + + sub load_refcounts{ + $REFCOUNTS_LOADED = 1; + + use File::Basename; + my $myname, $mydir, $myext; + ($myname, $mydir, $myext) = fileparse(__FILE__, '\..*'); + chop $mydir; # remove trailing '/' + ($myname, $mydir, $myext) = fileparse($mydir, '\..*'); + chop $mydir; # remove trailing '/' + $mydir = getcwd() . "$dd$mydir" + unless $mydir =~ s|^/|/|; + local $_; + my $filename = "$mydir${dd}api${dd}refcounts.dat"; + open(REFCOUNT_FILE, "<$filename") || die "\n$!\n"; + print "[loading API refcount data]"; + while () { + if (/([a-zA-Z0-9_]+):PyObject\*:([a-zA-Z0-9_]*):(0|[-+]1):(.*)$/) { + my($func, $param, $count, $comment) = ($1, $2, $3, $4); + #print "\n$func($param) --> $count"; + $REFCOUNTS{"$func:$param"} = $count; + } + } + } + + sub get_refcount{ + my ($func, $param) = @_; + load_refcounts() + unless $REFCOUNTS_LOADED; + return $REFCOUNTS{"$func:$param"}; + } + sub do_env_cfuncdesc{ local($_) = @_; *************** *** 581,600 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" ! . get_indexsubitem()); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; # ???? return "
$return_type $idx ($arg_list)\n
" . $_ . '
'; } sub do_env_ctypedesc{ local($_) = @_; my $type_name = next_argument(); ! my $idx = make_str_index_entry("$type_name" ! . get_indexsubitem()); ! $idx =~ s/ \(.*\)//; ! return "
$idx\n
" . $_ . '
' --- 621,665 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry( ! "$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; # ???? + my $result_rc = get_refcount($function_name, ''); + my $rcinfo = ''; + if ($result_rc eq '+1') { + $rcinfo = 'Return value:' + . "\n New reference."; + } + elsif ($result_rc eq '0') { + $rcinfo = 'Return value:' + . "\n Borrowed reference."; + } + if ($rcinfo ne '') { + $rcinfo = "\n
\n $rcinfo\n
"; + } return "
$return_type $idx ($arg_list)\n
" + . $rcinfo . $_ . '
'; } + sub do_env_csimplemacrodesc{ + local($_) = @_; + my $name = next_argument(); + my $idx = make_str_index_entry("$name"); + return "
$idx\n
" + . $_ + . '
' + } + sub do_env_ctypedesc{ local($_) = @_; + my $index_name = next_optional_argument(); my $type_name = next_argument(); ! $index_name = $type_name ! unless $index_name; ! my($name,$aname,$ahref) = new_link_info(); ! add_index_entry("$index_name (C type)", $ahref); ! return "
$aname$type_name\n
" . $_ . '
' *************** *** 605,609 **** my $var_type = next_argument(); my $var_name = next_argument(); ! my $idx = make_str_index_entry("$var_name" . get_indexsubitem()); $idx =~ s/ \(.*\)//; --- 670,674 ---- my $var_type = next_argument(); my $var_name = next_argument(); ! my $idx = make_str_index_entry("$var_name" . get_indexsubitem()); $idx =~ s/ \(.*\)//; *************** *** 618,622 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; --- 683,687 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $idx = make_str_index_entry("$function_name()" . get_indexsubitem()); $idx =~ s/ \(.*\)//; *************** *** 629,633 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! return "
$function_name" . " ($arg_list)\n" . '
' --- 694,698 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! return "
$function_name" . " ($arg_list)\n" . '
' *************** *** 640,644 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name()"; my $idx = make_str_index_entry($prefix . get_indexsubitem()); $prefix =~ s/\(\)//; --- 705,709 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name()"; my $idx = make_str_index_entry($prefix . get_indexsubitem()); $prefix =~ s/\(\)//; *************** *** 651,655 **** my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name"; return "
$prefix ($arg_list)\n
" . $_; --- 716,720 ---- my $function_name = next_argument(); my $arg_list = next_argument(); ! my $prefix = "$function_name"; return "
$prefix ($arg_list)\n
" . $_; *************** *** 668,677 **** my $idx; if ($INDEX_OPCODES) { ! $idx = make_str_index_entry( ! "$opcode_name (byte code instruction)"); $idx =~ s/ \(byte code instruction\)//; } else { ! $idx = "$opcode_name"; } my $stuff = "
$idx"; --- 733,742 ---- my $idx; if ($INDEX_OPCODES) { ! $idx = make_str_index_entry("$opcode_name" ! . " (byte code instruction)"); $idx =~ s/ \(byte code instruction\)//; } else { ! $idx = "$opcode_name"; } my $stuff = "
$idx"; *************** *** 712,716 **** local($_) = @_; my $excname = next_argument(); ! my $idx = make_str_index_entry("$excname"); return "
$idx\n
" . $_ . '
' } --- 777,781 ---- local($_) = @_; my $excname = next_argument(); ! my $idx = make_str_index_entry("$excname"); return "
$idx\n
" . $_ . '
' } *************** *** 724,728 **** my $arg_list = next_argument(); $idx = make_str_index_entry( ! "$THIS_CLASS (class in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; return "
$idx ($arg_list)\n
" . $_ . '
'; --- 789,793 ---- my $arg_list = next_argument(); $idx = make_str_index_entry( ! "$THIS_CLASS (class in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; return "
$idx ($arg_list)\n
" . $_ . '
'; *************** *** 741,745 **** $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 806,810 ---- $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 759,763 **** $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 824,828 ---- $extra = " ($class_name method)"; } ! my $idx = make_str_index_entry("$method()$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 796,800 **** $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 861,865 ---- $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 812,816 **** $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; --- 877,881 ---- $extra = " ($class attribute)" if ($class ne ''); ! my $idx = make_str_index_entry("$member$extra"); $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; *************** *** 822,826 **** next_optional_argument(); my $member = next_argument(); ! return "
$member\n
" . $_ . '
'; } --- 887,893 ---- next_optional_argument(); my $member = next_argument(); ! return "
$member\n
" ! . $_ ! . '
'; } *************** *** 830,852 **** next_optional_argument(); my $member = next_argument(); ! return "
$member
" . $_; } ! @col_aligns = ("
" . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " . "\n " ! . "\n " ! . $_ . "\n " . "\n
$NEXT", "", "", ""); $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR; - sub get_th{ - my $a = @_[0]; - my $r = ''; - if ($a eq 'l') - { $r = ''; } - elsif (substr($a, 0, 1) eq 'p') - { $r = ''; } - elsif ($a eq 'r') - { $r = ''; } - return $r; - } - sub fix_font{ # do a little magic on a font name to get the right behavior in the first --- 897,907 ---- next_optional_argument(); my $member = next_argument(); ! return "
$member
" . $_; } ! @col_aligns = ('
', '', '', ''); $TABLE_HEADER_BGCOLOR = $NAV_BGCOLOR; sub fix_font{ # do a little magic on a font name to get the right behavior in the first *************** *** 857,878 **** } elsif ($font eq 'file' || $font eq 'filenq') { ! $font = 'tt class=file'; } return $font; } sub setup_column_alignments{ local($_) = @_; ! my($a1,$a2,$a3,$a4) = split(/[|]/,$_); ! my($th1,$th2,$th3,$th4) = ('', '', '', ''); ! $col_aligns[0] = (($a1 eq 'c') ? '' ! : ''); ! $col_aligns[1] = (($a2 eq 'c') ? '' : ''); ! $col_aligns[2] = (($a3 eq 'c') ? '' : ''); ! $col_aligns[3] = (($a4 eq 'c') ? '' : ''); # return the aligned header start tags ! return (get_th($a1), get_th($a2), get_th($a3), get_th($a4)); } sub do_env_tableii{ local($_) = @_; --- 912,964 ---- } elsif ($font eq 'file' || $font eq 'filenq') { ! $font = 'tt class="file"'; } + elsif ($font eq 'member') { + $font = 'tt class="member"'; + } return $font; } + sub figure_column_alignment{ + my $a = @_[0]; + my $mark = substr($a, 0, 1); + my $r = ''; + if ($mark eq 'c') + { $r = ' align="center"'; } + elsif ($mark eq 'r') + { $r = ' align="right"'; } + elsif ($mark eq 'l') + { $r = ' align="left"'; } + elsif ($mark eq 'p') + { $r = ' align="left"'; } + return $r; + } + sub setup_column_alignments{ local($_) = @_; ! my($s1,$s2,$s3,$s4) = split(/[|]/,$_); ! my $a1 = figure_column_alignment($s1); ! my $a2 = figure_column_alignment($s2); ! my $a3 = figure_column_alignment($s3); ! my $a4 = figure_column_alignment($s4); ! $col_aligns[0] = ""; ! $col_aligns[1] = ""; ! $col_aligns[2] = ""; ! $col_aligns[3] = ""; # return the aligned header start tags ! return ("", "", "", ""); } + sub get_table_col1_fonts{ + my $font = $globals{'lineifont'}; + my ($sfont,$efont) = ('', ''); + if ($font) { + $sfont = "<$font>"; + $efont = ""; + $efont =~ s/ .*>/>/; + } + return ($font, $sfont, $efont); + } + sub do_env_tableii{ local($_) = @_; *************** *** 883,894 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " . "\n " ! . "\n " ! . $_ . "\n " . "\n
"; --- 969,983 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! s/\\lineii' . "\n
"; *************** *** 897,912 **** sub do_cmd_lineii{ local($_) = @_; my $c1 = next_argument(); my $c2 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; ! } ! my($c1align,$c2align) = @col_aligns[0,1]; ! return "\n $c1align$sfont$c1$efont\n" ! . " $c2align$c2\ " . $_; } --- 986,1002 ---- sub do_cmd_lineii{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c2 = ' ' if ($c2 eq ''); ! my($c1align,$c2align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; ! } ! return "\n $c1align$sfont$c1$efont$padding\n" ! . " $c2align$c2" . $_; } *************** *** 921,932 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " ! . "\n $th3$h3\ \ " . "\n " ! . "\n " . $_ . "\n " --- 1011,1026 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! my $a3 = $col_aligns[2]; ! s/\\lineiii' . "\n " . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " ! . "\n $th3$h3\ " . "\n " ! . "\n " . $_ . "\n " *************** *** 936,953 **** sub do_cmd_lineiii{ local($_) = @_; my $c1 = next_argument(); my $c2 = next_argument(); my $c3 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; } ! my($c1align,$c2align,$c3align) = @col_aligns[0,1,2]; ! return "\n $c1align$sfont$c1$efont\n" . " $c2align$c2\n" ! . " $c3align$c3\ " . $_; } --- 1030,1048 ---- sub do_cmd_lineiii{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); my $c3 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c3 = ' ' if ($c3 eq ''); ! my($c1align,$c2align,$c3align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; } ! return "\n $c1align$sfont$c1$efont$padding\n" . " $c2align$c2\n" ! . " $c3align$c3" . $_; } *************** *** 963,975 **** s/[\s\n]+//; $globals{'lineifont'} = $font; ! return '
' . "\n " . "\n " ! . "\n $th1$h1\ \ " ! . "\n $th2$h2\ \ " ! . "\n $th3$h3\ \ " ! . "\n $th4$h4\ \ " . "\n " ! . "\n " . $_ . "\n " --- 1058,1075 ---- s/[\s\n]+//; $globals{'lineifont'} = $font; ! my $a1 = $col_aligns[0]; ! my $a2 = $col_aligns[1]; ! my $a3 = $col_aligns[2]; ! my $a4 = $col_aligns[3]; ! s/\\lineiv' . "\n " . "\n " ! . "\n $th1$h1\ " ! . "\n $th2$h2\ " ! . "\n $th3$h3\ " ! . "\n $th4$h4\ " . "\n " ! . "\n " . $_ . "\n " *************** *** 979,982 **** --- 1079,1083 ---- sub do_cmd_lineiv{ local($_) = @_; + my $aligns = next_optional_argument(); my $c1 = next_argument(); my $c2 = next_argument(); *************** *** 984,998 **** my $c4 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = ($globals{'lineifont'}, '', ''); ! if ($font) { ! $sfont = "<$font>"; ! $efont = ""; ! $efont =~ s/ .*>/>/; } ! my($c1align,$c2align,$c3align,$c4align) = @col_aligns; ! return "\n $c1align$sfont$c1$efont\n" . " $c2align$c2\n" . " $c3align$c3\n" ! . " $c4align$c4\ " . $_; } --- 1085,1099 ---- my $c4 = next_argument(); s/[\s\n]+//; ! my($font,$sfont,$efont) = get_table_col1_fonts(); ! $c4 = ' ' if ($c4 eq ''); ! my($c1align,$c2align,$c3align,$c4align) = split('\|', $aligns); ! my $padding = ''; ! if ($c1align =~ /align="right"/) { ! $padding = ' '; } ! return "\n $c1align$sfont$c1$efont$padding\n" . " $c2align$c2\n" . " $c3align$c3\n" ! . " $c4align$c4" . $_; } *************** *** 1000,1004 **** sub do_cmd_maketitle { local($_) = @_; ! my $the_title = "\n
"; if ($t_title) { $the_title .= "\n

$t_title

"; --- 1101,1105 ---- sub do_cmd_maketitle { local($_) = @_; ! my $the_title = "\n
"; if ($t_title) { $the_title .= "\n

$t_title

"; *************** *** 1126,1131 **** sub do_env_seealso{ ! return "
\n " ! . "

See Also:

\n" . @_[0] . '
'; --- 1227,1232 ---- sub do_env_seealso{ ! return "
\n " ! . "

See Also:

\n" . @_[0] . '
'; *************** *** 1145,1150 **** $period = ''; } ! return '
' ! . "\n
Module " . "$module:" . "\n
$text$period\n
" --- 1246,1251 ---- $period = ''; } ! return '
' ! . "\n
Module " . "$module:" . "\n
$text$period\n
" *************** *** 1155,1159 **** local($_) = @_; my $content = next_argument(); ! return '

' . $content . '

' . $_; } --- 1256,1260 ---- local($_) = @_; my $content = next_argument(); ! return '

' . $content . '

' . $_; } *************** *** 1165,1169 **** sub do_env_definitions{ local($_) = @_; ! return "
$_
\n"; } --- 1266,1270 ---- sub do_env_definitions{ local($_) = @_; ! return "
$_
\n"; } From python-dev@python.org Mon Apr 3 05:41:21 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:41:21 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref2.tex,1.17,1.18 ref3.tex,1.39,1.40 ref4.tex,1.21,1.22 ref5.tex,1.27,1.28 ref7.tex,1.18,1.19 Message-ID: <200004030441.AAA08839@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/ref In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/ref Modified Files: ref2.tex ref3.tex ref4.tex ref5.tex ref7.tex Log Message: Merged changes from the 1.5.2p2 release. Index: ref2.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** ref2.tex 1999/03/05 18:30:21 1.17 --- ref2.tex 2000/04/03 04:41:18 1.18 *************** *** 149,153 **** A formfeed character may be present at the start of the line; it will ! be ignored for the indentation calculations above. A formfeed characters occurring elsewhere in the leading whitespace have an undefined effect (for instance, they may reset the space count to --- 149,153 ---- A formfeed character may be present at the start of the line; it will ! be ignored for the indentation calculations above. Formfeed characters occurring elsewhere in the leading whitespace have an undefined effect (for instance, they may reset the space count to *************** *** 370,374 **** backslashes). Specifically, \emph{a raw string cannot end in a single backslash} (since the backslash would escape the following quote ! character). \subsection{String literal concatenation\label{string-catenation}} --- 370,376 ---- backslashes). Specifically, \emph{a raw string cannot end in a single backslash} (since the backslash would escape the following quote ! character). Note also that a single backslash followed by a newline ! is interpreted as those two characters as part of the string, ! \emph{not} as a line continuation. \subsection{String literal concatenation\label{string-catenation}} *************** *** 465,469 **** Note that the integer part of a floating point number cannot look like ! an octal integer. The allowed range of floating point literals is implementation-dependent. --- 467,473 ---- Note that the integer part of a floating point number cannot look like ! an octal integer, though the exponent may look like an octal literal ! but will always be interpreted using radix 10. For example, ! \samp{1e010} is legal, while \samp{07.1} is a syntax error. The allowed range of floating point literals is implementation-dependent. *************** *** 486,490 **** \end{verbatim} ! An imaginary literals yields a complex number with a real part of 0.0. Complex numbers are represented as a pair of floating point numbers and have the same restrictions on their range. To create a --- 490,494 ---- \end{verbatim} ! An imaginary literal yields a complex number with a real part of 0.0. Complex numbers are represented as a pair of floating point numbers and have the same restrictions on their range. To create a *************** *** 523,527 **** The period can also occur in floating-point and imaginary literals. A ! sequence of three periods has a special meaning as ellipses in slices. The following printing ASCII characters have special meaning as part --- 527,531 ---- The period can also occur in floating-point and imaginary literals. A ! sequence of three periods has a special meaning as an ellipsis in slices. The following printing ASCII characters have special meaning as part Index: ref3.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** ref3.tex 1999/11/10 16:13:25 1.39 --- ref3.tex 2000/04/03 04:41:18 1.40 *************** *** 145,149 **** numbers are of course strongly related to mathematical numbers, but subject to the limitations of numerical representation in computers. - \obindex{number} \obindex{numeric} --- 145,148 ---- *************** *** 163,167 **** (The range may be larger on machines with a larger natural word size, but not smaller.) ! When the result of an operation falls outside this range, the exception \exception{OverflowError} is raised. For the purpose of shift and mask operations, integers are assumed to --- 162,166 ---- (The range may be larger on machines with a larger natural word size, but not smaller.) ! When the result of an operation would fall outside this range, the exception \exception{OverflowError} is raised. For the purpose of shift and mask operations, integers are assumed to *************** *** 222,226 **** index set contains the numbers 0, 1, \ldots, \var{n}-1. Item \var{i} of sequence \var{a} is selected by \code{\var{a}[\var{i}]}. ! \obindex{seqence} \index{index operation} \index{item selection} --- 221,225 ---- index set contains the numbers 0, 1, \ldots, \var{n}-1. Item \var{i} of sequence \var{a} is selected by \code{\var{a}[\var{i}]}. ! \obindex{sequence} \index{index operation} \index{item selection} *************** *** 619,623 **** they have methods with certain special names. See section \ref{specialnames}, ``Special method names.'' ! \obindex{number} \obindex{sequence} \obindex{mapping} --- 618,622 ---- they have methods with certain special names. See section \ref{specialnames}, ``Special method names.'' ! \obindex{numeric} \obindex{sequence} \obindex{mapping} *************** *** 703,715 **** \ttindex{co_varnames}} ! The following flag bits are defined for \member{co_flags}: bit 2 is set ! if the function uses the \samp{*arguments} syntax to accept an ! arbitrary number of positional arguments; bit 3 is set if the function ! uses the \samp{**keywords} syntax to accept arbitrary keyword ! arguments; other bits are used internally or reserved for future use. ! If a code object represents a function, the first item in ! \member{co_consts} is the documentation string of the ! function, or \code{None} if undefined. ! \index{documentation string} \item[Frame objects] --- 702,713 ---- \ttindex{co_varnames}} ! The following flag bits are defined for \member{co_flags}: bit ! \code{0x04} is set if the function uses the \samp{*arguments} syntax ! to accept an arbitrary number of positional arguments; bit ! \code{0x08} is set if the function uses the \samp{**keywords} syntax ! to accept arbitrary keyword arguments; other bits are used internally ! or reserved for future use. If\index{documentation string} a code ! object represents a function, the first item in \member{co_consts} is ! the documentation string of the function, or \code{None} if undefined. \item[Frame objects] *************** *** 1099,1106 **** The returned object should be of the same type as \var{self}. Note that missing \var{i} or \var{j} in the slice expression are replaced ! by zero or \code{sys.maxint}, respectively, and no further ! transformations on the indices is performed. The interpretation of ! negative indices and indices larger than the length of the sequence is ! up to the method. \end{methoddesc} --- 1097,1107 ---- The returned object should be of the same type as \var{self}. Note that missing \var{i} or \var{j} in the slice expression are replaced ! by zero or \code{sys.maxint}, respectively. If negative indexes are ! used in the slice, the length of the sequence is added to that index. ! If the instance does not implement the \method{__len__()} method, an ! \exception{AttributeError} is raised. ! No guarantee is made that indexes adjusted this way are not still ! negative. Indexes which are greater than the length of the sequence ! are not modified. \end{methoddesc} Index: ref4.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** ref4.tex 1999/05/13 18:38:11 1.21 --- ref4.tex 2000/04/03 04:41:18 1.22 *************** *** 184,192 **** executed whether an exception occurred or not in the preceding code. ! Python uses the ``termination'' model of error handling: an exception ! handler can find out what happened and continue execution at an outer ! level, but it cannot repair the cause of the error and retry the ! failing operation (except by re-entering the offending piece of ! code from the top). When an exception is not handled at all, the interpreter terminates --- 184,192 ---- executed whether an exception occurred or not in the preceding code. ! Python uses the ``termination'' \index{termination model}model of ! error handling: an exception handler can find out what happened and ! continue execution at an outer level, but it cannot repair the cause ! of the error and retry the failing operation (except by re-entering ! the offending piece of code from the top). When an exception is not handled at all, the interpreter terminates *************** *** 211,214 **** being raised. ! See also the description of the \keyword{try} and \keyword{raise} ! statements in chapter \ref{compound}. --- 211,214 ---- being raised. ! See also the description of the \keyword{try} statement in section ! \ref{try} and \keyword{raise} statement in section \ref{raise}. Index: ref5.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** ref5.tex 1999/05/06 14:46:35 1.27 --- ref5.tex 2000/04/03 04:41:18 1.28 *************** *** 116,120 **** the same object or a different object with the same value. \indexiii{immutable}{data}{type} ! \indexii{immutable}{objects} \subsection{Parenthesized forms\label{parenthesized}} --- 116,120 ---- the same object or a different object with the same value. \indexiii{immutable}{data}{type} ! \indexii{immutable}{object} \subsection{Parenthesized forms\label{parenthesized}} *************** *** 190,194 **** are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. ! \indexii{immutable}{objects} \subsection{String conversions\label{string-conversions}} --- 190,194 ---- are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. ! \indexii{immutable}{object} \subsection{String conversions\label{string-conversions}} *************** *** 339,343 **** evaluate to a sequence object. The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the ! sequence's length, respectively. If either bound is negative, the sequence's length is added to it. The slicing now selects all items with index \var{k} such that --- 339,343 ---- evaluate to a sequence object. The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the ! \code{sys.maxint}, respectively. If either bound is negative, the sequence's length is added to it. The slicing now selects all items with index \var{k} such that *************** *** 508,512 **** ! \section{Unary arithmetic operations\label{unary}} \indexiii{unary}{arithmetic}{operation} \indexiii{unary}{bit-wise}{operation} --- 508,512 ---- ! \section{Unary arithmetic operations \label{unary}} \indexiii{unary}{arithmetic}{operation} \indexiii{unary}{bit-wise}{operation} *************** *** 527,531 **** \index{plus} ! The unary \code{~} (invert) operator yields the bit-wise inversion of its plain or long integer argument. The bit-wise inversion of \code{x} is defined as \code{-(x+1)}. It only applies to integral --- 527,531 ---- \index{plus} ! The unary \code{\~} (invert) operator yields the bit-wise inversion of its plain or long integer argument. The bit-wise inversion of \code{x} is defined as \code{-(x+1)}. It only applies to integral Index: ref7.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** ref7.tex 1999/08/24 22:14:01 1.18 --- ref7.tex 2000/04/03 04:41:18 1.19 *************** *** 307,313 **** parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not ! expressed by the grammar.\footnote{ ! Currently this is not checked; instead, \code{def f(a=1, b)} is ! interpreted as \code{def f(a=1, b=None)}.} \indexiii{default}{parameter}{value} --- 307,311 ---- parameter has a default value, all following parameters must also have a default value --- this is a syntactic restriction that is not ! expressed by the grammar. \indexiii{default}{parameter}{value} From python-dev@python.org Mon Apr 3 05:43:08 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:43:08 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/paper-letter .cvsignore,1.7,1.8 Makefile,1.13,1.14 Message-ID: <200004030443.AAA08922@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/paper-letter In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/paper-letter Modified Files: .cvsignore Makefile Log Message: Merged changes from the 1.5.2p2 release. Index: .cvsignore =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/paper-letter/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/03/16 16:14:50 1.7 --- .cvsignore 2000/04/03 04:43:05 1.8 *************** *** 14,15 **** --- 14,16 ---- *.how README + api.tex Index: Makefile =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/paper-letter/Makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** Makefile 1999/10/29 20:49:23 1.13 --- Makefile 2000/04/03 04:43:05 1.14 *************** *** 59,73 **** ! README: $(PSFILES) $(TOOLSDIR)/getpagecounts >$@ # Python/C API Reference Manual ! api.dvi: $(APIFILES) $(MKDVI) api ! api.pdf: $(APIFILES) $(MKPDF) api # Documenting Python doc.dvi: $(DOCFILES) --- 59,76 ---- ! README: $(PSFILES) $(TOOLSDIR)/getpagecounts $(TOOLSDIR)/getpagecounts >$@ # Python/C API Reference Manual ! api.dvi: api.tex $(APIFILES) $(MKDVI) api ! api.pdf: api.tex $(APIFILES) $(MKPDF) api + api.tex: ../api/api.tex ../api/refcounts.dat ../tools/anno-api.py + $(PYTHON) ../tools/anno-api.py -o $@ ../api/api.tex + # Documenting Python doc.dvi: $(DOCFILES) *************** *** 114,118 **** clean: ! rm -f *~ *.aux *.idx *.ilg *.ind *.log *.toc *.bkm *.syn *.pla clobber: clean --- 117,121 ---- clean: ! rm -f *~ *.aux *.idx *.ilg *.ind *.log *.toc *.bkm *.syn *.pla api.tex clobber: clean From python-dev@python.org Mon Apr 3 05:47:19 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:47:19 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.15,1.16 Message-ID: <200004030447.AAA08994@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/doc In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/doc Modified Files: doc.tex Log Message: Merged changes from the 1.5.2p2 release. Index: doc.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** doc.tex 1999/11/10 22:51:18 1.15 --- doc.tex 2000/04/03 04:47:16 1.16 *************** *** 227,230 **** --- 227,243 ---- facilities. + \subsection{Meta-information Markup \label{meta-info}} + + \begin{macrodesc}{sectionauthor}{\p{author}\p{email}} + Identifies the author of the current section. \var{author} + should be the author's name such that it can be used for + presentation (though it isn't), and \var{email} should be the + author's email address. The domain name portion of + the address should be lower case. + + No presentation is generated from this markup, but it is used to + help keep track of contributions. + \end{macrodesc} + \subsection{Information Units \label{info-units}} *************** *** 413,417 **** \begin{macrodesc}{email}{\p{address}} An email address. Note that this is \emph{not} hyperlinked in ! any of the possible output formats. \end{macrodesc} --- 426,431 ---- \begin{macrodesc}{email}{\p{address}} An email address. Note that this is \emph{not} hyperlinked in ! any of the possible output formats. The domain name portion of ! the address should be lower case. \end{macrodesc} *************** *** 690,695 **** table generated by this environment contains two columns, and each row is defined by an alternate definition of ! \macro{modulesynopsis}. This environment is not normally use by ! the user, but is created by the \macro{localmoduletable} macro. --- 704,709 ---- table generated by this environment contains two columns, and each row is defined by an alternate definition of ! \macro{modulesynopsis}. This environment is not normally used by ! authors, but is created by the \macro{localmoduletable} macro. *************** *** 727,731 **** Effective index generation for technical documents can be very ! difficult, especially for someone familliar with the topic but not the creation of indexes. Much of the difficulty arises in the area of terminology: including the terms an expert would use for a --- 741,745 ---- Effective index generation for technical documents can be very ! difficult, especially for someone familiar with the topic but not the creation of indexes. Much of the difficulty arises in the area of terminology: including the terms an expert would use for a *************** *** 736,740 **** The truly difficult aspects of index generation are not areas with which the documentation tools can help. However, ease ! of producing the index once content decisions are make is within the scope of the tools. Markup is provided which the processing software is able to use to generate a variety of kinds of index --- 750,754 ---- The truly difficult aspects of index generation are not areas with which the documentation tools can help. However, ease ! of producing the index once content decisions are made is within the scope of the tools. Markup is provided which the processing software is able to use to generate a variety of kinds of index From python-dev@python.org Mon Apr 3 05:51:15 2000 From: python-dev@python.org (Fred Drake) Date: Mon, 3 Apr 2000 00:51:15 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/html Makefile,1.30,1.31 index.html.in,1.4,1.5 Message-ID: <200004030451.AAA09076@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/html In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/html Modified Files: Makefile index.html.in Log Message: Merged changes from the 1.5.2p2 release. Index: Makefile =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/Makefile,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** Makefile 1999/11/18 20:56:29 1.30 --- Makefile 2000/04/03 04:51:13 1.31 *************** *** 54,58 **** tut: tut/tut.html ! $(INDEXFILES): $(COMMONPERL) $(TOPDIR)/html/about.dat # The index.html target is at the end since it screws up font-lock. --- 54,60 ---- tut: tut/tut.html ! $(INDEXFILES): $(COMMONPERL) \ ! $(TOPDIR)/html/about.dat \ ! $(TOPDIR)/tools/node2label.pl # The index.html target is at the end since it screws up font-lock. Index: index.html.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** index.html.in 1999/05/27 21:56:11 1.4 --- index.html.in 2000/04/03 04:51:13 1.5 *************** *** 1,5 **** ! Python 1.5.2 Documentation ! !
! ! ! ! ! ! ! --- 2,28 ---- Python @RELEASE@ Documentation - @DATE@ ! ! !
! Python DocumentationModule Index
! ! ! ! ! ! ! *************** *** 29,33 ****
!

Python Documentation

--- 30,34 ----
!

Python Documentation

*************** *** 43,74 ****
--- 44,83 ---- From python-dev@python.org Fri Apr 28 18:45:30 2000 From: python-dev@python.org (Fred Drake) Date: Fri, 28 Apr 2000 13:45:30 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/html .cvsignore,1.7,1.8 Message-ID: <200004281745.NAA18694@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/html In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/html Modified Files: .cvsignore Log Message: Don't worry about the output dirs for the distutils manuals. Index: .cvsignore =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/html/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/09/24 13:48:38 1.7 --- .cvsignore 2000/04/28 17:45:27 1.8 *************** *** 6,9 **** --- 6,11 ---- ref tut + dist + inst index.html modindex.html From python-dev@python.org Fri Apr 28 19:17:26 2000 From: python-dev@python.org (Fred Drake) Date: Fri, 28 Apr 2000 14:17:26 -0400 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib librobotparser.tex,1.1,1.2 Message-ID: <200004281817.OAA18950@seahag.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Doc/lib In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Doc/lib Modified Files: librobotparser.tex Log Message: \file and \filenq should not be used in section titles; they are not sufficiently robust to survive the creation of bookmarks in the PDF format. Index: librobotparser.tex =================================================================== RCS file: /projects/cvsroot/python/dist/src/Doc/lib/librobotparser.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** librobotparser.tex 2000/03/31 17:51:10 1.1 --- librobotparser.tex 2000/04/28 18:17:23 1.2 *************** *** 1,4 **** \section{\module{robotparser} --- ! Parser for \filenq{robots.txt}} \declaremodule{standard}{robotparser} --- 1,4 ---- \section{\module{robotparser} --- ! Parser for robots.txt} \declaremodule{standard}{robotparser} From python-dev@python.org Fri Apr 28 20:03:57 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 28 Apr 2000 15:03:57 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.130,2.131 Message-ID: <200004281903.PAA17701@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Python In directory eric:/projects/python/develop/guido/src/Python Modified Files: import.c Log Message: As Marc-Andre Lemburg points out, the magic number needs to change because we've added Unicode marshalling to the repertoire. Index: import.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Python/import.c,v retrieving revision 2.130 retrieving revision 2.131 diff -C2 -r2.130 -r2.131 *** import.c 2000/04/24 15:08:18 2.130 --- import.c 2000/04/28 19:03:54 2.131 *************** *** 85,89 **** added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (20121 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* See _PyImport_FixupExtension() below */ --- 85,89 ---- added to the .pyc file header? */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ ! #define MAGIC (50428 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* See _PyImport_FixupExtension() below */ From python-dev@python.org Fri Apr 28 21:40:00 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 28 Apr 2000 16:40:00 -0400 (EDT) Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.9,1.10 Message-ID: <200004282040.QAA18998@eric.cnri.reston.va.us> Update of /projects/cvsroot/python/dist/src/Lib/test In directory eric:/projects/python/develop/guido/src/Lib/test Modified Files: test_unicode.py Log Message: Get rid of memory leak caused by assingning sys.exc_info() to a local. Store sys.exc_info()[:2] instead. Index: test_unicode.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** test_unicode.py 2000/04/13 14:11:56 1.9 --- test_unicode.py 2000/04/28 20:39:58 1.10 *************** *** 17,21 **** except: value = sys.exc_type ! exc = sys.exc_info() else: exc = None --- 17,21 ---- except: value = sys.exc_type ! exc = sys.exc_info()[:2] else: exc = None *************** *** 25,29 **** print '*',f, `input`, `output`, `value` if exc: ! print ' value == %s: %s' % (exc[:2]) else: if verbose: --- 25,29 ---- print '*',f, `input`, `output`, `value` if exc: ! print ' value == %s: %s' % (exc) else: if verbose:
! Python DocumentationModule Index