@classmethod
    def parse(cls, string):
        """Parse a date and return a `Period` object or `None` if the
        string is empty.
        """
        if not string:
            return None
        ordinal = string.count('-')
        if ordinal >= len(cls.date_formats):
            # Too many components.
            return None
        date_format = cls.date_formats[ordinal]
        try:
            date = datetime.strptime(string, date_format)
        except __HOLE__:
            # Parsing failed.
            return None
        precision = cls.precisions[ordinal]
        return cls(date, precision)
dataset/ETHPy150Open beetbox/beets/beets/dbcore/query.py/Period.parse