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

Function is_free_format

numpy/distutils/fcompiler/__init__.py:984–1005  ·  view source on GitHub ↗

Check if file is in free format Fortran.

(file)

Source from the content-addressed store, hash-verified

982_free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]', re.I).match
983
984def is_free_format(file):
985 """Check if file is in free format Fortran."""
986 # f90 allows both fixed and free format, assuming fixed unless
987 # signs of free format are detected.
988 result = 0
989 with open(file, encoding='latin1') as f:
990 line = f.readline()
991 n = 10000 # the number of non-comment lines to scan for hints
992 if _has_f_header(line) or _has_fix_header(line):
993 n = 0
994 elif _has_f90_header(line):
995 n = 0
996 result = 1
997 while n>0 and line:
998 line = line.rstrip()
999 if line and line[0]!='!':
1000 n -= 1
1001 if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-1:]=='&':
1002 result = 1
1003 break
1004 line = f.readline()
1005 return result
1006
1007def has_f90_header(src):
1008 with open(src, encoding='latin1') as f:

Callers 1

_compileMethod · 0.70

Calls 2

openFunction · 0.85
rstripMethod · 0.80

Tested by

no test coverage detected