Skip to content
Snippets Groups Projects
Commit b58b599f authored by florian's avatar florian
Browse files

STY: autopep'd

parent 42ca0bec
No related branches found
No related tags found
2 merge requests!53Release 0.1,!35FIX: Fix number of arguments in main crawler function
Pipeline #28519 failed
...@@ -823,7 +823,8 @@ class Crawler(object): ...@@ -823,7 +823,8 @@ class Crawler(object):
if self.identifiableAdapter is None: if self.identifiableAdapter is None:
raise RuntimeError("Should not happen.") raise RuntimeError("Should not happen.")
to_be_inserted, to_be_updated = self.split_into_inserts_and_updates(target_data) to_be_inserted, to_be_updated = self.split_into_inserts_and_updates(
target_data)
# TODO: refactoring of typo # TODO: refactoring of typo
for el in to_be_updated: for el in to_be_updated:
...@@ -831,14 +832,17 @@ class Crawler(object): ...@@ -831,14 +832,17 @@ class Crawler(object):
self.replace_entities_with_ids(el) self.replace_entities_with_ids(el)
identified_records = [ identified_records = [
self.identifiableAdapter.retrieve_identified_record_for_record(record) self.identifiableAdapter.retrieve_identified_record_for_record(
record)
for record in to_be_updated] for record in to_be_updated]
# remove unnecessary updates from list by comparing the target records to the existing ones # remove unnecessary updates from list by comparing the target records to the existing ones
self.remove_unnecessary_updates(to_be_updated, identified_records) self.remove_unnecessary_updates(to_be_updated, identified_records)
if commit_changes: if commit_changes:
self.execute_inserts_in_list(to_be_inserted, self.securityMode, self.run_id) self.execute_inserts_in_list(
self.execute_updates_in_list(to_be_updated, self.securityMode, self.run_id) to_be_inserted, self.securityMode, self.run_id)
self.execute_updates_in_list(
to_be_updated, self.securityMode, self.run_id)
update_cache = UpdateCache() update_cache = UpdateCache()
pending_inserts = update_cache.get_inserts(self.run_id) pending_inserts = update_cache.get_inserts(self.run_id)
...@@ -859,7 +863,8 @@ class Crawler(object): ...@@ -859,7 +863,8 @@ class Crawler(object):
# only done in SSS mode # only done in SSS mode
if "SHARED_DIR" in os.environ: if "SHARED_DIR" in os.environ:
filename = OldCrawler.save_form([el[3] for el in pending_changes], path, run_id) filename = OldCrawler.save_form(
[el[3] for el in pending_changes], path, run_id)
OldCrawler.send_mail([el[3] for el in pending_changes], filename) OldCrawler.send_mail([el[3] for el in pending_changes], filename)
for i, el in enumerate(pending_changes): for i, el in enumerate(pending_changes):
...@@ -870,7 +875,8 @@ UNAUTHORIZED UPDATE ({} of {}): ...@@ -870,7 +875,8 @@ UNAUTHORIZED UPDATE ({} of {}):
____________________\n""".format(i + 1, len(pending_changes)) + str(el[3])) ____________________\n""".format(i + 1, len(pending_changes)) + str(el[3]))
logger.info("There were unauthorized changes (see above). An " logger.info("There were unauthorized changes (see above). An "
"email was sent to the curator.\n" "email was sent to the curator.\n"
"You can authorize the " + ("inserts" if inserts else "updates") "You can authorize the " +
("inserts" if inserts else "updates")
+ " by invoking the crawler" + " by invoking the crawler"
" with the run id: {rid}\n".format(rid=run_id)) " with the run id: {rid}\n".format(rid=run_id))
...@@ -1121,6 +1127,7 @@ def parse_args(): ...@@ -1121,6 +1127,7 @@ def parse_args():
return parser.parse_args() return parser.parse_args()
def main(): def main():
args = parse_args() args = parse_args()
...@@ -1147,5 +1154,6 @@ def main(): ...@@ -1147,5 +1154,6 @@ def main():
"update": SecurityMode.UPDATE}[args.security_mode] "update": SecurityMode.UPDATE}[args.security_mode]
)) ))
if __name__ == "__main__": if __name__ == "__main__":
main() main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment