Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Commit 122e44b

Browse files
committed
initial import of public tutorial information
0 parents  commit 122e44b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+891
-0
lines changed

80x15.png

688 Bytes

buildout/bootstrap.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
##############################################################################
2+
#
3+
# Copyright (c) 2006 Zope Corporation and Contributors.
4+
# All Rights Reserved.
5+
#
6+
# This software is subject to the provisions of the Zope Public License,
7+
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
8+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9+
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10+
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11+
# FOR A PARTICULAR PURPOSE.
12+
#
13+
##############################################################################
14+
"""Bootstrap a buildout-based project
15+
16+
Simply run this script in a directory containing a buildout.cfg.
17+
The script accepts buildout command-line options, so you can
18+
use the -c option to specify an alternate configuration file.
19+
20+
$Id$
21+
"""
22+
23+
import os, shutil, sys, tempfile, urllib2
24+
25+
tmpeggs = tempfile.mkdtemp()
26+
27+
try:
28+
import pkg_resources
29+
except ImportError:
30+
ez = {}
31+
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
32+
).read() in ez
33+
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
34+
35+
import pkg_resources
36+
37+
if sys.platform == 'win32':
38+
def quote(c):
39+
if ' ' in c:
40+
return '"%s"' % c # work around spawn lamosity on windows
41+
else:
42+
return c
43+
else:
44+
def quote (c):
45+
return c
46+
47+
cmd = 'from setuptools.command.easy_install import main; main()'
48+
ws = pkg_resources.working_set
49+
assert os.spawnle(
50+
os.P_WAIT, sys.executable, quote (sys.executable),
51+
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout',
52+
dict(os.environ,
53+
PYTHONPATH=
54+
ws.find(pkg_resources.Requirement.parse('setuptools')).location
55+
),
56+
) == 0
57+
58+
ws.add_entry(tmpeggs)
59+
ws.require('zc.buildout')
60+
import zc.buildout.buildout
61+
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
62+
shutil.rmtree(tmpeggs)

buildout/buildout.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[buildout]
2+
parts = py
3+
versions = versions
4+
5+
[versions]
6+
xlrd=0.7.1
7+
xlwt=0.7.2
8+
xlutils=1.3.0
9+
10+
[py]
11+
recipe = zc.recipe.egg
12+
eggs =
13+
xlrd
14+
xlwt
15+
xlutils
16+
testfixtures
17+
interpreter = py

buildout/runall.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# this script should be run as:
2+
# bin\py runall.py
3+
4+
import os
5+
6+
from glob import glob
7+
from os.path import join as j, abspath
8+
from re import compile
9+
from subprocess import call,STDOUT
10+
from tempfile import TemporaryFile
11+
from testfixtures import diff
12+
13+
runner = abspath(j(os.path.split(__file__)[0],'py'))
14+
15+
sub_res = [
16+
(compile('0+x[0-9A-Fa-f]+'),'...'),
17+
(compile('".+'+os.sep.replace('\\','\\\\')+'(.+.py)"'),'"\\1"'),
18+
]
19+
20+
base = os.path.abspath('..')
21+
for path in ('xlrd','xlwt','xlutils'):
22+
dir = j(base,'students',path)
23+
expected_dir = j(base,'expected',path)
24+
os.chdir(dir)
25+
for py in glob(j(dir,'*.py')):
26+
name = os.path.split(py)[1]
27+
28+
before_listing = set(os.listdir(dir))
29+
print py
30+
31+
output = TemporaryFile('w+')
32+
expected_base = j(expected_dir,os.path.splitext(name)[0])
33+
34+
call([runner,py],stdout=output,stderr=STDOUT)
35+
36+
after_listing = set(os.listdir(dir))
37+
created = after_listing.difference(before_listing)
38+
39+
expected_names = set()
40+
if os.path.exists(expected_base):
41+
expected_names = set(os.listdir(expected_base))
42+
for name in created:
43+
ap = j(dir,name)
44+
af = open(ap,'rb')
45+
actual = af.read()
46+
af.close()
47+
if name in expected_names:
48+
expected = open(j(expected_base,name),'rb').read()
49+
expected_names.remove(name)
50+
if actual==expected:
51+
os.remove(ap)
52+
else:
53+
print 'different:',name
54+
else:
55+
print "unexpected:",name
56+
for name in expected_names:
57+
if name!='.svn':
58+
print "missing:",name
59+
60+
output.seek(0)
61+
output = output.read().strip().replace('\r','')
62+
for re,rp in sub_res:
63+
output = re.sub(rp,output)
64+
expected_path = j(expected_base+'.txt')
65+
if not os.path.exists(expected_path):
66+
expected = ''
67+
else:
68+
expected = open(expected_path).read().strip().replace('\r','')
69+
if output!=expected:
70+
print '='*len(name)
71+
print diff(expected,output)
72+
print '='*len(name)
73+

