mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add reasons for invalid values
This commit is contained in:
parent
296a169dd3
commit
ed2e19a150
@ -122,7 +122,12 @@ class CrawlerSection(Section):
|
|||||||
return Redownload.ALWAYS
|
return Redownload.ALWAYS
|
||||||
elif value == "always-smart":
|
elif value == "always-smart":
|
||||||
return Redownload.ALWAYS_SMART
|
return Redownload.ALWAYS_SMART
|
||||||
self.invalid_value("redownload", value)
|
|
||||||
|
self.invalid_value(
|
||||||
|
"redownload",
|
||||||
|
value,
|
||||||
|
"Must be 'never', 'never-smart', 'always' or 'always-smart'"
|
||||||
|
)
|
||||||
|
|
||||||
def on_conflict(self) -> OnConflict:
|
def on_conflict(self) -> OnConflict:
|
||||||
value = self.s.get("on_conflict", "prompt")
|
value = self.s.get("on_conflict", "prompt")
|
||||||
@ -134,7 +139,12 @@ class CrawlerSection(Section):
|
|||||||
return OnConflict.REMOTE_FIRST
|
return OnConflict.REMOTE_FIRST
|
||||||
elif value == "no-delete":
|
elif value == "no-delete":
|
||||||
return OnConflict.NO_DELETE
|
return OnConflict.NO_DELETE
|
||||||
self.invalid_value("on_conflict", value)
|
|
||||||
|
self.invalid_value(
|
||||||
|
"on_conflict",
|
||||||
|
value,
|
||||||
|
"Must be 'prompt', 'local-first', 'remote-first' or 'no-delete'",
|
||||||
|
)
|
||||||
|
|
||||||
def transform(self) -> str:
|
def transform(self) -> str:
|
||||||
return self.s.get("transform", "")
|
return self.s.get("transform", "")
|
||||||
@ -167,7 +177,7 @@ class CrawlerSection(Section):
|
|||||||
self.missing_value("auth")
|
self.missing_value("auth")
|
||||||
auth = authenticators.get(f"auth:{value}")
|
auth = authenticators.get(f"auth:{value}")
|
||||||
if auth is None:
|
if auth is None:
|
||||||
self.invalid_value("auth", value)
|
self.invalid_value("auth", value, "No such auth section exists")
|
||||||
return auth
|
return auth
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,19 +19,22 @@ class LocalCrawlerSection(CrawlerSection):
|
|||||||
def crawl_delay(self) -> Optional[float]:
|
def crawl_delay(self) -> Optional[float]:
|
||||||
value = self.s.getfloat("crawl_delay")
|
value = self.s.getfloat("crawl_delay")
|
||||||
if value <= 0:
|
if value <= 0:
|
||||||
self.invalid_value("crawl_delay", value)
|
self.invalid_value("crawl_delay", value,
|
||||||
|
"Must be greater than 0")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def download_delay(self) -> Optional[float]:
|
def download_delay(self) -> Optional[float]:
|
||||||
value = self.s.getfloat("download_delay")
|
value = self.s.getfloat("download_delay")
|
||||||
if value <= 0:
|
if value <= 0:
|
||||||
self.invalid_value("download_delay", value)
|
self.invalid_value("download_delay", value,
|
||||||
|
"Must be greater than 0")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def download_speed(self) -> Optional[int]:
|
def download_speed(self) -> Optional[int]:
|
||||||
value = self.s.getint("download_speed")
|
value = self.s.getint("download_speed")
|
||||||
if value <= 0:
|
if value <= 0:
|
||||||
self.invalid_value("download_speed", value)
|
self.invalid_value("download_speed", value,
|
||||||
|
"Must be greater than 0")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user