Пример #1
0
def generateDateParser(cLocale):
    l = cLocale
    vals = []

    datep = [
        And(doLex(DateFormat.createDateInstance(DateFormat.SHORT,l).toPattern().encode('utf-8'),l)),
        And(doLex(DateFormat.createDateInstance(DateFormat.MEDIUM,l).toPattern().encode('utf-8'),l)),
        And(doLex(DateFormat.createDateInstance(DateFormat.LONG,l).toPattern().encode('utf-8'),l))
        ]

    timep = [
        And(doLex(DateFormat.createTimeInstance(DateFormat.SHORT,l).toPattern().encode('utf-8'),l)),
        And(doLex(DateFormat.createTimeInstance(DateFormat.MEDIUM,l).toPattern().encode('utf-8'),l)),
        And(doLex(DateFormat.createTimeInstance(DateFormat.LONG,l).toPattern().encode('utf-8'),l))
        ]

    datetimep = []

    for x in datep:
        for y in timep:
            datetimep.append(x + y)

    datep = [x+StringEnd() for x in datep]
    timep = [x+StringEnd() for x in timep]

    final = datep + timep + datetimep
    return Or(final)
Пример #2
0
    def __init__(self, compact, lastCompact, versions):

        self.compact = compact
        self.compacting = None

        pre = wx.PreDialog()
        pre.Create(None, -1, _(u"Purge Obsolete Data"), wx.DefaultPosition,
                   wx.DefaultSize, wx.DEFAULT_DIALOG_STYLE)
        self.this = pre.this

        sizer = wx.BoxSizer(wx.VERTICAL)
        grid = wx.FlexGridSizer(3, 1, 2, 2)

        # compact message
        format = DateFormat.createDateInstance(DateFormat.kMedium)
        since = format.format(lastCompact)
        text = _(
            u"Chandler needs to purge obsolete data. This operation may take a while but will make the application run faster."
        ) % {
            'since': since,
            'versions': versions
        }
        message = wx.StaticText(self, -1, text)
        message.Wrap(360)
        grid.Add(message, 0, wx.ALIGN_LEFT | wx.ALL, 3)

        # status message
        self.auto = _(
            u"Purging will start automatically in %(numOf)d seconds.")
        self.status = wx.StaticText(self, -1,
                                    self.auto % {"numOf": self.COUNTDOWN})
        self.status.Wrap(360)

        grid.Add(self.status, 0, wx.ALIGN_LEFT | wx.ALL, 3)

        # progress bar
        self.gauge = wx.Gauge(self, size=(360, 15))
        grid.Add(self.gauge, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(grid, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        # now and later/cancel buttons
        grid = wx.GridSizer(1, 2, 2, 2)
        self.now = wx.Button(self, wx.ID_OK, _(u"Purge Now"))
        grid.Add(self.now, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.later = wx.Button(self, wx.ID_CANCEL, _(u"Purge Later"))
        grid.Add(self.later, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        sizer.Add(grid, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5)

        self.Bind(wx.EVT_BUTTON, self.onNow, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.onLater, id=wx.ID_CANCEL)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
    def getCustomDescription(self):
        """Return a string describing custom rules.

        @rtype: C{str}

        """
        too_frequent = False
        if hasattr(self, 'rrules') and len(self.rrules) > 0:
            for rule in self.rrules:
                if rule.freq in SHORT_FREQUENCIES:
                    too_frequent = True
                    break

        if self.isComplex():
            if not too_frequent:
                return _(u"No description.")
            else:
                return _(u"Too frequent.")
        else:
            # Get the rule values we can interpret (so far...)
            rule = self.rrules.first()
            freq = rule.freq
            interval = rule.interval
            until = rule.calculatedUntil()
            days = rule.byweekday

            # Build the index and argument dictionary
            # The index must be built in the 'fxdus' order
            index = 'f'
            dct = {}

            if too_frequent:
                index += 'x'

            elif freq == 'weekly' and days is not None:
                index += 'd'
                daylist = [weekdayAbbrevMap[i.weekday] for i in days]
                dct['days'] = u" ".join(daylist)

            dct['frequencyplural'] = pluralFrequencyMap[freq]
            dct['frequencysingular'] = singularFrequencyMap[freq]
            dct['frequencyadverb'] = adverbFrequencyMap[freq]

            if not too_frequent and until is not None:
                index += 'u'
                formatter = DateFormat.createDateInstance(DateFormat.kShort)
                dct['date'] = unicode(formatter.format(until))

            if interval != 1:
                dct['interval'] = str(interval)
                index += 'p'
            else:
                index += 's'

            return descriptionFormat[index] % dct
Пример #4
0
    def getCustomDescription(self):
        """Return a string describing custom rules.

        @rtype: C{str}

        """
        too_frequent = False
        if hasattr(self, 'rrules') and len(self.rrules) > 0:
            for rule in self.rrules:
                if rule.freq in SHORT_FREQUENCIES:
                    too_frequent = True
                    break
        
        if self.isComplex():
            if not too_frequent:
                return _(u"No description.")
            else:
                return _(u"Too frequent.")
        else:
            # Get the rule values we can interpret (so far...)
            rule = self.rrules.first()
            freq = rule.freq
            interval = rule.interval
            until = rule.calculatedUntil()
            days = rule.byweekday
            
            # Build the index and argument dictionary
            # The index must be built in the 'fxdus' order
            index = 'f'
            dct = {}
            
            if too_frequent:
                index += 'x'
            
            elif freq == 'weekly' and days is not None:
                index += 'd'
                daylist = [weekdayAbbrevMap[i.weekday] for i in days]
                dct['days'] = u" ".join(daylist)

            dct['frequencyplural'] = pluralFrequencyMap[freq]
            dct['frequencysingular'] = singularFrequencyMap[freq]
            dct['frequencyadverb'] = adverbFrequencyMap[freq]

            if not too_frequent and until is not None:
                index += 'u'
                formatter = DateFormat.createDateInstance(DateFormat.kShort)
                dct['date'] = unicode(formatter.format(until))
            
            if interval != 1:
                dct['interval'] = str(interval)
                index += 'p'
            else:
                index += 's'

            return descriptionFormat[index] % dct
Пример #5
0
    def __init__(self, compact, lastCompact, versions):

        self.compact = compact
        self.compacting = None

        pre = wx.PreDialog()
        pre.Create(None, -1, _(u"Purge Obsolete Data"),
                   wx.DefaultPosition, wx.DefaultSize, wx.DEFAULT_DIALOG_STYLE)
        self.this = pre.this

        sizer = wx.BoxSizer(wx.VERTICAL)
        grid = wx.FlexGridSizer(3, 1, 2, 2)

        # compact message
        format = DateFormat.createDateInstance(DateFormat.kMedium)
        since = format.format(lastCompact)
        text = _(u"Chandler needs to purge obsolete data. This operation may take a while but will make the application run faster.") %{ 'since': since, 'versions': versions }
        message = wx.StaticText(self, -1, text)
        message.Wrap(360)
        grid.Add(message, 0, wx.ALIGN_LEFT|wx.ALL, 3)

        # status message
        self.auto = _(u"Purging will start automatically in %(numOf)d seconds.")
        self.status = wx.StaticText(self, -1, self.auto % {"numOf": self.COUNTDOWN})
        self.status.Wrap(360)

        grid.Add(self.status, 0, wx.ALIGN_LEFT|wx.ALL, 3)

        # progress bar
        self.gauge = wx.Gauge(self, size=(360, 15))
        grid.Add(self.gauge, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        sizer.Add(grid, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        # now and later/cancel buttons
        grid = wx.GridSizer(1, 2, 2, 2)
        self.now = wx.Button(self, wx.ID_OK, _(u"Purge Now"))
        grid.Add(self.now, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        self.later = wx.Button(self, wx.ID_CANCEL, _(u"Purge Later"))
        grid.Add(self.later, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        sizer.Add(grid, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.Bind(wx.EVT_BUTTON, self.onNow, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.onLater, id=wx.ID_CANCEL)
        
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)