Beispiel #1
0
def reviewer(reviewer, patchsets=None, reviewed=None, verified=None,
             status=None, since=None):
    search = 'status:%s reviewer:%s' % (status or 'open', reviewer)
    if since:
        cut_date = datetime.now() - timedelta_parser.parse(since)

    def format_output(changes):
        for change in changes:
            if patchsets == 'last':
                patchSets = [change.patchSets[-1]]
            else:
                patchSets = change.patchSets
            if cut_date:
                patchSets = [patchSet for patchSet in patchSets if
                             cut_date <= patchSet.createdOn]
            if reviewed is not None:
                patchSets = [patchSet for patchSet in patchSets if
                             patchSet.reviewed(reviewed)]
            if verified is not None:
                patchSets = [patchSet for patchSet in patchSets if
                             patchSet.verified(verified)]
            if patchSets:
                print '%r' % change
                print '\t%s' % change.url
                for patchSet in patchSets:
                    print '\t%r' % patchSet
                print '\n'

    execute_search(search, format_output)
Beispiel #2
0
 def _handle_UNTIL(self, rrkwargs, name, value, **kwargs):
     global parser
     if not parser:
         #from dateutil import parser
         from dateparser import parser
     try:
         rrkwargs["until"] = parser.parse(value,
                                        ignoretz=kwargs.get("ignoretz"),
                                        tzinfos=kwargs.get("tzinfos"))
     except ValueError:
         raise ValueError, "invalid until date"
Beispiel #3
0
 def _handle_UNTIL(self, rrkwargs, name, value, **kwargs):
     global parser
     if not parser:
         #from dateutil import parser
         from dateparser import parser
     try:
         rrkwargs["until"] = parser.parse(value,
                                          ignoretz=kwargs.get("ignoretz"),
                                          tzinfos=kwargs.get("tzinfos"))
     except ValueError:
         raise ValueError, "invalid until date"
Beispiel #4
0
def reviewer(reviewer,
             patchsets=None,
             reviewed=None,
             verified=None,
             status=None,
             since=None):
    search = 'status:%s reviewer:%s' % (status or 'open', reviewer)
    if since:
        cut_date = datetime.now() - timedelta_parser.parse(since)

    def format_output(changes):
        for change in changes:
            if patchsets == 'last':
                patchSets = [change.patchSets[-1]]
            else:
                patchSets = change.patchSets
            if cut_date:
                patchSets = [
                    patchSet for patchSet in patchSets
                    if cut_date <= patchSet.createdOn
                ]
            if reviewed is not None:
                patchSets = [
                    patchSet for patchSet in patchSets
                    if patchSet.reviewed(reviewed)
                ]
            if verified is not None:
                patchSets = [
                    patchSet for patchSet in patchSets
                    if patchSet.verified(verified)
                ]
            if patchSets:
                print '%r' % change
                print '\t%s' % change.url
                for patchSet in patchSets:
                    print '\t%r' % patchSet
                print '\n'

    execute_search(search, format_output)
Beispiel #5
0
 def _parse_rfc(self, s,
                dtstart=None,
                cache=False,
                unfold=False,
                forceset=False,
                compatible=False,
                ignoretz=False,
                tzinfos=None):
     global parser
     if compatible:
         forceset = True
         unfold = True
     s = s.upper()
     if not s.strip():
         raise ValueError, "empty string"
     if unfold:
         lines = s.splitlines()
         i = 0
         while i < len(lines):
             line = lines[i].rstrip()
             if not line:
                 del lines[i]
             elif i > 0 and line[0] == " ":
                 lines[i-1] += line[1:]
                 del lines[i]
             else:
                 i += 1
     else:
         lines = s.split()
     if (not forceset and len(lines) == 1 and
         (s.find(':') == -1 or s.startswith('RRULE:'))):
         return self._parse_rfc_rrule(lines[0], cache=cache,
                                      dtstart=dtstart, ignoretz=ignoretz,
                                      tzinfos=tzinfos)
     else:
         rrulevals = []
         rdatevals = []
         exrulevals = []
         exdatevals = []
         for line in lines:
             if not line:
                 continue
             if line.find(':') == -1:
                 name = "RRULE"
                 value = line
             else:
                 name, value = line.split(':', 1)
             parms = name.split(';')
             if not parms:
                 raise ValueError, "empty property name"
             name = parms[0]
             parms = parms[1:]
             if name == "RRULE":
                 for parm in parms:
                     raise ValueError, "unsupported RRULE parm: "+parm
                 rrulevals.append(value)
             elif name == "RDATE":
                 for parm in parms:
                     if parm != "VALUE=DATE-TIME":
                         raise ValueError, "unsupported RDATE parm: "+parm
                 rdatevals.append(value)
             elif name == "EXRULE":
                 for parm in parms:
                     raise ValueError, "unsupported EXRULE parm: "+parm
                 exrulevals.append(value)
             elif name == "EXDATE":
                 for parm in parms:
                     if parm != "VALUE=DATE-TIME":
                         raise ValueError, "unsupported RDATE parm: "+parm
                 exdatevals.append(value)
             elif name == "DTSTART":
                 for parm in parms:
                     raise ValueError, "unsupported DTSTART parm: "+parm
                 if not parser:
                     #from dateutil import parser
                     from dateparser import parser
                 dtstart = parser.parse(value, ignoretz=ignoretz,
                                        tzinfos=tzinfos)
             else:
                 raise ValueError, "unsupported property: "+name
         if (forceset or len(rrulevals) > 1 or
             rdatevals or exrulevals or exdatevals):
             if not parser and (rdatevals or exdatevals):
                 #from dateutil import parser
                 from dateparser import parser
             set = rruleset(cache=cache)
             for value in rrulevals:
                 set.rrule(self._parse_rfc_rrule(value, dtstart=dtstart,
                                                 ignoretz=ignoretz,
                                                 tzinfos=tzinfos))
             for value in rdatevals:
                 for datestr in value.split(','):
                     set.rdate(parser.parse(datestr,
                                            ignoretz=ignoretz,
                                            tzinfos=tzinfos))
             for value in exrulevals:
                 set.exrule(self._parse_rfc_rrule(value, dtstart=dtstart,
                                                  ignoretz=ignoretz,
                                                  tzinfos=tzinfos))
             for value in exdatevals:
                 for datestr in value.split(','):
                     set.exdate(parser.parse(datestr,
                                             ignoretz=ignoretz,
                                             tzinfos=tzinfos))
             if compatible and dtstart:
                 set.rdate(dtstart)
             return set
         else:
             return self._parse_rfc_rrule(rrulevals[0],
                                          dtstart=dtstart,
                                          cache=cache,
                                          ignoretz=ignoretz,
                                          tzinfos=tzinfos)
