Coverage for jsanctions/management/commands/show_unique_json_values.py: 0%

# Coverage for jsanctions/management/commands/show_unique_json_values.py : 0%

## 26 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 from jutil.command import SafeCommand

2

3 from jsanctions.un import load_un_sanction_list_as_dict

4

5

6 class Command(SafeCommand):

7 help = "Shows unique JSON values in data file"

8

9 def do(self, *args, **options): # pylint: disable=too-many-branches

10 data = load_un_sanction_list_as_dict('data/un/consolidated.xml')

11

12 print('INDIVIDUALS')

13 vals = set()

14 for e in data['INDIVIDUALS']['INDIVIDUAL']:

15 if 'INDIVIDUAL_DOCUMENT' in e:

16 for e2 in e['INDIVIDUAL_DOCUMENT']:

17 if not e2:

18 continue

19 for k in e2.keys():

20 vals.add(k)

21 print(vals)

22

23 print('ENTITIES')

24 vals = set()

25 for e in data['ENTITIES']['ENTITY']:

26 if 'ENTITY_ADDRESS' in e:

27 for e2 in e['ENTITY_ADDRESS']:

28 if not e2:

29 continue

30 for k in e2.keys():

31 vals.add(k)

32

33 print(vals)