~francesco-marella/specto/blacklist-plugins

« back to all changes in this revision

Viewing changes to spectlib/plugins/watch_sn_twitter.py

  • Committer: Jean-François Fortin Tam
  • Date: 2010-11-04 21:40:45 UTC
  • mfrom: (147.1.1 locale-breakage)
  • Revision ID: nekohayo@gmail.com-20101104214045-voxs3wxmhdgpq5a0
Merge Emilio's fix for timestamp locales in the Twitter plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import tempfile
29
29
import time
30
30
import calendar
 
31
import locale
31
32
import urllib
32
33
import urllib2
33
34
import urlparse
258
259
    Returns:
259
260
      The time this status message was posted, in seconds since the epoch.
260
261
    '''
261
 
    return calendar.timegm(time.strptime(self.created_at, '%a %b %d %H:%M:%S +0000 %Y'))
 
262
    old_locale = locale.getlocale(locale.LC_TIME)
 
263
    locale.setlocale(locale.LC_TIME, 'C')
 
264
    return_value = calendar.timegm(time.strptime(self.created_at, '%a %b %d %H:%M:%S +0000 %Y'))
 
265
    locale.setlocale(locale.LC_TIME, old_locale)
 
266
    return return_value
262
267
 
263
268
  created_at_in_seconds = property(GetCreatedAtInSeconds,
264
269
                                   doc="The time this status message was "
810
815
    Returns:
811
816
      The time this direct message was posted, in seconds since the epoch.
812
817
    '''
813
 
    return calendar.timegm(time.strptime(self.created_at, '%a %b %d %H:%M:%S +0000 %Y'))
 
818
    # Change the locale to C so we don't break on non-english locales
 
819
    old_locale = locale.getlocale(locale.LC_TIME)
 
820
    locale.setlocale(locale.LC_TIME, 'C')
 
821
    return_value = calendar.timegm(time.strptime(self.created_at, '%a %b %d %H:%M:%S +0000 %Y'))
 
822
    locale.setlocale(locale.LC_TIME, old_locale)
 
823
    return return_value
814
824
 
815
825
  created_at_in_seconds = property(GetCreatedAtInSeconds,
816
826
                                   doc="The time this direct message was "
1688
1698
 
1689
1699
  def _GetPrefix(self,hashed_key):
1690
1700
    return os.path.sep.join(hashed_key[0:_FileCache.DEPTH])
1691
 
        
 
 
b'\\ No newline at end of file'