コード例 #1
0
 def _load_schema(self):
     schema_file = os.path.abspath(os.path.join(
         common.get_schemadir(), 'snapcraft.yaml'))
     try:
         with open(schema_file) as fp:
             self._schema = yaml.load(fp)
     except FileNotFoundError:
         raise errors.SnapcraftSchemaError(
             'snapcraft validation file is missing from installation path')
コード例 #2
0
def _snapcraft_yaml_load(yaml_file):
    with open(yaml_file, 'rb') as fp:
        bs = fp.read(2)

    if bs == codecs.BOM_UTF16_LE or bs == codecs.BOM_UTF16_BE:
        encoding = 'utf-16'
    else:
        encoding = 'utf-8'

    try:
        with open(yaml_file, encoding=encoding) as fp:
            return yaml.load(fp)
    except yaml.scanner.ScannerError as e:
        raise errors.SnapcraftSchemaError('{} on line {} of {}'.format(
            e.problem, e.problem_mark.line + 1, yaml_file))