MCPcopy Create free account
hub / github.com/numpy/numpy / cracktypespec

Function cracktypespec

numpy/f2py/crackfortran.py:1860–1916  ·  view source on GitHub ↗
(typespec, selector)

Source from the content-addressed store, hash-verified

1858
1859
1860def cracktypespec(typespec, selector):
1861 kindselect = None
1862 charselect = None
1863 typename = None
1864 if selector:
1865 if typespec in ['complex', 'integer', 'logical', 'real']:
1866 kindselect = kindselector.match(selector)
1867 if not kindselect:
1868 outmess(
1869 'cracktypespec: no kindselector pattern found for %s\n' % (repr(selector)))
1870 return
1871 kindselect = kindselect.groupdict()
1872 kindselect['*'] = kindselect['kind2']
1873 del kindselect['kind2']
1874 for k in list(kindselect.keys()):
1875 if not kindselect[k]:
1876 del kindselect[k]
1877 for k, i in list(kindselect.items()):
1878 kindselect[k] = rmbadname1(i)
1879 elif typespec == 'character':
1880 charselect = charselector.match(selector)
1881 if not charselect:
1882 outmess(
1883 'cracktypespec: no charselector pattern found for %s\n' % (repr(selector)))
1884 return
1885 charselect = charselect.groupdict()
1886 charselect['*'] = charselect['charlen']
1887 del charselect['charlen']
1888 if charselect['lenkind']:
1889 lenkind = lenkindpattern.match(
1890 markoutercomma(charselect['lenkind']))
1891 lenkind = lenkind.groupdict()
1892 for lk in ['len', 'kind']:
1893 if lenkind[lk + '2']:
1894 lenkind[lk] = lenkind[lk + '2']
1895 charselect[lk] = lenkind[lk]
1896 del lenkind[lk + '2']
1897 if lenkind['f2py_len'] is not None:
1898 # used to specify the length of assumed length strings
1899 charselect['f2py_len'] = lenkind['f2py_len']
1900 del charselect['lenkind']
1901 for k in list(charselect.keys()):
1902 if not charselect[k]:
1903 del charselect[k]
1904 for k, i in list(charselect.items()):
1905 charselect[k] = rmbadname1(i)
1906 elif typespec == 'type':
1907 typename = re.match(r'\s*\(\s*(?P<name>\w+)\s*\)', selector, re.I)
1908 if typename:
1909 typename = typename.group('name')
1910 else:
1911 outmess('cracktypespec: no typename found in %s\n' %
1912 (repr(typespec + selector)))
1913 else:
1914 outmess('cracktypespec: no selector used for %s\n' %
1915 (repr(selector)))
1916 return kindselect, charselect, typename
1917######

Callers 3

analyzelineFunction · 0.85
updatevarsFunction · 0.85
analyzevarsFunction · 0.85

Calls 4

rmbadname1Function · 0.85
markoutercommaFunction · 0.85
keysMethod · 0.80
outmessFunction · 0.70

Tested by

no test coverage detected