From 5f1df356a28e6ec0ca09fc966cc3fd9397a69a90 Mon Sep 17 00:00:00 2001 From: Darren Dale Date: Sun, 20 Feb 2011 16:46:45 -0500 Subject: [PATCH 1/2] add .gitattributes and .gitignore, fix CRLF --- .gitattributes | 1 + .gitignore | 81 +++ lib/enthought/traits/api.py | 318 ++++----- .../traits/tests/keyword_args_test_case.py | 38 +- lib/enthought/traits/tests/other.py | 8 +- lib/enthought/traits/tests/simple.py | 20 +- .../traits/tests/simple_test_case.py | 102 +-- lib/enthought/traits/ui/api.py | 172 ++--- lib/enthought/traits/ui/delegating_handler.py | 342 ++++----- .../traits/ui/extras/checkbox_column.py | 148 ++-- lib/enthought/traits/ui/extras/core.py | 34 +- lib/enthought/traits/ui/traits.py | 56 +- .../mpl-data/images/stock_close.xpm | 42 +- lib/matplotlib/mpl-data/images/stock_down.xpm | 88 +-- lib/matplotlib/mpl-data/images/stock_left.xpm | 90 +-- .../mpl-data/images/stock_refresh.xpm | 70 +- .../mpl-data/images/stock_right.xpm | 88 +-- .../mpl-data/images/stock_save_as.xpm | 260 +++---- lib/matplotlib/mpl-data/images/stock_up.xpm | 90 +-- .../mpl-data/images/stock_zoom-in.xpm | 122 ++-- .../mpl-data/images/stock_zoom-out.xpm | 118 ++-- lib/pytz/README.txt | 652 +++++++++--------- 22 files changed, 1511 insertions(+), 1429 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..176a458f94e0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..f798098a0095 --- /dev/null +++ b/.gitignore @@ -0,0 +1,81 @@ +# Editor temporary/working/backup files # +######################################### +.#* +[#]*# +*~ +*$ +*.bak +*.diff +*.org +.project +*.rej +.settings/ +.*.sw[nop] +.sw[nop] +*.tmp + +# Compiled source # +################### +*.a +*.com +*.class +*.dll +*.exe +*.o +*.py[ocd] +*.so + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.bz2 +*.bzip2 +*.dmg +*.iso +*.jar +*.rar +*.tar +*.tbz2 +*.tgz +*.zip + +# Python files # +################ +# setup.py working directory +build +# sphinx build directory +_build +# setup.py dist directory +dist +doc/build +doc/cdoc/build +# Egg metadata +*.egg-info +# The shelf plugin uses this dir +./.shelf + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# Patches # +########### +*.patch +*.diff + +# OS generated files # +###################### +.gdb_history +.DS_Store? +ehthumbs.db +Icon? +Thumbs.db + +# Things specific to this project # +################################### +lib/matplotlib/mpl-data/matplotlib.conf +lib/matplotlib/mpl-data/matplotlibrc diff --git a/lib/enthought/traits/api.py b/lib/enthought/traits/api.py index e63a5fb6260b..4d8b93daa24a 100644 --- a/lib/enthought/traits/api.py +++ b/lib/enthought/traits/api.py @@ -1,159 +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 +#------------------------------------------------------------------------------ +# +# 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 diff --git a/lib/enthought/traits/tests/keyword_args_test_case.py b/lib/enthought/traits/tests/keyword_args_test_case.py index 28b07eda5e3c..842aa96227e2 100644 --- a/lib/enthought/traits/tests/keyword_args_test_case.py +++ b/lib/enthought/traits/tests/keyword_args_test_case.py @@ -1,19 +1,19 @@ -from enthought.traits.api import HasTraits, Instance, Int - -import unittest - -class Bar(HasTraits): - b = Int(3) - -class Foo(HasTraits): - bar = Instance(Bar) - -class KeyWordArgsTest(unittest.TestCase): - def test_using_kw(self): - bar = Bar(b=5) - foo = Foo(bar=bar) - self.assertEqual(foo.bar.b, 5) - - def test_not_using_kw(self): - foo = Foo() - self.assertEqual(foo.bar, None) +from enthought.traits.api import HasTraits, Instance, Int + +import unittest + +class Bar(HasTraits): + b = Int(3) + +class Foo(HasTraits): + bar = Instance(Bar) + +class KeyWordArgsTest(unittest.TestCase): + def test_using_kw(self): + bar = Bar(b=5) + foo = Foo(bar=bar) + self.assertEqual(foo.bar.b, 5) + + def test_not_using_kw(self): + foo = Foo() + self.assertEqual(foo.bar, None) diff --git a/lib/enthought/traits/tests/other.py b/lib/enthought/traits/tests/other.py index c81859bb8328..50e5ad28867c 100644 --- a/lib/enthought/traits/tests/other.py +++ b/lib/enthought/traits/tests/other.py @@ -1,5 +1,5 @@ -from enthought.traits.api import HasTraits, Str - -class Other(HasTraits): - +from enthought.traits.api import HasTraits, Str + +class Other(HasTraits): + name = Str \ No newline at end of file diff --git a/lib/enthought/traits/tests/simple.py b/lib/enthought/traits/tests/simple.py index 6bb088edc7bd..85940d34891a 100644 --- a/lib/enthought/traits/tests/simple.py +++ b/lib/enthought/traits/tests/simple.py @@ -1,11 +1,11 @@ - -from enthought.traits.api import HasTraits, Str, Instance - -#from enthought.traits.tests.other import Other -#from other import Other -class Simple(HasTraits): - - name = Str - other = Instance('enthought.traits.tests.other.Other') - #other = Instance(Other) + +from enthought.traits.api import HasTraits, Str, Instance + +#from enthought.traits.tests.other import Other +#from other import Other +class Simple(HasTraits): + + name = Str + other = Instance('enthought.traits.tests.other.Other') + #other = Instance(Other) \ No newline at end of file diff --git a/lib/enthought/traits/tests/simple_test_case.py b/lib/enthought/traits/tests/simple_test_case.py index d513cca7a0f4..bc97b5a9de9c 100644 --- a/lib/enthought/traits/tests/simple_test_case.py +++ b/lib/enthought/traits/tests/simple_test_case.py @@ -1,51 +1,51 @@ - -import unittest -import sys - -from simple import Simple - -class SimpleTestCase( unittest.TestCase ): - - def wontfix_test_assignment(self): - """ see enthought trac ticket #416 - http://www.enthought.com/enthought/ticket/416 - """ - print '\nFirst import and assignment' - simple = self._import_other_to_create_simple() - print 'Second import and assignment' - simple = self._import_other_to_create_simple() - - def _import_other_to_create_simple(self): - other_mod = self._import( 'enthought.traits.tests.other', object_name='Other') - other_klass = other_mod.__getattribute__('Other') - - simple = Simple(name='simon') - other = other_klass(name='other') - simple.other = other - self.failUnless( simple.other is other ) - - simple2 = Simple(name='simon') - other2 = other_klass(name='other') - simple2.other = other2 - - self.failUnless( simple2.other is other2 ) - return simple - - def _import(self, module_name, object_name=''): - """ Import the action prototype for the given module name. - """ - print 'sys.module.keys ', [ name for name in sys.modules.keys() if name.endswith('other') ] - if module_name is not None: - print sys.modules.keys() - if sys.modules.has_key( module_name ): - imported_module = sys.modules[module_name] - print '*** reload,', module_name - reload( imported_module ) - else: - print '*** __import__', module_name - imported_module = __import__(module_name, globals(), locals(), [object_name]) - - else: - imported_module = None - - return imported_module + +import unittest +import sys + +from simple import Simple + +class SimpleTestCase( unittest.TestCase ): + + def wontfix_test_assignment(self): + """ see enthought trac ticket #416 + http://www.enthought.com/enthought/ticket/416 + """ + print '\nFirst import and assignment' + simple = self._import_other_to_create_simple() + print 'Second import and assignment' + simple = self._import_other_to_create_simple() + + def _import_other_to_create_simple(self): + other_mod = self._import( 'enthought.traits.tests.other', object_name='Other') + other_klass = other_mod.__getattribute__('Other') + + simple = Simple(name='simon') + other = other_klass(name='other') + simple.other = other + self.failUnless( simple.other is other ) + + simple2 = Simple(name='simon') + other2 = other_klass(name='other') + simple2.other = other2 + + self.failUnless( simple2.other is other2 ) + return simple + + def _import(self, module_name, object_name=''): + """ Import the action prototype for the given module name. + """ + print 'sys.module.keys ', [ name for name in sys.modules.keys() if name.endswith('other') ] + if module_name is not None: + print sys.modules.keys() + if sys.modules.has_key( module_name ): + imported_module = sys.modules[module_name] + print '*** reload,', module_name + reload( imported_module ) + else: + print '*** __import__', module_name + imported_module = __import__(module_name, globals(), locals(), [object_name]) + + else: + imported_module = None + + return imported_module diff --git a/lib/enthought/traits/ui/api.py b/lib/enthought/traits/ui/api.py index 6e8f0e2eaf1d..139d7bdebff5 100644 --- a/lib/enthought/traits/ui/api.py +++ b/lib/enthought/traits/ui/api.py @@ -1,86 +1,86 @@ -#------------------------------------------------------------------------------ -# 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: 10/07/2004 -# -# Description: Export the symbols defined by the traits.ui package. -# -#------------------------------------------------------------------------------ - -#------------------------------------------------------------------------------- -# Imports: -#------------------------------------------------------------------------------- - -from handler \ - import Handler, ViewHandler, default_handler - -from view \ - import View - -from group \ - import Group, HGroup, VGroup, VGrid, HFlow, VFlow, HSplit, VSplit, Tabbed - -from ui \ - import UI - -from ui_info \ - import UIInfo - -from help \ - import on_help_call - -from include \ - import Include - -from item \ - import Item, Label, Heading, Spring, spring - -from editor_factory \ - import EditorFactory - -from editor \ - import Editor - -from toolkit \ - import toolkit - -from undo \ - import UndoHistory, AbstractUndoItem, UndoItem, ListUndoItem, \ - UndoHistoryUndoItem - -from view_element \ - import ViewElement, ViewSubElement - -from help_template \ - import help_template - -from message \ - import message, error - -from tree_node \ - import TreeNode, ObjectTreeNode, TreeNodeObject, MultiTreeNode - -from 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 editors \ - import ColorTrait, RGBColorTrait, \ - FontTrait, SetEditor, HTMLEditor, KeyBindingEditor, \ - ShellEditor, TitleEditor, ValueEditor, NullEditor - -import view_elements - +#------------------------------------------------------------------------------ +# 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: 10/07/2004 +# +# Description: Export the symbols defined by the traits.ui package. +# +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------- +# Imports: +#------------------------------------------------------------------------------- + +from handler \ + import Handler, ViewHandler, default_handler + +from view \ + import View + +from group \ + import Group, HGroup, VGroup, VGrid, HFlow, VFlow, HSplit, VSplit, Tabbed + +from ui \ + import UI + +from ui_info \ + import UIInfo + +from help \ + import on_help_call + +from include \ + import Include + +from item \ + import Item, Label, Heading, Spring, spring + +from editor_factory \ + import EditorFactory + +from editor \ + import Editor + +from toolkit \ + import toolkit + +from undo \ + import UndoHistory, AbstractUndoItem, UndoItem, ListUndoItem, \ + UndoHistoryUndoItem + +from view_element \ + import ViewElement, ViewSubElement + +from help_template \ + import help_template + +from message \ + import message, error + +from tree_node \ + import TreeNode, ObjectTreeNode, TreeNodeObject, MultiTreeNode + +from 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 editors \ + import ColorTrait, RGBColorTrait, \ + FontTrait, SetEditor, HTMLEditor, KeyBindingEditor, \ + ShellEditor, TitleEditor, ValueEditor, NullEditor + +import view_elements + diff --git a/lib/enthought/traits/ui/delegating_handler.py b/lib/enthought/traits/ui/delegating_handler.py index 8a0687fa2053..c512c7a00722 100644 --- a/lib/enthought/traits/ui/delegating_handler.py +++ b/lib/enthought/traits/ui/delegating_handler.py @@ -1,171 +1,171 @@ -#----------------------------------------------------------------------------- -# -# Copyright (c) 2006 by Enthought, Inc. -# All rights reserved. -# -#----------------------------------------------------------------------------- - -""" -A handler that delegates the handling of events to a set of sub-handlers. - -This is typically used as the handler for dynamic views. See the -**enthought.traits.has_dynamic_view** module. - -""" - - -# Standard library imports. -import logging - -# Enthought library imports. -from enthought.traits.api import HasTraits, List -from enthought.traits.ui.ui import Dispatcher - -# Local imports. -from handler import Handler - - -# Setup a logger for this module. -logger = logging.getLogger(__name__) - - -class DelegatingHandler(Handler): - """ - A handler that delegates the handling of events to a set of sub-handlers. - - """ - - ########################################################################## - # Attributes - ########################################################################## - - #### public 'DelegatingHandler' interface ################################ - - # The list of sub-handlers this object delegates to. - sub_handlers = List(HasTraits) - - - #### protected 'DelegatingHandler' interface ############################# - - # A list of dispatchable handler methods - _dispatchers = List - - - ########################################################################## - # 'Handler' interface - ########################################################################## - - #### public methods ###################################################### - - def closed(self, info, is_ok): - """ - Handles the user interface being closed by the user. - - This method is overridden here to unregister any dispatchers that were - set up in the init() method. - - """ - - for d in self._dispatchers: - d.remove() - - return - - - def init(self, info): - """ - Initializes the controls of a user interface. - - Parameters - ---------- - info : *UIInfo* object - The UIInfo object associated with the view - - Returns - ------- - A boolean, indicating whether the user interface was successfully - initialized. A True value indicates that the UI can be displayed; - a False value indicates that the display operation should be - cancelled. - - Description - ----------- - This method is called after all user interface elements have been - created, but before the user interface is displayed. Use this method to - further customize the user interface before it is displayed. - - This method is overridden here to delegate to sub-handlers. - - """ - - # Iterate through our sub-handlers, and for each method whose name is - # of the form 'object_name_changed', where 'object' is the name of an - # object in the UI's context, create a trait notification handler that - # will call the method whenever object's 'name' trait changes. - logger.debug('Initializing delegation in DelegatingHandler [%s]', self) - context = info.ui.context - for h in self.sub_handlers: - # fixme: I don't know why this wasn't here before... I'm not - # sure this is right! - h.init(info) - - for name in self._each_trait_method(h): - if name[-8:] == '_changed': - prefix = name[:-8] - col = prefix.find( '_', 1 ) - if col >= 0: - object = context.get(prefix[:col]) - if object is not None: - logger.debug('\tto method [%s] on handler[%s]', - name, h) - method = getattr(h, name) - trait_name = prefix[col + 1:] - self._dispatchers.append( - Dispatcher(method, info, object, trait_name) - ) - - # Also invoke the method immediately so initial - # user interface state can be correctly set. - if object.base_trait(trait_name).type != 'event': - method(info) - - # fixme: These are explicit workarounds for problems with:- - # - # 'GeometryHierarchyViewHandler' - # - # which is used in the :- - # - # 'GeometryHierarchyTreeEditor' - # - # which are in the 'encode.cad.ui.geometry' package. - # - # The tree editor has dynamic views, and hence the handler gets - # wrapped by a 'DelegatingHandler'. Unfortunately the handler - # has a couple of methods that aren't picked up by the usual - # wrapping strategy:- - # - # 1) 'tree_item_selected' - # - # - which is obviously called when a tree item is selected. - # - # 2) 'inspect_object' - # - # - which is called directly as as action from the context menu - # defined in the tree editor. - # - elif name in ['tree_item_selected', 'inspect_object']: - self.__dict__[name] = self._create_delegate(h, name) - - return True - - def _create_delegate(self, h, name): - """ Quick fix for handler methods that are currently left out! """ - - def delegate(*args, **kw): - method = getattr(h, name) - return method(*args, **kw) - - return delegate - -#### EOF ##################################################################### - +#----------------------------------------------------------------------------- +# +# Copyright (c) 2006 by Enthought, Inc. +# All rights reserved. +# +#----------------------------------------------------------------------------- + +""" +A handler that delegates the handling of events to a set of sub-handlers. + +This is typically used as the handler for dynamic views. See the +**enthought.traits.has_dynamic_view** module. + +""" + + +# Standard library imports. +import logging + +# Enthought library imports. +from enthought.traits.api import HasTraits, List +from enthought.traits.ui.ui import Dispatcher + +# Local imports. +from handler import Handler + + +# Setup a logger for this module. +logger = logging.getLogger(__name__) + + +class DelegatingHandler(Handler): + """ + A handler that delegates the handling of events to a set of sub-handlers. + + """ + + ########################################################################## + # Attributes + ########################################################################## + + #### public 'DelegatingHandler' interface ################################ + + # The list of sub-handlers this object delegates to. + sub_handlers = List(HasTraits) + + + #### protected 'DelegatingHandler' interface ############################# + + # A list of dispatchable handler methods + _dispatchers = List + + + ########################################################################## + # 'Handler' interface + ########################################################################## + + #### public methods ###################################################### + + def closed(self, info, is_ok): + """ + Handles the user interface being closed by the user. + + This method is overridden here to unregister any dispatchers that were + set up in the init() method. + + """ + + for d in self._dispatchers: + d.remove() + + return + + + def init(self, info): + """ + Initializes the controls of a user interface. + + Parameters + ---------- + info : *UIInfo* object + The UIInfo object associated with the view + + Returns + ------- + A boolean, indicating whether the user interface was successfully + initialized. A True value indicates that the UI can be displayed; + a False value indicates that the display operation should be + cancelled. + + Description + ----------- + This method is called after all user interface elements have been + created, but before the user interface is displayed. Use this method to + further customize the user interface before it is displayed. + + This method is overridden here to delegate to sub-handlers. + + """ + + # Iterate through our sub-handlers, and for each method whose name is + # of the form 'object_name_changed', where 'object' is the name of an + # object in the UI's context, create a trait notification handler that + # will call the method whenever object's 'name' trait changes. + logger.debug('Initializing delegation in DelegatingHandler [%s]', self) + context = info.ui.context + for h in self.sub_handlers: + # fixme: I don't know why this wasn't here before... I'm not + # sure this is right! + h.init(info) + + for name in self._each_trait_method(h): + if name[-8:] == '_changed': + prefix = name[:-8] + col = prefix.find( '_', 1 ) + if col >= 0: + object = context.get(prefix[:col]) + if object is not None: + logger.debug('\tto method [%s] on handler[%s]', + name, h) + method = getattr(h, name) + trait_name = prefix[col + 1:] + self._dispatchers.append( + Dispatcher(method, info, object, trait_name) + ) + + # Also invoke the method immediately so initial + # user interface state can be correctly set. + if object.base_trait(trait_name).type != 'event': + method(info) + + # fixme: These are explicit workarounds for problems with:- + # + # 'GeometryHierarchyViewHandler' + # + # which is used in the :- + # + # 'GeometryHierarchyTreeEditor' + # + # which are in the 'encode.cad.ui.geometry' package. + # + # The tree editor has dynamic views, and hence the handler gets + # wrapped by a 'DelegatingHandler'. Unfortunately the handler + # has a couple of methods that aren't picked up by the usual + # wrapping strategy:- + # + # 1) 'tree_item_selected' + # + # - which is obviously called when a tree item is selected. + # + # 2) 'inspect_object' + # + # - which is called directly as as action from the context menu + # defined in the tree editor. + # + elif name in ['tree_item_selected', 'inspect_object']: + self.__dict__[name] = self._create_delegate(h, name) + + return True + + def _create_delegate(self, h, name): + """ Quick fix for handler methods that are currently left out! """ + + def delegate(*args, **kw): + method = getattr(h, name) + return method(*args, **kw) + + return delegate + +#### EOF ##################################################################### + diff --git a/lib/enthought/traits/ui/extras/checkbox_column.py b/lib/enthought/traits/ui/extras/checkbox_column.py index 10b78e750796..3a1ee7e199b1 100644 --- a/lib/enthought/traits/ui/extras/checkbox_column.py +++ b/lib/enthought/traits/ui/extras/checkbox_column.py @@ -1,74 +1,74 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2006, 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: Jason Sugg -# -# Date: 03/28/2006 -# -# Description: Define the table column descriptor used for toggleable -# columns. -# -# Symbols defined: CheckboxColumn -# -#------------------------------------------------------------------------------ - -#------------------------------------------------------------------------------- -# Imports: -#------------------------------------------------------------------------------- - -from enthought.pyface.grid.checkbox_renderer \ - import CheckboxRenderer - -from enthought.traits.ui.table_column \ - import ObjectColumn - -#------------------------------------------------------------------------------- -# 'CheckboxColumn' class: -#------------------------------------------------------------------------------- - -class CheckboxColumn ( ObjectColumn ): - - - #--------------------------------------------------------------------------- - # Initializes the object: - #--------------------------------------------------------------------------- - - def __init__ ( self, **traits ): - """ Initializes the object. - """ - super( CheckboxColumn, self ).__init__( **traits ) - - # force the renderer to be a checkbox renderer - self.renderer = CheckboxRenderer() - - #--------------------------------------------------------------------------- - # Returns the cell background color for the column for a specified object: - #--------------------------------------------------------------------------- - - def get_cell_color ( self, object ): - """ Returns the cell background color for the column for a specified - object. - """ - # we override this from the parent class to ALWAYS provide the - # standard color - return self.cell_color_ - - #--------------------------------------------------------------------------- - # Returns whether the column is editable for a specified object: - #--------------------------------------------------------------------------- - - def is_editable ( self, object ): - """ Returns whether the column is editable for a specified object. - """ - # Although a checkbox column is always editable, we return this - # to keep a standard editor from appearing. The editing is handled - # in the renderer's handlers. - return False +#------------------------------------------------------------------------------ +# +# Copyright (c) 2006, 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: Jason Sugg +# +# Date: 03/28/2006 +# +# Description: Define the table column descriptor used for toggleable +# columns. +# +# Symbols defined: CheckboxColumn +# +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------- +# Imports: +#------------------------------------------------------------------------------- + +from enthought.pyface.grid.checkbox_renderer \ + import CheckboxRenderer + +from enthought.traits.ui.table_column \ + import ObjectColumn + +#------------------------------------------------------------------------------- +# 'CheckboxColumn' class: +#------------------------------------------------------------------------------- + +class CheckboxColumn ( ObjectColumn ): + + + #--------------------------------------------------------------------------- + # Initializes the object: + #--------------------------------------------------------------------------- + + def __init__ ( self, **traits ): + """ Initializes the object. + """ + super( CheckboxColumn, self ).__init__( **traits ) + + # force the renderer to be a checkbox renderer + self.renderer = CheckboxRenderer() + + #--------------------------------------------------------------------------- + # Returns the cell background color for the column for a specified object: + #--------------------------------------------------------------------------- + + def get_cell_color ( self, object ): + """ Returns the cell background color for the column for a specified + object. + """ + # we override this from the parent class to ALWAYS provide the + # standard color + return self.cell_color_ + + #--------------------------------------------------------------------------- + # Returns whether the column is editable for a specified object: + #--------------------------------------------------------------------------- + + def is_editable ( self, object ): + """ Returns whether the column is editable for a specified object. + """ + # Although a checkbox column is always editable, we return this + # to keep a standard editor from appearing. The editing is handled + # in the renderer's handlers. + return False diff --git a/lib/enthought/traits/ui/extras/core.py b/lib/enthought/traits/ui/extras/core.py index 2b4bc56cdb48..d0b2bddfd953 100644 --- a/lib/enthought/traits/ui/extras/core.py +++ b/lib/enthought/traits/ui/extras/core.py @@ -1,17 +1,17 @@ -#------------------------------------------------------------------------------ -# -# Copyright (c) 2006, Enthought, Inc. -# All rights reserved. -# -# Defines 'pseudo' package that imports all of the traits extras -# symbols. -# -# Written by: Jason Sugg -# -# Date: 03/28/2006 -# -#------------------------------------------------------------------------------ - -from enthought.traits.ui.extras.checkbox_column \ - import * - +#------------------------------------------------------------------------------ +# +# Copyright (c) 2006, Enthought, Inc. +# All rights reserved. +# +# Defines 'pseudo' package that imports all of the traits extras +# symbols. +# +# Written by: Jason Sugg +# +# Date: 03/28/2006 +# +#------------------------------------------------------------------------------ + +from enthought.traits.ui.extras.checkbox_column \ + import * + diff --git a/lib/enthought/traits/ui/traits.py b/lib/enthought/traits/ui/traits.py index 7512dee4b671..3c83a65ea518 100644 --- a/lib/enthought/traits/ui/traits.py +++ b/lib/enthought/traits/ui/traits.py @@ -1,28 +1,28 @@ -#------------------------------------------------------------------------------- -# -# UI specific trait definitions. -# -# Written by: David C. Morrill -# -# Date: 02/26/2007 -# -# (c) Copyright 2007 by Enthought, Inc. -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Imports: -#------------------------------------------------------------------------------- - -from enthought.traits.traits \ - import Str - -from enthought.traits.ui.editors \ - import TitleEditor - -#------------------------------------------------------------------------------- -# Defines a Title trait: -#------------------------------------------------------------------------------- - -Title = Str( editor = TitleEditor() ) - +#------------------------------------------------------------------------------- +# +# UI specific trait definitions. +# +# Written by: David C. Morrill +# +# Date: 02/26/2007 +# +# (c) Copyright 2007 by Enthought, Inc. +# +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# Imports: +#------------------------------------------------------------------------------- + +from enthought.traits.traits \ + import Str + +from enthought.traits.ui.editors \ + import TitleEditor + +#------------------------------------------------------------------------------- +# Defines a Title trait: +#------------------------------------------------------------------------------- + +Title = Str( editor = TitleEditor() ) + diff --git a/lib/matplotlib/mpl-data/images/stock_close.xpm b/lib/matplotlib/mpl-data/images/stock_close.xpm index 4ae0b95b02c9..005ce14dbf37 100644 --- a/lib/matplotlib/mpl-data/images/stock_close.xpm +++ b/lib/matplotlib/mpl-data/images/stock_close.xpm @@ -1,21 +1,21 @@ -/* XPM */ -static char * stock_close_xpm[] = { -"16 16 2 1", -" g None", -". g #000000", -" ", -" ", -" . . ", -" . ... ", -" .. .... ", -" .. ... ", -" ..... ", -" ... ", -" ..... ", -" ....... ", -" ... .... ", -" ... .... ", -" ... .. ", -" ", -" ", -" "}; +/* XPM */ +static char * stock_close_xpm[] = { +"16 16 2 1", +" g None", +". g #000000", +" ", +" ", +" . . ", +" . ... ", +" .. .... ", +" .. ... ", +" ..... ", +" ... ", +" ..... ", +" ....... ", +" ... .... ", +" ... .... ", +" ... .. ", +" ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_down.xpm b/lib/matplotlib/mpl-data/images/stock_down.xpm index a394f91e9de0..26d0c28ab927 100644 --- a/lib/matplotlib/mpl-data/images/stock_down.xpm +++ b/lib/matplotlib/mpl-data/images/stock_down.xpm @@ -1,44 +1,44 @@ -/* XPM */ -static char * stock_down_xpm[] = { -"16 16 25 1", -" c None", -". c #000000", -"+ c #B5C9DC", -"@ c #9BB6D0", -"# c #91B0CC", -"$ c #49749C", -"% c #456F96", -"& c #AFC5DA", -"* c #A0BAD3", -"= c #9EB8D1", -"- c #3F6588", -"; c #375978", -"> c #B2C7DB", -", c #9CB7D1", -"' c #9AB5CF", -") c #B6CADD", -"! c #5B88B2", -"~ c #A4BDD5", -"{ c #2A435B", -"] c #5080AD", -"^ c #97B3CE", -"/ c #080D11", -"( c #5F8BB4", -"_ c #95B2CE", -": c #4C79A3", -" ", -" ", -" ....... ", -" .+@#$%. ", -" .&*=-;. ", -" .>,'-;. ", -" .),'-;. ", -" .)@@-;. ", -" ....)',-;.... ", -" .!=~*,---{. ", -" .],,,--{. ", -" .]^*-{. ", -" /(_{. ", -" .:. ", -" . ", -" "}; +/* XPM */ +static char * stock_down_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #B5C9DC", +"@ c #9BB6D0", +"# c #91B0CC", +"$ c #49749C", +"% c #456F96", +"& c #AFC5DA", +"* c #A0BAD3", +"= c #9EB8D1", +"- c #3F6588", +"; c #375978", +"> c #B2C7DB", +", c #9CB7D1", +"' c #9AB5CF", +") c #B6CADD", +"! c #5B88B2", +"~ c #A4BDD5", +"{ c #2A435B", +"] c #5080AD", +"^ c #97B3CE", +"/ c #080D11", +"( c #5F8BB4", +"_ c #95B2CE", +": c #4C79A3", +" ", +" ", +" ....... ", +" .+@#$%. ", +" .&*=-;. ", +" .>,'-;. ", +" .),'-;. ", +" .)@@-;. ", +" ....)',-;.... ", +" .!=~*,---{. ", +" .],,,--{. ", +" .]^*-{. ", +" /(_{. ", +" .:. ", +" . ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_left.xpm b/lib/matplotlib/mpl-data/images/stock_left.xpm index 1e26e19406c2..503bc36616e2 100644 --- a/lib/matplotlib/mpl-data/images/stock_left.xpm +++ b/lib/matplotlib/mpl-data/images/stock_left.xpm @@ -1,45 +1,45 @@ -/* XPM */ -static char * stock_left_xpm[] = { -"16 16 26 1", -" c None", -". c #000000", -"+ c #C4D4E3", -"@ c #A3BCD4", -"# c #A6BED5", -"$ c #AAC1D7", -"% c #ABC2D8", -"& c #AFC5DA", -"* c #AEC4D9", -"= c #6892B9", -"- c #9CB7D1", -"; c #A4BDD5", -"> c #9FB9D2", -", c #9BB6D0", -"' c #9AB5CF", -") c #49759E", -"! c #1C2D3D", -"~ c #C5D5E4", -"{ c #A0BAD3", -"] c #9EB8D1", -"^ c #4B78A2", -"/ c #2A435B", -"( c #3F6588", -"_ c #34536F", -": c #29425A", -"< c #2D4760", -" ", -" . ", -" .. ", -" .+. ", -" .+@....... ", -" .+#$%&%*@=. ", -" .+-;@>,,>'). ", -" !~>{]]->>>>^. ", -" ./((((((((_. ", -" ./((:::::<. ", -" ./(....... ", -" ./. ", -" .. ", -" . ", -" ", -" "}; +/* XPM */ +static char * stock_left_xpm[] = { +"16 16 26 1", +" c None", +". c #000000", +"+ c #C4D4E3", +"@ c #A3BCD4", +"# c #A6BED5", +"$ c #AAC1D7", +"% c #ABC2D8", +"& c #AFC5DA", +"* c #AEC4D9", +"= c #6892B9", +"- c #9CB7D1", +"; c #A4BDD5", +"> c #9FB9D2", +", c #9BB6D0", +"' c #9AB5CF", +") c #49759E", +"! c #1C2D3D", +"~ c #C5D5E4", +"{ c #A0BAD3", +"] c #9EB8D1", +"^ c #4B78A2", +"/ c #2A435B", +"( c #3F6588", +"_ c #34536F", +": c #29425A", +"< c #2D4760", +" ", +" . ", +" .. ", +" .+. ", +" .+@....... ", +" .+#$%&%*@=. ", +" .+-;@>,,>'). ", +" !~>{]]->>>>^. ", +" ./((((((((_. ", +" ./((:::::<. ", +" ./(....... ", +" ./. ", +" .. ", +" . ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_refresh.xpm b/lib/matplotlib/mpl-data/images/stock_refresh.xpm index d686de9f2920..1659cff3dd52 100644 --- a/lib/matplotlib/mpl-data/images/stock_refresh.xpm +++ b/lib/matplotlib/mpl-data/images/stock_refresh.xpm @@ -1,35 +1,35 @@ -/* XPM */ -static char * stock_refresh_xpm[] = { -"16 16 16 1", -" c None", -". c #000000", -"+ c #8FA8BE", -"@ c #D5DEE6", -"# c #BBCBD8", -"$ c #A6BACB", -"% c #A2B7C9", -"& c #83A0B8", -"* c #7393AE", -"= c #4F6F8A", -"- c #48667F", -"; c #92ABC0", -"> c #33485A", -", c #22303B", -"' c #7897B1", -") c #4B6A84", -" ", -" . ", -" ..+. ", -" .@#$%. ", -" .&*==-. ", -" .;>.,. ", -" .'. . . ", -" .). .. ", -" .. .@. ", -" . . .=. ", -" .@.>=. ", -" .@===>. ", -" .'=>>. ", -" .'.. ", -" . ", -" "}; +/* XPM */ +static char * stock_refresh_xpm[] = { +"16 16 16 1", +" c None", +". c #000000", +"+ c #8FA8BE", +"@ c #D5DEE6", +"# c #BBCBD8", +"$ c #A6BACB", +"% c #A2B7C9", +"& c #83A0B8", +"* c #7393AE", +"= c #4F6F8A", +"- c #48667F", +"; c #92ABC0", +"> c #33485A", +", c #22303B", +"' c #7897B1", +") c #4B6A84", +" ", +" . ", +" ..+. ", +" .@#$%. ", +" .&*==-. ", +" .;>.,. ", +" .'. . . ", +" .). .. ", +" .. .@. ", +" . . .=. ", +" .@.>=. ", +" .@===>. ", +" .'=>>. ", +" .'.. ", +" . ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_right.xpm b/lib/matplotlib/mpl-data/images/stock_right.xpm index 2f1607d67b3d..f63c1d34051b 100644 --- a/lib/matplotlib/mpl-data/images/stock_right.xpm +++ b/lib/matplotlib/mpl-data/images/stock_right.xpm @@ -1,44 +1,44 @@ -/* XPM */ -static char * stock_right_xpm[] = { -"16 16 25 1", -" c None", -". c #000000", -"+ c #5B88B2", -"@ c #9EB8D1", -"# c #5080AD", -"$ c #B5C9DC", -"% c #AFC5DA", -"& c #B2C7DB", -"* c #B6CADD", -"= c #A4BDD5", -"- c #9CB7D1", -"; c #080D11", -"> c #9BB6D0", -", c #A0BAD3", -"' c #9AB5CF", -") c #97B3CE", -"! c #5F8BB4", -"~ c #91B0CC", -"{ c #95B2CE", -"] c #4C79A3", -"^ c #49749C", -"/ c #3F6588", -"( c #2A435B", -"_ c #456F96", -": c #375978", -" ", -" . ", -" .. ", -" .+. ", -" .......@#. ", -" .$%&***=-#; ", -" .>,-->',-)!. ", -" .~@''>---,{]. ", -" .^////////(. ", -" ._::::://(. ", -" ......./(. ", -" .(. ", -" .. ", -" . ", -" ", -" "}; +/* XPM */ +static char * stock_right_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #5B88B2", +"@ c #9EB8D1", +"# c #5080AD", +"$ c #B5C9DC", +"% c #AFC5DA", +"& c #B2C7DB", +"* c #B6CADD", +"= c #A4BDD5", +"- c #9CB7D1", +"; c #080D11", +"> c #9BB6D0", +", c #A0BAD3", +"' c #9AB5CF", +") c #97B3CE", +"! c #5F8BB4", +"~ c #91B0CC", +"{ c #95B2CE", +"] c #4C79A3", +"^ c #49749C", +"/ c #3F6588", +"( c #2A435B", +"_ c #456F96", +": c #375978", +" ", +" . ", +" .. ", +" .+. ", +" .......@#. ", +" .$%&***=-#; ", +" .>,-->',-)!. ", +" .~@''>---,{]. ", +" .^////////(. ", +" ._::::://(. ", +" ......./(. ", +" .(. ", +" .. ", +" . ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_save_as.xpm b/lib/matplotlib/mpl-data/images/stock_save_as.xpm index 63f65f797f63..0981c7c57c61 100644 --- a/lib/matplotlib/mpl-data/images/stock_save_as.xpm +++ b/lib/matplotlib/mpl-data/images/stock_save_as.xpm @@ -1,130 +1,130 @@ -/* XPM */ -static char * stock_save_as_xpm[] = { -"16 16 111 2", -" c None", -". c #000000", -"+ c #F7F8FA", -"@ c #CBDDEB", -"# c #C88A80", -"$ c #D18F84", -"% c #CF8D82", -"& c #A49626", -"* c #634A1E", -"= c #A8BBCC", -"- c #BFD5E8", -"; c #DBE7F1", -"> c #8DA9BE", -", c #B7877E", -"' c #C77568", -") c #C77467", -"! c #C57366", -"~ c #FCEB3D", -"{ c #F7B544", -"] c #61522E", -"^ c #72899A", -"/ c #54697C", -"( c #CFE0ED", -"_ c #D7D7D7", -": c #FEFEFE", -"< c #FCFCFC", -"[ c #F9DF39", -"} c #F7B545", -"| c #6C5F34", -"1 c #B4B4B4", -"2 c #84A0B5", -"3 c #4F6475", -"4 c #D6D6D6", -"5 c #F8D837", -"6 c #EFB44D", -"7 c #584D2B", -"8 c #8F8F8F", -"9 c #F1F1F1", -"0 c #819AAE", -"a c #496072", -"b c #FDFDFD", -"c c #F6D236", -"d c #EDA43E", -"e c #584E2B", -"f c #AAAAAA", -"g c #D3D3D3", -"h c #485F71", -"i c #D5D5D5", -"j c #D7AE74", -"k c #61562F", -"l c #737373", -"m c #C5C5C5", -"n c #B0B0B0", -"o c #7F98AC", -"p c #EDEDED", -"q c #4F4115", -"r c #8D8D8D", -"s c #EBEBEB", -"t c #ECECEC", -"u c #ACBDCB", -"v c #6F767D", -"w c #9AA3AC", -"x c #BFCBD6", -"y c #BDC9D4", -"z c #A1B6C4", -"A c #8BA7BC", -"B c #809CB0", -"C c #6C8394", -"D c #7D97AB", -"E c #7D97AC", -"F c #A4ACB8", -"G c #B9B9B9", -"H c #C7C7C7", -"I c #E1E1E1", -"J c #D4D4D4", -"K c #9C9D9D", -"L c #2F4656", -"M c #80868C", -"N c #183042", -"O c #33495A", -"P c #132D3C", -"Q c #586D80", -"R c #97A5B0", -"S c #86A4B9", -"T c #CDCDCD", -"U c #2E4353", -"V c #5A7082", -"W c #BFBFBF", -"X c #112835", -"Y c #9DA9B0", -"Z c #6B7882", -"` c #829DB1", -" . c #CBCBCB", -".. c #E5E5E5", -"+. c #213648", -"@. c #5F7989", -"#. c #C2C2C2", -"$. c #B2B2B2", -"%. c #112C3A", -"&. c #9FA9B0", -"*. c #59636D", -"=. c #A1A1A1", -"-. c #C0C0C0", -";. c #909090", -">. c #868686", -",. c #6E6E6E", -"'. c #7A7A7A", -"). c #2D3949", -"!. c #3E4F5C", -"~. c #80878F", -"{. c #1A3140", -" . . . . . . . . . . . . . . ", -". + @ # $ $ $ $ % . & * . = - . ", -". ; > , ' ) ) ! . ~ { ] . ^ / . ", -". ( > _ : : < . [ } | . 1 2 3 . ", -". ( > _ _ 4 . 5 6 7 . 8 9 0 a . ", -". ( > _ b . c d e . f g 9 0 h . ", -". ( > _ i . j k . l m n 9 o a . ", -". ( > p . q . . r g s s t 0 a . ", -". ( > u . . v w x x x y z 0 a . ", -". ( > A B C 0 0 0 0 D E 0 0 a . ", -". ( > A F G G H I J K L M 0 a . ", -". ( > 2 m m N O i m G P Q R a . ", -". ( S 0 m T U V m m W X V Y a . ", -". Z ` o ...+.@.m #.$.%.V &.a . ", -". . *.3 =.-.;.;.>.,.'.).!.~.{.. ", -" . . . . . . . . . . . . . . "}; +/* XPM */ +static char * stock_save_as_xpm[] = { +"16 16 111 2", +" c None", +". c #000000", +"+ c #F7F8FA", +"@ c #CBDDEB", +"# c #C88A80", +"$ c #D18F84", +"% c #CF8D82", +"& c #A49626", +"* c #634A1E", +"= c #A8BBCC", +"- c #BFD5E8", +"; c #DBE7F1", +"> c #8DA9BE", +", c #B7877E", +"' c #C77568", +") c #C77467", +"! c #C57366", +"~ c #FCEB3D", +"{ c #F7B544", +"] c #61522E", +"^ c #72899A", +"/ c #54697C", +"( c #CFE0ED", +"_ c #D7D7D7", +": c #FEFEFE", +"< c #FCFCFC", +"[ c #F9DF39", +"} c #F7B545", +"| c #6C5F34", +"1 c #B4B4B4", +"2 c #84A0B5", +"3 c #4F6475", +"4 c #D6D6D6", +"5 c #F8D837", +"6 c #EFB44D", +"7 c #584D2B", +"8 c #8F8F8F", +"9 c #F1F1F1", +"0 c #819AAE", +"a c #496072", +"b c #FDFDFD", +"c c #F6D236", +"d c #EDA43E", +"e c #584E2B", +"f c #AAAAAA", +"g c #D3D3D3", +"h c #485F71", +"i c #D5D5D5", +"j c #D7AE74", +"k c #61562F", +"l c #737373", +"m c #C5C5C5", +"n c #B0B0B0", +"o c #7F98AC", +"p c #EDEDED", +"q c #4F4115", +"r c #8D8D8D", +"s c #EBEBEB", +"t c #ECECEC", +"u c #ACBDCB", +"v c #6F767D", +"w c #9AA3AC", +"x c #BFCBD6", +"y c #BDC9D4", +"z c #A1B6C4", +"A c #8BA7BC", +"B c #809CB0", +"C c #6C8394", +"D c #7D97AB", +"E c #7D97AC", +"F c #A4ACB8", +"G c #B9B9B9", +"H c #C7C7C7", +"I c #E1E1E1", +"J c #D4D4D4", +"K c #9C9D9D", +"L c #2F4656", +"M c #80868C", +"N c #183042", +"O c #33495A", +"P c #132D3C", +"Q c #586D80", +"R c #97A5B0", +"S c #86A4B9", +"T c #CDCDCD", +"U c #2E4353", +"V c #5A7082", +"W c #BFBFBF", +"X c #112835", +"Y c #9DA9B0", +"Z c #6B7882", +"` c #829DB1", +" . c #CBCBCB", +".. c #E5E5E5", +"+. c #213648", +"@. c #5F7989", +"#. c #C2C2C2", +"$. c #B2B2B2", +"%. c #112C3A", +"&. c #9FA9B0", +"*. c #59636D", +"=. c #A1A1A1", +"-. c #C0C0C0", +";. c #909090", +">. c #868686", +",. c #6E6E6E", +"'. c #7A7A7A", +"). c #2D3949", +"!. c #3E4F5C", +"~. c #80878F", +"{. c #1A3140", +" . . . . . . . . . . . . . . ", +". + @ # $ $ $ $ % . & * . = - . ", +". ; > , ' ) ) ! . ~ { ] . ^ / . ", +". ( > _ : : < . [ } | . 1 2 3 . ", +". ( > _ _ 4 . 5 6 7 . 8 9 0 a . ", +". ( > _ b . c d e . f g 9 0 h . ", +". ( > _ i . j k . l m n 9 o a . ", +". ( > p . q . . r g s s t 0 a . ", +". ( > u . . v w x x x y z 0 a . ", +". ( > A B C 0 0 0 0 D E 0 0 a . ", +". ( > A F G G H I J K L M 0 a . ", +". ( > 2 m m N O i m G P Q R a . ", +". ( S 0 m T U V m m W X V Y a . ", +". Z ` o ...+.@.m #.$.%.V &.a . ", +". . *.3 =.-.;.;.>.,.'.).!.~.{.. ", +" . . . . . . . . . . . . . . "}; diff --git a/lib/matplotlib/mpl-data/images/stock_up.xpm b/lib/matplotlib/mpl-data/images/stock_up.xpm index 359aed160ad6..994623624c88 100644 --- a/lib/matplotlib/mpl-data/images/stock_up.xpm +++ b/lib/matplotlib/mpl-data/images/stock_up.xpm @@ -1,45 +1,45 @@ -/* XPM */ -static char * stock_up_xpm[] = { -"16 16 26 1", -" c None", -". c #1C2D3D", -"+ c #000000", -"@ c #C5D5E4", -"# c #C4D4E3", -"$ c #9FB9D2", -"% c #2A435B", -"& c #9CB7D1", -"* c #A0BAD3", -"= c #3F6588", -"- c #A6BED5", -"; c #A4BDD5", -"> c #9EB8D1", -", c #A3BCD4", -"' c #AAC1D7", -") c #ABC2D8", -"! c #29425A", -"~ c #AFC5DA", -"{ c #9BB6D0", -"] c #AEC4D9", -"^ c #9AB5CF", -"/ c #6892B9", -"( c #49759E", -"_ c #4B78A2", -": c #34536F", -"< c #2D4760", -" ", -" . ", -" +@+ ", -" +#$%+ ", -" +#&*=%+ ", -" +#-;>==%+ ", -" +#,',>===%+ ", -" ++++)$&=!++++ ", -" +~{$=!+ ", -" +){$=!+ ", -" +]$$=!+ ", -" +,^$=!+ ", -" +/(_:<+ ", -" +++++++ ", -" ", -" "}; +/* XPM */ +static char * stock_up_xpm[] = { +"16 16 26 1", +" c None", +". c #1C2D3D", +"+ c #000000", +"@ c #C5D5E4", +"# c #C4D4E3", +"$ c #9FB9D2", +"% c #2A435B", +"& c #9CB7D1", +"* c #A0BAD3", +"= c #3F6588", +"- c #A6BED5", +"; c #A4BDD5", +"> c #9EB8D1", +", c #A3BCD4", +"' c #AAC1D7", +") c #ABC2D8", +"! c #29425A", +"~ c #AFC5DA", +"{ c #9BB6D0", +"] c #AEC4D9", +"^ c #9AB5CF", +"/ c #6892B9", +"( c #49759E", +"_ c #4B78A2", +": c #34536F", +"< c #2D4760", +" ", +" . ", +" +@+ ", +" +#$%+ ", +" +#&*=%+ ", +" +#-;>==%+ ", +" +#,',>===%+ ", +" ++++)$&=!++++ ", +" +~{$=!+ ", +" +){$=!+ ", +" +]$$=!+ ", +" +,^$=!+ ", +" +/(_:<+ ", +" +++++++ ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm b/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm index 33b16b674a9b..349e87e73200 100644 --- a/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm +++ b/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm @@ -1,61 +1,61 @@ -/* XPM */ -static char * stock_zoom_in_xpm[] = { -"16 16 42 1", -" c None", -". c #000000", -"+ c #262626", -"@ c #C5C5C5", -"# c #EEEEEE", -"$ c #EDEDED", -"% c #ABABAB", -"& c #464646", -"* c #878787", -"= c #F1F1F1", -"- c #FEFEFE", -"; c #FDFDFD", -"> c #FCFCFC", -", c #EAEAEA", -"' c #707070", -") c #252525", -"! c #282828", -"~ c #FBFBFB", -"{ c #E8E8E8", -"] c #B0B0B0", -"^ c #FFFFFF", -"/ c #050505", -"( c #040404", -"_ c #FAFAFA", -": c #A4A4A4", -"< c #090909", -"[ c #242424", -"} c #E5E5E5", -"| c #E4E4E4", -"1 c #F9F9F9", -"2 c #BABABA", -"3 c #E7E7E7", -"4 c #858585", -"5 c #E3E3E3", -"6 c #6D6D6D", -"7 c #A1A1A1", -"8 c #202020", -"9 c #686868", -"0 c #343434", -"a c #797979", -"b c #3A3A3A", -"c c #1F1F1F", -" .... ", -" .+@#$%&. ", -" .*=--;>,'. ", -" &=--)!;~{& ", -".]--^/(;>_:. ", -".#-//<(([_}. ", -".$;[(../[_|. ", -".%>;;((~_12. ", -" &,~><)_13& ", -" .4{___156. ", -" .&:}|7&.... ", -" .... 88.. ", -" .90.. ", -" .ab..", -" .9c.", -" .. "}; +/* XPM */ +static char * stock_zoom_in_xpm[] = { +"16 16 42 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #252525", +"! c #282828", +"~ c #FBFBFB", +"{ c #E8E8E8", +"] c #B0B0B0", +"^ c #FFFFFF", +"/ c #050505", +"( c #040404", +"_ c #FAFAFA", +": c #A4A4A4", +"< c #090909", +"[ c #242424", +"} c #E5E5E5", +"| c #E4E4E4", +"1 c #F9F9F9", +"2 c #BABABA", +"3 c #E7E7E7", +"4 c #858585", +"5 c #E3E3E3", +"6 c #6D6D6D", +"7 c #A1A1A1", +"8 c #202020", +"9 c #686868", +"0 c #343434", +"a c #797979", +"b c #3A3A3A", +"c c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=--)!;~{& ", +".]--^/(;>_:. ", +".#-//<(([_}. ", +".$;[(../[_|. ", +".%>;;((~_12. ", +" &,~><)_13& ", +" .4{___156. ", +" .&:}|7&.... ", +" .... 88.. ", +" .90.. ", +" .ab..", +" .9c.", +" .. "}; diff --git a/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm b/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm index 044355850404..a9d479124a67 100644 --- a/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm +++ b/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm @@ -1,59 +1,59 @@ -/* XPM */ -static char * stock_zoom_out_xpm[] = { -"16 16 40 1", -" c None", -". c #000000", -"+ c #262626", -"@ c #C5C5C5", -"# c #EEEEEE", -"$ c #EDEDED", -"% c #ABABAB", -"& c #464646", -"* c #878787", -"= c #F1F1F1", -"- c #FEFEFE", -"; c #FDFDFD", -"> c #FCFCFC", -", c #EAEAEA", -"' c #707070", -") c #FBFBFB", -"! c #E8E8E8", -"~ c #B0B0B0", -"{ c #FFFFFF", -"] c #FAFAFA", -"^ c #A4A4A4", -"/ c #050505", -"( c #090909", -"_ c #040404", -": c #242424", -"< c #E5E5E5", -"[ c #E4E4E4", -"} c #F9F9F9", -"| c #BABABA", -"1 c #E7E7E7", -"2 c #858585", -"3 c #E3E3E3", -"4 c #6D6D6D", -"5 c #A1A1A1", -"6 c #202020", -"7 c #686868", -"8 c #343434", -"9 c #797979", -"0 c #3A3A3A", -"a c #1F1F1F", -" .... ", -" .+@#$%&. ", -" .*=--;>,'. ", -" &=----;)!& ", -".~--{--;>]^. ", -".#-//(__:]<. ", -".$;:_../:][. ", -".%>;;;>)]}|. ", -" &,)>))]}1& ", -" .2!]]]}34. ", -" .&^<[5&.... ", -" .... 66.. ", -" .78.. ", -" .90..", -" .7a.", -" .. "}; +/* XPM */ +static char * stock_zoom_out_xpm[] = { +"16 16 40 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #FBFBFB", +"! c #E8E8E8", +"~ c #B0B0B0", +"{ c #FFFFFF", +"] c #FAFAFA", +"^ c #A4A4A4", +"/ c #050505", +"( c #090909", +"_ c #040404", +": c #242424", +"< c #E5E5E5", +"[ c #E4E4E4", +"} c #F9F9F9", +"| c #BABABA", +"1 c #E7E7E7", +"2 c #858585", +"3 c #E3E3E3", +"4 c #6D6D6D", +"5 c #A1A1A1", +"6 c #202020", +"7 c #686868", +"8 c #343434", +"9 c #797979", +"0 c #3A3A3A", +"a c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=----;)!& ", +".~--{--;>]^. ", +".#-//(__:]<. ", +".$;:_../:][. ", +".%>;;;>)]}|. ", +" &,)>))]}1& ", +" .2!]]]}34. ", +" .&^<[5&.... ", +" .... 66.. ", +" .78.. ", +" .90..", +" .7a.", +" .. "}; diff --git a/lib/pytz/README.txt b/lib/pytz/README.txt index 39fb0eab845a..4186dfb356bd 100644 --- a/lib/pytz/README.txt +++ b/lib/pytz/README.txt @@ -1,326 +1,326 @@ -pytz - World Timezone Definitions for Python -============================================ - -:Author: Stuart Bishop - -Introduction -~~~~~~~~~~~~ - -pytz brings the Olson tz database into Python. This library allows -accurate and cross platform timezone calculations using Python 2.3 -or higher. It also solves the issue of ambiguous times at the end -of daylight savings, which you can read more about in the Python -Library Reference (datetime.tzinfo). - -Amost all (over 540) of the Olson timezones are supported [*]_. - -Note that if you perform date arithmetic on local times that cross -DST boundaries, the results may be in an incorrect timezone (ie. -subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 -0:59 EST instead of the correct 2002-10-27 1:59 EDT). This cannot -be resolved without modifying the Python datetime implementation. -However, these tzinfo classes provide a normalize() method which -allows you to correct these values. - - -Installation -~~~~~~~~~~~~ - -This is a standard Python distutils distribution. To install the -package, run the following command as an administrative user:: - - python setup.py install - - -Example & Usage -~~~~~~~~~~~~~~~ - ->>> from datetime import datetime, timedelta ->>> from pytz import timezone ->>> import pytz ->>> utc = pytz.utc ->>> utc.zone -'UTC' ->>> eastern = timezone('US/Eastern') ->>> eastern.zone -'US/Eastern' ->>> fmt = '%Y-%m-%d %H:%M:%S %Z%z' - -The preferred way of dealing with times is to always work in UTC, -converting to localtime only when generating output to be read -by humans. - ->>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc) ->>> loc_dt = utc_dt.astimezone(eastern) ->>> loc_dt.strftime(fmt) -'2002-10-27 01:00:00 EST-0500' - -This library also allows you to do date arithmetic using local -times, although it is more complicated than working in UTC as you -need to use the `normalize` method to handle daylight savings time -and other timezone transitions. In this example, `loc_dt` is set -to the instant when daylight savings time ends in the US/Eastern -timezone. - ->>> before = loc_dt - timedelta(minutes=10) ->>> before.strftime(fmt) -'2002-10-27 00:50:00 EST-0500' ->>> eastern.normalize(before).strftime(fmt) -'2002-10-27 01:50:00 EDT-0400' ->>> after = eastern.normalize(before + timedelta(minutes=20)) ->>> after.strftime(fmt) -'2002-10-27 01:10:00 EST-0500' - -Creating localtimes is also tricky, and the reason why working with -local times is not recommended. Unfortunately, you cannot just pass -a 'tzinfo' argument when constructing a datetime (see the next section -for more details) - ->>> dt = datetime(2002, 10, 27, 1, 30, 0) ->>> dt1 = eastern.localize(dt, is_dst=True) ->>> dt1.strftime(fmt) -'2002-10-27 01:30:00 EDT-0400' ->>> dt2 = eastern.localize(dt, is_dst=False) ->>> dt2.strftime(fmt) -'2002-10-27 01:30:00 EST-0500' - -Converting between timezones also needs special attention. This also needs -to use the normalize method to ensure the conversion is correct. - ->>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899)) ->>> utc_dt.strftime(fmt) -'2006-03-26 21:34:59 UTC+0000' ->>> au_tz = timezone('Australia/Sydney') ->>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) ->>> au_dt.strftime(fmt) -'2006-03-27 08:34:59 EST+1100' ->>> utc_dt2 = utc.normalize(au_dt.astimezone(utc)) ->>> utc_dt2.strftime(fmt) -'2006-03-26 21:34:59 UTC+0000' - -You can also take shortcuts when dealing with the UTC side of timezone -conversions. Normalize and localize are not really necessary because there -are no daylight savings time transitions to deal with. - ->>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc) ->>> utc_dt.strftime(fmt) -'2006-03-26 21:34:59 UTC+0000' ->>> au_tz = timezone('Australia/Sydney') ->>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) ->>> au_dt.strftime(fmt) -'2006-03-27 08:34:59 EST+1100' ->>> utc_dt2 = au_dt.astimezone(utc) ->>> utc_dt2.strftime(fmt) -'2006-03-26 21:34:59 UTC+0000' - - -Problems with Localtime -~~~~~~~~~~~~~~~~~~~~~~~ - -The major problem we have to deal with is that certain datetimes -may occur twice in a year. For example, in the US/Eastern timezone -on the last Sunday morning in October, the following sequence -happens: - - - 01:00 EDT occurs - - 1 hour later, instead of 2:00am the clock is turned back 1 hour - and 01:00 happens again (this time 01:00 EST) - -In fact, every instant between 01:00 and 02:00 occurs twice. This means -that if you try and create a time in the US/Eastern timezone using -the standard datetime syntax, there is no way to specify if you meant -before of after the end-of-daylight-savings-time transition. - ->>> loc_dt = datetime(2002, 10, 27, 1, 30, 00, tzinfo=eastern) ->>> loc_dt.strftime(fmt) -'2002-10-27 01:30:00 EST-0500' - -As you can see, the system has chosen one for you and there is a 50% -chance of it being out by one hour. For some applications, this does -not matter. However, if you are trying to schedule meetings with people -in different timezones or analyze log files it is not acceptable. - -The best and simplest solution is to stick with using UTC. The pytz package -encourages using UTC for internal timezone representation by including a -special UTC implementation based on the standard Python reference -implementation in the Python documentation. This timezone unpickles to be -the same instance, and pickles to a relatively small size. The UTC -implementation can be obtained as pytz.utc, pytz.UTC, or -pytz.timezone('UTC'). Note that this instance is not the same -instance (or implementation) as other timezones with the same meaning -(GMT, Greenwich, Universal, etc.). - ->>> import pickle, pytz ->>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc) ->>> naive = dt.replace(tzinfo=None) ->>> p = pickle.dumps(dt, 1) ->>> naive_p = pickle.dumps(naive, 1) ->>> len(p), len(naive_p), len(p) - len(naive_p) -(60, 43, 17) ->>> new = pickle.loads(p) ->>> new == dt -True ->>> new is dt -False ->>> new.tzinfo is dt.tzinfo -True ->>> pytz.utc is pytz.UTC is pytz.timezone('UTC') -True ->>> utc is pytz.timezone('GMT') -False - -If you insist on working with local times, this library provides a -facility for constructing them almost unambiguously. - ->>> loc_dt = datetime(2002, 10, 27, 1, 30, 00) ->>> est_dt = eastern.localize(loc_dt, is_dst=True) ->>> edt_dt = eastern.localize(loc_dt, is_dst=False) ->>> print est_dt.strftime(fmt), '/', edt_dt.strftime(fmt) -2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500 - -Note that although this handles many cases, it is still not possible -to handle all. In cases where countries change their timezone definitions, -cases like the end-of-daylight-savings-time occur with no way of resolving -the ambiguity. For example, in 1915 Warsaw switched from Warsaw time to -Central European time. So at the stroke of midnight on August 4th 1915 -the clocks were wound back 24 minutes creating a ambiguous time period -that cannot be specified without referring to the timezone abbreviation -or the actual UTC offset. - -The 'Standard' Python way of handling all these ambiguities is not to, -such as demonstrated in this example using the US/Eastern timezone -definition from the Python documentation (Note that this implementation -only works for dates between 1987 and 2006 - it is included for tests only!): - ->>> from pytz.reference import Eastern # pytz.reference only for tests ->>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern) ->>> str(dt) -'2002-10-27 00:30:00-04:00' ->>> str(dt + timedelta(hours=1)) -'2002-10-27 01:30:00-05:00' ->>> str(dt + timedelta(hours=2)) -'2002-10-27 02:30:00-05:00' ->>> str(dt + timedelta(hours=3)) -'2002-10-27 03:30:00-05:00' - -Notice the first two results? At first glance you might think they are -correct, but taking the UTC offset into account you find that they are -actually two hours appart instead of the 1 hour we asked for. - ->>> from pytz.reference import UTC # pytz.reference only for tests ->>> str(dt.astimezone(UTC)) -'2002-10-27 04:30:00+00:00' ->>> str((dt + timedelta(hours=1)).astimezone(UTC)) -'2002-10-27 06:30:00+00:00' - - -What is UTC -~~~~~~~~~~~ - -`UTC` is Universal Time, formerly known as Greenwich Mean Time or GMT. -All other timezones are given as offsets from UTC. No daylight savings -time occurs in UTC, making it a useful timezone to perform date arithmetic -without worrying about the confusion and ambiguities caused by daylight -savings time transitions, your country changing its timezone, or mobile -computers that move roam through multiple timezones. - - -Helpers -~~~~~~~ - -There are two lists of timezones provided. - -`all_timezones` is the exhaustive list of the timezone names that can be used. - ->>> from pytz import all_timezones ->>> len(all_timezones) >= 500 -True ->>> 'Etc/Greenwich' in all_timezones -True - -`common_timezones` is a list of useful, current timezones. It doesn't -contain deprecated zones or historical zones. It is also a sequence of -strings. - ->>> from pytz import common_timezones ->>> len(common_timezones) < len(all_timezones) -True ->>> 'Etc/Greenwich' in common_timezones -False - -You can also retrieve lists of timezones used by particular countries -using the `country_timezones()` method. It requires an ISO-3166 two letter -country code. - ->>> from pytz import country_timezones ->>> country_timezones('ch') -['Europe/Zurich'] ->>> country_timezones('CH') -['Europe/Zurich'] - -License -~~~~~~~ - -MIT license. - -This code is also available as part of Zope 3 under the Zope Public -License, Version 2.1 (ZPL). - -I'm happy to relicense this code if necessary for inclusion in other -open source projects. - -Latest Versions -~~~~~~~~~~~~~~~ - -This package will be updated after releases of the Olson timezone database. -The latest version can be downloaded from the Python Cheeseshop_ or -Sourceforge_. The code that is used to generate this distribution is -available using the Bazaar_ revision control system using:: - - bzr branch http://bazaar.launchpad.net/~stub/pytz/devel - -.. _Cheeseshop: http://cheeseshop.python.org/pypi/pytz/ -.. _Sourceforge: http://sourceforge.net/projects/pytz/ -.. _Bazaar: http://bazaar-vcs.org/ - -Bugs, Feature Requests & Patches -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Bugs can be reported using Launchpad at -https://bugs.launchpad.net/products/pytz - -Issues & Limitations -~~~~~~~~~~~~~~~~~~~~ - -- Offsets from UTC are rounded to the nearest whole minute, so timezones - such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This is - a limitation of the Python datetime library. - -- If you think a timezone definition is incorrect, I probably can't fix - it. pytz is a direct translation of the Olson timezone database, and - changes to the timezone definitions need to be made to this source. - If you find errors they should be reported to the time zone mailing - list, linked from http://www.twinsun.com/tz/tz-link.htm - -Further Reading -~~~~~~~~~~~~~~~ - -More info than you want to know about timezones: -http://www.twinsun.com/tz/tz-link.htm - - -Contact -~~~~~~~ - -Stuart Bishop - -.. [*] The missing few are for Riyadh Solar Time in 1987, 1988 and 1989. - As Saudi Arabia gave up trying to cope with their timezone - definition, I see no reason to complicate my code further - to cope with them. (I understand the intention was to set - sunset to 0:00 local time, the start of the Islamic day. - In the best case caused the DST offset to change daily and - worst case caused the DST offset to change each instant - depending on how you interpreted the ruling.) - - +pytz - World Timezone Definitions for Python +============================================ + +:Author: Stuart Bishop + +Introduction +~~~~~~~~~~~~ + +pytz brings the Olson tz database into Python. This library allows +accurate and cross platform timezone calculations using Python 2.3 +or higher. It also solves the issue of ambiguous times at the end +of daylight savings, which you can read more about in the Python +Library Reference (datetime.tzinfo). + +Amost all (over 540) of the Olson timezones are supported [*]_. + +Note that if you perform date arithmetic on local times that cross +DST boundaries, the results may be in an incorrect timezone (ie. +subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 +0:59 EST instead of the correct 2002-10-27 1:59 EDT). This cannot +be resolved without modifying the Python datetime implementation. +However, these tzinfo classes provide a normalize() method which +allows you to correct these values. + + +Installation +~~~~~~~~~~~~ + +This is a standard Python distutils distribution. To install the +package, run the following command as an administrative user:: + + python setup.py install + + +Example & Usage +~~~~~~~~~~~~~~~ + +>>> from datetime import datetime, timedelta +>>> from pytz import timezone +>>> import pytz +>>> utc = pytz.utc +>>> utc.zone +'UTC' +>>> eastern = timezone('US/Eastern') +>>> eastern.zone +'US/Eastern' +>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z' + +The preferred way of dealing with times is to always work in UTC, +converting to localtime only when generating output to be read +by humans. + +>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc) +>>> loc_dt = utc_dt.astimezone(eastern) +>>> loc_dt.strftime(fmt) +'2002-10-27 01:00:00 EST-0500' + +This library also allows you to do date arithmetic using local +times, although it is more complicated than working in UTC as you +need to use the `normalize` method to handle daylight savings time +and other timezone transitions. In this example, `loc_dt` is set +to the instant when daylight savings time ends in the US/Eastern +timezone. + +>>> before = loc_dt - timedelta(minutes=10) +>>> before.strftime(fmt) +'2002-10-27 00:50:00 EST-0500' +>>> eastern.normalize(before).strftime(fmt) +'2002-10-27 01:50:00 EDT-0400' +>>> after = eastern.normalize(before + timedelta(minutes=20)) +>>> after.strftime(fmt) +'2002-10-27 01:10:00 EST-0500' + +Creating localtimes is also tricky, and the reason why working with +local times is not recommended. Unfortunately, you cannot just pass +a 'tzinfo' argument when constructing a datetime (see the next section +for more details) + +>>> dt = datetime(2002, 10, 27, 1, 30, 0) +>>> dt1 = eastern.localize(dt, is_dst=True) +>>> dt1.strftime(fmt) +'2002-10-27 01:30:00 EDT-0400' +>>> dt2 = eastern.localize(dt, is_dst=False) +>>> dt2.strftime(fmt) +'2002-10-27 01:30:00 EST-0500' + +Converting between timezones also needs special attention. This also needs +to use the normalize method to ensure the conversion is correct. + +>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899)) +>>> utc_dt.strftime(fmt) +'2006-03-26 21:34:59 UTC+0000' +>>> au_tz = timezone('Australia/Sydney') +>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) +>>> au_dt.strftime(fmt) +'2006-03-27 08:34:59 EST+1100' +>>> utc_dt2 = utc.normalize(au_dt.astimezone(utc)) +>>> utc_dt2.strftime(fmt) +'2006-03-26 21:34:59 UTC+0000' + +You can also take shortcuts when dealing with the UTC side of timezone +conversions. Normalize and localize are not really necessary because there +are no daylight savings time transitions to deal with. + +>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc) +>>> utc_dt.strftime(fmt) +'2006-03-26 21:34:59 UTC+0000' +>>> au_tz = timezone('Australia/Sydney') +>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz)) +>>> au_dt.strftime(fmt) +'2006-03-27 08:34:59 EST+1100' +>>> utc_dt2 = au_dt.astimezone(utc) +>>> utc_dt2.strftime(fmt) +'2006-03-26 21:34:59 UTC+0000' + + +Problems with Localtime +~~~~~~~~~~~~~~~~~~~~~~~ + +The major problem we have to deal with is that certain datetimes +may occur twice in a year. For example, in the US/Eastern timezone +on the last Sunday morning in October, the following sequence +happens: + + - 01:00 EDT occurs + - 1 hour later, instead of 2:00am the clock is turned back 1 hour + and 01:00 happens again (this time 01:00 EST) + +In fact, every instant between 01:00 and 02:00 occurs twice. This means +that if you try and create a time in the US/Eastern timezone using +the standard datetime syntax, there is no way to specify if you meant +before of after the end-of-daylight-savings-time transition. + +>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00, tzinfo=eastern) +>>> loc_dt.strftime(fmt) +'2002-10-27 01:30:00 EST-0500' + +As you can see, the system has chosen one for you and there is a 50% +chance of it being out by one hour. For some applications, this does +not matter. However, if you are trying to schedule meetings with people +in different timezones or analyze log files it is not acceptable. + +The best and simplest solution is to stick with using UTC. The pytz package +encourages using UTC for internal timezone representation by including a +special UTC implementation based on the standard Python reference +implementation in the Python documentation. This timezone unpickles to be +the same instance, and pickles to a relatively small size. The UTC +implementation can be obtained as pytz.utc, pytz.UTC, or +pytz.timezone('UTC'). Note that this instance is not the same +instance (or implementation) as other timezones with the same meaning +(GMT, Greenwich, Universal, etc.). + +>>> import pickle, pytz +>>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc) +>>> naive = dt.replace(tzinfo=None) +>>> p = pickle.dumps(dt, 1) +>>> naive_p = pickle.dumps(naive, 1) +>>> len(p), len(naive_p), len(p) - len(naive_p) +(60, 43, 17) +>>> new = pickle.loads(p) +>>> new == dt +True +>>> new is dt +False +>>> new.tzinfo is dt.tzinfo +True +>>> pytz.utc is pytz.UTC is pytz.timezone('UTC') +True +>>> utc is pytz.timezone('GMT') +False + +If you insist on working with local times, this library provides a +facility for constructing them almost unambiguously. + +>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00) +>>> est_dt = eastern.localize(loc_dt, is_dst=True) +>>> edt_dt = eastern.localize(loc_dt, is_dst=False) +>>> print est_dt.strftime(fmt), '/', edt_dt.strftime(fmt) +2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500 + +Note that although this handles many cases, it is still not possible +to handle all. In cases where countries change their timezone definitions, +cases like the end-of-daylight-savings-time occur with no way of resolving +the ambiguity. For example, in 1915 Warsaw switched from Warsaw time to +Central European time. So at the stroke of midnight on August 4th 1915 +the clocks were wound back 24 minutes creating a ambiguous time period +that cannot be specified without referring to the timezone abbreviation +or the actual UTC offset. + +The 'Standard' Python way of handling all these ambiguities is not to, +such as demonstrated in this example using the US/Eastern timezone +definition from the Python documentation (Note that this implementation +only works for dates between 1987 and 2006 - it is included for tests only!): + +>>> from pytz.reference import Eastern # pytz.reference only for tests +>>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern) +>>> str(dt) +'2002-10-27 00:30:00-04:00' +>>> str(dt + timedelta(hours=1)) +'2002-10-27 01:30:00-05:00' +>>> str(dt + timedelta(hours=2)) +'2002-10-27 02:30:00-05:00' +>>> str(dt + timedelta(hours=3)) +'2002-10-27 03:30:00-05:00' + +Notice the first two results? At first glance you might think they are +correct, but taking the UTC offset into account you find that they are +actually two hours appart instead of the 1 hour we asked for. + +>>> from pytz.reference import UTC # pytz.reference only for tests +>>> str(dt.astimezone(UTC)) +'2002-10-27 04:30:00+00:00' +>>> str((dt + timedelta(hours=1)).astimezone(UTC)) +'2002-10-27 06:30:00+00:00' + + +What is UTC +~~~~~~~~~~~ + +`UTC` is Universal Time, formerly known as Greenwich Mean Time or GMT. +All other timezones are given as offsets from UTC. No daylight savings +time occurs in UTC, making it a useful timezone to perform date arithmetic +without worrying about the confusion and ambiguities caused by daylight +savings time transitions, your country changing its timezone, or mobile +computers that move roam through multiple timezones. + + +Helpers +~~~~~~~ + +There are two lists of timezones provided. + +`all_timezones` is the exhaustive list of the timezone names that can be used. + +>>> from pytz import all_timezones +>>> len(all_timezones) >= 500 +True +>>> 'Etc/Greenwich' in all_timezones +True + +`common_timezones` is a list of useful, current timezones. It doesn't +contain deprecated zones or historical zones. It is also a sequence of +strings. + +>>> from pytz import common_timezones +>>> len(common_timezones) < len(all_timezones) +True +>>> 'Etc/Greenwich' in common_timezones +False + +You can also retrieve lists of timezones used by particular countries +using the `country_timezones()` method. It requires an ISO-3166 two letter +country code. + +>>> from pytz import country_timezones +>>> country_timezones('ch') +['Europe/Zurich'] +>>> country_timezones('CH') +['Europe/Zurich'] + +License +~~~~~~~ + +MIT license. + +This code is also available as part of Zope 3 under the Zope Public +License, Version 2.1 (ZPL). + +I'm happy to relicense this code if necessary for inclusion in other +open source projects. + +Latest Versions +~~~~~~~~~~~~~~~ + +This package will be updated after releases of the Olson timezone database. +The latest version can be downloaded from the Python Cheeseshop_ or +Sourceforge_. The code that is used to generate this distribution is +available using the Bazaar_ revision control system using:: + + bzr branch http://bazaar.launchpad.net/~stub/pytz/devel + +.. _Cheeseshop: http://cheeseshop.python.org/pypi/pytz/ +.. _Sourceforge: http://sourceforge.net/projects/pytz/ +.. _Bazaar: http://bazaar-vcs.org/ + +Bugs, Feature Requests & Patches +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Bugs can be reported using Launchpad at +https://bugs.launchpad.net/products/pytz + +Issues & Limitations +~~~~~~~~~~~~~~~~~~~~ + +- Offsets from UTC are rounded to the nearest whole minute, so timezones + such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This is + a limitation of the Python datetime library. + +- If you think a timezone definition is incorrect, I probably can't fix + it. pytz is a direct translation of the Olson timezone database, and + changes to the timezone definitions need to be made to this source. + If you find errors they should be reported to the time zone mailing + list, linked from http://www.twinsun.com/tz/tz-link.htm + +Further Reading +~~~~~~~~~~~~~~~ + +More info than you want to know about timezones: +http://www.twinsun.com/tz/tz-link.htm + + +Contact +~~~~~~~ + +Stuart Bishop + +.. [*] The missing few are for Riyadh Solar Time in 1987, 1988 and 1989. + As Saudi Arabia gave up trying to cope with their timezone + definition, I see no reason to complicate my code further + to cope with them. (I understand the intention was to set + sunset to 0:00 local time, the start of the Islamic day. + In the best case caused the DST offset to change daily and + worst case caused the DST offset to change each instant + depending on how you interpreted the ruling.) + + From e531c434ba649afec96606ad39e709f402c55898 Mon Sep 17 00:00:00 2001 From: Darren Dale Date: Sun, 20 Feb 2011 17:12:51 -0500 Subject: [PATCH 2/2] don't gitignore patch files --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index f798098a0095..6680e577eb15 100644 --- a/.gitignore +++ b/.gitignore @@ -62,11 +62,6 @@ doc/cdoc/build *.sql *.sqlite -# Patches # -########### -*.patch -*.diff - # OS generated files # ###################### .gdb_history pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy