rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
c.registerFont0(f) | c.addFont(f) | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) | c.addFont(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) | c.addFont(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
euroMac = SingleByteEncoding('MacRomanEncoding') | euroMac = Encoding('MacRomanEncoding') | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) | c.addFont(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
narrowEnc = SingleByteEncoding('WinAnsiEncoding') | narrowEnc = Encoding('WinAnsiEncoding') | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) | c.addFont(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) | def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf' | 1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1fe5c2ca28f1a89e8758aa0785f65e7c5f62e022/pdfmetrics.py |
"""Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" | """Get the full source code for a function or method. Works with a list of lines since we will typically grab several things out of the same file. It extracts a multiline text block. It can be fooled by devious use of dedentation inside brackets, which could be fixed in a future version that watched the nesting level.""" | def getFunctionBody(f, linesInFile): """Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" if hasattr(f, 'im_func'): #it's a method, drill down and get its function f = f.im_func extracted = [] firstLineNo = f.func_code.co_firstlineno - 1 startingIndent = indentLevel(linesInFile[firstLineNo]) extracted.append(linesInFile[firstLineNo]) #brackets = 0 for line in linesInFile[firstLineNo+1:]: ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) # we are not indented return string.join(extracted, '\n') # ??? usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') | 4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb/graphdocpy.py |
ind = indentLevel(line) if ind <= startingIndent: break | stripped = string.strip(line) if len(stripped) == 0: continue elif stripped[0] == ' continue | def getFunctionBody(f, linesInFile): """Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" if hasattr(f, 'im_func'): #it's a method, drill down and get its function f = f.im_func extracted = [] firstLineNo = f.func_code.co_firstlineno - 1 startingIndent = indentLevel(linesInFile[firstLineNo]) extracted.append(linesInFile[firstLineNo]) #brackets = 0 for line in linesInFile[firstLineNo+1:]: ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) # we are not indented return string.join(extracted, '\n') # ??? usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') | 4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb/graphdocpy.py |
extracted.append(line) | ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) | def getFunctionBody(f, linesInFile): """Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" if hasattr(f, 'im_func'): #it's a method, drill down and get its function f = f.im_func extracted = [] firstLineNo = f.func_code.co_firstlineno - 1 startingIndent = indentLevel(linesInFile[firstLineNo]) extracted.append(linesInFile[firstLineNo]) #brackets = 0 for line in linesInFile[firstLineNo+1:]: ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) # we are not indented return string.join(extracted, '\n') # ??? usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') | 4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb/graphdocpy.py |
usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') | def getFunctionBody(f, linesInFile): """Pass in the function object and the lines in the file. Since we will typically grab several things out of the same file. it extracts a multiline text block. Works with methods too.""" if hasattr(f, 'im_func'): #it's a method, drill down and get its function f = f.im_func extracted = [] firstLineNo = f.func_code.co_firstlineno - 1 startingIndent = indentLevel(linesInFile[firstLineNo]) extracted.append(linesInFile[firstLineNo]) #brackets = 0 for line in linesInFile[firstLineNo+1:]: ind = indentLevel(line) if ind <= startingIndent: break else: extracted.append(line) # we are not indented return string.join(extracted, '\n') # ??? usefulLines = lines[firstLineNo:lineNo+1] return string.join(usefulLines, '\n') | 4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/4ceb4d2a0f38ac2e44bb809a2be98f1573ec1ebb/graphdocpy.py |
|
if filters is not None and not dictionary.has_key("Filters"): | if filters is not None and not dictionary.dict.has_key("Filters"): | def format(self, document): dictionary = self.dictionary # copy it for modification dictionary = PDFDictionary(dictionary.dict.copy()) content = self.content filters = self.filters if self.content is None: raise ValueError, "stream content not set" if filters is None: filters = document.defaultStreamFilters # only apply filters if they haven't been applied elsewhere if filters is not None and not dictionary.has_key("Filters"): # apply filters in reverse order listed rf = list(filters) rf.reverse() fnames = [] for f in rf: #print "*****************content:"; print repr(content[:200]) #print "*****************filter", f.pdfname content = f.encode(content) fnames.insert(0, PDFName(f.pdfname)) #print "*****************finally:"; print content[:200] #print "****** FILTERS", fnames #stop dictionary["Filter"] = PDFArray(fnames) fc = format(content, document) #print "type(content)", type(content), len(content), type(self.dictionary) lc = len(content) #if fc!=content: burp # set dictionary length parameter dictionary["Length"] = lc fd = format(dictionary, document) sdict = LINEENDDICT.copy() sdict["dictionary"] = fd sdict["content"] = fc return STREAMFMT % sdict | dd5954a1604fc1f31f87513b6ab3082910c486d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dd5954a1604fc1f31f87513b6ab3082910c486d4/pdfdoc.py |
radius = self._radius = self._cx - 5 | radius = self._radius = self._cx-self.x | def draw(self): slices = self.slices _3d_angle = self.angle_3d _3dva = self._3dva = _360(_3d_angle+90) a0 = _2rad(_3dva) self._xdepth_3d = cos(a0)*self.depth_3d self._ydepth_3d = sin(a0)*self.depth_3d self._cx = self.x+self.width/2.0 self._cy = self.y+(self.height - self._ydepth_3d)/2.0 radius = self._radius = self._cx - 5 self._radiusx = radiusx = radius self._radiusy = radiusy = (1.0 - self.perspective/100.0)*radius data = self.normalizeData() sum = self._sum | 6231c6a4bfec70d1e8b5577eccd857a504ee7bda /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/6231c6a4bfec70d1e8b5577eccd857a504ee7bda/piecharts.py |
if '.' in path: | while '.' in path: if debug: print 'removed . from path' | def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') name = parts[0] if baseDir is None: path = sys.path[:] else: if type(baseDir) not in SeqTypes: path = [baseDir] else: path = list(baseDir) path = filter(None,path) if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule | 116148472c2fdeac4e8dea6e3401cdb4bce70920 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/116148472c2fdeac4e8dea6e3401cdb4bce70920/utils.py |
if abspath in path: | while abspath in path: if debug: print 'removed "%s" from path' % abspath | def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') name = parts[0] if baseDir is None: path = sys.path[:] else: if type(baseDir) not in SeqTypes: path = [baseDir] else: path = list(baseDir) path = filter(None,path) if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule | 116148472c2fdeac4e8dea6e3401cdb4bce70920 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/116148472c2fdeac4e8dea6e3401cdb4bce70920/utils.py |
__version__ = '$Id: ttfonts.py,v 1.1 2002/05/28 15:33:57 rgbecker Exp $' | __version__ = '$Id: ttfonts.py,v 1.2 2002/07/02 21:28:29 dinu_gherman Exp $' | def getSubsetInternalName(self, subset, doc): '''Returns the name of a PDF Font object corresponding to a given subset of this dynamic font. Use this function instead of PDFDocument.getInternalFontName.''' | dc9fc2a23ae8cc092d04aa76950652ec03fc6c00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dc9fc2a23ae8cc092d04aa76950652ec03fc6c00/ttfonts.py |
while length > 1: | while length > 0: | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. | dc9fc2a23ae8cc092d04aa76950652ec03fc6c00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dc9fc2a23ae8cc092d04aa76950652ec03fc6c00/ttfonts.py |
if char < 0x20 or char > 0x7E: | if char < 33 or char > 126 or chr(char) in \ ('[', ']', '(', ')', '{', '}', '<', '>', '/', '%'): | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. | dc9fc2a23ae8cc092d04aa76950652ec03fc6c00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dc9fc2a23ae8cc092d04aa76950652ec03fc6c00/ttfonts.py |
length = length - 2 | length = length - 1 break elif platformId == 1 and encodingId == 0 and languageId == 0 \ and nameId == 6: psName = self.get_chunk(string_data_offset + offset, length) for char in psName: char = ord(char) if char < 33 or char > 126 or chr(char) in \ ('[', ']', '(', ')', '{', '}', '<', '>', '/', '%'): raise TTFError, "PostScript contains invalid character %02X" % char break | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. | dc9fc2a23ae8cc092d04aa76950652ec03fc6c00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dc9fc2a23ae8cc092d04aa76950652ec03fc6c00/ttfonts.py |
raise TTFError, 'Font does not have cmap for Unicode (platform 3, encoding 1, format 4)' | raise TTFError, 'Font does not have cmap for Unicode (platform 3, encoding 1, format 4 or platform 0 any encoding format 4)' | def extractInfo(self, charInfo=1): """Extract typographic information from the loaded font file. | dc9fc2a23ae8cc092d04aa76950652ec03fc6c00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/dc9fc2a23ae8cc092d04aa76950652ec03fc6c00/ttfonts.py |
return lambda v, s=start, e=end, f=f: f(v,s,e,_3d_dx=_3d_dx,_3d_dy=_3d_dy) | return lambda v, s=start, e=end, f=f,_3d_dx=_3d_dx,_3d_dy=_3d_dy: f(v,s,e,_3d_dx=_3d_dx,_3d_dy=_3d_dy) | def _getLineFunc(self, start, end, parent=None): _3d_dx = getattr(parent,'_3d_dx',None) if _3d_dx is not None: _3d_dy = getattr(parent,'_3d_dy',None) f = self._dataIndex and self._cyLine3d or self._cxLine3d return lambda v, s=start, e=end, f=f: f(v,s,e,_3d_dx=_3d_dx,_3d_dy=_3d_dy) else: f = self._dataIndex and self._cyLine or self._cxLine return lambda v, s=start, e=end, f=f: f(v,s,e) | 842bea12fd6f610f6406985c79da84c4921f0bc2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/842bea12fd6f610f6406985c79da84c4921f0bc2/axes.py |
if self.fillColor is not None: | if self._fillColor is not None: | def drawCentredString(self, x, y, text, text_anchor='middle'): if self.fillColor is not None: textLen = stringWidth(text, self._font,self._fontSize) if text_anchor=='end': x = x-textLen elif text_anchor=='middle': x = x - textLen/2 self.drawString(x,y,text) | 8a366f063aaff6cff478ee881451c0403b911ad2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/8a366f063aaff6cff478ee881451c0403b911ad2/renderPS.py |
mask=mask, | mask=self._mask, | def draw(self): #center it self.canv.drawImage(self.filename, 0, 0, self.drawWidth, self.drawHeight, mask=mask, ) | 3836e7fad155f205445228a83252c2eb87c2fbe0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/3836e7fad155f205445228a83252c2eb87c2fbe0/flowables.py |
(groupX, groupWidth) = self.categoryAxis.scale(colNo) x = groupX + (0.5 * self.groupSpacing * normFactor) y = self.valueAxis.scale(0) height = self.valueAxis.scale(datum) - y lineRow.append((x, y+height)) | if datum is not None: (groupX, groupWidth) = self.categoryAxis.scale(colNo) x = groupX + (0.5 * self.groupSpacing * normFactor) y = self.valueAxis.scale(0) height = self.valueAxis.scale(datum) - y lineRow.append((x, y+height)) | def calcPositions(self): """Works out where they go. | f81a0e2ab01f1f1debe5719c9d72f4ac34b88a74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f81a0e2ab01f1f1debe5719c9d72f4ac34b88a74/linecharts.py |
if callout: callout(self,g,thisx,y,colorNamePairs[count]) | if callout: callout(self,g,thisx,y,(col,name)) | def gAdd(t,g=g,fontName=fontName,fontSize=fontSize,fillColor=fillColor): t.fontName = fontName t.fontSize = fontSize t.fillColor = fillColor return g.add(t) | a3cb5bace045b38885c035998e20281066ff9a9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a3cb5bace045b38885c035998e20281066ff9a9e/legends.py |
if S[-1]=='': del S[-1] | if S==[]: S = [''] | def _getFragWords(frags): ''' given a Parafrag list return a list of fragwords [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text #del f.text # we can't do this until we sort out splitting # of paragraphs if text!='': S = split(text) if S[-1]=='': del S[-1] if W!=[] and text[0] in whitespace: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in whitespace: W.insert(0,n) R.append(W) W = [] n = 0 elif hasattr(f,'cbDefn'): W.append((f,'')) if W!=[]: W.insert(0,n) R.append(W) return R | bacf9da3f34fcc980069662749fea10714080f99 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bacf9da3f34fcc980069662749fea10714080f99/paragraph.py |
if sys.platform=='win32' and ('install' in sys.argv or 'install_ext' in sys.argv): | if sys.hexversion<0x2030000 and sys.platform=='win32' and ('install' in sys.argv or 'install_ext' in sys.argv): | def raiseConfigError(msg): import exceptions class ConfigError(exceptions.Exception): pass raise ConfigError(msg) | 78fc70c06d0c9e0d72d4389ab9f0b2666df8997e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/78fc70c06d0c9e0d72d4389ab9f0b2666df8997e/setup.py |
def _addObjImport(obj,I): | def _addObjImport(obj,I,n=None): | def _addObjImport(obj,I): '''add an import of obj's class to a dictionary of imports''' from inspect import getmodule c = obj.__class__ m = getmodule(c).__name__ cn = c.__name__ if not I.has_key(m): I[m] = [cn] elif cn not in I[m]: I[m].append(cn) | 79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7/shapes.py |
cn = c.__name__ | n = n or c.__name__ | def _addObjImport(obj,I): '''add an import of obj's class to a dictionary of imports''' from inspect import getmodule c = obj.__class__ m = getmodule(c).__name__ cn = c.__name__ if not I.has_key(m): I[m] = [cn] elif cn not in I[m]: I[m].append(cn) | 79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7/shapes.py |
I[m] = [cn] elif cn not in I[m]: I[m].append(cn) | I[m] = [n] elif n not in I[m]: I[m].append(n) | def _addObjImport(obj,I): '''add an import of obj's class to a dictionary of imports''' from inspect import getmodule c = obj.__class__ m = getmodule(c).__name__ cn = c.__name__ if not I.has_key(m): I[m] = [cn] elif cn not in I[m]: I[m].append(cn) | 79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7/shapes.py |
P.extend(args) | P.extend(list(args)) | def definePath(pathSegs=[],isClipPath=0, dx=0, dy=0, **kw): O = [] P = [] for seg in pathSegs: if type(seg) not in [ListType,TupleType]: opName = seg args = [] else: opName = seg[0] args = seg[1:] if opName not in _PATH_OP_NAMES: raise ValueError, 'bad operator name %s' % opName op = _PATH_OP_NAMES.index(opName) if len(args)!=_PATH_OP_ARG_COUNT[op]: raise ValueError, '%s bad arguments %s' % (opName,str(args)) O.append(op) P.extend(args) for d,o in (dx,0), (dy,1): for i in xrange(o,len(P),2): P[i] = P[i]+d return apply(Path,(P,O,isClipPath),kw) | 79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/79d3a5b5f63d0b4c99d9cddf85c0854ebb240aa7/shapes.py |
else: self._syntax_error('<onDraw/> needs at least a name attribute') | else: self._syntax_error('<onDraw> needs at least a name attribute') | def start_onDraw(self,attr): defn = ParaFrag() if attr.has_key('name'): defn.name = attr['name'] else: self._syntax_error('<onDraw/> needs at least a name attribute') | 348618da9c231b4c66e4e222709ad5c1c1899b51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/348618da9c231b4c66e4e222709ad5c1c1899b51/paraparser.py |
def end_onDraw(self): if hasattr(self,'text'): self._syntax_error('Only <onDraw/> tag allowed') else: self.handle_data('') | self.handle_data('') | def start_onDraw(self,attr): defn = ParaFrag() if attr.has_key('name'): defn.name = attr['name'] else: self._syntax_error('<onDraw/> needs at least a name attribute') | 348618da9c231b4c66e4e222709ad5c1c1899b51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/348618da9c231b4c66e4e222709ad5c1c1899b51/paraparser.py |
print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, '|%s|'%l.text[:25] | print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, '|%s|'%l.text[:25], if hasattr(l,'cbDefn'): print 'cbDefn',l.cbDefn.name,l.cbDefn.label,l.cbDefn.kind else: print | def check_text(text,p=_parser): print '##########' text = cleanBlockQuotedText(text) l,rv,bv = p.parse(text,style) if rv is None: for l in _parser.errors: print l else: print 'ParaStyle', l.fontName,l.fontSize,l.textColor for l in rv: print l.fontName,l.fontSize,l.textColor,l.bold, l.rise, '|%s|'%l.text[:25] | 348618da9c231b4c66e4e222709ad5c1c1899b51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/348618da9c231b4c66e4e222709ad5c1c1899b51/paraparser.py |
child.setProperties(Widget.getProperties(self)) | for i in child._attrMap.keys(): del child.__dict__[i] child = TypedPropertyElementWrapper(self,child) | def __getitem__(self, index): try: return self._children[index] except KeyError: child = self._prototype() #should we copy down? how to keep in synch? child.setProperties(Widget.getProperties(self)) self._children[index] = child return child | 5e75a3723764d5b941659cdcd2dc7aefa0ad6c98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/5e75a3723764d5b941659cdcd2dc7aefa0ad6c98/widgetbase.py |
def getModuleObjects(folder, rootName, typ): "Get a list of all function objects defined *somewhere* in a package." folders = [folder] + subFoldersOfFolder(folder) objects = [] for f in folders: sys.path.insert(0, f) os.chdir(f) pattern = os.path.join('*.py') prefix = f[string.find(f, rootName):] prefix = string.replace(prefix, os.sep, '.') modNames = glob.glob(pattern) modNames = filter(lambda m:string.find(m, '__init__.py') == -1, modNames) # Make module names fully qualified. for i in range(len(modNames)): modNames[i] = prefix + '.' + modNames[i][:string.find(modNames[i], '.')] for mName in modNames: module = __import__(mName) # Get the 'real' (leaf) module # (__import__ loads only the top-level one). if string.find(mName, '.') != -1: for part in string.split(mName, '.')[1:]: module = getattr(module, part) # Find the objects in the module's content. modContentNames = dir(module) # Handle modules. if typ == types.ModuleType: if string.find(module.__name__, 'reportlab') > -1: objects.append((mName, module)) continue for n in modContentNames: obj = eval(mName + '.' + n) # Handle functions and classes. if typ in (types.FunctionType, types.ClassType): if type(obj) == typ: objects.append((mName, obj)) # Handle methods. elif typ == types.MethodType: if type(obj) == types.ClassType: for m in dir(obj): a = getattr(obj, m) if type(a) == typ: cName = obj.__name__ objects.append(("%s.%s" % (mName, cName), a)) del sys.path[0] return objects | 9d3eb3bed02bb6b9c7db798cb91bc83e0a8b21b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/9d3eb3bed02bb6b9c7db798cb91bc83e0a8b21b3/test_docstrings.py |
||
class DocstringTestCase(unittest.TestCase): | class DocstringTestCase(SecureTestCase): | def getModuleObjects(folder, rootName, typ): "Get a list of all function objects defined *somewhere* in a package." folders = [folder] + subFoldersOfFolder(folder) objects = [] for f in folders: sys.path.insert(0, f) os.chdir(f) pattern = os.path.join('*.py') prefix = f[string.find(f, rootName):] prefix = string.replace(prefix, os.sep, '.') modNames = glob.glob(pattern) modNames = filter(lambda m:string.find(m, '__init__.py') == -1, modNames) # Make module names fully qualified. for i in range(len(modNames)): modNames[i] = prefix + '.' + modNames[i][:string.find(modNames[i], '.')] for mName in modNames: module = __import__(mName) # Get the 'real' (leaf) module # (__import__ loads only the top-level one). if string.find(mName, '.') != -1: for part in string.split(mName, '.')[1:]: module = getattr(module, part) # Find the objects in the module's content. modContentNames = dir(module) # Handle modules. if typ == types.ModuleType: if string.find(module.__name__, 'reportlab') > -1: objects.append((mName, module)) continue for n in modContentNames: obj = eval(mName + '.' + n) # Handle functions and classes. if typ in (types.FunctionType, types.ClassType): if type(obj) == typ: objects.append((mName, obj)) # Handle methods. elif typ == types.MethodType: if type(obj) == types.ClassType: for m in dir(obj): a = getattr(obj, m) if type(a) == typ: cName = obj.__name__ objects.append(("%s.%s" % (mName, cName), a)) del sys.path[0] return objects | 9d3eb3bed02bb6b9c7db798cb91bc83e0a8b21b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/9d3eb3bed02bb6b9c7db798cb91bc83e0a8b21b3/test_docstrings.py |
h = s/5 z = s/2 star = Polygon(points = [ h-z, 0-z, h*1.5-z, h*2.05-z, 0-z, h*3-z, h*1.95-z, h*3-z, z-z, s-z, h*3.25-z, h*3-z, s-z, h*3-z, s-h*1.5-z, h*2.05-z, s-h-z, 0-z, z-z, h-z, ], | star = Polygon(P, | def draw(self): s = float(self.size) #abbreviate as we will use this a lot g = Group() | ec9acd74860c916ac188fac39fcd8b4b8fb1c1f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ec9acd74860c916ac188fac39fcd8b4b8fb1c1f6/flags.py |
"""This function produces two pdf files with examples of all the signs and symbols from this file. | """This function produces three pdf files with examples of all the signs and symbols from this file. | def test(): """This function produces two pdf files with examples of all the signs and symbols from this file. """ | ec9acd74860c916ac188fac39fcd8b4b8fb1c1f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ec9acd74860c916ac188fac39fcd8b4b8fb1c1f6/flags.py |
rowCount = er - sr | rowCount = er - sr + 1 | def _drawBkgrnd(self): nrows = self._nrows ncols = self._ncols for cmd, (sc, sr), (ec, er), arg in self._bkgrndcmds: if sc < 0: sc = sc + ncols if ec < 0: ec = ec + ncols if sr < 0: sr = sr + nrows if er < 0: er = er + nrows x0 = self._colpositions[sc] y0 = self._rowpositions[sr] x1 = self._colpositions[min(ec+1,ncols)] y1 = self._rowpositions[min(er+1,nrows)] w, h = x1-x0, y1-y0 canv = self.canv if callable(arg): apply(arg,(self,canv, x0, y0, w, h)) elif cmd == 'ROWBACKGROUNDS': #Need a list of colors to cycle through. The arguments #might be already colours, or convertible to colors, or # None, or the string 'None'. #It's very common to alternate a pale shade with None. #print 'rowHeights=', self._rowHeights colorCycle = map(colors.toColorOrNone, arg) count = len(colorCycle) rowCount = er - sr for i in range(rowCount): color = colorCycle[i%count] h = self._rowHeights[sr + i] if color: canv.setFillColor(color) canv.rect(x0, y0, w, -h, stroke=0,fill=1) #print ' draw %0.0f, %0.0f, %0.0f, %0.0f' % (x0,y0,w,-h) y0 = y0 - h | 27e5291923a8a6f676a1948e2126f3b2337cb16a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/27e5291923a8a6f676a1948e2126f3b2337cb16a/tables.py |
colCount = ec - sc | colCount = ec - sc + 1 | def _drawBkgrnd(self): nrows = self._nrows ncols = self._ncols for cmd, (sc, sr), (ec, er), arg in self._bkgrndcmds: if sc < 0: sc = sc + ncols if ec < 0: ec = ec + ncols if sr < 0: sr = sr + nrows if er < 0: er = er + nrows x0 = self._colpositions[sc] y0 = self._rowpositions[sr] x1 = self._colpositions[min(ec+1,ncols)] y1 = self._rowpositions[min(er+1,nrows)] w, h = x1-x0, y1-y0 canv = self.canv if callable(arg): apply(arg,(self,canv, x0, y0, w, h)) elif cmd == 'ROWBACKGROUNDS': #Need a list of colors to cycle through. The arguments #might be already colours, or convertible to colors, or # None, or the string 'None'. #It's very common to alternate a pale shade with None. #print 'rowHeights=', self._rowHeights colorCycle = map(colors.toColorOrNone, arg) count = len(colorCycle) rowCount = er - sr for i in range(rowCount): color = colorCycle[i%count] h = self._rowHeights[sr + i] if color: canv.setFillColor(color) canv.rect(x0, y0, w, -h, stroke=0,fill=1) #print ' draw %0.0f, %0.0f, %0.0f, %0.0f' % (x0,y0,w,-h) y0 = y0 - h | 27e5291923a8a6f676a1948e2126f3b2337cb16a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/27e5291923a8a6f676a1948e2126f3b2337cb16a/tables.py |
group = transformNode(self.doc, "g", transform="") self.currGroup.appendChild(group) | currGroup, group = self.currGroup, transformNode(self.doc, "g", transform="") currGroup.appendChild(group) | def startGroup(self): if self.verbose: print "+++ begin SVGCanvas.startGroup" group = transformNode(self.doc, "g", transform="") self.currGroup.appendChild(group) self.currGroup = group if self.verbose: print "+++ end SVGCanvas.startGroup" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
def endGroup(self): | return currGroup def endGroup(self,currGroup): | def startGroup(self): if self.verbose: print "+++ begin SVGCanvas.startGroup" group = transformNode(self.doc, "g", transform="") self.currGroup.appendChild(group) self.currGroup = group if self.verbose: print "+++ end SVGCanvas.startGroup" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
if not self.currGroup.getAttribute("transform"): pass | self.currGroup = currGroup | def endGroup(self): if self.verbose: print "+++ begin SVGCanvas.endGroup" if not self.currGroup.getAttribute("transform"): pass #self.currGroup.removeAttribute("transform") # self.currGroup = self.currGroup.parentNode if self.verbose: print "+++ end SVGCanvas.endGroup" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
def transform(self, a, b, c, d, e, f): if self.verbose: print "!!! begin SVGCanvas.transform", a, b, c, d, e, f tr = self.currGroup.getAttribute("transform") t = 'matrix(%f, %f, %f, %f, %f, %f)' % (a,b,c,d,e,f) if (a, b, c, d, e, f) != (1, 0, 0, 1, 0, 0): self.currGroup.setAttribute("transform", "%s %s" % (tr, t)) # self.currGroup = self.currGroup.parentNode | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
||
self._canvas.startGroup() | currGroup = self._canvas.startGroup() | def drawGroup(self, group): if self.verbose: print "### begin _SVGRenderer.drawGroup" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
self._canvas.endGroup() | def drawGroup(self, group): if self.verbose: print "### begin _SVGRenderer.drawGroup" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
|
def applyStateChanges(self, delta, newState): """This takes a set of states, and outputs the operators needed to set those properties""" | bdd3c784f062da948b8d9fcb8a343d179516359d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/bdd3c784f062da948b8d9fcb8a343d179516359d/renderSVG.py |
||
valueStep = P[1]-P[0] | if len(P)>1: valueStep = P[1]-P[0] else: oVS = self.valueStep self.valueStep = None P = self._calcTickPositions() self.valueStep = oVS if len(P)>1: valueStep = P[1]-P[0] else: valueStep = self._valueStep | def _setRange(self, dataSeries): """Set minimum and maximum axis values. | 0381bea6798e59b4b21874fd50ad46c7b13d4618 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0381bea6798e59b4b21874fd50ad46c7b13d4618/axes.py |
for r in R: f = r[1][0] | def _getFragWords(frags): ''' given a fragment list return a list of lists [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text #del f.text # we can't do this until we sort out splitting # of paragraphs if text!='': S = string.split(text,' ') if W!=[] and text[0] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 if W!=[]: W.insert(0,n) R.append(W) for r in R: f = r[1][0] return R | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
|
for l in bfrag.lines[start:stop-1]: | lines = bfrag.lines[start:stop] for l in lines: | def _getFragWords(frags): ''' given a fragment list return a list of lists [[size, (f00,w00), ..., (f0n,w0n)],....,[size, (fm0,wm0), ..., (f0n,wmn)]] each pair f,w represents a style and some string each sublist represents a word ''' R = [] W = [] n = 0 for f in frags: text = f.text #del f.text # we can't do this until we sort out splitting # of paragraphs if text!='': S = string.split(text,' ') if W!=[] and text[0] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 for w in S[:-1]: W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) W.insert(0,n) R.append(W) W = [] n = 0 w = S[-1] W.append((f,w)) n = n + stringWidth(w, f.fontName, f.fontSize) if text[-1] in [' ','\t']: W.insert(0,n) R.append(W) W = [] n = 0 if W!=[]: W.insert(0,n) R.append(W) for r in R: f = r[1][0] return R | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
words[-1].text = w[1][1] | words[-1].text = nText | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
words[-1].text = words[-1].text+' ' | if nText!='' and nText[0]!=' ': words[-1].text = words[-1].text + ' ' | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
words[-1].text = w[1][1] | words[-1].text = nText | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
words[-1].text = words[-1].text + ' ' + w[1][1] | words[-1].text = words[-1].text + ' ' + nText | def breakLines(self, width): """ Returns a broken line structure. There are two cases A) For the simple case of a single formatting input fragment the output is A fragment specifier with kind = 0 fontName, fontSize, leading, textColor lines= A list of lines Each line has two items. 1) unused width in points 2) word list | cd50818787943255f4fd36ac26d500bae6989957 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/cd50818787943255f4fd36ac26d500bae6989957/paragraph.py |
self.decimalPlaces = places self.decimalSeparator = decimalSep self.thousandSeparator = thousandSep | self.places = places self.dot = decimalSep self.comma = thousandSep | def __init__(self, places=2, decimalSep='.', thousandSep=None, prefix=None, suffix=None): self.decimalPlaces = places self.decimalSeparator = decimalSep self.thousandSeparator = thousandSep self.prefix = prefix self.suffix = suffix | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
places, sep = self.decimalPlaces, self.decimalSeparator | places, sep = self.places, self.dot | def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | strInt = ('%.' + str(places) + 'f') % num if places: strInt, strFrac = strInt.split('.') strFrac = sep + strFrac if strip: while strFrac and strFrac[-1] in ['0',sep]: strFrac = strFrac[:-1] else: strFrac = '' | def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
if self.thousandSeparator is not None: | if self.comma is not None: | def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
||
strNew = self.thousandSeparator + right + strNew | strNew = self.comma + right + strNew | def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
strFrac = sep + strFrac if strip: while strFrac and strFrac[-1] in ['0',sep]: strFrac = strFrac[:-1] | def format(self, num): # positivize the numbers sign=num<0 if sign: num = -num places, sep = self.decimalPlaces, self.decimalSeparator strip = places<=0 if places and strip: places = -places strInt, strFrac = (('%.' + str(places) + 'f') % num).split('.') | b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/b4bda7469f194e7f4a4cebbbb96c86ddd2f5fba3/formatters.py |
|
return (NameString, AttDict, ContentList, ExtraStuff) | return (NameString, AttDict, ContentList, ExtraStuff), len(xmltext) | def parsexml0(xmltext, startingat=0, toplevel=1, # snarf in some globals strip=string.strip, split=string.split, find=string.find, entityReplacer=unEscapeContentList, #len=len, None=None #LENCDATAMARKER=LENCDATAMARKER, CDATAMARKER=CDATAMARKER ): """simple recursive descent xml parser... return (dictionary, endcharacter) special case: comment returns (None, endcharacter)""" #from string import strip, split, find #print "parsexml0", `xmltext[startingat: startingat+10]` # DEFAULTS NameString = NONAME ContentList = AttDict = ExtraStuff = None if toplevel is not None: #if verbose: print "at top level" #if startingat!=0: # raise ValueError, "have to start at 0 for top level!" xmltext = strip(xmltext) cursor = startingat #look for interesting starting points firstbracket = find(xmltext, "<", cursor) afterbracket2char = xmltext[firstbracket+1:firstbracket+3] #print "a", `afterbracket2char` #firstampersand = find(xmltext, "&", cursor) #if firstampersand>0 and firstampersand<firstbracket: # raise ValueError, "I don't handle ampersands yet!!!" docontents = 1 if firstbracket<0: # no tags #if verbose: print "no tags" if toplevel is not None: #D = {NAMEKEY: NONAME, CONTENTSKEY: [xmltext[cursor:]]} ContentList = [xmltext[cursor:]] if entityReplacer: ContentList = entityReplacer(ContentList) return (NameString, AttDict, ContentList, ExtraStuff) else: raise ValueError, "no tags at non-toplevel %s" % `xmltext[cursor:cursor+20]` #D = {} L = [] # look for start tag # NEED to force always outer level is unnamed!!! #if toplevel and firstbracket>0: #afterbracket2char = xmltext[firstbracket:firstbracket+2] if toplevel is not None: #print "toplevel with no outer tag" NameString = name = NONAME cursor = skip_prologue(xmltext, cursor) #break elif firstbracket<0: raise ValueError, "non top level entry should be at start tag: %s" % repr(xmltext[:10]) # special case: CDATA elif afterbracket2char=="![" and xmltext[firstbracket:firstbracket+9]=="<![CDATA[": #print "in CDATA", cursor # skip straight to the close marker startcdata = firstbracket+9 endcdata = find(xmltext, CDATAENDMARKER, startcdata) if endcdata<0: raise ValueError, "unclosed CDATA %s" % repr(xmltext[cursor:cursor+20]) NameString = CDATAMARKER ContentList = [xmltext[startcdata: endcdata]] cursor = endcdata+len(CDATAENDMARKER) docontents = None # special case COMMENT elif afterbracket2char=="!-" and xmltext[firstbracket:firstbracket+4]=="<!--": #print "in COMMENT" endcommentdashes = find(xmltext, "--", firstbracket+4) if endcommentdashes<firstbracket: raise ValueError, "unterminated comment %s" % repr(xmltext[cursor:cursor+20]) endcomment = endcommentdashes+2 if xmltext[endcomment]!=">": raise ValueError, "invalid comment: contains double dashes %s" % repr(xmltext[cursor:cursor+20]) return (None, endcomment+1) # shortcut exit else: # get the rest of the tag #if verbose: print "parsing start tag" # make sure the tag isn't in doublequote pairs closebracket = find(xmltext, ">", firstbracket) noclose = closebracket<0 startsearch = closebracket+1 pastfirstbracket = firstbracket+1 tagcontent = xmltext[pastfirstbracket:closebracket] # shortcut, no equal means nothing but name in the tag content if '=' not in tagcontent: if tagcontent[-1]=="/": # simple case #print "simple case", tagcontent tagcontent = tagcontent[:-1] docontents = None name = strip(tagcontent) NameString = name cursor = startsearch else: if '"' in tagcontent: # check double quotes stop = None # not inside double quotes! (the split should have odd length) if noclose or len(split(tagcontent+".", '"'))% 2: stop=1 while stop is None: closebracket = find(xmltext, ">", startsearch) startsearch = closebracket+1 noclose = closebracket<0 tagcontent = xmltext[pastfirstbracket:closebracket] # not inside double quotes! (the split should have odd length) if noclose or len(split(tagcontent+".", '"'))% 2: stop=1 if noclose: raise ValueError, "unclosed start tag %s" % repr(xmltext[firstbracket:firstbracket+20]) cursor = startsearch #cursor = closebracket+1 # handle simple tag /> syntax if xmltext[closebracket-1]=="/": #if verbose: print "it's a simple tag" closebracket = closebracket-1 tagcontent = tagcontent[:-1] docontents = None #tagcontent = xmltext[firstbracket+1:closebracket] tagcontent = strip(tagcontent) taglist = split(tagcontent, "=") #if not taglist: # raise ValueError, "tag with no name %s" % repr(xmltext[firstbracket:firstbracket+20]) taglist0 = taglist[0] taglist0list = split(taglist0) #if len(taglist0list)>2: # raise ValueError, "bad tag head %s" % repr(taglist0) name = taglist0list[0] #print "tag name is", name NameString = name # now parse the attributes attributename = taglist0list[-1] # put a fake att name at end of last taglist entry for consistent parsing taglist[-1] = taglist[-1]+" f" AttDict = D = {} taglistindex = 1 lasttaglistindex = len(taglist) #for attentry in taglist[1:]: while taglistindex<lasttaglistindex: #print "looking for attribute named", attributename attentry = taglist[taglistindex] taglistindex = taglistindex+1 attentry = strip(attentry) if attentry[0]!='"': raise ValueError, "attribute value must start with double quotes" + repr(attentry) while '"' not in attentry[1:]: # must have an = inside the attribute value... if taglistindex>lasttaglistindex: raise ValueError, "unclosed value " + repr(attentry) nextattentry = taglist[taglistindex] taglistindex = taglistindex+1 attentry = "%s=%s" % (attentry, nextattentry) attentry = strip(attentry) # only needed for while loop... attlist = split(attentry) nextattname = attlist[-1] attvalue = attentry[:-len(nextattname)] attvalue = strip(attvalue) try: first = attvalue[0]; last=attvalue[-1] except: raise ValueError, "attvalue,attentry,attlist="+repr((attvalue, attentry,attlist)) if first==last=='"' or first==last=="'": attvalue = attvalue[1:-1] #print attributename, "=", attvalue D[attributename] = attvalue attributename = nextattname # pass over other tags and content looking for end tag if docontents is not None: #print "now looking for end tag" ContentList = L while docontents is not None: nextopenbracket = find(xmltext, "<", cursor) if nextopenbracket<cursor: #if verbose: print "no next open bracket found" if name==NONAME: #print "no more tags for noname", repr(xmltext[cursor:cursor+10]) docontents=None # done remainder = xmltext[cursor:] cursor = len(xmltext) if remainder: L.append(remainder) else: raise ValueError, "no close bracket for %s found after %s" % (name,repr(xmltext[cursor: cursor+20])) # is it a close bracket? elif xmltext[nextopenbracket+1]=="/": #print "found close bracket", repr(xmltext[nextopenbracket:nextopenbracket+20]) nextclosebracket = find(xmltext, ">", nextopenbracket) if nextclosebracket<nextopenbracket: raise ValueError, "unclosed close tag %s" % repr(xmltext[nextopenbracket: nextopenbracket+20]) closetagcontents = xmltext[nextopenbracket+2: nextclosebracket] closetaglist = split(closetagcontents) #if len(closetaglist)!=1: #print closetagcontents #raise ValueError, "bad close tag format %s" % repr(xmltext[nextopenbracket: nextopenbracket+20]) # name should match closename = closetaglist[0] #if verbose: print "closetag name is", closename if name!=closename: prefix = xmltext[:cursor] endlinenum = len(split(prefix, "\n")) prefix = xmltext[:startingat] linenum = len(split(prefix, "\n")) raise ValueError, \ "at lines %s...%s close tag name doesn't match %s...%s %s" %( linenum, endlinenum, `name`, `closename`, repr(xmltext[cursor: cursor+100])) remainder = xmltext[cursor:nextopenbracket] if remainder: #if verbose: print "remainder", repr(remainder) L.append(remainder) cursor = nextclosebracket+1 #print "for", name, "found close tag" docontents = None # done # otherwise we are looking at a new tag, recursively parse it... # first record any intervening content else: remainder = xmltext[cursor:nextopenbracket] if remainder: L.append(remainder) #if verbose: # #print "skipping", repr(remainder) # #print "--- recursively parsing starting at", xmltext[nextopenbracket:nextopenbracket+20] (parsetree, cursor) = parsexml0(xmltext, startingat=nextopenbracket, toplevel=None, entityReplacer=entityReplacer) if parsetree: L.append(parsetree) # maybe should check for trailing garbage? # toplevel: # remainder = strip(xmltext[cursor:]) # if remainder: # raise ValueError, "trailing garbage at top level %s" % repr(remainder[:20]) if ContentList: if entityReplacer: ContentList = entityReplacer(ContentList) t = (NameString, AttDict, ContentList, ExtraStuff) return (t, cursor) | d0e16f3dc613b527f024cc872e50a87b7cec1bca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/d0e16f3dc613b527f024cc872e50a87b7cec1bca/rparsexml.py |
filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' | if self.sourceFilename: filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' | def saveAsPresentation(self): """Write the PDF document, one slide per page.""" if self.verbose: print 'saving presentation...' pageSize = (self.pageWidth, self.pageHeight) filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' if self.outDir: filename = os.path.join(self.outDir,os.path.basename(filename)) if self.verbose: print filename canv = canvas.Canvas(filename, pagesize = pageSize) canv.setPageCompression(self.compression) | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
canv = canvas.Canvas(filename, pagesize = pageSize) | outfile = cStringIO.StringIO() canv = canvas.Canvas(outfile, pagesize = pageSize) | def saveAsPresentation(self): """Write the PDF document, one slide per page.""" if self.verbose: print 'saving presentation...' pageSize = (self.pageWidth, self.pageHeight) filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' if self.outDir: filename = os.path.join(self.outDir,os.path.basename(filename)) if self.verbose: print filename canv = canvas.Canvas(filename, pagesize = pageSize) canv.setPageCompression(self.compression) | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' doc = SimpleDocTemplate(filename, pagesize=rl_config.defaultPageSize, showBoundary=0) | if self.sourceFilename : filename = os.path.splitext(self.sourceFilename)[0] + '.pdf' outfile = cStringIO.StringIO() doc = SimpleDocTemplate(outfile, pagesize=rl_config.defaultPageSize, showBoundary=0) | def saveAsHandout(self): """Write the PDF document, multiple slides per page.""" | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
self.saveAsHandout() | return self.saveAsHandout() | def save(self): "Save the PDF document." | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
self.saveAsPresentation() | return self.saveAsPresentation() | def save(self): "Save the PDF document." | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
rawdata = open(datafilename).read() | def process(datafilename, notes=0, handout=0, cols=0, verbose=0, outDir=None): "Process one PythonPoint source file." from reportlab.tools.pythonpoint.stdparser import PPMLParser parser = PPMLParser() parser.sourceFilename = datafilename rawdata = open(datafilename).read() parser.feed(rawdata) pres = parser.getPresentation() pres.sourceFilename = datafilename pres.outDir = outDir pres.notes = notes pres.handout = handout pres.cols = cols pres.verbose = verbose #this does all the work pres.save() if verbose: print 'saved presentation %s.pdf' % os.path.splitext(datafilename)[0] parser.close() | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
|
pres.save() | pdfcontent = pres.save() | def process(datafilename, notes=0, handout=0, cols=0, verbose=0, outDir=None): "Process one PythonPoint source file." from reportlab.tools.pythonpoint.stdparser import PPMLParser parser = PPMLParser() parser.sourceFilename = datafilename rawdata = open(datafilename).read() parser.feed(rawdata) pres = parser.getPresentation() pres.sourceFilename = datafilename pres.outDir = outDir pres.notes = notes pres.handout = handout pres.cols = cols pres.verbose = verbose #this does all the work pres.save() if verbose: print 'saved presentation %s.pdf' % os.path.splitext(datafilename)[0] parser.close() | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
return pdfcontent | def process(datafilename, notes=0, handout=0, cols=0, verbose=0, outDir=None): "Process one PythonPoint source file." from reportlab.tools.pythonpoint.stdparser import PPMLParser parser = PPMLParser() parser.sourceFilename = datafilename rawdata = open(datafilename).read() parser.feed(rawdata) pres = parser.getPresentation() pres.sourceFilename = datafilename pres.outDir = outDir pres.notes = notes pres.handout = handout pres.cols = cols pres.verbose = verbose #this does all the work pres.save() if verbose: print 'saved presentation %s.pdf' % os.path.splitext(datafilename)[0] parser.close() | f1978dc295686f0bc28de276ebf41b91d67e5b87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/f1978dc295686f0bc28de276ebf41b91d67e5b87/pythonpoint.py |
|
self.filename = filename | self._file = self.filename = filename | def __init__(self, filename, width=None, height=None, kind='direct', mask="auto", lazy=1): """If size to draw at not specified, get it from the image.""" self.hAlign = 'CENTER' self._mask = mask # if it is a JPEG, will be inlined within the file - # but we still need to know its size now fp = hasattr(filename,'read') if fp: self.filename = `filename` else: self.filename = filename if not fp and os.path.splitext(filename)[1] in ['.jpg', '.JPG', '.jpeg', '.JPEG']: f = open(filename, 'rb') info = pdfutils.readJPEGInfo(f) f.close() self.imageWidth = info[0] self.imageHeight = info[1] self._setup(width,height,kind,0) self._img = None elif fp: self._setup(width,height,kind,0) else: self._setup(width,height,kind,lazy) | 1c036cda6a558fbdd3287a8f1333b70fa63f54b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1c036cda6a558fbdd3287a8f1333b70fa63f54b2/flowables.py |
self._img = ImageReader(self.filename) | self._img = ImageReader(self._file) del self._file | def __getattr__(self,a): if a=='_img': from reportlab.lib.utils import ImageReader #this may raise an error self._img = ImageReader(self.filename) return self._img elif a in ('drawWidth','drawHeight','imageWidth','imageHeight'): self._setup_inner() return self.__dict__[a] raise AttributeError(a) | 1c036cda6a558fbdd3287a8f1333b70fa63f54b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/1c036cda6a558fbdd3287a8f1333b70fa63f54b2/flowables.py |
do_exec('mv docs/reference/*.pdf %s'%dst) do_exec('mv docs/reference/*.pdf %s'%htmldir) | do_exec('cp docs/reference/*.pdf %s' % htmldir) do_exec('mv docs/reference/*.pdf %s' % dst) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) recursive_rmdir(cvsdir) recursive_rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst) do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst) do_exec("mv reportlab/demos/py2pdf/idle_print.py %s" % dst) do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt reportlab/pdfgen/test", "reducing size") do_exec("mv %s %s" % (projdir,dst)) do_exec("chmod a+x %s/py2pdf.py %s/idle_print.py" % (dst, dst)) CVS_remove(dst) else: do_exec(cvs+' co docs') dst = os.path.join(d,"reportlab","docs") do_exec("mkdir %s" % dst) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (d,opp) else: os.environ['PYTHONPATH']=d os.chdir('docs/reference') do_exec(python + ' ../tools/yaml2pdf.py reference.yml') os.chdir(d) do_exec('mv docs/reference/*.pdf %s'%dst) do_exec('mv docs/reference/*.pdf %s'%htmldir) os.chdir('docs/userguide') do_exec(python + ' genuserguide.py') os.chdir(d) do_exec('mv docs/userguide/*.pdf %s'%dst) do_exec('mv docs/userguide/*.pdf %s'%htmldir) recursive_rmdir('docs') #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp | 0695ee6796c745fa3c3027e83c103e4ff1c7e510 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0695ee6796c745fa3c3027e83c103e4ff1c7e510/daily.py |
do_exec('mv docs/userguide/*.pdf %s'%dst) do_exec('mv docs/userguide/*.pdf %s'%htmldir) | do_exec('cp docs/userguide/*.pdf %s' % htmldir) do_exec('mv docs/userguide/*.pdf %s' % dst) | def cvs_checkout(d): os.chdir(d) cvsdir = os.path.join(d,projdir) recursive_rmdir(cvsdir) recursive_rmdir('docs') cvs = find_exe('cvs') python = find_exe('python') if cvs is None: os.exit(1) os.environ['CVSROOT']=':pserver:%[email protected]:/cvsroot/reportlab' % USER if release: do_exec(cvs+(' export -r %s %s' % (tagname,projdir)), 'the export phase') else: do_exec(cvs+' co %s' % projdir, 'the checkout phase') if py2pdf: # now we need to move the files & delete those we don't need dst = py2pdf_dir recursive_rmdir(dst) os.mkdir(dst) do_exec("mv reportlab/demos/py2pdf/py2pdf.py %s"%dst) do_exec("mv reportlab/demos/py2pdf/PyFontify.py %s" % dst) do_exec("mv reportlab/demos/py2pdf/idle_print.py %s" % dst) do_exec("rm -r reportlab/demos reportlab/platypus reportlab/lib/styles.py reportlab/README.pdfgen.txt reportlab/pdfgen/test", "reducing size") do_exec("mv %s %s" % (projdir,dst)) do_exec("chmod a+x %s/py2pdf.py %s/idle_print.py" % (dst, dst)) CVS_remove(dst) else: do_exec(cvs+' co docs') dst = os.path.join(d,"reportlab","docs") do_exec("mkdir %s" % dst) #add our reportlab parent to the path so we import from there if os.environ.has_key('PYTHONPATH'): opp = os.environ['PYTHONPATH'] os.environ['PYTHONPATH']='%s:%s' % (d,opp) else: os.environ['PYTHONPATH']=d os.chdir('docs/reference') do_exec(python + ' ../tools/yaml2pdf.py reference.yml') os.chdir(d) do_exec('mv docs/reference/*.pdf %s'%dst) do_exec('mv docs/reference/*.pdf %s'%htmldir) os.chdir('docs/userguide') do_exec(python + ' genuserguide.py') os.chdir(d) do_exec('mv docs/userguide/*.pdf %s'%dst) do_exec('mv docs/userguide/*.pdf %s'%htmldir) recursive_rmdir('docs') #restore the python path if opp is None: del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = opp | 0695ee6796c745fa3c3027e83c103e4ff1c7e510 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/0695ee6796c745fa3c3027e83c103e4ff1c7e510/daily.py |
folder = os.path.dirname(sys.argv[0]) | folder = os.path.dirname(sys.argv[0]) or os.getcwd() | def makeSuite(folder): "Build a test suite of all available test files." allTests = unittest.TestSuite() sys.path.insert(0, folder) for filename in GlobDirectoryWalker(folder, 'test_*.py'): modname = os.path.splitext(os.path.basename(filename))[0] try: module = __import__(modname) allTests.addTest(module.makeSuite()) except ImportError: pass del sys.path[0] return allTests | fcc4ff563440632ab267d623bc9bee53e6f3c379 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/fcc4ff563440632ab267d623bc9bee53e6f3c379/runAll.py |
self.assertEquals(map(lambda x:x.text, fragList), [u'Hello ',u'\xc2\xa9',u' copyright']) | self.assertEquals(map(lambda x:x.text, fragList), [u'Hello ',u'\xa9',u' copyright']) | def testEntityUnicode(self): "Numeric entities should be unescaped by parser" txt = u"Hello © copyright" fragList = ParaParser().parse(txt, self.style)[1] self.assertEquals(map(lambda x:x.text, fragList), [u'Hello ',u'\xc2\xa9',u' copyright']) | a6355d4910de1f9d166a541f09fce797104fd26c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a6355d4910de1f9d166a541f09fce797104fd26c/test_platypus_paraparser.py |
story.append(FrameBreak()) | def code(txt): story.append(Preformatted(txt,styleSheet['Code'])) code('''import reportlab.rl_config reportlab.rl_config.warnOnMissingFontGlyphs = 0 from reportlab.pdfbase import pdfmetrics fontDir = os.path.join(os.path.dirname(reportlab.__file__),'fonts') face = pdfmetrics.EmbeddedType1Face(os.path.join(fontDir,'LeERC___.AFM'), os.path.join(fontDir,'LeERC___.PFB')) faceName = face.name pdfmetrics.registerTypeFace(face) font = pdfmetrics.Font(faceName, faceName, 'WinAnsiEncoding') pdfmetrics.registerFont(font) story.append(Paragraph( """This is an ordinary paragraph, which happens to contain text in an embedded font: <font name="LettErrorRobot-Chrome">LettErrorRobot-Chrome</font>. Now for the real challenge...""", styleSheet['Normal'])) styRobot = ParagraphStyle('Robot', styleSheet['Normal']) styRobot.fontSize = 16 styRobot.leading = 20 styRobot.fontName = 'LettErrorRobot-Chrome' story.append(Paragraph( "This whole paragraph is 16-point Letterror-Robot-Chrome.", styRobot))''') story.append(FrameBreak()) if _GIF: story.append(Paragraph("""We can use images via the file name""", styleSheet['BodyText'])) code(''' story.append(platypus.Image('%s'))'''%_GIF) code(''' story.append(platypus.Image('%s'.encode('utf8')))''' % _GIF) story.append(Paragraph("""They can also be used with a file URI or from an open python file!""", styleSheet['BodyText'])) code(''' story.append(platypus.Image('%s'))'''% getFurl(_GIF)) code(''' story.append(platypus.Image(open_for_read('%s','b')))''' % _GIF) story.append(FrameBreak()) story.append(Paragraph("""Images can even be obtained from the internet.""", styleSheet['BodyText'])) code(''' img = platypus.Image('http://www.reportlab.com/rsrc/encryption.gif') story.append(img)''') story.append(FrameBreak()) if _JPG: story.append(Paragraph("""JPEGs are a native PDF image format. They should be available even if PIL cannot be used.""", styleSheet['BodyText'])) story.append(FrameBreak()) | def getCommentary(): """Returns the story for the commentary - all the paragraphs.""" styleSheet = getSampleStyleSheet() story = [] story.append(Paragraph(""" PLATYPUS User Guide and Test Script """, styleSheet['Heading1'])) spam = """ Welcome to PLATYPUS! Platypus stands for "Page Layout and Typography Using Scripts". It is a high level page layout library which lets you programmatically create complex documents with a minimum of effort. This document is both the user guide & the output of the test script. In other words, a script used platypus to create the document you are now reading, and the fact that you are reading it proves that it works. Or rather, that it worked for this script anyway. It is a first release! Platypus is built 'on top of' PDFgen, the Python library for creating PDF documents. To learn about PDFgen, read the document testpdfgen.pdf. """ for text in getParagraphs(spam): story.append(Paragraph(text, styleSheet['BodyText'])) story.append(Paragraph(""" What concepts does PLATYPUS deal with? """, styleSheet['Heading2'])) story.append(Paragraph(""" The central concepts in PLATYPUS are Flowable Objects, Frames, Flow Management, Styles and Style Sheets, Paragraphs and Tables. This is best explained in contrast to PDFgen, the layer underneath PLATYPUS. PDFgen is a graphics library, and has primitive commans to draw lines and strings. There is nothing in it to manage the flow of text down the page. PLATYPUS works at the conceptual level fo a desktop publishing package; you can write programs which deal intelligently with graphic objects and fit them onto the page. """, styleSheet['BodyText'])) story.append(Paragraph(""" How is this document organized? """, styleSheet['Heading2'])) story.append(Paragraph(""" Since this is a test script, we'll just note how it is organized. the top of each page contains commentary. The bottom half contains example drawings and graphic elements to whicht he commentary will relate. Down below, you can see the outline of a text frame, and various bits and pieces within it. We'll explain how they work on the next page. """, styleSheet['BodyText'])) story.append(FrameBreak()) ####################################################################### # Commentary Page 2 ####################################################################### story.append(Paragraph(""" Flowable Objects """, styleSheet['Heading2'])) spam = """ The first and most fundamental concept is that of a 'Flowable Object'. In PDFgen, you draw stuff by calling methods of the canvas to set up the colors, fonts and line styles, and draw the graphics primitives. If you set the pen color to blue, everything you draw after will be blue until you change it again. And you have to handle all of the X-Y coordinates yourself. A 'Flowable object' is exactly what it says. It knows how to draw itself on the canvas, and the way it does so is totally independent of what you drew before or after. Furthermore, it draws itself at the location on the page you specify. The most fundamental Flowable Objects in most documents are likely to be paragraphs, tables, diagrams/charts and images - but there is no restriction. You can write your own easily, and I hope that people will start to contribute them. PINGO users - we provide a "PINGO flowable" object to let you insert platform-independent graphics into the flow of a document. When you write a flowable object, you inherit from Flowable and must implement two methods. object.wrap(availWidth, availHeight) will be called by other parts of the system, and tells you how much space you have. You should return how much space you are going to use. For a fixed-size object, this is trivial, but it is critical - PLATYPUS needs to figure out if things will fit on the page before drawing them. For other objects such as paragraphs, the height is obviously determined by the available width. The second method is object.draw(). Here, you do whatever you want. The Flowable base class sets things up so that you have an origin of (0,0) for your drawing, and everything will fit nicely if you got the height and width right. It also saves and restores the graphics state around your calls, so you don;t have to reset all the properties you changed. Programs which actually draw a Flowable don't call draw() this directly - they call object.drawOn(canvas, x, y). So you can write code in your own coordinate system, and things can be drawn anywhere on the page (possibly even scaled or rotated). """ for text in getParagraphs(spam): story.append(Paragraph(text, styleSheet['BodyText'])) story.append(FrameBreak()) ####################################################################### # Commentary Page 3 ####################################################################### story.append(Paragraph(""" Available Flowable Objects """, styleSheet['Heading2'])) story.append(Paragraph(""" Platypus comes with a basic set of flowable objects. Here we list their class names and tell you what they do: """, styleSheet['BodyText'])) #we can use the bullet feature to do a definition list story.append(Paragraph(""" <para color=green bcolor=red bg=pink>This is a contrived object to give an example of a Flowable - just a fixed-size box with an X through it and a centred string.</para>""", styleSheet['Definition'], bulletText='XBox ' #hack - spot the extra space after )) story.append(Paragraph(""" This is the basic unit of a document. Paragraphs can be finely tuned and offer a host of properties through their associated ParagraphStyle.""", styleSheet['Definition'], bulletText='Paragraph ' #hack - spot the extra space after )) story.append(Paragraph(""" This is used for printing code and other preformatted text. There is no wrapping, and line breaks are taken where they occur. Many paragraph style properties do not apply. You may supply an optional 'dedent' parameter to trim a number of characters off the front of each line.""", styleSheet['Definition'], bulletText='Preformatted ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a straight wrapper around an external image file. By default the image will be drawn at a scale of one pixel equals one point, and centred in the frame. You may supply an optional width and height.""", styleSheet['Definition'], bulletText='Image ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a table drawing class; it is intended to be simpler than a full HTML table model yet be able to draw attractive output, and behave intelligently when the numbers of rows and columns vary. Still need to add the cell properties (shading, alignment, font etc.)""", styleSheet['Definition'], bulletText='Table ' #hack - spot the extra space after )) story.append(Paragraph(""" This is a 'null object' which merely takes up space on the page. Use it when you want some extra padding betweene elements.""", styleSheet['Definition'], bulletText='Spacer ' #hack - spot the extra space after )) story.append(Paragraph(""" A FrameBreak causes the document to call its handle_frameEnd method.""", styleSheet['Definition'], bulletText='FrameBreak ' #hack - spot the extra space after )) story.append(Paragraph(""" This is in progress, but a macro is basically a chunk of Python code to be evaluated when it is drawn. It could do lots of neat things.""", styleSheet['Definition'], bulletText='Macro ' #hack - spot the extra space after )) story.append(FrameBreak()) story.append(Paragraph( "The next example uses a custom font", styleSheet['Italic'])) story.append(FrameBreak()) return story | 70b47bdfe92e0dc0682ee7991557e3fa42af8d8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/70b47bdfe92e0dc0682ee7991557e3fa42af8d8f/test_platypus_general.py |
story.append(platypus.Preformatted(code, styleSheet['Code'], dedent=4)) | story.append(Preformatted(code, styleSheet['Code'], dedent=4)) | def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height) | 70b47bdfe92e0dc0682ee7991557e3fa42af8d8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/70b47bdfe92e0dc0682ee7991557e3fa42af8d8f/test_platypus_general.py |
from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile, open_for_read if haveImages: gif = os.path.join(_RL_DIR,'test','pythonpowered.gif') if rl_isfile(gif): data = [] t = data.append furl = gif.replace(os.sep,'/') if sys.platform=='win32' and furl[1]==':': furl = furl[0]+'|'+furl[2:] if furl[0]!='/': furl = '/'+furl furl = 'file://'+furl t([ Paragraph("Here is an Image flowable obtained from a string filename.",styleSheet['Italic']), platypus.Image(gif), Paragraph("Here is an Image flowable obtained from a string file url.",styleSheet['Italic']), platypus.Image(furl)]) t([ Paragraph("Here is an Image flowable obtained from a string http url.",styleSheet['Italic']), platypus.Image('http://www.reportlab.com/rsrc/encryption.gif'), Paragraph( "Here is an Image flowable obtained from a utf8 filename.", styleSheet['Italic']), platypus.Image(gif.encode('utf8'))]) t([Paragraph("Here is an Image flowable obtained from an open file.",styleSheet['Italic']), platypus.Image(open_for_read(gif,'b')), '','']) story.append(platypus.Table(data,[96,None,96,None], [None, None,None])) jpg = os.path.join(_RL_DIR,'docs','images','lj8100.jpg') if rl_isfile(jpg): story.append(Paragraph("Here is an JPEG Image flowable obtained from a filename.",styleSheet['Italic'])) img = platypus.Image(jpg) story.append(img) story.append(Paragraph("Here is an JPEG Image flowable obtained from an open file.",styleSheet['Italic'])) img = platypus.Image(open_for_read(jpg,'b')) story.append(img) | def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height) | 70b47bdfe92e0dc0682ee7991557e3fa42af8d8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/70b47bdfe92e0dc0682ee7991557e3fa42af8d8f/test_platypus_general.py |
|
def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height) | 70b47bdfe92e0dc0682ee7991557e3fa42af8d8f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/70b47bdfe92e0dc0682ee7991557e3fa42af8d8f/test_platypus_general.py |
||
"""Draw an ellipse with foci at (x1,y1) (x2,y2). | """Draw an ellipse defined by an enclosing rectangle. Note that (x1,y1) and (x2,y2) are the corner points of the enclosing rectangle. | def ellipse(self, x1, y1, x2, y2, stroke=1, fill=0): """Draw an ellipse with foci at (x1,y1) (x2,y2). Uses bezierArc, which conveniently handles 360 degrees. Special thanks to Robert Kern.""" ### XXXX above documentation is WRONG. Exactly what are (x1,y1), (x2,y2)? pointList = pdfgeom.bezierArc(x1,y1, x2,y2, 0, 360) #move to first point self._code.append('n %s m' % fp_str(pointList[0][:2])) for curve in pointList: self._code.append('%s c' % fp_str(curve[2:])) #finish self._code.append(PATH_OPS[stroke, fill, self._fillMode]) | 28c63b6544ec14b179d0ad0fbb42915c9c143515 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/28c63b6544ec14b179d0ad0fbb42915c9c143515/canvas.py |
def ellipse(self, x1, y1, x2, y2, stroke=1, fill=0): """Draw an ellipse with foci at (x1,y1) (x2,y2). Uses bezierArc, which conveniently handles 360 degrees. Special thanks to Robert Kern.""" ### XXXX above documentation is WRONG. Exactly what are (x1,y1), (x2,y2)? pointList = pdfgeom.bezierArc(x1,y1, x2,y2, 0, 360) #move to first point self._code.append('n %s m' % fp_str(pointList[0][:2])) for curve in pointList: self._code.append('%s c' % fp_str(curve[2:])) #finish self._code.append(PATH_OPS[stroke, fill, self._fillMode]) | 28c63b6544ec14b179d0ad0fbb42915c9c143515 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/28c63b6544ec14b179d0ad0fbb42915c9c143515/canvas.py |
||
os.system("python genAll.py -s") | os.system("%s genAll.py -s" % sys.executable) | def test0(self): "Test if all manuals buildable from source." | ec709d8e14f2919a9757f988ede711d8583af5a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ec709d8e14f2919a9757f988ede711d8583af5a5/test_docs_build.py |
unittest.TextTestRunner().run(makeSuite()) | unittest.TextTestRunner().run(makeSuite()) | def makeSuite(): suite = unittest.TestSuite() loader = unittest.TestLoader() if sys.platform[:4] != 'java': suite.addTest(loader.loadTestsFromTestCase(ManualTestCase)) return suite | ec709d8e14f2919a9757f988ede711d8583af5a5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/ec709d8e14f2919a9757f988ede711d8583af5a5/test_docs_build.py |
r = os.path.splitext(self.pfbFileName)[0] + ext if os.path.isfile(r): return r | r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e | def findT1File(self,ext='.pfb'): if hasattr(self,'pfbFileName'): r = os.path.splitext(self.pfbFileName)[0] + ext if os.path.isfile(r): return r try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': pfb = os.path.splitext(afm)[0] + 'pfb' if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r | a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a/pdfmetrics.py |
pfb = os.path.splitext(afm)[0] + 'pfb' if os.path.isfile(pfb): r = pfb else: r = None | for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None | def findT1File(self,ext='.pfb'): if hasattr(self,'pfbFileName'): r = os.path.splitext(self.pfbFileName)[0] + ext if os.path.isfile(r): return r try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if ext == '.pfb': pfb = os.path.splitext(afm)[0] + 'pfb' if os.path.isfile(pfb): r = pfb else: r = None elif ext == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r | a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a/pdfmetrics.py |
pfb = os.path.splitext(afm)[0] + '.pfb' | for e in ('.pfb', '.PFB'): pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): break | def getTypeFace(faceName): """Lazily construct known typefaces if not found""" try: return _typefaces[faceName] except KeyError: # not found, construct it if known if faceName in standardFonts: face = TypeFace(faceName) registerTypeFace(face) #print 'auto-constructing type face %s' % face.name return face else: #try a brute force search afm = bruteForceSearchForAFM(faceName) if afm: pfb = os.path.splitext(afm)[0] + '.pfb' assert os.path.isfile(pfb), 'file %s not found!' % pfb face = EmbeddedType1Face(afm, pfb) registerTypeFace(face) return face else: raise | a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/a49bc7d0c3410d4fa3628b3b6a7d025f24bd507a/pdfmetrics.py |
def drawInlineImage(self, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" self._currentPageHasImages = 1 | 30c753a6c7edabf444bd57d12dd1b4c3dcf01906 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/30c753a6c7edabf444bd57d12dd1b4c3dcf01906/canvas.py |
||
imageFile.seek(0) | imageFile.seek(0) | def drawInlineImage(self, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" self._currentPageHasImages = 1 | 30c753a6c7edabf444bd57d12dd1b4c3dcf01906 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/30c753a6c7edabf444bd57d12dd1b4c3dcf01906/canvas.py |
imagedata.append('BI') imagedata.append('/Width %0.2f /Height %0.2f' %(info[0], info[1])) imagedata.append('/BitsPerComponent 8') imagedata.append('/ColorSpace /%s' % colorSpace) imagedata.append('/Filter [ /ASCII85Decode /DCTDecode]') imagedata.append('ID') | imagedata.append('BI /W %d /H %d /BPC 8 /CS /%s /F [/A85 /DCT] ID' % (info[0], info[1], colorSpace)) | def drawInlineImage(self, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" self._currentPageHasImages = 1 | 30c753a6c7edabf444bd57d12dd1b4c3dcf01906 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/30c753a6c7edabf444bd57d12dd1b4c3dcf01906/canvas.py |
imagedata.append('BI') | def drawInlineImage(self, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" self._currentPageHasImages = 1 | 30c753a6c7edabf444bd57d12dd1b4c3dcf01906 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/30c753a6c7edabf444bd57d12dd1b4c3dcf01906/canvas.py |
|
imagedata.append('/W %0.2f /H %0.2f /BPC 8 /CS /RGB /F [/A85 /Fl]' % (imgwidth, imgheight)) imagedata.append('ID') | imagedata.append('BI /W %d /H %d /BPC 8 /CS /RGB /F [/A85 /Fl] ID' % (imgwidth, imgheight)) | def drawInlineImage(self, image, x,y, width=None,height=None): """Draw an Image into the specified rectangle. If width and height are omitted, they are calculated from the image size. Also allow file names as well as images. This allows a caching mechanism""" self._currentPageHasImages = 1 | 30c753a6c7edabf444bd57d12dd1b4c3dcf01906 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/30c753a6c7edabf444bd57d12dd1b4c3dcf01906/canvas.py |
L.strokeColor = self.strokeColor L.strokeWidth = self.strokeWidth L.strokeDashArray = self.strokeDashArray | L.strokeColor = strokeColor L.strokeWidth = strokeWidth L.strokeDashArray = strokeDashArray | def _makeLines(self,g,start,end,strokeColor,strokeWidth,strokeDashArray): for i in range(self._catCount + 1): y = self._y + i*self._barWidth L = Line(self._x+start, y, self._x+end, y) L.strokeColor = self.strokeColor L.strokeWidth = self.strokeWidth L.strokeDashArray = self.strokeDashArray g.add(L) | 2cf879d2e722e4f9186b7500687b1d7341dc3a5c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/2cf879d2e722e4f9186b7500687b1d7341dc3a5c/axes.py |
eg(""" def __init__(self,filename, pagesize=(595.27,841.89), bottomup = 1, pageCompression=0, encoding=rl_config.defaultEncoding, verbosity=0): """) | 639e694d1db2c46d0d4ee812c772c39676c56229 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/639e694d1db2c46d0d4ee812c772c39676c56229/ch2_graphics.py |
||
self._parent._parent._in -= 1 | self._parent._parent._in = self._parent._parent._in - 1 | def __call__(self, *args, **kwargs) : """The fake method is called, print it then call the real one.""" if not self._parent._parent._in : self._precomment() self._parent._parent._PyWrite(" %s.%s(%s)" % (self._parent._name, self._action, apply(buildargs, args, kwargs))) self._postcomment() self._parent._parent._in = self._parent._parent._in + 1 retcode = apply(getattr(self._parent._object, self._action), args, kwargs) self._parent._parent._in -= 1 return retcode | 3e44ba24f2b4f661de43f0c0594c1d83be0e9816 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/3e44ba24f2b4f661de43f0c0594c1d83be0e9816/pycanvas.py |
self._parent._contextlevel -= 1 | self._parent._contextlevel = self._parent._contextlevel - 1 | def _precomment(self) : """Outputs comments before the method call.""" if self._action == "showPage" : self._parent._PyWrite("\n # Ends page %i" % self._parent._pagenumber) elif self._action == "saveState" : state = {} d = self._parent._object.__dict__ for name in self._parent._object.STATE_ATTRIBUTES: state[name] = d[name] self._parent._PyWrite("\n # Saves context level %i %s" % (self._parent._contextlevel, state)) self._parent._contextlevel = self._parent._contextlevel + 1 elif self._action == "restoreState" : self._parent._contextlevel -= 1 self._parent._PyWrite("\n # Restores context level %i %s" % (self._parent._contextlevel, self._parent._object.state_stack[-1])) elif self._action == "beginForm" : self._parent._formnumber = self._parent._formnumber + 1 self._parent._PyWrite("\n # Begins form %i" % self._parent._formnumber) elif self._action == "endForm" : self._parent._PyWrite("\n # Ends form %i" % self._parent._formnumber) elif self._action == "save" : self._parent._PyWrite("\n # Saves the PDF document to disk") | 3e44ba24f2b4f661de43f0c0594c1d83be0e9816 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/3e44ba24f2b4f661de43f0c0594c1d83be0e9816/pycanvas.py |
elif self._action == "endForm" : | elif self._action in [ "endForm", "drawPath", "clipPath" ] : | def _postcomment(self) : """Outputs comments after the method call.""" if self._action == "showPage" : self._parent._pagenumber = self._parent._pagenumber + 1 self._parent._PyWrite("\n # Begins page %i" % self._parent._pagenumber) elif self._action == "endForm" : self._parent._PyWrite("") | 3e44ba24f2b4f661de43f0c0594c1d83be0e9816 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/3e44ba24f2b4f661de43f0c0594c1d83be0e9816/pycanvas.py |
for op, (sc, sr), (ec, er), weight, color in cmds: | for c in cmds: c = tuple(c) (sc,sr), (ec,er) = c[1:3] | def _cr_0(self,n,cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if sr>=n: continue if er>=n: er = n-1 self._addCommand((op, (sc, sr), (ec, er), weight, color)) | 11eb40f3a3d8b8d0f34ebf418a68ac6839a1a3b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/11eb40f3a3d8b8d0f34ebf418a68ac6839a1a3b0/tables.py |
self._addCommand((op, (sc, sr), (ec, er), weight, color)) | self._addCommand((c[0],)+((sc, sr), (ec, er))+c[3:]) | def _cr_0(self,n,cmds): for op, (sc, sr), (ec, er), weight, color in cmds: if sr>=n: continue if er>=n: er = n-1 self._addCommand((op, (sc, sr), (ec, er), weight, color)) | 11eb40f3a3d8b8d0f34ebf418a68ac6839a1a3b0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7053/11eb40f3a3d8b8d0f34ebf418a68ac6839a1a3b0/tables.py |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.