GithubUserAudit.py
def validate_and_process_request_date_range(self):
        """ validate arg: validate stats request dates """
        """ supported: Xh, Xd, YYYY-MM-DD, YYYY-MM-DD-YYYY-MM-DD, """
        check_value = False
        ucnow = datetime.now()
        if self.date_range is None:
            """ allow None (default) as an acceptable value """
            check_value = True
        else:
            m = re.match(r'^(\d{1,3})([d|h])$', self.date_range)
        if (check_value is False and m and m is not None
                and m.group(1) is not None and
                m.group(2) is not None):
            this_timedelta = timedelta(hours=int(m.group(1)))
            if m.group(2) == 'd':
                this_timedelta = timedelta(days=int(m.group(1)))
            self.date_start = ucnow - this_timedelta
            self.date_end = ucnow
            check_value = True
        if (check_value is False):
            m = re.match(r'^(0?[1-9]|1[0-9]|2[0-5])([h])$', self.date_range)
            if (m is not None and m.group(1) is not None and
                    m.group(2) is not None):
                self.date_start = ucnow - \
                                  timedelta(hours=int(m.group(1)))
                self.date_end = ucnow
                check_value = True
        if (check_value is False):
            m = re.match(r'^(\d{4}\-\d{2}\-\d{2})(\-\d{4}\-\d{2}\-\d{2})?$',
                         self.date_range)
            if (m is not None and m.group(1) is not None):
                self.date_start = datetime.strptime(m.group(1), "%Y-%m-%d")
                if (m.group(2) is not None):
                    self.date_end = datetime.strptime(
                        m.group(2)[1:], "%Y-%m-%d")
                else:
                    self.date_end = ucnow
                check_value = True
        if (check_value is False):
            error_msg = ("Invalid date argument supplied.\n\n"
                         "Supported date formats:\n\n"
                         " * Xd\n"
                         " * Xh\n"
                         " * YYYY-MM-DD\n"
                         " * YYYY-MM-DD-YYYY-MM-DD")
            print(error_msg)
            sys.exit(1)

        """ misc sanity checks """
        if (self.date_start is not None and
           self.date_end is not None):
            if (self.date_end < self.date_start):
                tmp = self.date_end
                self.date_end = self.date_start
                self.date_start = tmp
            if (self.date_end > ucnow):
                self.date_end = ucnow
        return check_value
 validate arg: validate stats request dates 
validate arg: validate stats request dates
validate arg : validate stats request dates
def validate_and_process_request_date_range(self):
        check_value = False
        ucnow = datetime.now()
        if self.date_range is None:
            check_value = True
        else:
            m = re.match(r'^(\d{1,3})([d|h])$', self.date_range)
        if (check_value is False and m and m is not None
                and m.group(1) is not None and
                m.group(2) is not None):
            this_timedelta = timedelta(hours=int(m.group(1)))
            if m.group(2) == 'd':
                this_timedelta = timedelta(days=int(m.group(1)))
            self.date_start = ucnow - this_timedelta
            self.date_end = ucnow
            check_value = True
        if (check_value is False):
            m = re.match(r'^(0?[1-9]|1[0-9]|2[0-5])([h])$', self.date_range)
            if (m is not None and m.group(1) is not None and
                    m.group(2) is not None):
                self.date_start = ucnow - \
                                  timedelta(hours=int(m.group(1)))
                self.date_end = ucnow
                check_value = True
        if (check_value is False):
            m = re.match(r'^(\d{4}\-\d{2}\-\d{2})(\-\d{4}\-\d{2}\-\d{2})?$',
                         self.date_range)
            if (m is not None and m.group(1) is not None):
                self.date_start = datetime.strptime(m.group(1), "%Y-%m-%d")
                if (m.group(2) is not None):
                    self.date_end = datetime.strptime(
                        m.group(2)[1:], "%Y-%m-%d")
                else:
                    self.date_end = ucnow
                check_value = True
        if (check_value is False):
            error_msg = ("Invalid date argument supplied.\n\n"
                         "Supported date formats:\n\n"
                         " * Xd\n"
                         " * Xh\n"
                         " * YYYY-MM-DD\n"
                         " * YYYY-MM-DD-YYYY-MM-DD")
            print(error_msg)
            sys.exit(1)
        if (self.date_start is not None and
           self.date_end is not None):
            if (self.date_end < self.date_start):
                tmp = self.date_end
                self.date_end = self.date_start
                self.date_start = tmp
            if (self.date_end > ucnow):
                self.date_end = ucnow
        return check_value
def validate_and_process_request_date_range ( self ) : """ supported: Xh, Xd, YYYY-MM-DD, YYYY-MM-DD-YYYY-MM-DD, """ check_value = False ucnow = datetime . now ( ) if self . date_range is None : """ allow None (default) as an acceptable value """ check_value = True else : m = re . match ( r'^(\d{1,3})([d|h])$' , self . date_range ) if ( check_value is False and m and m is not None and m . group ( 1 ) is not None and m . group ( 2 ) is not None ) : this_timedelta = timedelta ( hours = int ( m . group ( 1 ) ) ) if m . group ( 2 ) == 'd' : this_timedelta = timedelta ( days = int ( m . group ( 1 ) ) ) self . date_start = ucnow - this_timedelta self . date_end = ucnow check_value = True if ( check_value is False ) : m = re . match ( r'^(0?[1-9]|1[0-9]|2[0-5])([h])$' , self . date_range ) if ( m is not None and m . group ( 1 ) is not None and m . group ( 2 ) is not None ) : self . date_start = ucnow - timedelta ( hours = int ( m . group ( 1 ) ) ) self . date_end = ucnow check_value = True if ( check_value is False ) : m = re . match ( r'^(\d{4}\-\d{2}\-\d{2})(\-\d{4}\-\d{2}\-\d{2})?$' , self . date_range ) if ( m is not None and m . group ( 1 ) is not None ) : self . date_start = datetime . strptime ( m . group ( 1 ) , "%Y-%m-%d" ) if ( m . group ( 2 ) is not None ) : self . date_end = datetime . strptime ( m . group ( 2 ) [ 1 : ] , "%Y-%m-%d" ) else : self . date_end = ucnow check_value = True if ( check_value is False ) : error_msg = ( "Invalid date argument supplied.\n\n" "Supported date formats:\n\n" " * Xd\n" " * Xh\n" " * YYYY-MM-DD\n" " * YYYY-MM-DD-YYYY-MM-DD" ) print ( error_msg ) sys . exit ( 1 ) """ misc sanity checks """ if ( self . date_start is not None and self . date_end is not None ) : if ( self . date_end < self . date_start ) : tmp = self . date_end self . date_end = self . date_start self . date_start = tmp if ( self . date_end > ucnow ) : self . date_end = ucnow return check_value
validate arg: validate stats request dates
validate arg : validate stats request dates
""" validate arg: validate stats request dates """ """ supported: Xh, Xd, YYYY-MM-DD, YYYY-MM-DD-YYYY-MM-DD, """ """ allow None (default) as an acceptable value """ """ misc sanity checks """
self