[bugfix/descriptor] Änderung im Verhalten von leeren Strings#157
Open
KoenigMjr wants to merge 1 commit into
Open
[bugfix/descriptor] Änderung im Verhalten von leeren Strings#157KoenigMjr wants to merge 1 commit into
KoenigMjr wants to merge 1 commit into
Conversation
The descriptor module previously used a truthy check (`if description:`) to determine whether a matching description was found. In Python, an empty string (`""`) evaluates to False, causing the module to incorrectly fall back to the default `scan_value` when an empty replacement string was explicitly defined (e.g., in a fallback regex catch-all `.*,,true`). Switched the conditional check to `if description is not None:` to properly differentiate between a missing match (`None`) and an intentional empty replacement string (`""`). This ensures catch-all fallback entries in CSVs can clear fields as intended.
Contributor
Author
|
checks not successful aufgrund #156 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Beschreibung
Dieser PR behebt einen Fehler im
descriptor-Modul, bei dem explizit definierte, leere Ersetzungstexte (add: "") ignoriert wurden.Das Problem
Wenn man in einer CSV- oder YAML-Konfiguration ein Wildcard- oder Catch-All-Regex-Muster verwendet (zum Beispiel
.*,,true, um ein Feld zu leeren oder zurückzusetzen, falls keine andere Regel greift), fiel das Modul fälschlicherweise auf den ursprünglichenscan_valuezurück. Dies geschah, weil die "Truthy"-Prüfungif description:einen leeren String ("") genauso behandelte wieNone(kein Treffer gefunden).Die Lösung
Die bedingte Prüfung in
doWork()wurde vonif description:aufif description is not None:umgestellt. Dadurch wird die Logik für „kein Treffer gefunden“ sauber von „Treffer gefunden, aber der Zielwert ist leer“ getrennt. Das ermöglicht es nun, Felder absichtlich zu leeren oder mit einem leeren Text zu überschreiben.Technische Änderungen
if description:in der Hauptschleife vondoWorkzuif description is not None:geändert.Verifizierung / Testergebnisse
.*,,true) das Zielfeld nun erfolgreich mit einem leeren String überschreiben.add-value) weiterhin korrekt zugewiesen werden, ohne die Abwärtskompatibilität zu beeinträchtigen._find_descriptionden WertNonezurückgibt.