Пример #1
0
 def __str__(self):
     lines = []
     for day, times in self.processed_days.items():
         line = day.capitalize() + ': '
         if times:
             schedule = ", ".join("%s - %s" %
                                  (to_time(opened), to_time(closed))
                                  for opened, closed in pairs(times))
         else:
             schedule = "Closed"
         lines.append(line + schedule)
     return '\n'.join(lines)
Пример #2
0
    def decode_list(self, node, cache, as_map_key):
        """Special case decodes map-as-array.
        Otherwise lists are treated as Python lists.

        Arguments follow the same convention as the top-level 'decode'
        function.
        """
        if node:
            if node[0] == MAP_AS_ARR:
                # key must be decoded before value for caching to work.
                returned_dict = {}
                for k,v in pairs(node[1:]):
                    key = self._decode(k, cache, True)
                    val = self._decode(v, cache, as_map_key)
                    returned_dict[key] = val
                return returned_dict

            decoded = self._decode(node[0], cache, as_map_key)
            if isinstance(decoded, Tag):
                return self.decode_tag(decoded.tag, self._decode(node[1], cache, as_map_key))
        return tuple(self._decode(x, cache, as_map_key) for x in node)
Пример #3
0
    def decode_list(self, node, cache, as_map_key):
        """Special case decodes map-as-array.
        Otherwise lists are treated as Python lists.

        Arguments follow the same convention as the top-level 'decode'
        function.
        """
        if node:
            if node[0] == MAP_AS_ARR:
                # key must be decoded before value for caching to work.
                returned_dict = {}
                for k, v in pairs(node[1:]):
                    key = self._decode(k, cache, True)
                    val = self._decode(v, cache, as_map_key)
                    returned_dict[key] = val
                return returned_dict

            decoded = self._decode(node[0], cache, as_map_key)
            if isinstance(decoded, Tag):
                return self.decode_tag(
                    decoded.tag, self._decode(node[1], cache, as_map_key))
        return tuple(self._decode(x, cache, as_map_key) for x in node)
Пример #4
0
 def from_rep(cmap):
     return transit_types.frozendict(pairs(cmap))
Пример #5
0
 def from_rep(cmap):
     return transit_types.frozendict(pairs(cmap))