From: <ds...@us...> - 2007-11-08 00:25:00
|
Revision: 4156 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4156&view=rev Author: dsdale Date: 2007-11-07 16:24:57 -0800 (Wed, 07 Nov 2007) Log Message: ----------- update enthought package to version 2.6b1, stripped of setuptools installed in site-packages, if not already present Modified Paths: -------------- trunk/matplotlib/examples/rc_traits.py trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/setupext.py Added Paths: ----------- trunk/matplotlib/lib/enthought/ trunk/matplotlib/lib/enthought/__init__.py trunk/matplotlib/lib/enthought/etsconfig/ trunk/matplotlib/lib/enthought/etsconfig/__init__.py trunk/matplotlib/lib/enthought/etsconfig/api.py trunk/matplotlib/lib/enthought/etsconfig/etsconfig.py trunk/matplotlib/lib/enthought/etsconfig/tests/ trunk/matplotlib/lib/enthought/etsconfig/tests/etsconfig_test_case.py trunk/matplotlib/lib/enthought/etsconfig/version.py trunk/matplotlib/lib/enthought/traits/ trunk/matplotlib/lib/enthought/traits/MANIFEST.in trunk/matplotlib/lib/enthought/traits/README.txt trunk/matplotlib/lib/enthought/traits/__init__.py trunk/matplotlib/lib/enthought/traits/__init__.pyc trunk/matplotlib/lib/enthought/traits/api.py trunk/matplotlib/lib/enthought/traits/category.py trunk/matplotlib/lib/enthought/traits/core.py trunk/matplotlib/lib/enthought/traits/core_traits.py trunk/matplotlib/lib/enthought/traits/ctraits.c trunk/matplotlib/lib/enthought/traits/has_dynamic_views.py trunk/matplotlib/lib/enthought/traits/has_traits.py trunk/matplotlib/lib/enthought/traits/images/ trunk/matplotlib/lib/enthought/traits/images/list_editor.gif trunk/matplotlib/lib/enthought/traits/info_traits.py trunk/matplotlib/lib/enthought/traits/plugins/ trunk/matplotlib/lib/enthought/traits/plugins/enthought_traits_vet.py trunk/matplotlib/lib/enthought/traits/standard.py trunk/matplotlib/lib/enthought/traits/tests/ trunk/matplotlib/lib/enthought/traits/tests/__init__.py trunk/matplotlib/lib/enthought/traits/tests/array_test_case.py trunk/matplotlib/lib/enthought/traits/tests/category_test_case.py trunk/matplotlib/lib/enthought/traits/tests/clone_test_case.py trunk/matplotlib/lib/enthought/traits/tests/container_events_test_case.py trunk/matplotlib/lib/enthought/traits/tests/delegate_test_case.py trunk/matplotlib/lib/enthought/traits/tests/images/ trunk/matplotlib/lib/enthought/traits/tests/images/bottom_left_origin.gif trunk/matplotlib/lib/enthought/traits/tests/images/bottom_right_origin.gif trunk/matplotlib/lib/enthought/traits/tests/images/top_left_origin.gif trunk/matplotlib/lib/enthought/traits/tests/images/top_right_origin.gif trunk/matplotlib/lib/enthought/traits/tests/keyword_args_test_case.py trunk/matplotlib/lib/enthought/traits/tests/list_test_case.py trunk/matplotlib/lib/enthought/traits/tests/other.py trunk/matplotlib/lib/enthought/traits/tests/range_test_case.py trunk/matplotlib/lib/enthought/traits/tests/regression/ trunk/matplotlib/lib/enthought/traits/tests/regression/__init__.py trunk/matplotlib/lib/enthought/traits/tests/regression/pickle_validated_dict_test_case.py trunk/matplotlib/lib/enthought/traits/tests/rich_compare_test_case.py trunk/matplotlib/lib/enthought/traits/tests/simple.py trunk/matplotlib/lib/enthought/traits/tests/simple_test_case.py trunk/matplotlib/lib/enthought/traits/tests/test_copy_traits.py trunk/matplotlib/lib/enthought/traits/tests/test_copyable_trait_names.py trunk/matplotlib/lib/enthought/traits/tests/test_event_order.py trunk/matplotlib/lib/enthought/traits/tests/test_events.py trunk/matplotlib/lib/enthought/traits/tests/test_listeners.py trunk/matplotlib/lib/enthought/traits/tests/test_property_notifications.py trunk/matplotlib/lib/enthought/traits/tests/test_str_handler.py trunk/matplotlib/lib/enthought/traits/tests/test_timing.py trunk/matplotlib/lib/enthought/traits/tests/test_trait_cycle.py trunk/matplotlib/lib/enthought/traits/tests/test_traits.py trunk/matplotlib/lib/enthought/traits/tests/test_ui.py trunk/matplotlib/lib/enthought/traits/tests/test_ui3.py trunk/matplotlib/lib/enthought/traits/tests/test_ui4.py trunk/matplotlib/lib/enthought/traits/tests/test_ui5.py trunk/matplotlib/lib/enthought/traits/tests/undefined_test_case.py trunk/matplotlib/lib/enthought/traits/trait_base.py trunk/matplotlib/lib/enthought/traits/trait_db.py trunk/matplotlib/lib/enthought/traits/trait_errors.py trunk/matplotlib/lib/enthought/traits/trait_handlers.py trunk/matplotlib/lib/enthought/traits/trait_notifiers.py trunk/matplotlib/lib/enthought/traits/trait_numeric.py trunk/matplotlib/lib/enthought/traits/traits.py trunk/matplotlib/lib/enthought/traits/ui/ trunk/matplotlib/lib/enthought/traits/ui/__init__.py trunk/matplotlib/lib/enthought/traits/ui/__init__.pyc trunk/matplotlib/lib/enthought/traits/ui/api.py trunk/matplotlib/lib/enthought/traits/ui/delegating_handler.py trunk/matplotlib/lib/enthought/traits/ui/dockable_view_element.py trunk/matplotlib/lib/enthought/traits/ui/editor.py trunk/matplotlib/lib/enthought/traits/ui/editor_factory.py trunk/matplotlib/lib/enthought/traits/ui/editors.py trunk/matplotlib/lib/enthought/traits/ui/extras/ trunk/matplotlib/lib/enthought/traits/ui/extras/__init__.py trunk/matplotlib/lib/enthought/traits/ui/extras/checkbox_column.py trunk/matplotlib/lib/enthought/traits/ui/extras/core.py trunk/matplotlib/lib/enthought/traits/ui/group.py trunk/matplotlib/lib/enthought/traits/ui/handler.py trunk/matplotlib/lib/enthought/traits/ui/help.py trunk/matplotlib/lib/enthought/traits/ui/help_template.py trunk/matplotlib/lib/enthought/traits/ui/helper.py trunk/matplotlib/lib/enthought/traits/ui/images/ trunk/matplotlib/lib/enthought/traits/ui/images/array_node.png trunk/matplotlib/lib/enthought/traits/ui/images/bool_node.png trunk/matplotlib/lib/enthought/traits/ui/images/complex_node.png trunk/matplotlib/lib/enthought/traits/ui/images/dict_node.png trunk/matplotlib/lib/enthought/traits/ui/images/float_node.png trunk/matplotlib/lib/enthought/traits/ui/images/int_node.png trunk/matplotlib/lib/enthought/traits/ui/images/list_node.png trunk/matplotlib/lib/enthought/traits/ui/images/none_node.png trunk/matplotlib/lib/enthought/traits/ui/images/object_node.png trunk/matplotlib/lib/enthought/traits/ui/images/other_node.png trunk/matplotlib/lib/enthought/traits/ui/images/string_node.png trunk/matplotlib/lib/enthought/traits/ui/images/traits_node.png trunk/matplotlib/lib/enthought/traits/ui/images/tuple_node.png trunk/matplotlib/lib/enthought/traits/ui/include.py trunk/matplotlib/lib/enthought/traits/ui/instance_choice.py trunk/matplotlib/lib/enthought/traits/ui/item.py trunk/matplotlib/lib/enthought/traits/ui/key_bindings.py trunk/matplotlib/lib/enthought/traits/ui/menu.py trunk/matplotlib/lib/enthought/traits/ui/message.py trunk/matplotlib/lib/enthought/traits/ui/null/ trunk/matplotlib/lib/enthought/traits/ui/null/__init__.py trunk/matplotlib/lib/enthought/traits/ui/null/color_trait.py trunk/matplotlib/lib/enthought/traits/ui/null/font_trait.py trunk/matplotlib/lib/enthought/traits/ui/null/rgb_color_trait.py trunk/matplotlib/lib/enthought/traits/ui/null/toolkit.py trunk/matplotlib/lib/enthought/traits/ui/table_column.py trunk/matplotlib/lib/enthought/traits/ui/table_filter.py trunk/matplotlib/lib/enthought/traits/ui/tests/ trunk/matplotlib/lib/enthought/traits/ui/tests/array_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/buttons_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/check_list_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/check_list_editor_test2.py trunk/matplotlib/lib/enthought/traits/ui/tests/code_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/enum_dynamic_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/html_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_drag_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test2.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test3.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test4.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test5.py trunk/matplotlib/lib/enthought/traits/ui/tests/instance_editor_test6.py trunk/matplotlib/lib/enthought/traits/ui/tests/list_traits_ui_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/set_dynamic_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/shell_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/table_editor_color_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/table_editor_focus_bug.py trunk/matplotlib/lib/enthought/traits/ui/tests/table_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/table_editor_test2.py trunk/matplotlib/lib/enthought/traits/ui/tests/table_list_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tests/tree_editor_test.py trunk/matplotlib/lib/enthought/traits/ui/tk/ trunk/matplotlib/lib/enthought/traits/ui/tk/__init__.py trunk/matplotlib/lib/enthought/traits/ui/tk/boolean_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/button_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/check_list_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/color_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/compound_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/constants.py trunk/matplotlib/lib/enthought/traits/ui/tk/directory_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/editor_factory.py trunk/matplotlib/lib/enthought/traits/ui/tk/enum_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/file_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/font_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/helper.py trunk/matplotlib/lib/enthought/traits/ui/tk/image_control.py trunk/matplotlib/lib/enthought/traits/ui/tk/image_enum_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/instance_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/list_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/menu.py trunk/matplotlib/lib/enthought/traits/ui/tk/range_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/rgb_color_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/text_editor.py trunk/matplotlib/lib/enthought/traits/ui/tk/toolkit.py trunk/matplotlib/lib/enthought/traits/ui/tk/ui_modal.py trunk/matplotlib/lib/enthought/traits/ui/tk/ui_nonmodal.py trunk/matplotlib/lib/enthought/traits/ui/tk/ui_panel.py trunk/matplotlib/lib/enthought/traits/ui/tk/ui_wizard.py trunk/matplotlib/lib/enthought/traits/ui/tk/view_application.py trunk/matplotlib/lib/enthought/traits/ui/toolkit.py trunk/matplotlib/lib/enthought/traits/ui/traits.py trunk/matplotlib/lib/enthought/traits/ui/tree_node.py trunk/matplotlib/lib/enthought/traits/ui/tuidb.py trunk/matplotlib/lib/enthought/traits/ui/ui.py trunk/matplotlib/lib/enthought/traits/ui/ui_info.py trunk/matplotlib/lib/enthought/traits/ui/ui_traits.py trunk/matplotlib/lib/enthought/traits/ui/undo.py trunk/matplotlib/lib/enthought/traits/ui/value_tree.py trunk/matplotlib/lib/enthought/traits/ui/view.py trunk/matplotlib/lib/enthought/traits/ui/view_element.py trunk/matplotlib/lib/enthought/traits/ui/view_elements.py trunk/matplotlib/lib/enthought/traits/version.py Removed Paths: ------------- trunk/matplotlib/lib/matplotlib/enthought/ Modified: trunk/matplotlib/examples/rc_traits.py =================================================================== --- trunk/matplotlib/examples/rc_traits.py 2007-11-08 00:09:17 UTC (rev 4155) +++ trunk/matplotlib/examples/rc_traits.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -7,7 +7,7 @@ # below. import sys, os, re -import matplotlib.enthought.traits.api as traits +import enthought.traits.api as traits from matplotlib.cbook import is_string_like from matplotlib.artist import Artist Added: trunk/matplotlib/lib/enthought/__init__.py =================================================================== --- trunk/matplotlib/lib/enthought/__init__.py (rev 0) +++ trunk/matplotlib/lib/enthought/__init__.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,11 @@ +#------------------------------------------------------------------------------ +# Copyright (c) 2007 by Enthought, Inc. +# All rights reserved. +#------------------------------------------------------------------------------ + +try: + pass +except: + pass + + Added: trunk/matplotlib/lib/enthought/etsconfig/__init__.py =================================================================== Added: trunk/matplotlib/lib/enthought/etsconfig/api.py =================================================================== --- trunk/matplotlib/lib/enthought/etsconfig/api.py (rev 0) +++ trunk/matplotlib/lib/enthought/etsconfig/api.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,4 @@ +from enthought.etsconfig.version import version, version as __version__ + + +from etsconfig import ETSConfig Added: trunk/matplotlib/lib/enthought/etsconfig/etsconfig.py =================================================================== --- trunk/matplotlib/lib/enthought/etsconfig/etsconfig.py (rev 0) +++ trunk/matplotlib/lib/enthought/etsconfig/etsconfig.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,385 @@ +""" Enthought Tool Suite configuration information. """ + + +# Standard library imports. +import sys +import os +from os import path + + +class ETSConfig(object): + """ + Enthought Tool Suite configuration information. + + This class should not use ANY other package in the tool suite so that it + will always work no matter which other packages are present. + + """ + + ########################################################################### + # 'object' interface. + ########################################################################### + + #### operator methods ##################################################### + + def __init__(self): + """ + Constructor. + + Note that this constructor can only ever be called from within this + module, since we don't expose the class. + + """ + + # Shadow attributes for properties. + self._application_data = None + self._application_home = None + self._company = None + self._toolkit = None + self._user_data = None + + return + + + ########################################################################### + # 'ETSConfig' interface. + ########################################################################### + + #### properties ########################################################### + + def _get_application_data(self): + """ + Property getter. + + This is a directory that applications and packages can safely write + non-user accessible data to i.e. configuration information, preferences + etc. + + Do not put anything in here that the user might want to navigate to + e.g. projects, user data files etc. + + The actual location differs between operating systems. + + """ + + if self._application_data is None: + self._application_data = self._initialize_application_data() + + return self._application_data + + + def _set_application_data(self, application_data): + """ + Property setter. + + """ + + self._application_data = application_data + + return + + + application_data = property(_get_application_data, _set_application_data) + + + def _get_application_home(self): + """ + Property getter. + + This is a directory named after the current, running application that + imported this module that applications and packages can safely write + non-user accessible data to i.e. configuration information, preferences + etc. It is a sub-directory of self.application_data, named after the + directory that contains the "main" python script that started the + process. For example, if application foo is started with a script named + "run.py" in a directory named "foo", then the application home would be: + <ETSConfig.application_data>/foo, regardless of if it was launched + with "python <path_to_foo>/run.py" or "cd <path_to_foo>; python run.py" + + This is useful for library modules used in apps that need to store + state, preferences, etc. for the specific app only, and not for all apps + which use that library module. If the library module uses + ETSConfig.application_home, they can store prefs for the app all in + one place and do not need to know the details of where each app might + reside. + + Do not put anything in here that the user might want to navigate to + e.g. projects, user home files etc. + + The actual location differs between operating systems. + + """ + + if self._application_home is None: + self._application_home = path.join(self.application_data, + self._get_application_dirname()) + + return self._application_home + + + def _set_application_home(self, application_home): + """ + Property setter. + + """ + + self._application_home = application_home + + return + + + application_home = property(_get_application_home, _set_application_home) + + + def _get_company(self): + """ + Property getter. + + """ + + if self._company is None: + self._company = self._initialize_company() + + return self._company + + + def _set_company(self, company): + """ + Property setter for the company name. + + """ + + self._company = company + + return + + + company = property(_get_company, _set_company) + + + def _get_toolkit(self): + """ + Property getter for the GUI toolkit. The value returned is, in order + of preference: the value set by the application; the value passed on + the command line using the '-toolkit' option; the value specified by + the 'ETS_TOOLKIT' environment variable; otherwise the empty string. + + """ + + if self._toolkit is None: + self._toolkit = self._initialize_toolkit() + + return self._toolkit + + + def _set_toolkit(self, toolkit): + """ + Property setter for the GUI toolkit. The toolkit can be set more than + once, but only if it is the same one each time. An application that is + written for a particular toolkit can explicitly set it before any other + module that gets the value is imported. + + """ + + if self._toolkit and self._toolkit != toolkit: + raise ValueError, "cannot set toolkit to %s because it has already been set to %s" % (toolkit, self._toolkit) + + self._toolkit = toolkit + + return + + + toolkit = property(_get_toolkit, _set_toolkit) + + + def _get_user_data(self): + """ + Property getter. + + This is a directory that users can safely write user accessible data + to i.e. user-defined functions, edited functions, etc. + + The actual location differs between operating systems. + + """ + + if self._user_data is None: + self._user_data = self._initialize_user_data() + + return self._user_data + + + def _set_user_data(self, user_data): + """ + Property setter. + + """ + + self._user_data = user_data + + return + + + user_data = property(_get_user_data, _set_user_data) + + + #### private methods ##################################################### + + # fixme: In future, these methods could allow the properties to be set + # via the (as yet non-existent) preference/configuration mechanism. This + # would allow configuration via (in order of precedence):- + # + # - a configuration file + # - environment variables + # - the command line + + def _get_application_dirname(self): + """ + Return the name of the directory (not a path) that the "main" + Python script which started this process resides in, or "" if it could + not be determined or is not appropriate. + + For example, if the script that started the current process was named + "run.py" in a directory named "foo", and was launched with "python + run.py", the name "foo" would be returned (this assumes the directory + name is the name of the app, which seems to be as good of an assumption + as any). + + """ + + dirname = "" + + main_mod = sys.modules.get('__main__', None) + if main_mod is not None: + if hasattr(main_mod, '__file__'): + main_mod_file = path.abspath(main_mod.__file__) + dirname = path.basename(path.dirname(main_mod_file)) + + return dirname + + + def _initialize_application_data(self): + """ + Initializes the (default) application data directory. + + """ + + if sys.platform == 'win32': + environment_variable = 'APPDATA' + directory_name = self.company + + else: + environment_variable = 'HOME' + directory_name = '.' + self.company.lower() + + # Lookup the environment variable. + parent_directory = os.environ.get(environment_variable, None) + if parent_directory is None: + raise ValueError( + 'Environment variable "%s" not set' % environment_variable + ) + + application_data = os.path.join(parent_directory, directory_name) + + # If a file already exists with this name then make sure that it is + # a directory! + if os.path.exists(application_data): + if not os.path.isdir(application_data): + raise ValueError('File "%s" already exists' % application_data) + + # Otherwise, create the directory. + else: + os.makedirs(application_data) + + return application_data + + + def _initialize_company(self): + """ + Initializes the (default) company. + + """ + + return 'Enthought' + + + def _initialize_toolkit(self): + """ + Initializes the toolkit. + + """ + + # We handle the command line option even though it doesn't have the + # highest precedence because we always want to remove it from the + # command line. + if '-toolkit' in sys.argv: + opt_idx = sys.argv.index('-toolkit') + + try: + opt_toolkit = sys.argv[opt_idx + 1] + except IndexError: + raise ValueError, "the -toolkit command line argument must be followed by a toolkit name" + + # Remove the option. + del sys.argv[opt_idx:opt_idx + 1] + else: + opt_toolkit = None + + if self._toolkit is not None: + toolkit = self._toolkit + elif opt_toolkit is not None: + toolkit = opt_toolkit + else: + toolkit = os.environ.get('ETS_TOOLKIT', '') + + return toolkit + + + def _initialize_user_data(self): + """ + Initializes the (default) user data directory. + + """ + + # We check what the os.path.expanduser returns + parent_directory = os.path.expanduser('~') + directory_name = self.company + + + if sys.platform == 'win32': + # Check if the usr_dir is C:\\John Doe\\Documents and Settings. + # If yes, then we should modify the usr_dir to be 'My Documents'. + # If no, then the user must have modified the os.environ + # variables and the directory chosen is a desirable one. + desired_dir = os.path.join(parent_directory, 'My Documents') + + if os.path.exists(desired_dir): + parent_directory = desired_dir + + else: + directory_name = directory_name.lower() + + # The final directory. + usr_dir = os.path.join(parent_directory, directory_name) + + # If a file already exists with this name then make sure that it is + # a directory! + if os.path.exists(usr_dir): + if not os.path.isdir(usr_dir): + raise ValueError('File "%s" already exists' % usr_dir) + + # Otherwise, create the directory. + else: + os.makedirs(usr_dir) + + return usr_dir + + + +# We very purposefully only have one object and do not export the class. We +# could have just made everything class methods, but that always seems a bit +# gorpy, especially with properties etc. +ETSConfig = ETSConfig() + + +#### EOF ###################################################################### Added: trunk/matplotlib/lib/enthought/etsconfig/tests/etsconfig_test_case.py =================================================================== --- trunk/matplotlib/lib/enthought/etsconfig/tests/etsconfig_test_case.py (rev 0) +++ trunk/matplotlib/lib/enthought/etsconfig/tests/etsconfig_test_case.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,241 @@ +""" Tests the 'ETSConfig' configuration object. """ + + +# Standard library imports. +import os, time, unittest + +# Enthought library imports. +from enthought.etsconfig.api import ETSConfig + + +class ETSConfigTestCase(unittest.TestCase): + """ Tests the 'ETSConfig' configuration object. """ + + ########################################################################### + # 'TestCase' interface. + ########################################################################### + + #### public methods ####################################################### + + def setUp(self): + """ + Prepares the test fixture before each test method is called. + + """ + + return + + def tearDown(self): + """ + Called immediately after each test method has been called. + + """ + + return + + + ########################################################################### + # 'ETSConfigTestCase' interface. + ########################################################################### + + #### public methods ####################################################### + + def test_application_data(self): + """ + application data + + """ + + dirname = ETSConfig.application_data + + self.assertEqual(os.path.exists(dirname), True) + self.assertEqual(os.path.isdir(dirname), True) + + return + + def test_set_application_data(self): + """ + set application data + + """ + + old = ETSConfig.application_data + + ETSConfig.application_data = 'foo' + self.assertEqual('foo', ETSConfig.application_data) + + ETSConfig.application_data = old + self.assertEqual(old, ETSConfig.application_data) + + return + + + def test_application_data_is_idempotent(self): + """ + application data is idempotent + + """ + + # Just do the previous test again! + self.test_application_data() + + return + + + def test_write_to_application_data_directory(self): + """ + write to application data directory + + """ + + ETSConfig.company = 'Blah' + dirname = ETSConfig.application_data + + path = os.path.join(dirname, 'dummy.txt') + data = str(time.time()) + + f = file(path, 'w') + f.write(data) + f.close() + + self.assertEqual(os.path.exists(path), True) + + f = file(path) + result = f.read() + f.close() + + os.remove(path) + + self.assertEqual(data, result) + + return + + + def test_default_company(self): + """ + default company + + """ + + self.assertEqual(ETSConfig.company, 'Enthought') + + return + + + def test_set_company(self): + """ + set company + + """ + + old = ETSConfig.company + + ETSConfig.company = 'foo' + self.assertEqual('foo', ETSConfig.company) + + ETSConfig.company = old + self.assertEqual(old, ETSConfig.company) + + return + + + def _test_default_application_home(self): + """ + application home + + """ + + # This test is only valid when run with the 'main' at the end of this + # file: "python app_dat_locator_test_case.py", in which case the + # app_name will be the directory this file is in ('tests'). + app_home = ETSConfig.application_home + (dirname, app_name) = os.path.split(app_home) + + self.assertEqual(dirname, ETSConfig.application_data) + self.assertEqual(app_name, 'tests') + + + def test_user_data(self): + """ + user data + + """ + + dirname = ETSConfig.user_data + + self.assertEqual(os.path.exists(dirname), True) + self.assertEqual(os.path.isdir(dirname), True) + + return + + + def test_set_user_data(self): + """ + set user data + + """ + + old = ETSConfig.user_data + + ETSConfig.user_data = 'foo' + self.assertEqual('foo', ETSConfig.user_data) + + ETSConfig.user_data = old + self.assertEqual(old, ETSConfig.user_data) + + return + + + def test_user_data_is_idempotent(self): + """ + user data is idempotent + + """ + + # Just do the previous test again! + self.test_user_data() + + return + + + def test_write_to_user_data_directory(self): + """ + write to user data directory + + """ + + ETSConfig.company = 'Blah' + dirname = ETSConfig.user_data + + path = os.path.join(dirname, 'dummy.txt') + data = str(time.time()) + + f = file(path, 'w') + f.write(data) + f.close() + + self.assertEqual(os.path.exists(path), True) + + f = file(path) + result = f.read() + f.close() + + os.remove(path) + + self.assertEqual(data, result) + + return + + +# For running as an individual set of tests. +if __name__ == '__main__': + + # Add the non-default test of application_home...non-default because it must + # be run using this module as a script to be valid. + suite = unittest.TestLoader().loadTestsFromTestCase(ETSConfigTestCase) + suite.addTest(ETSConfigTestCase('_test_default_application_home')) + + unittest.TextTestRunner(verbosity=2).run(suite) + + +#### EOF ###################################################################### Added: trunk/matplotlib/lib/enthought/etsconfig/version.py =================================================================== --- trunk/matplotlib/lib/enthought/etsconfig/version.py (rev 0) +++ trunk/matplotlib/lib/enthought/etsconfig/version.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,10 @@ +# Wrapped in a try/except in those situations where someone hasn't installed +# as an egg. What do we do then? For now, we just punt since we don't want +# to define the version number in two places. +#try: +# import pkg_resources +# version = pkg_resources.require('enthought.etsconfig')[0].version +#except: +# version = '' +version = '2.6b1-mpl' + Added: trunk/matplotlib/lib/enthought/traits/MANIFEST.in =================================================================== --- trunk/matplotlib/lib/enthought/traits/MANIFEST.in (rev 0) +++ trunk/matplotlib/lib/enthought/traits/MANIFEST.in 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1 @@ +exclude *_test*.py Added: trunk/matplotlib/lib/enthought/traits/README.txt =================================================================== --- trunk/matplotlib/lib/enthought/traits/README.txt (rev 0) +++ trunk/matplotlib/lib/enthought/traits/README.txt 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,67 @@ +Introduction +------------ + +'Traits' is a Python package for creating 'manifestly'-typed Python attributes. + +Installation +------------ + +The Traits package is installed using the standard Python 'distutils' package. + +Enter the following command in the 'traits-1.0' directory: + + python setup.py install + +This will perform a normal install of the Traits package into your Python +installation. Refer to the Python 'distutils' documentation for more +installation options. + +Download +-------- + +The Traits package is available as part of the Enthought Tool Suite (ETS), +available from: + + http://code.enthought.com/ets/ + +To install ETS using Enthought's egg-based 'Enstaller', download and run: + + http://code.enthought.com/enstaller/run_enstaller.py + +License +------- + +The 'traits' package is available under a BSD style license. + +Contact +------- + +If you encounter any problems using the 'traits' package, or have any comments +or suggestions about the package, please contact the author: + + David C. Morrill + dmo...@en... + +For discussion of the Traits package, as well as other tools in the Enthought +Tool Suite, use the enthought-dev mailing list: + + https://mail.enthought.com/mailman/listinfo/enthought-dev + + http://dir.gmane.org/gmane.comp.python.enthought.devel + +Prerequisites +------------- + +The base Traits package should work on any platform supporting Python >= 1.5.2. + +The user interface capabilities of the traits package require additional +Python packages to be installed. + +The UI toolkit backend that is actively maintained is wxPython. To use it, +install a version >= 2.3.3.1 (available from: http://www.wxpython.org). + +A UI toolkit backend for Tkinter exists, but is not actively maintained or +tested. If you wish to try Traits with Tkinter, you must also install: + + - Tkinter (usually installed as part of your Python distribution) + - PMW (Python MegaWidgets) (available from: http://pmw.sourceforge.net) Added: trunk/matplotlib/lib/enthought/traits/__init__.py =================================================================== --- trunk/matplotlib/lib/enthought/traits/__init__.py (rev 0) +++ trunk/matplotlib/lib/enthought/traits/__init__.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,26 @@ +#------------------------------------------------------------------------------ +# Copyright (c) 2005, Enthought, Inc. +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in enthought/LICENSE.txt and may be redistributed only +# under the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# Thanks for using Enthought open source! +# +# Author: David C. Morrill +# Date: 06/21/2002 +# Description: Define a 'traits' package that allows other classes to easily +# define 'type-checked' and/or 'delegated' traits for their +# instances. +# +# Note: A 'trait' is similar to a 'property', but is used instead +# of the word 'property' to differentiate it from the Python +# language 'property' feature. +#------------------------------------------------------------------------------ + +try: + # if the code is ran from an egg, the namespace must be declared + pass +except: + pass Added: trunk/matplotlib/lib/enthought/traits/__init__.pyc =================================================================== (Binary files differ) Property changes on: trunk/matplotlib/lib/enthought/traits/__init__.pyc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/matplotlib/lib/enthought/traits/api.py =================================================================== --- trunk/matplotlib/lib/enthought/traits/api.py (rev 0) +++ trunk/matplotlib/lib/enthought/traits/api.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,159 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2005, Enthought, Inc. +# All rights reserved. +# +# Written by: David C. Morrill +# +# Date: 12/06/2005 +# +#------------------------------------------------------------------------------ + + +""" Pseudo-package for all of the core symbols from Traits and TraitsUI. +Use this module for importing Traits names into your namespace. For example:: + + from enthought.traits.api import HasTraits + +""" + +from enthought.traits.version import version, version as __version__ + + +from info_traits \ + import __doc__ + +from trait_base \ + import Undefined, Missing, Self + +from trait_errors \ + import TraitError, TraitNotificationError, DelegationError + +from trait_notifiers \ + import push_exception_handler, pop_exception_handler, \ + TraitChangeNotifyWrapper + +from category \ + import Category + +from trait_db \ + import tdb + +from traits \ + import Event, List, Dict, Tuple, Range, Constant, CTrait, Trait, Delegate, \ + Property, Expression, Button, ToolbarButton, PythonValue, Any, Int, \ + Long, Float, Str, Unicode, Complex, Bool, CInt, CLong, CFloat, \ + CStr, CUnicode, WeakRef + +from traits \ + import CComplex, CBool, false, true, Regex, String, Password, File, \ + Directory, Function, Method, Class, Instance, Module, Type, This, \ + self, Either, Python, Disallow, ReadOnly, undefined, missing, ListInt + +from traits \ + import ListFloat, ListStr, ListUnicode, ListComplex, ListBool, \ + ListFunction, ListMethod, ListClass, ListInstance, ListThis, \ + DictStrAny, DictStrStr, DictStrInt, DictStrLong, DictStrFloat + +from traits \ + import DictStrBool, DictStrList, TraitFactory, Callable, Array, CArray, \ + Enum, Code, HTML, Default, Color, RGBColor, Font + +from has_traits \ + import method, HasTraits, HasStrictTraits, HasPrivateTraits, \ + SingletonHasTraits, SingletonHasStrictTraits, \ + SingletonHasPrivateTraits, MetaHasTraits, Vetoable, VetoableEvent, \ + traits_super + +from trait_handlers \ + import TraitHandler, TraitRange, TraitString, TraitType, TraitCastType, \ + TraitInstance, ThisClass, TraitClass, TraitFunction, TraitEnum, \ + TraitPrefixList, TraitMap, TraitPrefixMap, TraitCompound, \ + TraitList, TraitListEvent, TraitDict, TraitDictEvent, TraitTuple + +from traits \ + import UIDebugger + +################### +# ui imports +if False: + + from ui.handler \ + import Handler, ViewHandler, default_handler + + from ui.view \ + import View + + from ui.group \ + import Group, HGroup, VGroup, VGrid, HFlow, VFlow, HSplit, VSplit, Tabbed + + from ui.ui \ + import UI + + from ui.ui_info \ + import UIInfo + + from ui.help \ + import on_help_call + + from ui.include \ + import Include + + from ui.item \ + import Item, Label, Heading, Spring, spring + + from ui.editor_factory \ + import EditorFactory + + from ui.editor \ + import Editor + + from ui.toolkit \ + import toolkit + + from ui.undo \ + import UndoHistory, AbstractUndoItem, UndoItem, ListUndoItem, \ + UndoHistoryUndoItem + + from ui.view_element \ + import ViewElement, ViewSubElement + + from ui.help_template \ + import help_template + + from ui.message \ + import message, error + + from ui.tree_node \ + import TreeNode, ObjectTreeNode, TreeNodeObject, MultiTreeNode + + from ui.editors \ + import ArrayEditor, BooleanEditor, ButtonEditor, CheckListEditor, \ + CodeEditor, ColorEditor, RGBColorEditor, \ + CompoundEditor, DirectoryEditor, EnumEditor, FileEditor, \ + FontEditor, ImageEnumEditor, InstanceEditor, \ + ListEditor, RangeEditor, TextEditor, TreeEditor, \ + TableEditor, TupleEditor, DropEditor, DNDEditor, CustomEditor + + from ui.editors \ + import ColorTrait, RGBColorTrait, \ + FontTrait, SetEditor, HTMLEditor, KeyBindingEditor, \ + ShellEditor, TitleEditor, ValueEditor, NullEditor + + +import ui.view_elements + +#------------------------------------------------------------------------------- +# Patch the main traits module with the correct definition for the ViewElements +# class: +#------------------------------------------------------------------------------- + +import has_traits as has_traits +has_traits.ViewElements = ui.view_elements.ViewElements + +#------------------------------------------------------------------------------- +# Patch the main traits module with the correct definition for the ViewElement +# and ViewSubElement class: +#------------------------------------------------------------------------------- + +has_traits.ViewElement = ui.view_element.ViewElement Added: trunk/matplotlib/lib/enthought/traits/category.py =================================================================== --- trunk/matplotlib/lib/enthought/traits/category.py (rev 0) +++ trunk/matplotlib/lib/enthought/traits/category.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,105 @@ +#------------------------------------------------------------------------------ +# Copyright (c) 2005, Enthought, Inc. +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in enthought/LICENSE.txt and may be redistributed only +# under the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# Thanks for using Enthought open source! +# +# Author: David C. Morrill +# Date: 11/06/2004 +#------------------------------------------------------------------------------ +""" Adds a "category" capability to Traits-based classes, +similar to that provided by the Cocoa (Objective-C) environment for the +Macintosh. + +You can use categories to extend an existing HasTraits class, as an alternative +to subclassing. An advantage of categories over subclassing is that you can +access the added members on instances of the original class, without having to +change them to instances of a subclass. Unlike subclassing, categories do not +allow overriding trait attributes. +""" +#------------------------------------------------------------------------------- +# Imports: +#------------------------------------------------------------------------------- + +from has_traits \ + import MetaHasTraits, MetaHasTraitsObject, BaseTraits, ClassTraits, \ + PrefixTraits, ViewTraits + +#------------------------------------------------------------------------------- +# 'MetaCategory' class: +#------------------------------------------------------------------------------- + +class MetaCategory ( MetaHasTraits ): + + def __new__ ( cls, class_name, bases, class_dict ): + + # Make sure the correct usage is being applied: + if len( bases ) > 2: + raise TypeError, \ + "Correct usage is: class FooCategory(Category,Foo):" + + # Process any traits-related information in the class dictionary: + MetaCategoryObject( cls, class_name, bases, class_dict, True ) + + # Move all remaining items in our class dictionary to the base class's + # dictionary: + if len( bases ) == 2: + category_class = bases[1] + for name, value in class_dict.items(): + if not hasattr( category_class, name ): + setattr( category_class, name, value ) + del class_dict[ name ] + + # Finish building the class using the updated class dictionary: + return type.__new__( cls, class_name, bases, class_dict ) + +#------------------------------------------------------------------------------- +# 'MetaCategoryObject' class: +#------------------------------------------------------------------------------- + +class MetaCategoryObject ( MetaHasTraitsObject ): + + #--------------------------------------------------------------------------- + # Adds the traits meta-data to the class: + #--------------------------------------------------------------------------- + + def add_traits_meta_data ( self, bases, class_dict, base_traits, + class_traits, instance_traits, prefix_traits, + view_elements ): + if len( bases ) == 2: + # Update the class and each of the existing subclasses: + bases[1]._add_trait_category( base_traits, class_traits, + instance_traits, prefix_traits, view_elements ) + else: + MetaHasTraitsObject.add_traits_meta_data( self, bases, + class_dict, base_traits, class_traits, instance_traits, + prefix_traits, view_elements ) + +#------------------------------------------------------------------------------- +# 'Category' class: +#------------------------------------------------------------------------------- + +class Category ( object ): + """ Used for defining "category" extensions to existing classes. + + To define a class as a category, specify "Category," followed by the name + of the base class name in the base class list. + + The following example demonstrates defining a category:: + + from enthought.traits.api import HasTraits, Str, Category + + class Base(HasTraits): + x = Str("Base x") + y = Str("Base y") + + class BaseExtra(Category, Base): + z = Str("BaseExtra z") + """ + + __metaclass__ = MetaCategory + Added: trunk/matplotlib/lib/enthought/traits/core.py =================================================================== --- trunk/matplotlib/lib/enthought/traits/core.py (rev 0) +++ trunk/matplotlib/lib/enthought/traits/core.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,20 @@ +#------------------------------------------------------------------------------ +# +# Copyright (c) 2005, Enthought, Inc. +# All rights reserved. +# +# Written by: David C. Morrill +# +# Date: 12/06/2005 +# +#------------------------------------------------------------------------------ +""" Pseudo-package for all of the core symbols from Traits and TraitsUI. +""" +from enthought.traits.api \ + import * + +try: + from enthought.traits.ui.api \ + import * +except: + pass Added: trunk/matplotlib/lib/enthought/traits/core_traits.py =================================================================== --- trunk/matplotlib/lib/enthought/traits/core_traits.py (rev 0) +++ trunk/matplotlib/lib/enthought/traits/core_traits.py 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,84 @@ +#------------------------------------------------------------------------------ +# Copyright (c) 2005, Enthought, Inc. +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in enthought/LICENSE.txt and may be redistributed only +# under the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# Thanks for using Enthought open source! +# +# Author: David C. Morrill +# Date: 11/26/2004 +# ------------------------------------------------------------------------------ +""" Adds all of the core traits to the Traits database. +""" +if __name__ == '__main__': + + from enthought.traits.api import Event, List, Dict, Any, Int, Long, Float, Str + from enthought.traits.api import Unicode, Complex, Bool, CInt, CLong, CFloat + from enthought.traits.api import CStr, CUnicode, CComplex, CBool, false, true + from enthought.traits.api import String, Password, File, Directory, Function + from enthought.traits.api import Method, Class, Module, Type, This, self, Python + from enthought.traits.api import ReadOnly, ListInt, ListFloat, ListStr + from enthought.traits.api import ListUnicode, ListComplex, ListBool + from enthought.traits.api import ListFunction, ListMethod, ListClass + from enthought.traits.api import ListInstance, ListThis, DictStrAny, DictStrStr + from enthought.traits.api import DictStrInt, DictStrLong, DictStrFloat + from enthought.traits.api import DictStrBool,DictStrList + from enthought.traits.api import tdb + + define = tdb.define + define( 'Event', Event ) + define( 'List', List ) + define( 'Dict', Dict ) + define( 'Any', Any ) + define( 'Int', Int ) + define( 'Long', Long ) + define( 'Float', Float ) + define( 'Str', Str ) + define( 'Unicode', Unicode ) + define( 'Complex', Complex ) + define( 'Bool', Bool ) + define( 'CInt', CInt ) + define( 'CLong', CLong ) + define( 'CFloat', CFloat ) + define( 'CStr', CStr ) + define( 'CUnicode', CUnicode ) + define( 'CComplex', CComplex ) + define( 'CBool', CBool ) + define( 'false', false ) + define( 'true', true ) + define( 'String', String ) + define( 'Password', Password ) + define( 'File', File ) + define( 'Directory', Directory ) +# define( 'Function', Function ) +# define( 'Method', Method ) +# define( 'Class', Class ) +# define( 'Module', Module ) + define( 'Type', Type ) + define( 'This', This ) +# define( 'self', self ) + define( 'Python', Python ) +## define( 'ReadOnly', ReadOnly ) <-- 'Undefined' doesn't have right + # semantics when persisted + define( 'ListInt', ListInt ) + define( 'ListFloat', ListFloat ) + define( 'ListStr', ListStr ) + define( 'ListUnicode', ListUnicode ) + define( 'ListComplex', ListComplex ) + define( 'ListBool', ListBool ) +# define( 'ListFunction', ListFunction ) +# define( 'ListMethod', ListMethod ) +# define( 'ListClass', ListClass ) +# define( 'ListInstance', ListInstance ) + define( 'ListThis', ListThis ) + define( 'DictStrAny', DictStrAny ) + define( 'DictStrStr', DictStrStr ) + define( 'DictStrInt', DictStrInt ) + define( 'DictStrLong', DictStrLong ) + define( 'DictStrFloat', DictStrFloat ) + define( 'DictStrBool', DictStrBool ) + define( 'DictStrList', DictStrList ) + Added: trunk/matplotlib/lib/enthought/traits/ctraits.c =================================================================== --- trunk/matplotlib/lib/enthought/traits/ctraits.c (rev 0) +++ trunk/matplotlib/lib/enthought/traits/ctraits.c 2007-11-08 00:24:57 UTC (rev 4156) @@ -0,0 +1,4518 @@ +/****************************************************************************** +* Copyright (c) 2005, Enthought, Inc. +* All rights reserved. +* +* This software is provided without warranty under the terms of the BSD +* license included in enthought/LICENSE.txt and may be redistributed only +* under the conditions described in the aforementioned license. The license +* is also available online at http://www.enthought.com/licenses/BSD.txt +* Thanks for using Enthought open source! +* +* Author: David C. Morrill +* Date: 06/15/2004 +* Description: C based implementation of the Traits package +******************************************************************************/ + +/*----------------------------------------------------------------------------- +| Includes: ++----------------------------------------------------------------------------*/ + +#include "Python.h" +#include "structmember.h" + +/*----------------------------------------------------------------------------- +| Constants: ++----------------------------------------------------------------------------*/ + +static PyObject * class_traits; /* == "__class_traits__" */ +static PyObject * editor_property; /* == "editor" */ +static PyObject * class_prefix; /* == "__prefix__" */ +static PyObject * empty_tuple; /* == () */ +static PyObject * undefined; /* Global 'undefined' value */ +static PyObject * TraitError; /* TraitError exception */ +static PyObject * DelegationError; /* DelegationError exception */ +static PyObject * TraitListObject; /* TraitListObject class */ +static PyObject * TraitDictObject; /* TraitDictObject class */ +static PyTypeObject * ctrait_type; /* Python-level CTrait type reference */ +static PyObject * is_callable; /* Marker for 'callable' value */ +static PyObject * _HasTraits_monitors; /* Object creation monitors. */ + +/*----------------------------------------------------------------------------- +| Macro definitions: ++----------------------------------------------------------------------------*/ + +/* The following macro is automatically defined in Python 2.4 and later: */ +#ifndef Py_VISIT +#define Py_VISIT(op) \ +do { \ + if (op) { \ + int vret = visit((PyObject *)(op), arg); \ + if (vret) return vret; \ + } \ +} while (0) +#endif + +/* The following macro is automatically defined in Python 2.4 and later: */ +#ifndef Py_CLEAR +#define Py_CLEAR(op) \ +do { \ + if (op) { \ + PyObject *tmp = (PyObject *)(op); \ + (op) = NULL; \ + Py_DECREF(tmp); \ + } \ +} while (0) +#endif + +#define DEFERRED_ADDRESS(ADDR) 0 +#define PyTrait_CheckExact(op) ((op)->ob_type == ctrait_type) + +#define PyHasTraits_Check(op) PyObject_TypeCheck(op, &has_traits_type) +#define PyHasTraits_CheckExact(op) ((op)->ob_type == &has_traits_type) + +/* Trait method related: */ + +#define TP_DESCR_GET(t) \ + (PyType_HasFeature(t, Py_TPFLAGS_HAVE_CLASS) ? (t)->tp_descr_get : NULL) +#define OFF(x) offsetof(trait_method_object, x) + +/* Field accessors: */ +#define trait_method_GET_NAME(meth) \ + (((trait_method_object *) meth)->tm_name) +#define trait_method_GET_FUNCTION(meth) \ + (((trait_method_object *) meth)->tm_func) +#define trait_method_GET_SELF(meth) \ + (((trait_method_object *) meth)->tm_self) +#define trait_method_GET_TRAITS(meth) \ + (((trait_method_object *) meth)->tm_traits) +#define trait_method_GET_CLASS(meth) \ + (((trait_method_object *) meth)->tm_class) + +/* Python version dependent macros: */ +#if ( (PY_MAJOR_VERSION == 2) && (PY_MINOR_VERSION < 3) ) +#define PyMODINIT_FUNC void +#define PyDoc_VAR(name) static char name[] +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#ifdef WITH_DOC_STRINGS +#define PyDoc_STR(str) str +#else +#define PyDoc_STR(str) "" +#endif +#endif +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#endif + +/*----------------------------------------------------------------------------- +| Forward declarations: ++----------------------------------------------------------------------------*/ + +static PyTypeObject trait_type; +static PyTypeObject trait_method_type; + +/*----------------------------------------------------------------------------- +| 'ctraits' module doc string: ++----------------------------------------------------------------------------*/ + +PyDoc_STRVAR( ctraits__doc__, +"The ctraits module defines the CHasTraits and CTrait C extension types that\n" +"define the core performance oriented portions of the Traits package." ); + +/*----------------------------------------------------------------------------- +| HasTraits behavior modification flags: ++----------------------------------------------------------------------------*/ + +/* Object has been initialized: */ +#define HASTRAITS_INITED 0x00000001 + +/* Do not send notifications when a trait changes value: */ +#define HASTRAITS_NO_NOTIFY 0x00000002 + +/* Requests that no event notifications be sent when this object is assigned to + a trait: */ +#define HASTRAITS_VETO_NOTIFY 0x00000004 + +/*----------------------------------------------------------------------------- +| 'CHasTraits' instance definition: +| +| Note: traits are normally stored in the type's dictionary, but are added to +| the instance's traits dictionary 'trait_dict' when the traits are defined +| dynamically or 'on_trait_change' is called on an instance of the trait. +| +| All 'anytrait_changed' notification handlers are stored in the instance's +| 'notifiers' list. ++----------------------------------------------------------------------------*/ + +typedef struct { + PyObject_HEAD /* Standard Python object header */ + PyDictObject * ctrait_dict; /* Class traits dictionary */ + PyDictObject * itrait_dict; /* Instance traits dictionary */ + PyListObject * notifiers; /* List of 'any trait changed' notification + handlers */ + int flags; /* Behavior modification flags */ + PyObject * obj_dict; /* Object attribute dictionary ('__dict__') */ + /* NOTE: 'obj_dict' field MUST be last field */ +} has_traits_object; + +static int call_notifiers ( PyListObject *, PyListObject *, + has_traits_object *, PyObject *, PyObject *, + PyObject * new_value ); + +/*----------------------------------------------------------------------------- +| 'CTrait' flag values: ++----------------------------------------------------------------------------*/ + +/* The trait is a Property: */ +#define TRAIT_PROPERTY 0x00000001 + +/* Should the delegate be modified (or the original object)? */ +#define TRAIT_MODIFY_DELEGATE 0x00000002 + +/* Should a simple object identity test be performed (or a rich compare)? */ +#define TRAIT_OBJECT_IDENTITY 0x00000004 + +/*----------------------------------------------------------------------------- +| 'CTrait' instance definition: ++----------------------------------------------------------------------------*/ + +typedef struct _trait_object a_trait_object; +typedef PyObject * (*trait_getattr)( a_trait_object *, has_traits_object *, + PyObject * ); +typedef int (*trait_setattr)( a_trait_object *, a_trait_object *, + has_traits_object *, PyObject *, PyObject * ); +typedef int (*trait_post_setattr)( a_trait_object *, has_traits_object *, + PyObject *, PyObject * ); +typedef PyObject * (*trait_validate)( a_trait_object *, has_traits_object *, + PyObject *, PyObject * ); +typedef PyObject * (*delegate_attr_name_func)( a_trait_object *, + has_traits_object *, PyObject * ); + +typedef struct _trait_object { + PyObject_HEAD /* Standard Python object header */ + int flags; /* Flag bits */ + trait_getattr getattr; /* Get trait value handler */ + trait_setattr setattr; /* Set trait value handler */ + trait_post_setattr post_setattr; /* Optional post 'setattr' handler */ + PyObject * py_post_setattr; /* Python-based post 'setattr' hndlr */ + trait_validate validate; /* Validate trait value handler */ + P... [truncated message content] |