示例#1
0
 def setUp(self):
     self._start_point = "19991226T0930Z"
     # Note: the following timezone will be Z-ified *after* truncation
     # or offsets are applied.
     self._end_point = "20010506T1200+0200"
     self._parsers = {
         0:
         CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES)),
         2:
         CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 num_expanded_year_digits=2,
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES))
     }
示例#2
0
def init(num_expanded_year_digits=0, custom_dump_format=None, time_zone=None,
         assume_utc=False, cycling_mode=None):
    """Initialise workflow-setup-specific information."""
    if cycling_mode in Calendar.default().MODES:
        Calendar.default().set_mode(cycling_mode)

    if time_zone is None:
        if assume_utc:
            time_zone = "Z"
            time_zone_hours_minutes = (0, 0)
        else:
            time_zone = get_local_time_zone_format(TimeZoneFormatMode.reduced)
            time_zone_hours_minutes = get_local_time_zone()
    else:
        time_zone_hours_minutes = TimePointDumper().get_time_zone(time_zone)
    WorkflowSpecifics.ASSUMED_TIME_ZONE = time_zone_hours_minutes
    WorkflowSpecifics.NUM_EXPANDED_YEAR_DIGITS = num_expanded_year_digits
    if custom_dump_format is None:
        if num_expanded_year_digits > 0:
            WorkflowSpecifics.DUMP_FORMAT = (
                EXPANDED_DATE_TIME_FORMAT + time_zone
            )
        else:
            WorkflowSpecifics.DUMP_FORMAT = DATE_TIME_FORMAT + time_zone
    else:
        WorkflowSpecifics.DUMP_FORMAT = custom_dump_format
        if "+X" not in custom_dump_format and num_expanded_year_digits:
            raise IllegalValueError(
                'cycle point format',
                ('cylc', 'cycle point format'),
                WorkflowSpecifics.DUMP_FORMAT
            )

    WorkflowSpecifics.iso8601_parsers = CylcTimeParser.initiate_parsers(
        dump_format=WorkflowSpecifics.DUMP_FORMAT,
        num_expanded_year_digits=num_expanded_year_digits,
        assumed_time_zone=WorkflowSpecifics.ASSUMED_TIME_ZONE
    )

    (WorkflowSpecifics.point_parser,
     WorkflowSpecifics.interval_parser,
     WorkflowSpecifics.recurrence_parser) = WorkflowSpecifics.iso8601_parsers

    WorkflowSpecifics.abbrev_util = CylcTimeParser(
        None, None, WorkflowSpecifics.iso8601_parsers
    )
示例#3
0
    def __init__(self,
                 dep_section,
                 context_start_point=None,
                 context_end_point=None):
        SequenceBase.__init__(self, dep_section, context_start_point,
                              context_end_point)
        self.dep_section = dep_section

        if context_start_point is None:
            self.context_start_point = context_start_point
        elif isinstance(context_start_point, ISO8601Point):
            self.context_start_point = context_start_point
        else:
            self.context_start_point = ISO8601Point.from_nonstandard_string(
                context_start_point)

        if context_end_point is None:
            self.context_end_point = None
        elif isinstance(context_end_point, ISO8601Point):
            self.context_end_point = context_end_point
        else:
            self.context_end_point = ISO8601Point.from_nonstandard_string(
                context_end_point)

        self.offset = ISO8601Interval.get_null()

        self._cached_first_point_values = {}
        self._cached_next_point_values = {}
        self._cached_valid_point_booleans = {}
        self._cached_recent_valid_points = []

        self.spec = dep_section
        self.abbrev_util = CylcTimeParser(self.context_start_point,
                                          self.context_end_point,
                                          WorkflowSpecifics.iso8601_parsers)
        # Parse_recurrence returns an isodatetime TimeRecurrence object
        # and a list of exclusion strings.
        self.recurrence, excl_points = self.abbrev_util.parse_recurrence(
            dep_section)

        # Determine the exclusion start point and end point
        try:
            exclusion_start_point = ISO8601Point.from_nonstandard_string(
                str(self.recurrence.start_point))
        except IsodatetimeError:
            exclusion_start_point = self.context_start_point

        try:
            exclusion_end_point = ISO8601Point.from_nonstandard_string(
                str(self.recurrence.end_point))
        except IsodatetimeError:
            exclusion_end_point = self.context_end_point

        self.exclusions = []

        # Creating an exclusions object instead
        if excl_points:
            try:
                self.exclusions = ISO8601Exclusions(excl_points,
                                                    exclusion_start_point,
                                                    exclusion_end_point)
            except AttributeError:
                pass

        self.step = ISO8601Interval(str(self.recurrence.duration))
        self.value = str(self.recurrence)
        # Concatenate the strings in exclusion list
        if self.exclusions:
            self.value += '!' + str(self.exclusions)
示例#4
0
    def __init__(self,
                 dep_section,
                 context_start_point=None,
                 context_end_point=None):
        SequenceBase.__init__(self, dep_section, context_start_point,
                              context_end_point)
        self.dep_section = dep_section

        # cache is_on_sequence
        # see B019 - https://github.com/PyCQA/flake8-bugbear#list-of-warnings
        self.is_on_sequence = lru_cache(maxsize=100)(self._is_on_sequence)

        if (context_start_point is None
                or isinstance(context_start_point, ISO8601Point)):
            self.context_start_point = context_start_point
        else:
            self.context_start_point = ISO8601Point.from_nonstandard_string(
                context_start_point)

        if context_end_point is None:
            self.context_end_point = None
        elif isinstance(context_end_point, ISO8601Point):
            self.context_end_point = context_end_point
        else:
            self.context_end_point = ISO8601Point.from_nonstandard_string(
                context_end_point)

        self.offset = ISO8601Interval.get_null()

        self._cached_first_point_values = {}
        self._cached_next_point_values = {}
        self._cached_valid_point_booleans = {}
        self._cached_recent_valid_points = []

        self.spec = dep_section
        self.abbrev_util = CylcTimeParser(self.context_start_point,
                                          self.context_end_point,
                                          WorkflowSpecifics.iso8601_parsers)
        # Parse_recurrence returns an isodatetime TimeRecurrence object
        # and a list of exclusion strings.
        self.recurrence, excl_points = self.abbrev_util.parse_recurrence(
            dep_section)

        # Determine the exclusion start point and end point
        try:
            exclusion_start_point = ISO8601Point.from_nonstandard_string(
                str(self.recurrence.start_point))
        except IsodatetimeError:
            exclusion_start_point = self.context_start_point

        try:
            exclusion_end_point = ISO8601Point.from_nonstandard_string(
                str(self.recurrence.end_point))
        except IsodatetimeError:
            exclusion_end_point = self.context_end_point

        self.exclusions = []

        # Creating an exclusions object instead
        if excl_points:
            with contextlib.suppress(AttributeError):
                self.exclusions = ISO8601Exclusions(excl_points,
                                                    exclusion_start_point,
                                                    exclusion_end_point)

        self.step = ISO8601Interval(str(self.recurrence.duration))
        self.value = str(self.recurrence)
        # Concatenate the strings in exclusion list
        if self.exclusions:
            self.value += '!' + str(self.exclusions)