misc: extend |getlist on blocks, for compatibility names (#89777) #1423

Merged
fpeters merged 2 commits from wip/89777-getlist-block-relations into main 2024-04-26 08:30:18 +02:00
Owner
No description provided.
fpeters added 1 commit 2024-04-19 10:37:16 +02:00
fpeters force-pushed wip/89777-getlist-block-relations from 3612b0df16 to 804d5c00fc 2024-04-19 10:50:11 +02:00 Compare
fpeters force-pushed wip/89777-getlist-block-relations from 804d5c00fc to da1be3fd7f 2024-04-19 11:20:00 +02:00 Compare
fpeters changed title from WIP: getlist on blocks, with compatibility names (89663 à la base) to WIP: misc: extend |getlist on blocks, for compatibility names (#89777) 2024-04-19 11:20:13 +02:00
fpeters changed title from WIP: misc: extend |getlist on blocks, for compatibility names (#89777) to misc: extend |getlist on blocks, for compatibility names (#89777) 2024-04-19 11:56:27 +02:00
bdauvergne requested changes 2024-04-19 16:11:46 +02:00
Dismissed
wcs/variables.py Outdated
@ -1905,2 +1905,3 @@
else:
raise AttributeError('No such attribute %r' % key)
value = [CompatibilityNamesDict({'X': x}).get(f'X_{key}') for x in self]
if all(x is None for x in value):
Owner

Dans quel cas on aurait CompatibilityNamesDict({'X': x})[f'X_{key}'] qui lèverait KeyError pour un x mais pas tous ? Si ça n'arrive pas ça me parait plus sûr de juste faire

try:
     return [CompatibilityNamesDict({'X': x})[f'X_{key}'] for x in self]
except KeyError:
     raise AttributeError('No such attribute %s' % key)

Aussi all(x is None for x in value) est vrai si value est vide et il y a le cas où card_live_var_plop vaut effectivement None qu'il ne faudrait pas forcément empêcher.

Dans quel cas on aurait CompatibilityNamesDict({'X': x})[f'X_{key}'] qui lèverait KeyError pour un x mais pas tous ? Si ça n'arrive pas ça me parait plus sûr de juste faire ``` try: return [CompatibilityNamesDict({'X': x})[f'X_{key}'] for x in self] except KeyError: raise AttributeError('No such attribute %s' % key) ``` Aussi all(x is None for x in value) est vrai si value est vide et il y a le cas où card_live_var_plop vaut effectivement None qu'il ne faudrait pas forcément empêcher.
fpeters force-pushed wip/89777-getlist-block-relations from da1be3fd7f to 3d0bd02311 2024-04-21 10:32:45 +02:00 Compare
fpeters reviewed 2024-04-21 10:35:15 +02:00
@ -5158,0 +5196,4 @@
# add empty data
carddata = carddef.data_class()()
carddata.data = {}
Author
Owner

Test étendu avec une fiche vide, pour être sûr qu'une valeur est quand même obtenue.

Test étendu avec une fiche vide, pour être sûr qu'une valeur est quand même obtenue.
@ -665,3 +665,3 @@
warnings.warn('Deprecated access to formdef', DeprecationWarning)
return self._formdef
raise AttributeError('No such attribute %r' % attribute)
raise AttributeError(attribute)
Author
Owner

En passant sur l'AttributeError je me rends compte que ça devrait juste lever l'attribut en paramètre, ça se trouve dans le code initialement concerné par le ticket et à un autre endroit (ici), je le modifie dans un petit commit supplémentaire.

En passant sur l'AttributeError je me rends compte que ça devrait juste lever l'attribut en paramètre, ça se trouve dans le code initialement concerné par le ticket et à un autre endroit (ici), je le modifie dans un petit commit supplémentaire.
@ -1907,0 +1907,4 @@
value = [CompatibilityNamesDict({'X': x})[f'X_{key}'] for x in self]
except KeyError:
raise AttributeError(str(key))
return value
Author
Owner

Mise en place de la suggestion de Benjamin.

Mise en place de la suggestion de Benjamin.
fpeters dismissed bdauvergne’s review 2024-04-21 10:35:25 +02:00
Reason:

(prise en compte)

bdauvergne approved these changes 2024-04-21 20:36:55 +02:00
fpeters merged commit 19454beb04 into main 2024-04-26 08:30:18 +02:00
fpeters deleted branch wip/89777-getlist-block-relations 2024-04-26 08:30:18 +02:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: entrouvert/wcs#1423
No description provided.