Ejemplo n.º 1
0
    def filterPosts(self, posts, min=None, max=None, text=None):

        filtered = []

        for (post, title, date, creator, content, parent) in posts:

            intDate = MailDate(date).getInteger()

            #exist if date is bigger
            if (max != None and intDate > max):
                break

            #continue if is smaller
            if (min != None and intDate < min):
                continue

            #and then filter by text
            if (text == None):
                filtered.append((post, title, date, creator, content, parent))
            else:
                if (self.__like(title, text) or self.__like(content, text)):
                    filtered.append(
                        (post, title, date, creator, content, parent))

        return filtered
Ejemplo n.º 2
0
    def getPath(self):
        """Return the message's index name"""

        #replace vars
        #FIXME: format permited vars (feature #1355)
        index = self.config.get('format')

        #message date
        date = MailDate(self.date)

        #replace vars
        index = index.replace('DD', date.getStringDay())  #day
        index = index.replace('MMMM',
                              date.getLongStringMonth())  #long string month
        index = index.replace('MMM',
                              date.getShortStringMonth())  #short string month
        index = index.replace('MM', date.getStringMonth())  #numeric month
        index = index.replace('YYYY', date.getStringYear())  #year
        index = index.replace('ID', str(self.id))  #swaml id

        #create subdirs
        dirs = index.split('/')[:-1]
        index_dir = ''
        for one_dir in dirs:
            index_dir += one_dir + '/'
            if not (os.path.exists(self.config.get('dir') + index_dir)):
                os.mkdir(self.config.get('dir') + index_dir)

        return index
Ejemplo n.º 3
0
    def getPath(self):
        """Return the message's index name"""

        #replace vars        
        #FIXME: format permited vars (feature #1355)
        index = self.config.get('format')
        
        #message date
        date = MailDate(self.date)   
             
         #replace vars
        index = index.replace('DD', date.getStringDay()) #day
        index = index.replace('MMMM', date.getLongStringMonth()) #long string month
        index = index.replace('MMM', date.getShortStringMonth()) #short string month
        index = index.replace('MM', date.getStringMonth()) #numeric month
        index = index.replace('YYYY', date.getStringYear()) #year
        index = index.replace('ID', str(self.id)) #swaml id

        #create subdirs
        dirs = index.split('/')[:-1]
        index_dir = ''
        for one_dir in dirs:
            index_dir += one_dir + '/'
            if not (os.path.exists(self.config.get('dir')+index_dir)):
                os.mkdir(self.config.get('dir')+index_dir)
            
        return index
Ejemplo n.º 4
0
 def orderByDate(self, posts):
     #SPARQL in RDFLib doesn't support 'ORDER BY' queries
     #then we'll implement a rustic support to order by dates
     #state: testing
     
     #extract dates in integer long format
     dict = {}
     dates = []
     for (post, title, date, creator, content, parent) in posts:
         intDate = MailDate(date).getInteger()
         dates.append(intDate)
         dict[intDate] = (post, title, date, creator, content, parent)
         
     #and we put ordered into a new list
     dates.sort()
     ordered = [] 
     for date in dates:
         ordered.append(dict[date])
         
     return ordered