expected/xlrd/cell_access.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
text:u'S2R1CA'
2+
S2R1CA
3+
True
4+
1 S2R2CA
5+
1 S2R2CB

expected/xlrd/cell_types.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
XL_CELL_TEXT [(1, text:u'Text', u'Text'), (0, empty:'', ''), (0, empty:'', '')]
2+
XL_CELL_NUMBER [(2, number:13.0, 13.0), (2, number:4.2000000000000002, 4.2000000000000002), (0, empty:'', '')]
3+
XL_CELL_DATE [(3, xldate:39890.0, 39890.0), (3, xldate:39890.879675925928, 39890.879675925928), (3, xldate:0.87967592592592592, 0.87967592592592592)]
4+
XL_CELL_BOOLEAN [(4, bool:0, 0), (4, bool:1, 1), (0, empty:'', '')]
5+
XL_CELL_ERROR [(5, error:23, 23), (5, error:0, 0), (0, empty:'', '')]
6+
XL_CELL_BLANK [(0, empty:'', ''), (0, empty:'', ''), (0, empty:'', '')]
7+
XL_CELL_EMPTY [(0, empty:'', ''), (0, empty:'', ''), (0, empty:'', '')]
8+
9+
XL_CELL_TEXT [(1, text:u'Text' (XF:25), u'Text'), (0, empty:'' (XF:15), ''), (0, empty:'' (XF:15), '')]
10+
XL_CELL_NUMBER [(2, number:13.0 (XF:25), 13.0), (2, number:4.2000000000000002 (XF:25), 4.2000000000000002), (0, empty:'' (XF:15), '')]
11+
XL_CELL_DATE [(3, xldate:39890.0 (XF:26), 39890.0), (3, xldate:39890.879675925928 (XF:27), 39890.879675925928), (3, xldate:0.87967592592592592 (XF:28), 0.87967592592592592)]
12+
XL_CELL_BOOLEAN [(4, bool:0 (XF:29), 0), (4, bool:1 (XF:29), 1), (0, empty:'' (XF:15), '')]
13+
XL_CELL_ERROR [(5, error:23 (XF:25), 23), (5, error:0 (XF:25), 0), (0, empty:'' (XF:15), '')]
14+
XL_CELL_BLANK [(6, blank:'' (XF:24), ''), (0, empty:'' (XF:15), ''), (0, empty:'' (XF:15), '')]
15+
XL_CELL_EMPTY [(0, empty:'' (XF:15), ''), (0, empty:'' (XF:15), ''), (0, empty:'' (XF:15), '')]

expected/xlrd/dates.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2009-03-18 00:00:00 2009-03-18
2+
2009-03-18 21:06:44
3+
21:06:44
4+
Traceback (most recent call last):
5+
File "py-script.py", line 28, in <module>
6+
execfile(sys.argv[0])
7+
File "dates.py", line 13, in <module>
8+
print datetime(*time_value)
9+
ValueError: year is out of range

expected/xlrd/emptyblank.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
False False False
2+
6 ''
3+
0 ''

expected/xlrd/errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#REF!
2+
#NULL!

expected/xlrd/introspect_book.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2
2+
<xlrd.sheet.Sheet object at ...>
3+
<xlrd.sheet.Sheet object at ...>
4+
[u'Sheet1', u'Sheet2']
5+
<xlrd.sheet.Sheet object at ...>
6+
<xlrd.sheet.Sheet object at ...>
7+
<xlrd.sheet.Sheet object at ...>
8+
<xlrd.sheet.Sheet object at ...>

expected/xlrd/introspect_sheet.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Sheet1
2+
2
3+
3
4+
A1 - S1R1CA
5+
B1 - S1R1CB
6+
C1 - S1R1CC
7+
A2 - S1R2CA
8+
B2 - S1R2CB
9+
C2 - S1R2CC

