Skip to content

Commit

Permalink
Integrate Python scanf module into pyRAF
Browse files Browse the repository at this point in the history
  • Loading branch information
olebole committed Mar 18, 2024
1 parent 985c96a commit 4c19c30
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 452 deletions.
18 changes: 5 additions & 13 deletions pyraf/iraffunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ def _writeError(msg):
from . import cl2py as _cl2py
from . import gki
from . import irafecl
try:
from . import sscanf
except OSError:
# basic usage does not actually require sscanf
sscanf = None
print("Warning: sscanf library not installed on " + sys.platform)
from . import scanf


# FP_EPSILON is the smallest number such that: 1.0 + epsilon > 1.0; Use None
Expand Down Expand Up @@ -1988,15 +1983,12 @@ def fscanf(theLocals, line, format, *namelist, **kw):
_weirdEOF(theLocals, namelist)
_nscan = 0
return EOF
if sscanf is None:
raise RuntimeError("fscanf is not supported on this platform")
f = sscanf.sscanf(line, format)
n = min(len(f), len(namelist))
f = scanf.scanf(format, line)
# if list is null, add a null string
# ugly but should be right most of the time
if n == 0 and namelist:
f = ['']
n = 1
if f is None and namelist:
f = ('')
n = min(len(f), len(namelist))
if len(kw):
raise TypeError('unexpected keyword argument: ' +
repr(list(kw.keys())))
Expand Down
Loading

0 comments on commit 4c19c30

Please sign in to comment.