コード例 #1
0
ファイル: info.py プロジェクト: essil1/ase-laser
    def run(args):
        if not args.filename:
            print_info()
            if args.formats:
                print()
                print_formats()
            return

        n = max(len(filename) for filename in args.filename) + 2
        for filename in args.filename:
            try:
                format = filetype(filename)
            except FileNotFoundError:
                format = '?'
                description = 'No such file'
            except UnknownFileTypeError:
                format = '?'
                description = '?'
            else:
                description, code = all_formats.get(format, ('?', '?'))

            print('{:{}}{} ({})'.format(filename + ':', n,
                                        description, format))
            if args.verbose:
                if format == 'traj':
                    print_ulm_info(filename)
                elif format == 'bundletrajectory':
                    print_bundletrajectory_info(filename)
コード例 #2
0
ファイル: info.py プロジェクト: rchiechi/QuantumParse
    def run(args):
        if not args.filenames:
            print_info()
            return

        n = max(len(filename) for filename in args.filenames) + 2
        for filename in args.filenames:
            try:
                format = filetype(filename)
            except FileNotFoundError:
                format = '?'
                description = 'No such file'
            else:
                if format and format in all_formats:
                    description, code = all_formats[format]
                else:
                    format = '?'
                    description = '?'

            print('{:{}}{} ({})'.format(filename + ':', n,
                                        description, format))
            if args.verbose:
                if format == 'traj':
                    print_ulm_info(filename)
                elif format == 'bundletrajectory':
                    print_bundletrajectory_info(filename)
コード例 #3
0
ファイル: info.py プロジェクト: yfyh2013/ase
    def run(args):
        if not args.filenames:
            print_info()
            return

        n = max(len(filename) for filename in args.filenames) + 2
        for filename in args.filenames:
            try:
                format = filetype(filename)
            except FileNotFoundError:
                format = '?'
                description = 'No such file'
            else:
                if format and format in all_formats:
                    description, code = all_formats[format]
                else:
                    format = '?'
                    description = '?'

            print('{:{}}{} ({})'.format(filename + ':', n, description,
                                        format))
            if args.verbose:
                if format == 'traj':
                    print_ulm_info(filename)
                elif format == 'bundletrajectory':
                    print_bundletrajectory_info(filename)
コード例 #4
0
def test_bundletrajectory_info(images, bundletraj, capsys):
    print_bundletrajectory_info(bundletraj)
    output, _ = capsys.readouterr()

    natoms = len(images[0])
    expected_substring = f'Number of atoms: {natoms}'
    assert expected_substring in output

    # Same thing but via main():
    output2 = check_output(
        [sys.executable, '-m', 'ase.io.bundletrajectory', bundletraj],
        encoding='ascii')
    assert expected_substring in output2
コード例 #5
0
ファイル: info.py プロジェクト: grhawk/ASE
def main():
   p = OptionParser(usage='%prog file.traj [file2.traj ...]',
                    description=description)

   opts, args = p.parse_args()

   if len(args) == 0:
      p.error()

   for f in args:
      if os.path.isfile(f):
         print_trajectory_info(f)
      elif os.path.isdir(f):
         print_bundletrajectory_info(f)
      else:
         p.error('%s is neither a file nor a directory!' % f)
コード例 #6
0
    def run(args):
        if not args.filename:
            print_info()
            if args.formats:
                print()
                print_formats()
            if args.calculators:
                print()
                from ase.calculators.autodetect import (detect_calculators,
                                                        format_configs)
                configs = detect_calculators()
                print('Calculators:')
                for message in format_configs(configs):
                    print('  {}'.format(message))
                print()
                print('Available: {}'.format(','.join(sorted(configs))))
            return

        n = max(len(filename) for filename in args.filename) + 2
        nfiles_not_found = 0
        for filename in args.filename:
            try:
                format = filetype(filename)
            except FileNotFoundError:
                format = '?'
                description = 'No such file'
                nfiles_not_found += 1
            except UnknownFileTypeError:
                format = '?'
                description = '?'
            else:
                if format in ioformats:
                    description = ioformats[format].description
                else:
                    description = '?'

            print('{:{}}{} ({})'.format(filename + ':', n, description,
                                        format))
            if args.verbose:
                if format == 'traj':
                    print_ulm_info(filename)
                elif format == 'bundletrajectory':
                    print_bundletrajectory_info(filename)

        raise SystemExit(nfiles_not_found)
コード例 #7
0
ファイル: info.py プロジェクト: misdoro/python-ase
def main():
    p = OptionParser(usage='%prog file.traj [file2.traj ...]',
                     description=description)

    opts, args = p.parse_args()

    if len(args) == 0:
        p.error('Incorrect number of arguments')

    for f in args:
        ft = filetype(f)
        print("File type of '{0}' appears to be of type '{1}'".format(f, ft))
        if ft == 'traj':
            print_aff_info(f)
        elif tf == 'trj':
            print_trajectory_info(f)
        elif ft == 'bundle':
            print_bundletrajectory_info(f)
        else:
            p.error('%s is of type %s; cannot print info about this type of file' % f)
コード例 #8
0
ファイル: info.py プロジェクト: uu1477/MyAse
def main():
    p = OptionParser(usage='%prog file.traj [file2.traj ...]',
                     description=description)

    opts, args = p.parse_args()

    if len(args) == 0:
        p.error('Incorrect number of arguments')

    for f in args:
        ft = filetype(f)
        print("File type of '{0}' appears to be of type '{1}'".format(f, ft))
        if ft == 'traj':
            print_aff_info(f)
        elif ft == 'trj':
            print_trajectory_info(f)
        elif ft == 'bundle':
            print_bundletrajectory_info(f)
        else:
            p.error('%s is of type %s; cannot print info about this type of file' % f)