expected/xlrd/large_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
S2R1CA

expected/xlrd/open.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<xlrd.Book object at ...>
2+
<xlrd.Book object at ...>
3+
<xlrd.Book object at ...>

expected/xlrd/sheet_iteration.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[text:u'S1R1CA', text:u'S1R1CB', text:u'S1R1CC']
2+
[text:u'S1R1CA', text:u'S1R2CA']
3+
4+
[text:u'S1R1CB', text:u'S1R1CC']
5+
[text:u'S1R1CB']
6+
[u'S1R1CB', u'S1R1CC']
7+
[u'S1R1CB']
8+
array('B', [1, 1])
9+
array('B', [1])
10+
11+
[text:u'S2R2CA', text:u'S2R3CA']
12+
[text:u'S1R2CA']
13+
[u'S2R2CA', u'S2R3CA']
14+
[u'S1R2CA']
15+
[1, 1]
16+
[1]

expected/xlrd/simple.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Sheet: Sheet1
2+
S1R1CA,S1R1CB,S1R1CC
3+
S1R2CA,S1R2CB,S1R2CC
4+
S1R3CA,S1R3CB,S1R3CC
5+
6+
Sheet: Sheet2
7+
S2R1CA,S2R1CB,S2R1CC
8+
S2R2CA,S2R2CB,S2R2CC
9+
S2R3CA,S2R3CB,S2R3CC

expected/xlrd/utilities.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
A1 K11 CW101
2+
$B$4 $BH$42 $MU$266
3+
A K CW

expected/xlutils/copy/output.xls

5.5 KB
Binary file not shown.

expected/xlutils/display.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
People
2+
'Price(\xc2\xa3)'
3+
'My Sheet'
4+
'John''s Sheet'
5+
text (Adam Adamson)
6+
date (1978-06-13 00:00:00)
5.5 KB
Binary file not shown.

expected/xlutils/styles.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Person
2+
Country
3+
None

expected/xlwt/borders/borders.xls

5.5 KB
Binary file not shown.

expected/xlwt/cell_types/types.xls

5.5 KB
Binary file not shown.

expected/xlwt/easyxf_format/date.xls

5.5 KB
Binary file not shown.
Binary file not shown.

expected/xlwt/formulae/formula.xls

5.5 KB
Binary file not shown.
5.5 KB
Binary file not shown.

expected/xlwt/images/images.xls

41.5 KB
Binary file not shown.

expected/xlwt/merged/merged.xls

5.5 KB
Binary file not shown.

expected/xlwt/outlines/outlines.xls

5.5 KB
Binary file not shown.

expected/xlwt/overwriting.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Traceback (most recent call last):
2+
File "py-script.py", line 28, in <module>
3+
execfile(sys.argv[0])
4+
File "overwriting.py", line 11, in <module>
5+
sheet2.write(0,0,'new')
6+
File "Worksheet.py", line 1003, in write
7+
File "Row.py", line 231, in write
8+
File "Row.py", line 150, in insert_cell
9+
Exception: Attempt to overwrite cell: sheetname=u'Sheet 2' rowx=0 colx=0

expected/xlwt/panes/panes.xls

37.5 KB
Binary file not shown.

expected/xlwt/simple/simple.xls

5.5 KB
Binary file not shown.
5.5 KB
Binary file not shown.
5.5 KB
Binary file not shown.
5.5 KB
Binary file not shown.

expected/xlwt/utilities.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
AA -> 26
2+
A -> 0
3+
A1 -> (0, 0, False, False)
4+
$A$1 -> (0, 0, True, True)
5+
A1 -> (0, 0)
6+
(0, 0) -> A1
7+
(0, 0, False, True) -> $A1
8+
(0, 0, True, True) -> $A$1
9+
1:3 -> (0, 0, 2, -1)
10+
B:G -> (0, 1, -1, 6)
11+
A2:B7 -> (1, 0, 6, 1)
12+
A1 -> (0, 0, 0, 0)
13+
(0, 0, 100, 100) -> A1:CW101
14+
(0, 0, 100, 100, True, False, False, False) -> A$1:$CW101
15+
Is '' a valid sheet name? No
16+
Is "'quoted'" a valid sheet name? No
17+
Is "O'hare" a valid sheet name? Yes
18+
Is 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' a valid sheet name? No
19+
Is '[]:\\?/*\x00' a valid sheet name? No

