コード例 #1
0
def load_model_files(args):
    model = json.load(open(args.modelfile),
                      object_pairs_hook=OrderedDict)
    retry = json.load(open(args.retry_file),
                      object_pairs_hook=OrderedDict)
    enhancements = _load_enhancements_file(args.enhancements_file)
    service_name = os.path.splitext(os.path.basename(args.modelfile))[0]
    return ModelFiles(model, retry, enhancements, name=service_name)
コード例 #2
0
    def load_file(self, file_path):
        """
        Loads a regular data file (format-specific to subclass).

        This load is done uncached, so that you can always get the latest data
        as needed.

        Usage::

            >>> loader = JSONFileLoader()
            >>> loader.load_file('/path/to/some/thing.json')
            {
                # ...JSON data...
            }

        """
        try:
            with open(file_path) as fp:
                return json.load(fp, object_pairs_hook=OrderedDict)
        except ValueError:
            # For backward-compatibility with the previous implementation,
            # if the JSON is bad, we'll raise a ``DataNotFoundError`` exception
            # instead of letting it propagate.
            raise DataNotFoundError(data_path=file_path)
コード例 #3
0
    def load_file(self, file_path):
        """
        Loads a regular data file (format-specific to subclass).

        This load is done uncached, so that you can always get the latest data
        as needed.

        Usage::

            >>> loader = JSONFileLoader()
            >>> loader.load_file('/path/to/some/thing.json')
            {
                # ...JSON data...
            }

        """
        try:
            with open(file_path) as fp:
                return json.load(fp, object_pairs_hook=OrderedDict)
        except ValueError:
            # For backward-compatibility with the previous implementation,
            # if the JSON is bad, we'll raise a ``DataNotFoundError`` exception
            # instead of letting it propagate.
            raise DataNotFoundError(data_path=file_path)
コード例 #4
0
ファイル: translate.py プロジェクト: ttacon/awsebcli
def _load_enhancements_file(file_path):
    if not os.path.isfile(file_path):
        return {}
    else:
        return json.load(open(file_path), object_pairs_hook=OrderedDict)
コード例 #5
0
ファイル: translate.py プロジェクト: ttacon/awsebcli
def load_model_files(args):
    model = json.load(open(args.modelfile), object_pairs_hook=OrderedDict)
    retry = json.load(open(args.retry_file), object_pairs_hook=OrderedDict)
    enhancements = _load_enhancements_file(args.enhancements_file)
    service_name = os.path.splitext(os.path.basename(args.modelfile))[0]
    return ModelFiles(model, retry, enhancements, name=service_name)
コード例 #6
0
def _load_enhancements_file(file_path):
    if not os.path.isfile(file_path):
        return {}
    else:
        return json.load(open(file_path),
                         object_pairs_hook=OrderedDict)