示例#1
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
示例#3
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
示例#4
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)
示例#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)
    def __init__(self, backup=None):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        if backup is not None:
            lastMod = os.path.getmtime(backup)
            format = DateFormat.createDateTimeInstance(DateFormat.kFull,
                                                       DateFormat.kFull)
            lastMod = format.format(lastMod)
            title = _(u"Reload Your Data")
            text = _(
                u"Congratulations on upgrading to a new version of "
                "Chandler. Would you like to reload your data from the "
                "backup that was automatically created on %(datetime)s?"
                "\n\n"
                "Warning: Before reloading into this version of Chandler, "
                "make sure you quit the previous version of Chandler "
                "completely without any problems, as otherwise you may "
                "lose important edits.") % {
                    'datetime': lastMod
                }
        else:
            title = _(u"Incompatible Data")
            text = _(
                u"Your data was created by an incompatible version of "
                "Chandler. You can either proceed and delete all of your "
                "existing data, or click the Help button for instructions "
                "on how to manually move your data into this version of "
                "Chandler.")

        pre = wx.PreDialog()
        style = wx.CAPTION
        pre.Create(None, -1, title, wx.DefaultPosition, wx.DefaultSize, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.this = pre.this

        icon = wx.Icon("Chandler.egg-info/resources/icons/Chandler_32.ico",
                       wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSpacer((0, 3))

        logo = wx.GetApp().GetImage("Chandler_128.png")
        bitmap = wx.StaticBitmap(self, -1, logo)
        sizer.Add(bitmap, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 15)

        self.msgText = wx.StaticText(self, -1, text)
        self.msgText.Wrap(MIGRATION_DIALOG_WIDTH)
        sizer.Add(self.msgText, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=15)

        buttonSizer = wx.StdDialogButtonSizer()

        cancelButton = wx.Button(self, wx.ID_CANCEL)
        cancelButton.Bind(wx.EVT_BUTTON, self.onCancelButton)
        buttonSizer.AddButton(cancelButton)

        if backup is not None:
            reloadButton = wx.Button(self,
                                     wx.ID_OK,
                                     _(u"&Reload Data"),
                                     name="Reload Data")
            reloadButton.Bind(wx.EVT_BUTTON, self.onReloadButton)
            buttonSizer.AddButton(reloadButton)
            deleteButton = wx.Button(self,
                                     wx.ID_NO,
                                     _(u"&Start Fresh"),
                                     name="Start Fresh")
        else:
            helpButton = wx.Button(self, wx.ID_NO, _(u"&Help"), name="Help")
            helpButton.Bind(wx.EVT_BUTTON, self.onMoveDataButton)
            buttonSizer.AddButton(helpButton)
            deleteButton = wx.Button(self,
                                     wx.ID_OK,
                                     _(u"&Start Fresh"),
                                     name="Start Fresh")

        deleteButton.Bind(wx.EVT_BUTTON, self.onDeleteDataButton)
        buttonSizer.AddButton(deleteButton)
        buttonSizer.Realize()

        sizer.Add(buttonSizer,
                  1,
                  flag=wx.ALIGN_CENTER_VERTICAL | wx.BOTTOM | wx.EXPAND,
                  border=15)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.CenterOnScreen()

        if backup is not None:
            defaultButton = focusButton = reloadButton
        else:
            defaultButton = cancelButton
            focusButton = deleteButton

        defaultButton.SetDefault()
        focusButton.SetFocus()
示例#7
0
    def __init__(self, backup=None):
        # Instead of calling wx.Dialog.__init__ we precreate the dialog
        # so we can set an extra style that must be set before
        # creation, and then we create the GUI dialog using the Create
        # method.
        if backup is not None:
            lastMod = os.path.getmtime(backup)
            format = DateFormat.createDateTimeInstance(DateFormat.kFull, DateFormat.kFull)
            lastMod = format.format(lastMod)
            title = _(u"Reload Your Data")
            text = _(
                u"Congratulations on upgrading to a new version of "
                "Chandler. Would you like to reload your data from the "
                "backup that was automatically created on %(datetime)s?"
                "\n\n"
                "Warning: Before reloading into this version of Chandler, "
                "make sure you quit the previous version of Chandler "
                "completely without any problems, as otherwise you may "
                "lose important edits."
            ) % {"datetime": lastMod}
        else:
            title = _(u"Incompatible Data")
            text = _(
                u"Your data was created by an incompatible version of "
                "Chandler. You can either proceed and delete all of your "
                "existing data, or click the Help button for instructions "
                "on how to manually move your data into this version of "
                "Chandler."
            )

        pre = wx.PreDialog()
        style = wx.CAPTION
        pre.Create(None, -1, title, wx.DefaultPosition, wx.DefaultSize, style)

        # This next step is the most important, it turns this Python
        # object into the real wrapper of the dialog (instead of pre)
        # as far as the wxPython extension is concerned.
        self.this = pre.this

        icon = wx.Icon("Chandler.egg-info/resources/icons/Chandler_32.ico", wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSpacer((0, 3))

        logo = wx.GetApp().GetImage("Chandler_128.png")
        bitmap = wx.StaticBitmap(self, -1, logo)
        sizer.Add(bitmap, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 15)

        self.msgText = wx.StaticText(self, -1, text)
        self.msgText.Wrap(MIGRATION_DIALOG_WIDTH)
        sizer.Add(self.msgText, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=15)

        buttonSizer = wx.StdDialogButtonSizer()

        cancelButton = wx.Button(self, wx.ID_CANCEL)
        cancelButton.Bind(wx.EVT_BUTTON, self.onCancelButton)
        buttonSizer.AddButton(cancelButton)

        if backup is not None:
            reloadButton = wx.Button(self, wx.ID_OK, _(u"&Reload Data"), name="Reload Data")
            reloadButton.Bind(wx.EVT_BUTTON, self.onReloadButton)
            buttonSizer.AddButton(reloadButton)
            deleteButton = wx.Button(self, wx.ID_NO, _(u"&Start Fresh"), name="Start Fresh")
        else:
            helpButton = wx.Button(self, wx.ID_NO, _(u"&Help"), name="Help")
            helpButton.Bind(wx.EVT_BUTTON, self.onMoveDataButton)
            buttonSizer.AddButton(helpButton)
            deleteButton = wx.Button(self, wx.ID_OK, _(u"&Start Fresh"), name="Start Fresh")

        deleteButton.Bind(wx.EVT_BUTTON, self.onDeleteDataButton)
        buttonSizer.AddButton(deleteButton)
        buttonSizer.Realize()

        sizer.Add(buttonSizer, 1, flag=wx.ALIGN_CENTER_VERTICAL | wx.BOTTOM | wx.EXPAND, border=15)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.CenterOnScreen()

        if backup is not None:
            defaultButton = focusButton = reloadButton
        else:
            defaultButton = cancelButton
            focusButton = deleteButton

        defaultButton.SetDefault()
        focusButton.SetFocus()