예제 #1
0
 def from_json_file(filename, check_format=True):
   ''' Decode a datablock from a JSON file. '''
   from os.path import dirname, abspath
   from dxtbx.serialize.filename import temp_chdir
   filename = abspath(filename)
   with temp_chdir(dirname(filename)):
     with open(filename, 'r') as infile:
       return DataBlockFactory.from_json(infile.read(), check_format)
예제 #2
0
 def from_json_file(filename, check_format=True):
   ''' Load an experiment list from a json file. '''
   from dxtbx.serialize.filename import temp_chdir
   from os.path import dirname, abspath
   filename = abspath(filename)
   with temp_chdir(dirname(filename)):
     with open(filename, 'r') as infile:
       return ExperimentListFactory.from_json(infile.read(), check_format)
예제 #3
0
 def from_json_file(filename, check_format=True):
   ''' Decode a datablock from a JSON file. '''
   from os.path import dirname, abspath
   from dxtbx.serialize.filename import temp_chdir
   filename = abspath(filename)
   with temp_chdir(dirname(filename)):
     with open(filename, 'r') as infile:
       return DataBlockFactory.from_json(infile.read(), check_format)
예제 #4
0
 def from_json_file(filename, check_format=True):
   ''' Load an experiment list from a json file. '''
   from dxtbx.serialize.filename import temp_chdir
   from os.path import dirname, abspath
   filename = abspath(filename)
   with temp_chdir(dirname(filename)):
     with open(filename, 'r') as infile:
       return ExperimentListFactory.from_json(infile.read(), check_format)
예제 #5
0
 def tst_temp_chdir(self):
     from os import getcwd
     from os.path import join, realpath
     import libtbx
     cwd = realpath(getcwd())
     new_path = realpath(join(libtbx.env.dist_path('dxtbx'), 'serialize'))
     with temp_chdir(new_path):
         assert (realpath(getcwd()) == new_path)
     assert (realpath(getcwd()) == cwd)
     print 'OK'
예제 #6
0
 def tst_temp_chdir(self):
   from os import getcwd
   from os.path import join, realpath
   import libtbx
   cwd = realpath(getcwd())
   new_path = realpath(join(libtbx.env.dist_path('dxtbx'), 'serialize'))
   with temp_chdir(new_path):
     assert(realpath(getcwd()) == new_path)
   assert(realpath(getcwd()) == cwd)
   print 'OK'
예제 #7
0
 def _from_file(filename):
   ''' Load a model dictionary from a file. '''
   from dxtbx.serialize.load import _decode_dict
   from dxtbx.serialize.filename import load_path, temp_chdir
   import json
   from os.path import dirname
   filename = load_path(filename)
   try:
     with temp_chdir(dirname(filename)):
       with open(filename, 'r') as infile:
         return json.loads(infile.read(), object_hook=_decode_dict)
   except IOError, e:
     raise IOError('unable to read file, %s' % filename)
예제 #8
0
 def _from_file(filename):
     ''' Load a model dictionary from a file. '''
     from dxtbx.serialize.load import _decode_dict
     from dxtbx.serialize.filename import load_path, temp_chdir
     import json
     from os.path import dirname
     filename = load_path(filename)
     try:
         with temp_chdir(dirname(filename)):
             with open(filename, 'r') as infile:
                 return json.load(infile, object_hook=_decode_dict)
     except IOError:
         raise IOError('unable to read file, %s' % filename)
예제 #9
0
파일: load.py 프로젝트: hainm/cctbx_project
def imageset(filename):
  ''' Load the given JSON file.

  Params:
      infile The input filename

  Returns:
      The models

  '''
  from dxtbx.serialize.filename import temp_chdir
  from os.path import abspath, dirname
  # If the input is a string then open and read from that file
  filename = abspath(filename)
  with temp_chdir(dirname(filename)):
    with open(filename, 'r') as infile:
      return imageset_from_string(infile.read())