Пример #1
0
 def trackables(self, trackables):
     if type(trackables) is Trackable:
         self._trackables = [trackables]
     elif type(trackables) is not list:
         raise ValueError("Passed object is not list")
     else:
         self._trackables = trackables
Пример #2
0
 def location(self, location):
     if type(location) is str:
         location = Point.from_string(location)
     elif type(location) is not Point:
         raise ValueError(
             "Passed object is not Point instance nor string containing coordinates."
         )
     self._location = location
Пример #3
0
 def hidden(self, hidden):
     if type(hidden) is str:
         hidden = Util.parse_date(hidden)
     elif type(hidden) is not datetime.date:
         raise ValueError(
             "Passed object is not datetime.date instance nor string containing a date."
         )
     self._hidden = hidden
Пример #4
0
 def size(self, size):
     size = size.strip().lower()
     if size in self._possible_sizes.values():  # try to search in values
         self._size = size
     elif size in self._possible_sizes.keys(
     ):  # not in values => it must be a key
         self._size = self._possible_sizes[size]
     else:
         raise ValueError("Size '{}' is not possible.".format(size))
Пример #5
0
    def attributes(self, attributes):
        if type(attributes) is not dict:
            raise ValueError("Attribues is not dict.")

        self._attributes = {}
        for name, allowed in attributes.items():
            name = name.strip().lower()
            if name in self._possible_attributes:
                self._attributes[name] = allowed
            else:
                logging.warning("Unknown attribute '%s', ignoring.", name)
Пример #6
0
    def cache_type(self, cache_type):
        cache_type = cache_type.replace(" Geocache", "")  # with space!
        cache_type = cache_type.replace(" Cache", "")  # with space!
        cache_type = cache_type.strip()

        # walk trough each type and its synonyms
        for key, value in self._possible_types.items():
            for synonym in value:
                if cache_type.lower() == synonym.lower():
                    self._cache_type = self._possible_types[key][0]
                    return

        raise ValueError("Cache type '{}' is not possible.".format(cache_type))
Пример #7
0
 def terrain(self, terrain):
     terrain = float(terrain)
     if terrain < 1 or terrain > 5 or terrain * 10 % 5 != 0:  # X.0 or X.5
         raise ValueError(
             "Terrain must be from 1 to 5 and divisible by 0.5.")
     self._terrain = terrain
Пример #8
0
 def difficulty(self, difficulty):
     difficulty = float(difficulty)
     if difficulty < 1 or difficulty > 5 or difficulty * 10 % 5 != 0:  # X.0 or X.5
         raise ValueError(
             "Difficulty must be from 1 to 5 and divisible by 0.5.")
     self._difficulty = difficulty
Пример #9
0
 def geocaching(self, geocaching):
     if not hasattr(geocaching, "load_cache"):
         raise ValueError(
             "Passed object (type: '{}') doesn't contain 'load_cache' method."
             .format(type(geocaching)))
     self._geocaching = geocaching
Пример #10
0
 def wp(self, wp):
     wp = str(wp).upper().strip()
     if not wp.startswith("GC"):
         raise ValueError(
             "Waypoint '{}' doesn't start with 'GC'.".format(wp))
     self._wp = wp
Пример #11
0
 def size(self, size):
     size = size.strip().lower()
     if size not in self._possible_sizes:
         raise ValueError("Size '{}' is not possible.".format(size))
     self._size = size
Пример #12
0
 def cache_type(self, cache_type):
     cache_type = cache_type.strip().title()
     cache_type = cache_type.replace("Geocache", "Cache")
     if cache_type not in self._possible_types:
         raise ValueError("Cache type '{}' is not possible.".format(cache_type))
     self._cache_type = cache_type
Пример #13
0
 def tid(self, tid):
     tid = str(tid).upper().strip()
     if not tid.startswith("TB"):
         raise ValueError(
             "Trackable ID '{}' doesn't start with 'TB'.".format(tid))
     self._tid = tid