Changeset 2979 for branch


Ignore:
Timestamp:
Aug 9, 2017 12:08:10 PM (6 years ago)
Author:
toby
Message:

add scriptable option to browse data structure in IPython

Location:
branch/2frame
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branch/2frame/GSASIIpath.py

    r2967 r2979  
    549549   
    550550
    551 def IPyBreak_base():
     551def IPyBreak_base(userMsg=None):
    552552    '''A routine that invokes an IPython session at the calling location
    553553    This routine is only used when debug=True is set in config.py
     
    568568    frame = inspect.currentframe().f_back
    569569    msg   = 'Entering IPython console inside {0.f_code.co_filename} at line {0.f_lineno}\n'.format(frame)
     570    if userMsg: msg += userMsg
    570571    ipshell(msg,stack_depth=2) # Go up one level, to see the calling routine
    571572    sys.excepthook = savehook # reset IPython's change to the exception hook
  • branch/2frame/GSASIIscriptable.py

    r2974 r2979  
    14811481                for p in phases:
    14821482                    print(fname, p.name)
    1483 
     1483def IPyBrowse(*args):
     1484    """Load a .gpx file and then open a IPython shell to browse it
     1485    """
     1486    filename = []
     1487    for arg in args:
     1488        fname = arg
     1489        proj, nameList = LoadDictFromProjFile(fname)
     1490        msg = "\nfile {} loaded into proj (dict) with names in nameList".format(fname)
     1491        GSASIIpath.IPyBreak_base(msg)
     1492        break
    14841493
    14851494def refine(*args):
     
    15041513               "refine": refine,
    15051514               "seqrefine": seqrefine,
    1506                "export": export}
     1515               "export": export,
     1516               "browse": IPyBrowse}
    15071517
    15081518
     
    15151525    elif len(argv) == 1 or argv[1] in ('help', '--help', '-h'):
    15161526        # TODO print usage
    1517         subcommand_names = ' | '.join(subcommands.keys())
     1527        subcommand_names = ' | '.join(sorted(subcommands.keys()))
    15181528        print("USAGE: {} [ {} ] ...".format(argv[0], subcommand_names))
    15191529    else:
    15201530        print("Unknown subcommand: {}".format(argv[1]))
    15211531        print("Available subcommands:")
    1522         for name in subcommands.keys():
     1532        for name in sorted(subcommands.keys()):
    15231533            print("\t{}".format(name))
    15241534        sys.exit(-1)
Note: See TracChangeset for help on using the changeset viewer.