File: __init__.py

package info (click to toggle)
egenix-mx-base 3.2.1-1.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,496 kB
  • sloc: ansic: 21,976; python: 17,192; sh: 137; makefile: 116
file content (56 lines) | stat: -rw-r--r-- 1,708 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
""" mxDateTime - Date and time handling routines and types

    Copyright (c) 1998-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2011, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
"""
from DateTime import *
from DateTime import __version__

### Lazy import submodules
from mx.Misc import LazyModule

ISO = LazyModule.LazyModule('ISO',locals(),globals())
ARPA = LazyModule.LazyModule('ARPA',locals(),globals())
ODMG = LazyModule.LazyModule('ODMG',locals(),globals())
Locale = LazyModule.LazyModule('Locale',locals(),globals())
Feasts = LazyModule.LazyModule('Feasts',locals(),globals())
Parser = LazyModule.LazyModule('Parser',locals(),globals())
NIST = LazyModule.LazyModule('NIST',locals(),globals())
Timezone = LazyModule.LazyModule('Timezone',locals(),globals())

del LazyModule

### Make the types pickleable:

# Shortcuts for pickle (reduces the pickle's length)
def _DT(absdate,abstime,

        DateTimeFromAbsDateTime=DateTimeFromAbsDateTime):

    return DateTimeFromAbsDateTime(absdate,abstime)

def _DTD(seconds,

         DateTimeDeltaFromSeconds=DateTimeDeltaFromSeconds):

    return DateTimeDeltaFromSeconds(seconds)

# Module init
class modinit:

    ### Register the two types
    import copy_reg
    def pickle_DateTime(d):
        return _DT,(d.absdate,d.abstime)
    def pickle_DateTimeDelta(d):
        return _DTD,(d.seconds,)
    copy_reg.pickle(DateTimeType,
                    pickle_DateTime,
                    _DT)
    copy_reg.pickle(DateTimeDeltaType,
                    pickle_DateTimeDelta,
                    _DTD)

del modinit