source: camellia/trunk/camellia.py @ 21

Revision 21, 2.0 KB checked in by sgk, 14 years ago (diff)

sys.modules[name] = modにより、モジュール自体を入れ替えるようにした。

RevLine 
[18]1'''
[19]2camellia.py v 0.0
[18]3
4http://omake.accense.com/wiki/PythonCamellia
5
6Copyright (c) 2006, Accense Technology, Inc.
7All rights reserved.
8
9Redistribution and use in source and binary forms, with or without
10modification, are permitted provided that the following conditions are met:
11
[20]12o Redistributions of source code must retain the above copyright notice,
13  this list of conditions and the following disclaimer.
[18]14o Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17o Neither the name of the Accense Technology, Inc. nor the names of its
18  contributors may be used to endorse or promote products derived from this
19  software without specific prior written permission.
20
21THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31POSSIBILITY OF SUCH DAMAGE.
32'''
33
[21]34#
35# Try to import C version or Python version
36#
[18]37try:
[21]38  import ccamellia as mod
[18]39except:
[21]40  import pycamellia as mod
41
42#
43# Copy the __doc__ string above if the imported module doesn't have it.
44#
45import sys
46try:
47  if not mod.__doc__:
48    mod.__doc__ = __doc__
49except:
50  setattr(mod, '__doc__', __doc__)
51
52#
53# Replace the module registration with the C or Python version.
54#
55sys.modules[__name__] = mod
56
57#
58# Delete unwanted variables.
59#
60del mod, sys
Note: See TracBrowser for help on using the repository browser.