Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniFdezAlvarez committed Aug 26, 2024
2 parents c317ecf + 17cbdd7 commit 9338431
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def read(file_path):
setup(
name = 'shexer',
packages = find_packages(exclude=["*.local_code.*"]), # this must be the same as the name above
version = '2.5.3',
version = '2.5.4',
description = 'Automatic schema extraction for RDF graphs',
author = 'Daniel Fernandez-Alvarez',
author_email = '[email protected]',
url = 'https://github.com/DaniFdezAlvarez/shexer',
download_url = 'https://github.com/DaniFdezAlvarez/shexer/archive/2.5.3.tar.gz',
download_url = 'https://github.com/DaniFdezAlvarez/shexer/archive/2.5.4.tar.gz',
keywords = ['testing', 'shexer', 'shexerp3', "rdf", "shex", "shacl", "schema"],
long_description = read('README.md'),
long_description_content_type='text/markdown',
Expand Down
6 changes: 3 additions & 3 deletions shexer/io/graph/yielder/nt_triples_yielder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from shexer.utils.log import log_to_error
from shexer.utils.log import log_msg
from shexer.utils.uri import there_is_arroba_after_last_quotes
from shexer.utils.triple_yielders import tune_prop, tune_token # , check_if_property_belongs_to_namespace_list
from shexer.io.graph.yielder.base_triples_yielder import BaseTriplesYielder
Expand Down Expand Up @@ -29,8 +29,8 @@ def yield_triples(self):
tokens = self._look_for_tokens(a_line.strip())
if len(tokens) != 3:
self._error_triples += 1
log_to_error(msg="This line was discarded: " + a_line,
source=self._source_file)
log_msg(msg="This line was discarded: " + a_line,
source=self._source_file)
else:
yield (tune_token(a_token=tokens[0]),
tune_prop(a_token=tokens[1]),
Expand Down
15 changes: 7 additions & 8 deletions shexer/io/graph/yielder/tsv_nt_triples_yielder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

from shexer.utils.log import log_to_error
from shexer.utils.log import log_msg
from shexer.utils.triple_yielders import tune_token, tune_prop
from shexer.io.graph.yielder.base_triples_yielder import BaseTriplesYielder

Expand Down Expand Up @@ -27,15 +26,15 @@ def yield_triples(self):
tokens = self._look_for_tokens(a_line.strip())
if len(tokens) != 3:
self._error_triples += 1
log_to_error(msg="This line caused error: " + a_line,
log_msg(msg="This line caused error: " + a_line,
source=self._source_file)
else:
try:
yield (
tune_token(tokens[0]), tune_prop(tokens[1]), tune_token(tokens[2], allow_untyped_numbers=True))
self._triples_count += 1
except ValueError as ve:
log_to_error(msg=ve.message + "This line caused error: " + a_line,
log_msg(msg=ve.message + "This line caused error: " + a_line,
source=self._source_file)
# if self._triples_count % 10000 == 0:
# print("Reading..." + self._triples_count)
Expand All @@ -61,7 +60,7 @@ def _reset_count(self):
# tokens = self._look_for_tokens(a_line.strip())
# if len(tokens) != 3:
# self._error_triples += 1
# log_to_error(msg="This line caused error: " + a_line,
# log_msg(msg="This line caused error: " + a_line,
# source=self._source_file)
# else:
# try:
Expand All @@ -70,7 +69,7 @@ def _reset_count(self):
# tune_token(tokens[2], allow_untyped_numbers=self._allow_untyped_numbers))
# self._triples_count += 1
# except ValueError as ve:
# log_to_error(msg=ve.message + "This line caused error: " + a_line,
# log_msg(msg=ve.message + "This line caused error: " + a_line,
# source=self._source_file)
# if self._triples_count % 10000 == 0:
# print("Reading..." + self._triples_count)
Expand All @@ -81,7 +80,7 @@ def _reset_count(self):
# tokens = self._look_for_tokens(a_line.strip())
# if len(tokens) != 3:
# self._error_triples += 1
# log_to_error(msg="This line caused error: " + a_line,
# log_msg(msg="This line caused error: " + a_line,
# source=self._source_file)
# else:
# try:
Expand All @@ -94,7 +93,7 @@ def _reset_count(self):
#
# self._triples_count += 1
# except ValueError as ve:
# log_to_error(msg=ve.message + "This line caused error: " + a_line,
# log_msg(msg=ve.message + "This line caused error: " + a_line,
# source=self._source_file)
# if self._triples_count % 10000 == 0:
# print("Reading..." + self._triples_count)
10 changes: 5 additions & 5 deletions shexer/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ def _curr_time():
return datetime.now().strftime("%d/%m/%Y %H:%M:%S -- ")


def log_to_error(msg, source=None, target_log=sys.stderr):
# pass
print(msg + ". Source: " + (source if source is not None else "Not specified"), file=target_log)
# def log_to_error(msg, source=None, target_log=sys.stderr):
# # pass
# print(msg + ". Source: " + (source if source is not None else "Not specified"), file=target_log)


def log_msg(verbose, msg):
def log_msg(verbose, msg, err=True):
if verbose:
print(_curr_time() + msg, flush=True)
print(_curr_time() + msg, flush=True, file=None if not err else sys.stderr)

0 comments on commit 9338431

Please sign in to comment.