Better code quality for within area rule
This commit is contained in:
parent
7100c51a31
commit
7979bf79fd
@ -37,10 +37,10 @@ import re
|
|||||||
# Gramps modules
|
# Gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gramps.gen.errors import FilterError
|
||||||
from ....const import GRAMPS_LOCALE as glocale
|
from ....const import GRAMPS_LOCALE as glocale
|
||||||
from .. import Rule
|
from .. import Rule
|
||||||
from ....utils.place import conv_lat_lon
|
from ....utils.place import conv_lat_lon
|
||||||
from gramps.gen.errors import FilterError
|
|
||||||
|
|
||||||
_ = glocale.translation.sgettext
|
_ = glocale.translation.sgettext
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ class WithinArea(Rule):
|
|||||||
"D.D8")
|
"D.D8")
|
||||||
if self.latitude is None or self.longitude is None:
|
if self.latitude is None or self.longitude is None:
|
||||||
raise FilterError(_("Cannot use the filter 'within area'"),
|
raise FilterError(_("Cannot use the filter 'within area'"),
|
||||||
_("The place you selected contains bad coordinates. "
|
_("The place you selected contains bad"
|
||||||
"Please, run the tool 'clean input data'"))
|
" coordinates. Please, run the tool "
|
||||||
return
|
"'clean input data'"))
|
||||||
|
|
||||||
val = self.list[1]
|
val = self.list[1]
|
||||||
if isinstance(val, str):
|
if isinstance(val, str):
|
||||||
val = re.sub(r"\D", "", val) # suppress all alpha characters
|
val = re.sub(r"\D", "", val) # suppress all alpha characters
|
||||||
value = int(val)
|
value = int(val)
|
||||||
unit = int(self.list[2])
|
unit = int(self.list[2])
|
||||||
# earth perimeter in kilometers for latitude
|
# earth perimeter in kilometers for latitude
|
||||||
|
Loading…
Reference in New Issue
Block a user