Skip to content

Commit

Permalink
Reuse helpers method instead of local duplicate (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
lokal-profil authored Sep 28, 2018
1 parent f0d4c91 commit 9e68dd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
18 changes: 1 addition & 17 deletions wikidataStuff/WikidataStringSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def testInput(self, text, language=None, term_type=None, entities=None):
# Check each is correctly formatted
if not all(e.startswith('Q') and
helpers.is_str(e) and
WikidataStringSearch.is_int(e[1:])
helpers.is_int(e[1:])
for e in entities):
self._print('Each entity must be a string like Q<integer>')
return False
Expand Down Expand Up @@ -215,19 +215,3 @@ def sql_in_format(l):
"""
string_format = ', '.join(['%s'] * len(l))
return '(%s)' % string_format

@staticmethod
def is_int(s):
"""
Check if value is an int.
@param s: value to test
@type s: any
@return: if value can be interpreted as an integer
@rtype: bool
"""
try:
int(s)
return True
except (ValueError, TypeError):
return False
3 changes: 2 additions & 1 deletion wikidataStuff/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ def is_int(value):
@param value: The value to check
@type value: str, or int
@return bool
@return: if value can be interpreted as an integer
@rtype: bool
"""
try:
int(value)
Expand Down

0 comments on commit 9e68dd0

Please sign in to comment.