group-list = mailbox-list / CFWS / obs-group-list obs-group-list = 1*([CFWS] ",") [CFWS]
(value)
| 1927 | |
| 1928 | |
| 1929 | def get_group_list(value): |
| 1930 | """ group-list = mailbox-list / CFWS / obs-group-list |
| 1931 | obs-group-list = 1*([CFWS] ",") [CFWS] |
| 1932 | |
| 1933 | """ |
| 1934 | group_list = GroupList() |
| 1935 | if not value: |
| 1936 | group_list.defects.append(errors.InvalidHeaderDefect( |
| 1937 | "end of header before group-list")) |
| 1938 | return group_list, value |
| 1939 | leader = None |
| 1940 | if value and value[0] in CFWS_LEADER: |
| 1941 | leader, value = get_cfws(value) |
| 1942 | if not value: |
| 1943 | # This should never happen in email parsing, since CFWS-only is a |
| 1944 | # legal alternative to group-list in a group, which is the only |
| 1945 | # place group-list appears. |
| 1946 | group_list.defects.append(errors.InvalidHeaderDefect( |
| 1947 | "end of header in group-list")) |
| 1948 | group_list.append(leader) |
| 1949 | return group_list, value |
| 1950 | if value[0] == ';': |
| 1951 | group_list.append(leader) |
| 1952 | return group_list, value |
| 1953 | token, value = get_mailbox_list(value) |
| 1954 | if len(token.all_mailboxes)==0: |
| 1955 | if leader is not None: |
| 1956 | group_list.append(leader) |
| 1957 | group_list.extend(token) |
| 1958 | group_list.defects.append(errors.ObsoleteHeaderDefect( |
| 1959 | "group-list with empty entries")) |
| 1960 | return group_list, value |
| 1961 | if leader is not None: |
| 1962 | token[:0] = [leader] |
| 1963 | group_list.append(token) |
| 1964 | return group_list, value |
| 1965 | |
| 1966 | def get_group(value): |
| 1967 | """ group = display-name ":" [group-list] ";" [CFWS] |