| 126 | return pokemons |
| 127 | |
| 128 | def validate(self): |
| 129 | try: |
| 130 | if self.enabled: |
| 131 | errors = [] |
| 132 | data = self.fetch_raw() |
| 133 | |
| 134 | # Check whether the params really exist if they have been specified like so |
| 135 | if data: |
| 136 | if self.mappings.iv.exists and self.mappings.iv.param not in data[0]: |
| 137 | errors.append(self.mappings.iv.param) |
| 138 | if self.mappings.id.exists and self.mappings.id.param not in data[0]: |
| 139 | errors.append(self.mappings.id.param) |
| 140 | if self.mappings.name.exists and self.mappings.name.param not in data[0]: |
| 141 | errors.append(self.mappings.name.param) |
| 142 | if self.mappings.latitude.exists and self.mappings.latitude.param not in data[0]: |
| 143 | errors.append(self.mappings.latitude.param) |
| 144 | if self.mappings.longitude.exists and self.mappings.longitude.param not in data[0]: |
| 145 | errors.append(self.mappings.longitude.param) |
| 146 | if self.mappings.expiration.exists and self.mappings.expiration.param not in data[0]: |
| 147 | errors.append(self.mappings.expiration.param) |
| 148 | if self.mappings.encounter.exists and self.mappings.encounter.param not in data[0]: |
| 149 | errors.append(self.mappings.encounter.param) |
| 150 | if self.mappings.spawnpoint.exists and self.mappings.spawnpoint.param not in data[0]: |
| 151 | errors.append(self.mappings.spawnpoint.param) |
| 152 | |
| 153 | # All wrong mappings were gathered at once for a better usability (instead of raising multiple exceptions) |
| 154 | if errors: |
| 155 | raise LookupError("The following params dont exist: {}".format(", ".join(errors))) |
| 156 | else: |
| 157 | raise ValueError("Source is not enabled") |
| 158 | except requests.exceptions.Timeout: |
| 159 | raise ValueError("Fetching has timed out") |
| 160 | except requests.exceptions.ConnectionError: |
| 161 | raise ValueError("Source not available") |
| 162 | except: |
| 163 | raise |
| 164 | |
| 165 | def _fixname(self,name): |
| 166 | if name: |