expected/xlwt/xfstyle_format/date.xls

5.5 KB
Binary file not shown.

expected/xlwt/zoom/zoom.xls

5.5 KB
Binary file not shown.

notes.odt

70.5 KB
Binary file not shown.

students/xlrd/cell_access.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from xlrd import open_workbook,XL_CELL_TEXT
2+
3+
book = open_workbook('odd.xls')
4+
sheet = book.sheet_by_index(1)
5+
6+
cell = sheet.cell(0,0)
7+
print cell
8+
print cell.value
9+
print cell.ctype==XL_CELL_TEXT
10+
11+
for i in range(sheet.ncols):
12+
print sheet.cell_type(1,i),sheet.cell_value(1,i)

students/xlrd/cell_types.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from xlrd import open_workbook
2+
3+
def cell_contents(sheet,row_x):
4+
result = []
5+
for col_x in range(2,sheet.ncols):
6+
cell = sheet.cell(row_x,col_x)
7+
result.append((cell.ctype,cell,cell.value))
8+
return result
9+
10+
sheet = open_workbook('types.xls').sheet_by_index(0)
11+
12+
print 'XL_CELL_TEXT',cell_contents(sheet,1)
13+
print 'XL_CELL_NUMBER',cell_contents(sheet,2)
14+
print 'XL_CELL_DATE',cell_contents(sheet,3)
15+
print 'XL_CELL_BOOLEAN',cell_contents(sheet,4)
16+
print 'XL_CELL_ERROR',cell_contents(sheet,5)
17+
print 'XL_CELL_BLANK',cell_contents(sheet,6)
18+
print 'XL_CELL_EMPTY',cell_contents(sheet,7)
19+
20+
print
21+
sheet = open_workbook(
22+
'types.xls',formatting_info=True
23+
).sheet_by_index(0)
24+
25+
print 'XL_CELL_TEXT',cell_contents(sheet,1)
26+
print 'XL_CELL_NUMBER',cell_contents(sheet,2)
27+
print 'XL_CELL_DATE',cell_contents(sheet,3)
28+
print 'XL_CELL_BOOLEAN',cell_contents(sheet,4)
29+
print 'XL_CELL_ERROR',cell_contents(sheet,5)
30+
print 'XL_CELL_BLANK',cell_contents(sheet,6)
31+
print 'XL_CELL_EMPTY',cell_contents(sheet,7)
32+

students/xlrd/dates.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from datetime import date,datetime,time
2+
from xlrd import open_workbook,xldate_as_tuple
3+
4+
book = open_workbook('types.xls')
5+
sheet = book.sheet_by_index(0)
6+
7+
date_value = xldate_as_tuple(sheet.cell(3,2).value,book.datemode)
8+
print datetime(*date_value),date(*date_value[:3])
9+
datetime_value = xldate_as_tuple(sheet.cell(3,3).value,book.datemode)
10+
print datetime(*datetime_value)
11+
time_value = xldate_as_tuple(sheet.cell(3,4).value,book.datemode)
12+
print time(*time_value[3:])
13+
print datetime(*time_value)

students/xlrd/emptyblank.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from xlrd import open_workbook,empty_cell
2+
3+
print empty_cell.value
4+
5+
book = open_workbook('types.xls')
6+
sheet = book.sheet_by_index(0)
7+
empty = sheet.cell(6,2)
8+
blank = sheet.cell(7,2)
9+
print empty is blank, empty is empty_cell, blank is empty_cell
10+
11+
book = open_workbook('types.xls',formatting_info=True)
12+
sheet = book.sheet_by_index(0)
13+
empty = sheet.cell(6,2)
14+
blank = sheet.cell(7,2)
15+
print empty.ctype,repr(empty.value)
16+
print blank.ctype,repr(blank.value)

students/xlrd/errors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from xlrd import open_workbook,error_text_from_code
2+
3+
book = open_workbook('types.xls')
4+
sheet = book.sheet_by_index(0)
5+
6+
print error_text_from_code[sheet.cell(5,2).value]
7+
print error_text_from_code[sheet.cell(5,3).value]
8+

0 commit comments

Comments
 (0)