Returns last_name, the variable name without special chars, parenthesis or dimension specifiers. Alters groupcache to add the name, typespec, attrspec (and possibly value) of current variable.
(typespec, selector, attrspec, entitydecl)
| 1689 | |
| 1690 | |
| 1691 | def updatevars(typespec, selector, attrspec, entitydecl): |
| 1692 | """ |
| 1693 | Returns last_name, the variable name without special chars, parenthesis |
| 1694 | or dimension specifiers. |
| 1695 | |
| 1696 | Alters groupcache to add the name, typespec, attrspec (and possibly value) |
| 1697 | of current variable. |
| 1698 | """ |
| 1699 | global groupcache, groupcounter |
| 1700 | |
| 1701 | last_name = None |
| 1702 | kindselect, charselect, typename = cracktypespec(typespec, selector) |
| 1703 | # Clean up outer commas, whitespace and undesired chars from attrspec |
| 1704 | if attrspec: |
| 1705 | attrspec = [x.strip() for x in markoutercomma(attrspec).split('@,@')] |
| 1706 | l = [] |
| 1707 | c = re.compile(r'(?P<start>[a-zA-Z]+)') |
| 1708 | for a in attrspec: |
| 1709 | if not a: |
| 1710 | continue |
| 1711 | m = c.match(a) |
| 1712 | if m: |
| 1713 | s = m.group('start').lower() |
| 1714 | a = s + a[len(s):] |
| 1715 | l.append(a) |
| 1716 | attrspec = l |
| 1717 | el = [x.strip() for x in markoutercomma(entitydecl).split('@,@')] |
| 1718 | el1 = [] |
| 1719 | for e in el: |
| 1720 | for e1 in [x.strip() for x in markoutercomma(removespaces(markinnerspaces(e)), comma=' ').split('@ @')]: |
| 1721 | if e1: |
| 1722 | el1.append(e1.replace('@_@', ' ')) |
| 1723 | for e in el1: |
| 1724 | m = namepattern.match(e) |
| 1725 | if not m: |
| 1726 | outmess( |
| 1727 | 'updatevars: no name pattern found for entity=%s. Skipping.\n' % (repr(e))) |
| 1728 | continue |
| 1729 | ename = rmbadname1(m.group('name')) |
| 1730 | edecl = {} |
| 1731 | if ename in groupcache[groupcounter]['vars']: |
| 1732 | edecl = groupcache[groupcounter]['vars'][ename].copy() |
| 1733 | not_has_typespec = 'typespec' not in edecl |
| 1734 | if not_has_typespec: |
| 1735 | edecl['typespec'] = typespec |
| 1736 | elif typespec and (not typespec == edecl['typespec']): |
| 1737 | outmess('updatevars: attempt to change the type of "%s" ("%s") to "%s". Ignoring.\n' % ( |
| 1738 | ename, edecl['typespec'], typespec)) |
| 1739 | if 'kindselector' not in edecl: |
| 1740 | edecl['kindselector'] = copy.copy(kindselect) |
| 1741 | elif kindselect: |
| 1742 | for k in list(kindselect.keys()): |
| 1743 | if k in edecl['kindselector'] and (not kindselect[k] == edecl['kindselector'][k]): |
| 1744 | outmess('updatevars: attempt to change the kindselector "%s" of "%s" ("%s") to "%s". Ignoring.\n' % ( |
| 1745 | k, ename, edecl['kindselector'][k], kindselect[k])) |
| 1746 | else: |
| 1747 | edecl['kindselector'][k] = copy.copy(kindselect[k]) |
| 1748 | if 'charselector' not in edecl and charselect: |
no test coverage detected