From: <jd...@us...> - 2007-12-06 21:51:26
|
Revision: 4657 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4657&view=rev Author: jdh2358 Date: 2007-12-06 13:51:12 -0800 (Thu, 06 Dec 2007) Log Message: ----------- reor and fix pyrex examples Added Paths: ----------- trunk/py4science/examples/ trunk/py4science/examples/BeautifulSoup.py trunk/py4science/examples/__init__.py trunk/py4science/examples/basemap1.py trunk/py4science/examples/basemap2.py trunk/py4science/examples/basemap3.py trunk/py4science/examples/basemap4.py trunk/py4science/examples/basemap5.py trunk/py4science/examples/bessel.py trunk/py4science/examples/convolution_demo.py trunk/py4science/examples/data/ trunk/py4science/examples/data/HISTORY.gz trunk/py4science/examples/data/ascii_data.dat trunk/py4science/examples/data/ge.csv trunk/py4science/examples/data/hsales.dat trunk/py4science/examples/data/key_stats/ trunk/py4science/examples/data/key_stats/CROX_key_stats.html trunk/py4science/examples/data/key_stats/GE_key_stats.html trunk/py4science/examples/data/key_stats/GOOG_key_stats.html trunk/py4science/examples/data/key_stats/INTC_key_stats.html trunk/py4science/examples/data/key_stats/MSFT_key_stats.html trunk/py4science/examples/data/key_stats/WMT_key_stats.html trunk/py4science/examples/data/key_stats/YHOO_key_stats.html trunk/py4science/examples/data/monthly_sunspots.dat trunk/py4science/examples/data/moonlanding.jpg trunk/py4science/examples/data/moonlanding.png trunk/py4science/examples/data/nm560.dat trunk/py4science/examples/data/noisy_sine.dat trunk/py4science/examples/data/sst.nc trunk/py4science/examples/data/synapse_data.dat trunk/py4science/examples/data/synapse_times.dat trunk/py4science/examples/distributions.py trunk/py4science/examples/erathostenes.py trunk/py4science/examples/erathostenes_fperez.py trunk/py4science/examples/erathostenes_list.py trunk/py4science/examples/erathostenes_set.py trunk/py4science/examples/extras/ trunk/py4science/examples/extras/fft_demo.py trunk/py4science/examples/extras/spec_interp.py trunk/py4science/examples/extras/steinman_interp.py trunk/py4science/examples/extras/weave_examples.py trunk/py4science/examples/faces/ trunk/py4science/examples/faces/data_test/ trunk/py4science/examples/faces/data_test/face10tn.pcx trunk/py4science/examples/faces/data_test/face11tn.pcx trunk/py4science/examples/faces/data_test/face12tn.pcx trunk/py4science/examples/faces/data_test/face13tn.pcx trunk/py4science/examples/faces/data_test/face14tn.pcx trunk/py4science/examples/faces/data_test/face15tn.pcx trunk/py4science/examples/faces/data_test/face16tn.pcx trunk/py4science/examples/faces/data_test/face17tn.pcx trunk/py4science/examples/faces/data_test/face18tn.pcx trunk/py4science/examples/faces/data_test/face19tn.pcx trunk/py4science/examples/faces/data_test/face1tn.pcx trunk/py4science/examples/faces/data_test/face20tn.pcx trunk/py4science/examples/faces/data_test/face21tn.pcx trunk/py4science/examples/faces/data_test/face22tn.pcx trunk/py4science/examples/faces/data_test/face23tn.pcx trunk/py4science/examples/faces/data_test/face24tn.pcx trunk/py4science/examples/faces/data_test/face25tn.pcx trunk/py4science/examples/faces/data_test/face26tn.pcx trunk/py4science/examples/faces/data_test/face27tn.pcx trunk/py4science/examples/faces/data_test/face28tn.pcx trunk/py4science/examples/faces/data_test/face29tn.pcx trunk/py4science/examples/faces/data_test/face2tn.pcx trunk/py4science/examples/faces/data_test/face30tn.pcx trunk/py4science/examples/faces/data_test/face3tn.pcx trunk/py4science/examples/faces/data_test/face4tn.pcx trunk/py4science/examples/faces/data_test/face5tn.pcx trunk/py4science/examples/faces/data_test/face6tn.pcx trunk/py4science/examples/faces/data_test/face7tn.pcx trunk/py4science/examples/faces/data_test/face8tn.pcx trunk/py4science/examples/faces/data_test/face9tn.pcx trunk/py4science/examples/faces/data_train/ trunk/py4science/examples/faces/data_train/face10n.pcx trunk/py4science/examples/faces/data_train/face11n.pcx trunk/py4science/examples/faces/data_train/face12n.pcx trunk/py4science/examples/faces/data_train/face13n.pcx trunk/py4science/examples/faces/data_train/face14n.pcx trunk/py4science/examples/faces/data_train/face15n.pcx trunk/py4science/examples/faces/data_train/face16n.pcx trunk/py4science/examples/faces/data_train/face17n.pcx trunk/py4science/examples/faces/data_train/face18n.pcx trunk/py4science/examples/faces/data_train/face19n.pcx trunk/py4science/examples/faces/data_train/face1n.pcx trunk/py4science/examples/faces/data_train/face20n.pcx trunk/py4science/examples/faces/data_train/face21n.pcx trunk/py4science/examples/faces/data_train/face22n.pcx trunk/py4science/examples/faces/data_train/face23n.pcx trunk/py4science/examples/faces/data_train/face24n.pcx trunk/py4science/examples/faces/data_train/face25n.pcx trunk/py4science/examples/faces/data_train/face26n.pcx trunk/py4science/examples/faces/data_train/face27n.pcx trunk/py4science/examples/faces/data_train/face28n.pcx trunk/py4science/examples/faces/data_train/face29n.pcx trunk/py4science/examples/faces/data_train/face2n.pcx trunk/py4science/examples/faces/data_train/face30n.pcx trunk/py4science/examples/faces/data_train/face31n.pcx trunk/py4science/examples/faces/data_train/face32n.pcx trunk/py4science/examples/faces/data_train/face33n.pcx trunk/py4science/examples/faces/data_train/face34n.pcx trunk/py4science/examples/faces/data_train/face35n.pcx trunk/py4science/examples/faces/data_train/face36n.pcx trunk/py4science/examples/faces/data_train/face37n.pcx trunk/py4science/examples/faces/data_train/face38n.pcx trunk/py4science/examples/faces/data_train/face39n.pcx trunk/py4science/examples/faces/data_train/face3n.pcx trunk/py4science/examples/faces/data_train/face40n.pcx trunk/py4science/examples/faces/data_train/face41n.pcx trunk/py4science/examples/faces/data_train/face42n.pcx trunk/py4science/examples/faces/data_train/face43n.pcx trunk/py4science/examples/faces/data_train/face44n.pcx trunk/py4science/examples/faces/data_train/face45n.pcx trunk/py4science/examples/faces/data_train/face46n.pcx trunk/py4science/examples/faces/data_train/face47n.pcx trunk/py4science/examples/faces/data_train/face48n.pcx trunk/py4science/examples/faces/data_train/face49n.pcx trunk/py4science/examples/faces/data_train/face4n.pcx trunk/py4science/examples/faces/data_train/face50n.pcx trunk/py4science/examples/faces/data_train/face51n.pcx trunk/py4science/examples/faces/data_train/face52n.pcx trunk/py4science/examples/faces/data_train/face53n.pcx trunk/py4science/examples/faces/data_train/face54n.pcx trunk/py4science/examples/faces/data_train/face55n.pcx trunk/py4science/examples/faces/data_train/face56n.pcx trunk/py4science/examples/faces/data_train/face57n.pcx trunk/py4science/examples/faces/data_train/face58n.pcx trunk/py4science/examples/faces/data_train/face59n.pcx trunk/py4science/examples/faces/data_train/face5n.pcx trunk/py4science/examples/faces/data_train/face60n.pcx trunk/py4science/examples/faces/data_train/face61n.pcx trunk/py4science/examples/faces/data_train/face62n.pcx trunk/py4science/examples/faces/data_train/face63n.pcx trunk/py4science/examples/faces/data_train/face64n.pcx trunk/py4science/examples/faces/data_train/face65n.pcx trunk/py4science/examples/faces/data_train/face6n.pcx trunk/py4science/examples/faces/data_train/face7n.pcx trunk/py4science/examples/faces/data_train/face8n.pcx trunk/py4science/examples/faces/data_train/face9n.pcx trunk/py4science/examples/faces/faces.py trunk/py4science/examples/faces/fmatch.py trunk/py4science/examples/faces/imatch.py trunk/py4science/examples/faces/imatch2.py trunk/py4science/examples/faces/imtools.py trunk/py4science/examples/faces/test_imatch.py trunk/py4science/examples/fft_imdenoise.py trunk/py4science/examples/fit_synapse.py trunk/py4science/examples/fitting.py trunk/py4science/examples/getbibtex.py trunk/py4science/examples/glass_dots1.py trunk/py4science/examples/glass_dots2.py trunk/py4science/examples/logistic/ trunk/py4science/examples/logistic/__init__.py trunk/py4science/examples/logistic/exercise01.py trunk/py4science/examples/logistic/exercise02.py trunk/py4science/examples/logistic/maplib.py trunk/py4science/examples/logistic/maplib.pyc trunk/py4science/examples/logistic/sethna_ori/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ChaosLyapunov.pdf trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ChaosLyapunov.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/IterateMaps.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps2.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps2.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/ChaosLyapunov.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/InvariantMeasure.pdf trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/InvariantMeasure.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/Maps.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/ trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/InvariantMeasure.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/Maps.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/PeriodDoubling.pdf trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/PeriodDoubling.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/ trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/PeriodDoubling.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/ trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimension.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimensionHints.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimensions.pdf trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/IterateLogisticHints.py trunk/py4science/examples/logistic/sethna_ori/README trunk/py4science/examples/logistic/sethna_ori/src_ori.tgz trunk/py4science/examples/lotka_volterra.py trunk/py4science/examples/lsys.py trunk/py4science/examples/montecarlo_pi.py trunk/py4science/examples/noisy_sine.py trunk/py4science/examples/numpy-blitz_1000.png trunk/py4science/examples/numpy-blitz_300.png trunk/py4science/examples/numpy-blitz_500.png trunk/py4science/examples/numpy_slicing.py trunk/py4science/examples/numpy_wrap/ trunk/py4science/examples/numpy_wrap/f2py/ trunk/py4science/examples/numpy_wrap/f2py/example1/ trunk/py4science/examples/numpy_wrap/f2py/example1/Makefile trunk/py4science/examples/numpy_wrap/f2py/example1/fib.f trunk/py4science/examples/numpy_wrap/f2py/example1/fib.pyf trunk/py4science/examples/numpy_wrap/f2py/example1/fib.pyf.new trunk/py4science/examples/numpy_wrap/f2py/example2/ trunk/py4science/examples/numpy_wrap/f2py/example2/fib2.f trunk/py4science/examples/numpy_wrap/f2py/example3/ trunk/py4science/examples/numpy_wrap/f2py/example3/Laurence Tratt on Fibonacci.html trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile trunk/py4science/examples/numpy_wrap/f2py/example3/fib.py trunk/py4science/examples/numpy_wrap/f2py/example3/fib3.f trunk/py4science/examples/numpy_wrap/f2py/example3/test.py trunk/py4science/examples/numpy_wrap/pyrex/ trunk/py4science/examples/numpy_wrap/pyrex/MANIFEST trunk/py4science/examples/numpy_wrap/pyrex/Makefile trunk/py4science/examples/numpy_wrap/pyrex/c_numpy.pxd trunk/py4science/examples/numpy_wrap/pyrex/c_python.pxd trunk/py4science/examples/numpy_wrap/pyrex/notes trunk/py4science/examples/numpy_wrap/pyrex/numpyx.c trunk/py4science/examples/numpy_wrap/pyrex/numpyx.pyx trunk/py4science/examples/numpy_wrap/pyrex/run_test.py trunk/py4science/examples/numpy_wrap/pyrex/setup.py trunk/py4science/examples/numpy_wrap/swig/ trunk/py4science/examples/numpy_wrap/swig/HelperFunctions.txt trunk/py4science/examples/numpy_wrap/swig/Makefile trunk/py4science/examples/numpy_wrap/swig/README trunk/py4science/examples/numpy_wrap/swig/Series.i trunk/py4science/examples/numpy_wrap/swig/numpy.i trunk/py4science/examples/numpy_wrap/swig/series.cxx trunk/py4science/examples/numpy_wrap/swig/series.h trunk/py4science/examples/numpy_wrap/swig/setup.py trunk/py4science/examples/numpy_wrap/swig/testSeries.py trunk/py4science/examples/polyroots1d.py trunk/py4science/examples/pyrex/ trunk/py4science/examples/pyrex/movavg/ trunk/py4science/examples/pyrex/movavg/Makefile trunk/py4science/examples/pyrex/movavg/c_numpy.pxd trunk/py4science/examples/pyrex/movavg/c_python.pxd trunk/py4science/examples/pyrex/movavg/c_ringbuf.pxi trunk/py4science/examples/pyrex/movavg/circbuffer.py trunk/py4science/examples/pyrex/movavg/movavg.pyx trunk/py4science/examples/pyrex/movavg/movavg_test.py trunk/py4science/examples/pyrex/movavg/numpyx.pyx trunk/py4science/examples/pyrex/movavg/ringbuf.h trunk/py4science/examples/pyrex/movavg/ringbuf.pyx trunk/py4science/examples/pyrex/movavg/ringbuf_demo.py trunk/py4science/examples/pyrex/movavg/run_test.py trunk/py4science/examples/pyrex/movavg/setup.py trunk/py4science/examples/pyrex/sums/ trunk/py4science/examples/pyrex/sums/Makefile trunk/py4science/examples/pyrex/sums/c_numpy.pxd trunk/py4science/examples/pyrex/sums/c_python.pxd trunk/py4science/examples/pyrex/sums/numpyx.pyx trunk/py4science/examples/pyrex/sums/run_test.py trunk/py4science/examples/pyrex/sums/setup.py trunk/py4science/examples/pyrex/sums/sums.pyx trunk/py4science/examples/pyrex/sums/sums_test.py trunk/py4science/examples/qsort.py trunk/py4science/examples/quad_newton.py trunk/py4science/examples/quicksort.c trunk/py4science/examples/recarray_demo.py trunk/py4science/examples/regress.py trunk/py4science/examples/regress_demo.py trunk/py4science/examples/schrodinger/ trunk/py4science/examples/schrodinger/Schrodinger_FDTD.pdf trunk/py4science/examples/schrodinger/schrod_fdtd.py trunk/py4science/examples/scrape_key_stats.py trunk/py4science/examples/skel/ trunk/py4science/examples/skel/HISTORY.gz trunk/py4science/examples/skel/basemap1_skel.py trunk/py4science/examples/skel/basemap2_skel.py trunk/py4science/examples/skel/basemap3_skel.py trunk/py4science/examples/skel/basemap4_skel.py trunk/py4science/examples/skel/basemap5_skel.py trunk/py4science/examples/skel/convolution_demo_skel.py trunk/py4science/examples/skel/distributions_skel.py trunk/py4science/examples/skel/erathostenes_skel.py trunk/py4science/examples/skel/faces/ trunk/py4science/examples/skel/faces/faces_skel0.tgz trunk/py4science/examples/skel/faces/fmatch_skel1.py trunk/py4science/examples/skel/fft_imdenoise_skel.py trunk/py4science/examples/skel/fit_synapse_skel.py trunk/py4science/examples/skel/fitting_skel.py trunk/py4science/examples/skel/fortran_wrap/ trunk/py4science/examples/skel/fortran_wrap/Makefile trunk/py4science/examples/skel/fortran_wrap/fib3.f trunk/py4science/examples/skel/fortran_wrap/test.py trunk/py4science/examples/skel/glass_dots1_skel.py trunk/py4science/examples/skel/lotka_volterra_skel.py trunk/py4science/examples/skel/montecarlo_pi_skel.py trunk/py4science/examples/skel/moonlanding.jpg trunk/py4science/examples/skel/noisy_sine_skel.py trunk/py4science/examples/skel/polyroots1d_skel.py trunk/py4science/examples/skel/qsort_skel.py trunk/py4science/examples/skel/quad_newton_skel.py trunk/py4science/examples/skel/recarray_demo_skel.py trunk/py4science/examples/skel/regress_demo_skel.py trunk/py4science/examples/skel/scrape_key_stats_skel.py trunk/py4science/examples/skel/shoot_skel.py trunk/py4science/examples/skel/spline_demo_skel.py trunk/py4science/examples/skel/stats_descriptives_skel.py trunk/py4science/examples/skel/stats_distributions_skel.py trunk/py4science/examples/skel/stock_records_skel.py trunk/py4science/examples/skel/trapezoid_skel.py trunk/py4science/examples/skel/wallis_pi_skel.py trunk/py4science/examples/skel/wordfreqs_skel.py trunk/py4science/examples/spline_demo.py trunk/py4science/examples/stats_descriptives.py trunk/py4science/examples/stats_distributions.py trunk/py4science/examples/stock_demo.py trunk/py4science/examples/stock_records.py trunk/py4science/examples/test.ipy trunk/py4science/examples/trapezoid.py trunk/py4science/examples/visual/ trunk/py4science/examples/visual/bounce.py trunk/py4science/examples/visual/shoot.py trunk/py4science/examples/visual/shoot_t.py trunk/py4science/examples/visual/toroid_drag.py trunk/py4science/examples/wallis_pi.py trunk/py4science/examples/weave_blitz.py trunk/py4science/examples/weave_blitz0.py trunk/py4science/examples/weave_blitz_comp.png trunk/py4science/examples/weave_examples_simple.py trunk/py4science/examples/weave_exercises.py trunk/py4science/examples/wordfreqs.py Removed Paths: ------------- trunk/py4science/examples/ trunk/py4science/examples/BeautifulSoup.py trunk/py4science/examples/__init__.py trunk/py4science/examples/basemap1.py trunk/py4science/examples/basemap2.py trunk/py4science/examples/basemap3.py trunk/py4science/examples/basemap4.py trunk/py4science/examples/basemap5.py trunk/py4science/examples/bessel.py trunk/py4science/examples/convolution_demo.py trunk/py4science/examples/data/ trunk/py4science/examples/data/HISTORY.gz trunk/py4science/examples/data/ascii_data.dat trunk/py4science/examples/data/ge.csv trunk/py4science/examples/data/hsales.dat trunk/py4science/examples/data/key_stats/ trunk/py4science/examples/data/key_stats/CROX_key_stats.html trunk/py4science/examples/data/key_stats/GE_key_stats.html trunk/py4science/examples/data/key_stats/GOOG_key_stats.html trunk/py4science/examples/data/key_stats/INTC_key_stats.html trunk/py4science/examples/data/key_stats/MSFT_key_stats.html trunk/py4science/examples/data/key_stats/WMT_key_stats.html trunk/py4science/examples/data/key_stats/YHOO_key_stats.html trunk/py4science/examples/data/monthly_sunspots.dat trunk/py4science/examples/data/moonlanding.jpg trunk/py4science/examples/data/moonlanding.png trunk/py4science/examples/data/nm560.dat trunk/py4science/examples/data/noisy_sine.dat trunk/py4science/examples/data/sst.nc trunk/py4science/examples/data/synapse_data.dat trunk/py4science/examples/data/synapse_times.dat trunk/py4science/examples/distributions.py trunk/py4science/examples/erathostenes.py trunk/py4science/examples/erathostenes_fperez.py trunk/py4science/examples/erathostenes_list.py trunk/py4science/examples/erathostenes_set.py trunk/py4science/examples/extras/ trunk/py4science/examples/extras/fft_demo.py trunk/py4science/examples/extras/spec_interp.py trunk/py4science/examples/extras/steinman_interp.py trunk/py4science/examples/extras/weave_examples.py trunk/py4science/examples/faces/ trunk/py4science/examples/faces/data_test/ trunk/py4science/examples/faces/data_test/face10tn.pcx trunk/py4science/examples/faces/data_test/face11tn.pcx trunk/py4science/examples/faces/data_test/face12tn.pcx trunk/py4science/examples/faces/data_test/face13tn.pcx trunk/py4science/examples/faces/data_test/face14tn.pcx trunk/py4science/examples/faces/data_test/face15tn.pcx trunk/py4science/examples/faces/data_test/face16tn.pcx trunk/py4science/examples/faces/data_test/face17tn.pcx trunk/py4science/examples/faces/data_test/face18tn.pcx trunk/py4science/examples/faces/data_test/face19tn.pcx trunk/py4science/examples/faces/data_test/face1tn.pcx trunk/py4science/examples/faces/data_test/face20tn.pcx trunk/py4science/examples/faces/data_test/face21tn.pcx trunk/py4science/examples/faces/data_test/face22tn.pcx trunk/py4science/examples/faces/data_test/face23tn.pcx trunk/py4science/examples/faces/data_test/face24tn.pcx trunk/py4science/examples/faces/data_test/face25tn.pcx trunk/py4science/examples/faces/data_test/face26tn.pcx trunk/py4science/examples/faces/data_test/face27tn.pcx trunk/py4science/examples/faces/data_test/face28tn.pcx trunk/py4science/examples/faces/data_test/face29tn.pcx trunk/py4science/examples/faces/data_test/face2tn.pcx trunk/py4science/examples/faces/data_test/face30tn.pcx trunk/py4science/examples/faces/data_test/face3tn.pcx trunk/py4science/examples/faces/data_test/face4tn.pcx trunk/py4science/examples/faces/data_test/face5tn.pcx trunk/py4science/examples/faces/data_test/face6tn.pcx trunk/py4science/examples/faces/data_test/face7tn.pcx trunk/py4science/examples/faces/data_test/face8tn.pcx trunk/py4science/examples/faces/data_test/face9tn.pcx trunk/py4science/examples/faces/data_train/ trunk/py4science/examples/faces/data_train/face10n.pcx trunk/py4science/examples/faces/data_train/face11n.pcx trunk/py4science/examples/faces/data_train/face12n.pcx trunk/py4science/examples/faces/data_train/face13n.pcx trunk/py4science/examples/faces/data_train/face14n.pcx trunk/py4science/examples/faces/data_train/face15n.pcx trunk/py4science/examples/faces/data_train/face16n.pcx trunk/py4science/examples/faces/data_train/face17n.pcx trunk/py4science/examples/faces/data_train/face18n.pcx trunk/py4science/examples/faces/data_train/face19n.pcx trunk/py4science/examples/faces/data_train/face1n.pcx trunk/py4science/examples/faces/data_train/face20n.pcx trunk/py4science/examples/faces/data_train/face21n.pcx trunk/py4science/examples/faces/data_train/face22n.pcx trunk/py4science/examples/faces/data_train/face23n.pcx trunk/py4science/examples/faces/data_train/face24n.pcx trunk/py4science/examples/faces/data_train/face25n.pcx trunk/py4science/examples/faces/data_train/face26n.pcx trunk/py4science/examples/faces/data_train/face27n.pcx trunk/py4science/examples/faces/data_train/face28n.pcx trunk/py4science/examples/faces/data_train/face29n.pcx trunk/py4science/examples/faces/data_train/face2n.pcx trunk/py4science/examples/faces/data_train/face30n.pcx trunk/py4science/examples/faces/data_train/face31n.pcx trunk/py4science/examples/faces/data_train/face32n.pcx trunk/py4science/examples/faces/data_train/face33n.pcx trunk/py4science/examples/faces/data_train/face34n.pcx trunk/py4science/examples/faces/data_train/face35n.pcx trunk/py4science/examples/faces/data_train/face36n.pcx trunk/py4science/examples/faces/data_train/face37n.pcx trunk/py4science/examples/faces/data_train/face38n.pcx trunk/py4science/examples/faces/data_train/face39n.pcx trunk/py4science/examples/faces/data_train/face3n.pcx trunk/py4science/examples/faces/data_train/face40n.pcx trunk/py4science/examples/faces/data_train/face41n.pcx trunk/py4science/examples/faces/data_train/face42n.pcx trunk/py4science/examples/faces/data_train/face43n.pcx trunk/py4science/examples/faces/data_train/face44n.pcx trunk/py4science/examples/faces/data_train/face45n.pcx trunk/py4science/examples/faces/data_train/face46n.pcx trunk/py4science/examples/faces/data_train/face47n.pcx trunk/py4science/examples/faces/data_train/face48n.pcx trunk/py4science/examples/faces/data_train/face49n.pcx trunk/py4science/examples/faces/data_train/face4n.pcx trunk/py4science/examples/faces/data_train/face50n.pcx trunk/py4science/examples/faces/data_train/face51n.pcx trunk/py4science/examples/faces/data_train/face52n.pcx trunk/py4science/examples/faces/data_train/face53n.pcx trunk/py4science/examples/faces/data_train/face54n.pcx trunk/py4science/examples/faces/data_train/face55n.pcx trunk/py4science/examples/faces/data_train/face56n.pcx trunk/py4science/examples/faces/data_train/face57n.pcx trunk/py4science/examples/faces/data_train/face58n.pcx trunk/py4science/examples/faces/data_train/face59n.pcx trunk/py4science/examples/faces/data_train/face5n.pcx trunk/py4science/examples/faces/data_train/face60n.pcx trunk/py4science/examples/faces/data_train/face61n.pcx trunk/py4science/examples/faces/data_train/face62n.pcx trunk/py4science/examples/faces/data_train/face63n.pcx trunk/py4science/examples/faces/data_train/face64n.pcx trunk/py4science/examples/faces/data_train/face65n.pcx trunk/py4science/examples/faces/data_train/face6n.pcx trunk/py4science/examples/faces/data_train/face7n.pcx trunk/py4science/examples/faces/data_train/face8n.pcx trunk/py4science/examples/faces/data_train/face9n.pcx trunk/py4science/examples/faces/faces.py trunk/py4science/examples/faces/fmatch.py trunk/py4science/examples/faces/imatch.py trunk/py4science/examples/faces/imatch2.py trunk/py4science/examples/faces/imtools.py trunk/py4science/examples/faces/test_imatch.py trunk/py4science/examples/fft_imdenoise.py trunk/py4science/examples/fit_synapse.py trunk/py4science/examples/fitting.py trunk/py4science/examples/getbibtex.py trunk/py4science/examples/glass_dots1.py trunk/py4science/examples/glass_dots2.py trunk/py4science/examples/logistic/ trunk/py4science/examples/logistic/__init__.py trunk/py4science/examples/logistic/exercise01.py trunk/py4science/examples/logistic/exercise02.py trunk/py4science/examples/logistic/maplib.py trunk/py4science/examples/logistic/maplib.pyc trunk/py4science/examples/logistic/sethna_ori/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ChaosLyapunov.pdf trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ChaosLyapunov.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/IterateMaps.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps2.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/Maps2.pyc trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/ trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/ChaosLyapunov.py trunk/py4science/examples/logistic/sethna_ori/01-chaos_lyapunov/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/InvariantMeasure.pdf trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/InvariantMeasure.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/Maps.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/ trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/InvariantMeasure.py trunk/py4science/examples/logistic/sethna_ori/02-invariant_measures/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/IterateMaps.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/Maps.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/PeriodDoubling.pdf trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/PeriodDoubling.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/ trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/03-period_doubling/ori/PeriodDoubling.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/ trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimension.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimensionHints.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/FractalDimensions.pdf trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/IterateLogistic.py trunk/py4science/examples/logistic/sethna_ori/04-fractal_dimensions/IterateLogisticHints.py trunk/py4science/examples/logistic/sethna_ori/README trunk/py4science/examples/logistic/sethna_ori/src_ori.tgz trunk/py4science/examples/lotka_volterra.py trunk/py4science/examples/lsys.py trunk/py4science/examples/montecarlo_pi.py trunk/py4science/examples/noisy_sine.py trunk/py4science/examples/numpy-blitz_1000.png trunk/py4science/examples/numpy-blitz_300.png trunk/py4science/examples/numpy-blitz_500.png trunk/py4science/examples/numpy_slicing.py trunk/py4science/examples/numpy_wrap/ trunk/py4science/examples/numpy_wrap/f2py/ trunk/py4science/examples/numpy_wrap/f2py/example1/ trunk/py4science/examples/numpy_wrap/f2py/example1/Makefile trunk/py4science/examples/numpy_wrap/f2py/example1/fib.f trunk/py4science/examples/numpy_wrap/f2py/example1/fib.pyf trunk/py4science/examples/numpy_wrap/f2py/example1/fib.pyf.new trunk/py4science/examples/numpy_wrap/f2py/example2/ trunk/py4science/examples/numpy_wrap/f2py/example2/fib2.f trunk/py4science/examples/numpy_wrap/f2py/example3/ trunk/py4science/examples/numpy_wrap/f2py/example3/Laurence Tratt on Fibonacci.html trunk/py4science/examples/numpy_wrap/f2py/example3/Makefile trunk/py4science/examples/numpy_wrap/f2py/example3/fib.py trunk/py4science/examples/numpy_wrap/f2py/example3/fib3.f trunk/py4science/examples/numpy_wrap/f2py/example3/test.py trunk/py4science/examples/numpy_wrap/pyrex/ trunk/py4science/examples/numpy_wrap/pyrex/MANIFEST trunk/py4science/examples/numpy_wrap/pyrex/Makefile trunk/py4science/examples/numpy_wrap/pyrex/c_numpy.pxd trunk/py4science/examples/numpy_wrap/pyrex/c_python.pxd trunk/py4science/examples/numpy_wrap/pyrex/notes trunk/py4science/examples/numpy_wrap/pyrex/numpyx.c trunk/py4science/examples/numpy_wrap/pyrex/numpyx.pyx trunk/py4science/examples/numpy_wrap/pyrex/run_test.py trunk/py4science/examples/numpy_wrap/pyrex/setup.py trunk/py4science/examples/numpy_wrap/swig/ trunk/py4science/examples/numpy_wrap/swig/HelperFunctions.txt trunk/py4science/examples/numpy_wrap/swig/Makefile trunk/py4science/examples/numpy_wrap/swig/README trunk/py4science/examples/numpy_wrap/swig/Series.i trunk/py4science/examples/numpy_wrap/swig/numpy.i trunk/py4science/examples/numpy_wrap/swig/series.cxx trunk/py4science/examples/numpy_wrap/swig/series.h trunk/py4science/examples/numpy_wrap/swig/setup.py trunk/py4science/examples/numpy_wrap/swig/testSeries.py trunk/py4science/examples/polyroots1d.py trunk/py4science/examples/qsort.py trunk/py4science/examples/quad_newton.py trunk/py4science/examples/quicksort.c trunk/py4science/examples/recarray_demo.py trunk/py4science/examples/regress.py trunk/py4science/examples/regress_demo.py trunk/py4science/examples/schrodinger/ trunk/py4science/examples/schrodinger/Schrodinger_FDTD.pdf trunk/py4science/examples/schrodinger/schrod_fdtd.py trunk/py4science/examples/scrape_key_stats.py trunk/py4science/examples/skel/ trunk/py4science/examples/skel/HISTORY.gz trunk/py4science/examples/skel/basemap1_skel.py trunk/py4science/examples/skel/basemap2_skel.py trunk/py4science/examples/skel/basemap3_skel.py trunk/py4science/examples/skel/basemap4_skel.py trunk/py4science/examples/skel/basemap5_skel.py trunk/py4science/examples/skel/convolution_demo_skel.py trunk/py4science/examples/skel/distributions_skel.py trunk/py4science/examples/skel/erathostenes_skel.py trunk/py4science/examples/skel/faces/ trunk/py4science/examples/skel/faces/faces_skel0.tgz trunk/py4science/examples/skel/faces/fmatch_skel1.py trunk/py4science/examples/skel/fft_imdenoise_skel.py trunk/py4science/examples/skel/fit_synapse_skel.py trunk/py4science/examples/skel/fitting_skel.py trunk/py4science/examples/skel/fortran_wrap/ trunk/py4science/examples/skel/fortran_wrap/Makefile trunk/py4science/examples/skel/fortran_wrap/fib3.f trunk/py4science/examples/skel/fortran_wrap/test.py trunk/py4science/examples/skel/glass_dots1_skel.py trunk/py4science/examples/skel/lotka_volterra_skel.py trunk/py4science/examples/skel/montecarlo_pi_skel.py trunk/py4science/examples/skel/moonlanding.jpg trunk/py4science/examples/skel/noisy_sine_skel.py trunk/py4science/examples/skel/polyroots1d_skel.py trunk/py4science/examples/skel/qsort_skel.py trunk/py4science/examples/skel/quad_newton_skel.py trunk/py4science/examples/skel/recarray_demo_skel.py trunk/py4science/examples/skel/regress_demo_skel.py trunk/py4science/examples/skel/scrape_key_stats_skel.py trunk/py4science/examples/skel/shoot_skel.py trunk/py4science/examples/skel/spline_demo_skel.py trunk/py4science/examples/skel/stats_descriptives_skel.py trunk/py4science/examples/skel/stats_distributions_skel.py trunk/py4science/examples/skel/stock_records_skel.py trunk/py4science/examples/skel/trapezoid_skel.py trunk/py4science/examples/skel/wallis_pi_skel.py trunk/py4science/examples/skel/wordfreqs_skel.py trunk/py4science/examples/spline_demo.py trunk/py4science/examples/stats_descriptives.py trunk/py4science/examples/stats_distributions.py trunk/py4science/examples/stock_demo.py trunk/py4science/examples/stock_records.py trunk/py4science/examples/test.ipy trunk/py4science/examples/trapezoid.py trunk/py4science/examples/visual/ trunk/py4science/examples/visual/bounce.py trunk/py4science/examples/visual/shoot.py trunk/py4science/examples/visual/shoot_t.py trunk/py4science/examples/visual/toroid_drag.py trunk/py4science/examples/wallis_pi.py trunk/py4science/examples/weave_blitz.py trunk/py4science/examples/weave_blitz0.py trunk/py4science/examples/weave_blitz_comp.png trunk/py4science/examples/weave_examples_simple.py trunk/py4science/examples/weave_exercises.py trunk/py4science/examples/wordfreqs.py Copied: trunk/py4science/examples (from rev 4639, trunk/py4science/examples) Deleted: trunk/py4science/examples/BeautifulSoup.py =================================================================== --- trunk/py4science/examples/BeautifulSoup.py 2007-12-06 08:44:18 UTC (rev 4639) +++ trunk/py4science/examples/BeautifulSoup.py 2007-12-06 21:51:12 UTC (rev 4657) @@ -1,1767 +0,0 @@ -"""Beautiful Soup -Elixir and Tonic -"The Screen-Scraper's Friend" -http://www.crummy.com/software/BeautifulSoup/ - -Beautiful Soup parses a (possibly invalid) XML or HTML document into a -tree representation. It provides methods and Pythonic idioms that make -it easy to navigate, search, and modify the tree. - -A well-formed XML/HTML document yields a well-formed data -structure. An ill-formed XML/HTML document yields a correspondingly -ill-formed data structure. If your document is only locally -well-formed, you can use this library to find and process the -well-formed part of it. The BeautifulSoup class - -Beautiful Soup works with Python 2.2 and up. It has no external -dependencies, but you'll have more success at converting data to UTF-8 -if you also install these three packages: - -* chardet, for auto-detecting character encodings - http://chardet.feedparser.org/ -* cjkcodecs and iconv_codec, which add more encodings to the ones supported - by stock Python. - http://cjkpython.i18n.org/ - -Beautiful Soup defines classes for two main parsing strategies: - - * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific - language that kind of looks like XML. - - * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid - or invalid. This class has web browser-like heuristics for - obtaining a sensible parse tree in the face of common HTML errors. - -Beautiful Soup also defines a class (UnicodeDammit) for autodetecting -the encoding of an HTML or XML document, and converting it to -Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed Parser. - -For more than you ever wanted to know about Beautiful Soup, see the -documentation: -http://www.crummy.com/software/BeautifulSoup/documentation.html - -""" -from __future__ import generators - -__author__ = "Leonard Richardson (leo...@se...)" -__version__ = "3.0.4" -__copyright__ = "Copyright (c) 2004-2007 Leonard Richardson" -__license__ = "PSF" - -from sgmllib import SGMLParser, SGMLParseError -import codecs -import types -import re -import sgmllib -try: - from htmlentitydefs import name2codepoint -except ImportError: - name2codepoint = {} - -#This hack makes Beautiful Soup able to parse XML with namespaces -sgmllib.tagfind = re.compile('[a-zA-Z][-_.:a-zA-Z0-9]*') - -DEFAULT_OUTPUT_ENCODING = "utf-8" - -# First, the classes that represent markup elements. - -class PageElement: - """Contains the navigational information for some part of the page - (either a tag or a piece of text)""" - - def setup(self, parent=None, previous=None): - """Sets up the initial relations between this element and - other elements.""" - self.parent = parent - self.previous = previous - self.next = None - self.previousSibling = None - self.nextSibling = None - if self.parent and self.parent.contents: - self.previousSibling = self.parent.contents[-1] - self.previousSibling.nextSibling = self - - def replaceWith(self, replaceWith): - oldParent = self.parent - myIndex = self.parent.contents.index(self) - if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent: - # We're replacing this element with one of its siblings. - index = self.parent.contents.index(replaceWith) - if index and index < myIndex: - # Furthermore, it comes before this element. That - # means that when we extract it, the index of this - # element will change. - myIndex = myIndex - 1 - self.extract() - oldParent.insert(myIndex, replaceWith) - - def extract(self): - """Destructively rips this element out of the tree.""" - if self.parent: - try: - self.parent.contents.remove(self) - except ValueError: - pass - - #Find the two elements that would be next to each other if - #this element (and any children) hadn't been parsed. Connect - #the two. - lastChild = self._lastRecursiveChild() - nextElement = lastChild.next - - if self.previous: - self.previous.next = nextElement - if nextElement: - nextElement.previous = self.previous - self.previous = None - lastChild.next = None - - self.parent = None - if self.previousSibling: - self.previousSibling.nextSibling = self.nextSibling - if self.nextSibling: - self.nextSibling.previousSibling = self.previousSibling - self.previousSibling = self.nextSibling = None - - def _lastRecursiveChild(self): - "Finds the last element beneath this object to be parsed." - lastChild = self - while hasattr(lastChild, 'contents') and lastChild.contents: - lastChild = lastChild.contents[-1] - return lastChild - - def insert(self, position, newChild): - if (isinstance(newChild, basestring) - or isinstance(newChild, unicode)) \ - and not isinstance(newChild, NavigableString): - newChild = NavigableString(newChild) - - position = min(position, len(self.contents)) - if hasattr(newChild, 'parent') and newChild.parent != None: - # We're 'inserting' an element that's already one - # of this object's children. - if newChild.parent == self: - index = self.find(newChild) - if index and index < position: - # Furthermore we're moving it further down the - # list of this object's children. That means that - # when we extract this element, our target index - # will jump down one. - position = position - 1 - newChild.extract() - - newChild.parent = self - previousChild = None - if position == 0: - newChild.previousSibling = None - newChild.previous = self - else: - previousChild = self.contents[position-1] - newChild.previousSibling = previousChild - newChild.previousSibling.nextSibling = newChild - newChild.previous = previousChild._lastRecursiveChild() - if newChild.previous: - newChild.previous.next = newChild - - newChildsLastElement = newChild._lastRecursiveChild() - - if position >= len(self.contents): - newChild.nextSibling = None - - parent = self - parentsNextSibling = None - while not parentsNextSibling: - parentsNextSibling = parent.nextSibling - parent = parent.parent - if not parent: # This is the last element in the document. - break - if parentsNextSibling: - newChildsLastElement.next = parentsNextSibling - else: - newChildsLastElement.next = None - else: - nextChild = self.contents[position] - newChild.nextSibling = nextChild - if newChild.nextSibling: - newChild.nextSibling.previousSibling = newChild - newChildsLastElement.next = nextChild - - if newChildsLastElement.next: - newChildsLastElement.next.previous = newChildsLastElement - self.contents.insert(position, newChild) - - def findNext(self, name=None, attrs={}, text=None, **kwargs): - """Returns the first item that matches the given criteria and - appears after this Tag in the document.""" - return self._findOne(self.findAllNext, name, attrs, text, **kwargs) - - def findAllNext(self, name=None, attrs={}, text=None, limit=None, - **kwargs): - """Returns all items that match the given criteria and appear - before after Tag in the document.""" - return self._findAll(name, attrs, text, limit, self.nextGenerator) - - def findNextSibling(self, name=None, attrs={}, text=None, **kwargs): - """Returns the closest sibling to this Tag that matches the - given criteria and appears after this Tag in the document.""" - return self._findOne(self.findNextSiblings, name, attrs, text, - **kwargs) - - def findNextSiblings(self, name=None, attrs={}, text=None, limit=None, - **kwargs): - """Returns the siblings of this Tag that match the given - criteria and appear after this Tag in the document.""" - return self._findAll(name, attrs, text, limit, - self.nextSiblingGenerator, **kwargs) - fetchNextSiblings = findNextSiblings # Compatibility with pre-3.x - - def findPrevious(self, name=None, attrs={}, text=None, **kwargs): - """Returns the first item that matches the given criteria and - appears before this Tag in the document.""" - return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs) - - def findAllPrevious(self, name=None, attrs={}, text=None, limit=None, - **kwargs): - """Returns all items that match the given criteria and appear - before this Tag in the document.""" - return self._findAll(name, attrs, text, limit, self.previousGenerator, - **kwargs) - fetchPrevious = findAllPrevious # Compatibility with pre-3.x - - def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs): - """Returns the closest sibling to this Tag that matches the - given criteria and appears before this Tag in the document.""" - return self._findOne(self.findPreviousSiblings, name, attrs, text, - **kwargs) - - def findPreviousSiblings(self, name=None, attrs={}, text=None, - limit=None, **kwargs): - """Returns the siblings of this Tag that match the given - criteria and appear before this Tag in the document.""" - return self._findAll(name, attrs, text, limit, - self.previousSiblingGenerator, **kwargs) - fetchPreviousSiblings = findPreviousSiblings # Compatibility with pre-3.x - - def findParent(self, name=None, attrs={}, **kwargs): - """Returns the closest parent of this Tag that matches the given - criteria.""" - # NOTE: We can't use _findOne because findParents takes a different - # set of arguments. - r = None - l = self.findParents(name, attrs, 1) - if l: - r = l[0] - return r - - def findParents(self, name=None, attrs={}, limit=None, **kwargs): - """Returns the parents of this Tag that match the given - criteria.""" - - return self._findAll(name, attrs, None, limit, self.parentGenerator, - **kwargs) - fetchParents = findParents # Compatibility with pre-3.x - - #These methods do the real heavy lifting. - - def _findOne(self, method, name, attrs, text, **kwargs): - r = None - l = method(name, attrs, text, 1, **kwargs) - if l: - r = l[0] - return r - - def _findAll(self, name, attrs, text, limit, generator, **kwargs): - "Iterates over a generator looking for things that match." - - if isinstance(name, SoupStrainer): - strainer = name - else: - # Build a SoupStrainer - strainer = SoupStrainer(name, attrs, text, **kwargs) - results = ResultSet(strainer) - g = generator() - while True: - try: - i = g.next() - except StopIteration: - break - if i: - found = strainer.search(i) - if found: - results.append(found) - if limit and len(results) >= limit: - break - return results - - #These Generators can be used to navigate starting from both - #NavigableStrings and Tags. - def nextGenerator(self): - i = self - while i: - i = i.next - yield i - - def nextSiblingGenerator(self): - i = self - while i: - i = i.nextSibling - yield i - - def previousGenerator(self): - i = self - while i: - i = i.previous - yield i - - def previousSiblingGenerator(self): - i = self - while i: - i = i.previousSibling - yield i - - def parentGenerator(self): - i = self - while i: - i = i.parent - yield i - - # Utility methods - def substituteEncoding(self, str, encoding=None): - encoding = encoding or "utf-8" - return str.replace("%SOUP-ENCODING%", encoding) - - def toEncoding(self, s, encoding=None): - """Encodes an object to a string in some encoding, or to Unicode. - .""" - if isinstance(s, unicode): - if encoding: - s = s.encode(encoding) - elif isinstance(s, str): - if encoding: - s = s.encode(encoding) - else: - s = unicode(s) - else: - if encoding: - s = self.toEncoding(str(s), encoding) - else: - s = unicode(s) - return s - -class NavigableString(unicode, PageElement): - - def __getattr__(self, attr): - """text.string gives you text. This is for backwards - compatibility for Navigable*String, but for CData* it lets you - get the string without the CData wrapper.""" - if attr == 'string': - return self - else: - raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr) - - def __unicode__(self): - return self.__str__(None) - - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): - if encoding: - return self.encode(encoding) - else: - return self - -class CData(NavigableString): - - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): - return "<![CDATA[%s]]>" % NavigableString.__str__(self, encoding) - -class ProcessingInstruction(NavigableString): - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): - output = self - if "%SOUP-ENCODING%" in output: - output = self.substituteEncoding(output, encoding) - return "<?%s?>" % self.toEncoding(output, encoding) - -class Comment(NavigableString): - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): - return "<!--%s-->" % NavigableString.__str__(self, encoding) - -class Declaration(NavigableString): - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): - return "<!%s>" % NavigableString.__str__(self, encoding) - -class Tag(PageElement): - - """Represents a found HTML tag with its attributes and contents.""" - - XML_SPECIAL_CHARS_TO_ENTITIES = { "'" : "squot", - '"' : "quote", - "&" : "amp", - "<" : "lt", - ">" : "gt" } - - def __init__(self, parser, name, attrs=None, parent=None, - previous=None): - "Basic constructor." - - # We don't actually store the parser object: that lets extracted - # chunks be garbage-collected - self.parserClass = parser.__class__ - self.isSelfClosing = parser.isSelfClosingTag(name) - self.name = name - if attrs == None: - attrs = [] - self.attrs = attrs - self.contents = [] - self.setup(parent, previous) - self.hidden = False - self.containsSubstitutions = False - - def get(self, key, default=None): - """Returns the value of the 'key' attribute for the tag, or - the value given for 'default' if it doesn't have that - attribute.""" - return self._getAttrMap().get(key, default) - - def has_key(self, key): - return self._getAttrMap().has_key(key) - - def __getitem__(self, key): - """tag[key] returns the value of the 'key' attribute for the tag, - and throws an exception if it's not there.""" - return self._getAttrMap()[key] - - def __iter__(self): - "Iterating over a tag iterates over its contents." - return iter(self.contents) - - def __len__(self): - "The length of a tag is the length of its list of contents." - return len(self.contents) - - def __contains__(self, x): - return x in self.contents - - def __nonzero__(self): - "A tag is non-None even if it has no contents." - return True - - def __setitem__(self, key, value): - """Setting tag[key] sets the value of the 'key' attribute for the - tag.""" - self._getAttrMap() - self.attrMap[key] = value - found = False - for i in range(0, len(self.attrs)): - if self.attrs[i][0] == key: - self.attrs[i] = (key, value) - found = True - if not found: - self.attrs.append((key, value)) - self._getAttrMap()[key] = value - - def __delitem__(self, key): - "Deleting tag[key] deletes all 'key' attributes for the tag." - for item in self.attrs: - if item[0] == key: - self.attrs.remove(item) - #We don't break because bad HTML can define the same - #attribute multiple times. - self._getAttrMap() - if self.attrMap.has_key(key): - del self.attrMap[key] - - def __call__(self, *args, **kwargs): - """Calling a tag like a function is the same as calling its - findAll() method. Eg. tag('a') returns a list of all the A tags - found within this tag.""" - return apply(self.findAll, args, kwargs) - - def __getattr__(self, tag): - #print "Getattr %s.%s" % (self.__class__, tag) - if len(tag) > 3 and tag.rfind('Tag') == len(tag)-3: - return self.find(tag[:-3]) - elif tag.find('__') != 0: - return self.find(tag) - - def __eq__(self, other): - """Returns true iff this tag has the same name, the same attributes, - and the same contents (recursively) as the given tag. - - NOTE: right now this will return false if two tags have the - same attributes in a different order. Should this be fixed?""" - if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other): - return False - for i in range(0, len(self.contents)): - if self.contents[i] != other.contents[i]: - return False - return True - - def __ne__(self, other): - """Returns true iff this tag is not identical to the other tag, - as defined in __eq__.""" - return not self == other - - def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING): - """Renders this tag as a string.""" - return self.__str__(encoding) - - def __unicode__(self): - return self.__str__(None) - - def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING, - prettyPrint=False, indentLevel=0): - """Returns a string or Unicode representation of this tag and - its contents. To get Unicode, pass None for encoding. - - NOTE: since Python's HTML parser consumes whitespace, this - method is not certain to reproduce the whitespace present in - the original string.""" - - encodedName = self.toEncoding(self.name, encoding) - - attrs = [] - if self.attrs: - for key, val in self.attrs: - fmt = '%s="%s"' - if isString(val): - if self.containsSubstitutions and '%SOUP-ENCODING%' in val: - val = self.substituteEncoding(val, encoding) - - # The attribute value either: - # - # * Contains no embedded double quotes or single quotes. - # No problem: we enclose it in double quotes. - # * Contains embedded single quotes. No problem: - # double quotes work here too. - # * Contains embedded double quotes. No problem: - # we enclose it in single quotes. - # * Embeds both single _and_ double quotes. This - # can't happen naturally, but it can happen if - # you modify an attribute value after parsing - # the document. Now we have a bit of a - # problem. We solve it by enclosing the - # attribute in single quotes, and escaping any - # embedded single quotes to XML entities. - if '"' in val: - fmt = "%s='%s'" - # This can't happen naturally, but it can happen - # if you modify an attribute value after parsing. - if "'" in val: - val = val.replace("'", "&squot;") - - # Now we're okay w/r/t quotes. But the attribute - # value might also contain angle brackets, or - # ampersands that aren't part of entities. We need - # to escape those to XML entities too. - val = re.sub("([<>]|&(?![^\s]+;))", - lambda x: "&" + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]] + ";", - val) - - attrs.append(fmt % (self.toEncoding(key, encoding), - self.toEncoding(val, encoding))) - close = '' - closeTag = '' - if self.isSelfClosing: - close = ' /' - else: - closeTag = '</%s>' % encodedName - - indentTag, indentContents = 0, 0 - if prettyPrint: - indentTag = indentLevel - space = (' ' * (indentTag-1)) - indentContents = indentTag + 1 - contents = self.renderContents(encoding, prettyPrint, indentContents) - if self.hidden: - s = contents - else: - s = [] - attributeString = '' - if attrs: - attributeString = ' ' + ' '.join(attrs) - if prettyPrint: - s.append(space) - s.append('<%s%s%s>' % (encodedName, attributeString, close)) - if prettyPrint: - s.append("\n") - s.append(contents) - if prettyPrint and contents and contents[-1] != "\n": - s.append("\n") - if prettyPrint and closeTag: - s.append(space) - s.append(closeTag) - if prettyPrint and closeTag and self.nextSibling: - s.append("\n") - s = ''.join(s) - return s - - def prettify(self, encoding=DEFAULT_OUTPUT_ENCODING): - return self.__str__(encoding, True) - - def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING, - prettyPrint=False, ... [truncated message content] |