Beispiel #6
0
 def _parse_rfc(self,
                s,
                dtstart=None,
                cache=False,
                unfold=False,
                forceset=False,
                compatible=False,
                ignoretz=False,
                tzinfos=None):
     global parser
     if compatible:
         forceset = True
         unfold = True
     s = s.upper()
     if not s.strip():
         raise ValueError, "empty string"
     if unfold:
         lines = s.splitlines()
         i = 0
         while i < len(lines):
             line = lines[i].rstrip()
             if not line:
                 del lines[i]
             elif i > 0 and line[0] == " ":
                 lines[i - 1] += line[1:]
                 del lines[i]
             else:
                 i += 1
     else:
         lines = s.split()
     if (not forceset and len(lines) == 1
             and (s.find(':') == -1 or s.startswith('RRULE:'))):
         return self._parse_rfc_rrule(lines[0],
                                      cache=cache,
                                      dtstart=dtstart,
                                      ignoretz=ignoretz,
                                      tzinfos=tzinfos)
     else:
         rrulevals = []
         rdatevals = []
         exrulevals = []
         exdatevals = []
         for line in lines:
             if not line:
                 continue
             if line.find(':') == -1:
                 name = "RRULE"
                 value = line
             else:
                 name, value = line.split(':', 1)
             parms = name.split(';')
             if not parms:
                 raise ValueError, "empty property name"
             name = parms[0]
             parms = parms[1:]
             if name == "RRULE":
                 for parm in parms:
                     raise ValueError, "unsupported RRULE parm: " + parm
                 rrulevals.append(value)
             elif name == "RDATE":
                 for parm in parms:
                     if parm != "VALUE=DATE-TIME":
                         raise ValueError, "unsupported RDATE parm: " + parm
                 rdatevals.append(value)
             elif name == "EXRULE":
                 for parm in parms:
                     raise ValueError, "unsupported EXRULE parm: " + parm
                 exrulevals.append(value)
             elif name == "EXDATE":
                 for parm in parms:
                     if parm != "VALUE=DATE-TIME":
                         raise ValueError, "unsupported RDATE parm: " + parm
                 exdatevals.append(value)
             elif name == "DTSTART":
                 for parm in parms:
                     raise ValueError, "unsupported DTSTART parm: " + parm
                 if not parser:
                     #from dateutil import parser
                     from dateparser import parser
                 dtstart = parser.parse(value,
                                        ignoretz=ignoretz,
                                        tzinfos=tzinfos)
             else:
                 raise ValueError, "unsupported property: " + name
         if (forceset or len(rrulevals) > 1 or rdatevals or exrulevals
                 or exdatevals):
             if not parser and (rdatevals or exdatevals):
                 #from dateutil import parser
                 from dateparser import parser
             set = rruleset(cache=cache)
             for value in rrulevals:
                 set.rrule(
                     self._parse_rfc_rrule(value,
                                           dtstart=dtstart,
                                           ignoretz=ignoretz,
                                           tzinfos=tzinfos))
             for value in rdatevals:
                 for datestr in value.split(','):
                     set.rdate(
                         parser.parse(datestr,
                                      ignoretz=ignoretz,
                                      tzinfos=tzinfos))
             for value in exrulevals:
                 set.exrule(
                     self._parse_rfc_rrule(value,
                                           dtstart=dtstart,
                                           ignoretz=ignoretz,
                                           tzinfos=tzinfos))
             for value in exdatevals:
                 for datestr in value.split(','):
                     set.exdate(
                         parser.parse(datestr,
                                      ignoretz=ignoretz,
                                      tzinfos=tzinfos))
             if compatible and dtstart:
                 set.rdate(dtstart)
             return set
         else:
             return self._parse_rfc_rrule(rrulevals[0],
                                          dtstart=dtstart,
                                          cache=cache,
                                          ignoretz=ignoretz,
                                          tzinfos=tzinfos)