Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet committed Aug 13, 2024
1 parent 07e9a33 commit 1602de7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions checkcel/checkcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ def validate(self):
validator_set = set(self.validators)
self.missing_validators = self.column_set - validator_set
if self.missing_validators:
self.info("\033[1;33m", "Missing...", "\033[0m")
self._log_missing_validators()

if not self.ignore_missing_validators:
self.info("\033[1;33m", "Missing...", "\033[0m")
self._log_missing_validators()
return False

self.missing_fields = validator_set - self.column_set
Expand Down
3 changes: 3 additions & 0 deletions checkcel/checkplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def load_from_python_file(self, file_path):
self.ignore_space = getattr(custom_class, 'ignore_space', False)
self.expected_rows = getattr(custom_class, 'expected_rows', 0)
self.freeze_header = getattr(custom_class, 'freeze_header', False)
self.ignore_missing_validators = getattr(custom_class, 'ignore_missing_validators', False)
try:
self.expected_rows = int(self.expected_rows)
except ValueError:
Expand Down Expand Up @@ -154,6 +155,8 @@ def _load_from_dict(self, data):
self.skip_generation = data.get('skip_generation', False)
self.skip_validation = data.get('skip_validation', False)
self.freeze_header = data.get('freeze_header', False)
self.ignore_missing_validators = data.get('ignore_missing_validators', False)

try:
self.expected_rows = int(self.expected_rows)
except ValueError:
Expand Down
16 changes: 16 additions & 0 deletions checkcel/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def validate(self, field, row_number, row):

if field and self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -252,6 +254,8 @@ def validate(self, field, row_number, row):

if field and self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -367,6 +371,8 @@ def validate(self, field, row_number, row):
)
if field and self.unique:
if str(field) in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(str(field))

Expand Down Expand Up @@ -467,6 +473,8 @@ def validate(self, field, row_number, row):

if field and self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -578,6 +586,8 @@ def validate(self, field, row_number, row):

if field and self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -686,6 +696,8 @@ def validate(self, field, row_number, row):

if field and self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -764,6 +776,8 @@ def validate(self, field, row_number, row):
raise ValidationException(e)
if self.unique:
if field in self.unique_values:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException("'{}' is already in the column".format(field))
self.unique_values.add(field)

Expand Down Expand Up @@ -968,6 +982,8 @@ def validate(self, field, row_number, row):
if self._can_be_empty(row):
return
else:
self.invalid_dict["invalid_set"].add(field)
self.invalid_dict["invalid_rows"].add(row_number)
raise ValidationException(
"Field cannot be empty"
)
Expand Down

0 comments on commit 1602de7

Please sign in to comment.