<commit_before>@import './list';

// error generator
// ---------------
@function class--throw-error($classname, $prop, $msg) {
  @return 'The attribute #{$prop} from the class #{$classname} #{$msg}';
}


// choices checker
// ---------------
@function class--choices($classname, $prop, $value, $choices) {
  // if the $choices is not a list, converts it into a list
  $choices: convert-into-list($choices);

  // if $value is not one the value of choices throw an error
  @if not index($choices, $value) {
    @error '#{class--throw-error($classname, $prop, 'must be one of thoses value : #{$choices}')}';
  }

  @return true;
}


// nullable checker
// ----------------
@function class--nullable($classname, $prop, $value, $nullable) {
  // if $value is null and $nullable is not accepted
  @if ($value == null and not $nullable) {
    @error '#{class--throw-error($classname, $prop, 'cannot be null')}';
  }

  @return true;
}


// type checker
// ------------
@function class--type($classname, $prop, $value, $type) {
  // if the $value do not respect the $type passed
  @if type-of($value) != $type and $value != null {
    @error '#{class--throw-error($classname, $prop, 'must be a #{$type}')}';
  }

  @return true;
}


// collection
// TDB if required


// attribute getter
// ----------------
@function class--get-attribute($class, $prop, $nth: null) {
  $value: map-get($class, $prop);

  @if $nth and type-of($value) == 'list' {
    @return nth($value, $nth);
  }

  @return $value;
}


// attribute setter
// ---------------
@function class--set-attribute($class, $prop, $value) {
  @return map-merge($class, ($prop: $value));
}

// append attribute
@function class--append-attribute($class, $prop, $value) {
  $previous-value: class--get-attribute($class, $prop);

  @if not $previous-value {
    @return class--set-attribute($class, $prop, ($value, ));
  }

  $previous-value: convert-into-list($previous-value);
  @return class--set-attribute($class, $prop, append($previous-value, $value));
}<commit_msg>avoid object with null as prop value<commit_after>@import './list';

// error generator
// ---------------
@function class--throw-error($classname, $prop, $msg) {
  @return 'The attribute #{$prop} from the class #{$classname} #{$msg}';
}


// choices checker
// ---------------
@function class--choices($classname, $prop, $value, $choices) {
  // if the $choices is not a list, converts it into a list
  $choices: convert-into-list($choices);

  // if $value is not one the value of choices throw an error
  @if not index($choices, $value) {
    @error '#{class--throw-error($classname, $prop, 'must be one of thoses value : #{$choices}')}';
  }

  @return true;
}


// nullable checker
// ----------------
@function class--nullable($classname, $prop, $value, $nullable) {
  // if $value is null and $nullable is not accepted
  @if ($value == null and not $nullable) {
    @error '#{class--throw-error($classname, $prop, 'cannot be null')}';
  }

  @return true;
}


// type checker
// ------------
@function class--type($classname, $prop, $value, $type) {
  // if the $value do not respect the $type passed
  @if type-of($value) != $type and $value != null {
    @error '#{class--throw-error($classname, $prop, 'must be a #{$type}')}';
  }

  @return true;
}


// collection
// TDB if required


// attribute getter
// ----------------
@function class--get-attribute($class, $prop, $nth: null) {
  $value: map-get($class, $prop);

  @if $nth and type-of($value) == 'list' {
    @return nth($value, $nth);
  }

  @return $value;
}


// attribute setter
// ---------------
@function class--set-attribute($class, $prop, $value) {
  // avoid to return prop with null as value
  @if not $value {
    @return $class;
  }

  @return map-merge($class, ($prop: $value));
}

// append attribute
@function class--append-attribute($class, $prop, $value) {
  $previous-value: class--get-attribute($class, $prop);

  @if not $previous-value {
    @return class--set-attribute($class, $prop, ($value, ));
  }

  $previous-value: convert-into-list($previous-value);
  @return class--set-attribute($class, $prop, append($previous-value, $value));
}
{'fraction_non_alphanumeric': 0.2251926782273603, 'fraction_numerical': 0.0, 'mean_word_length': 2.947718631178707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2328558', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1362, 'n_words': 389}