Checks that a reference format exists and if not, raises a helpful exception
5700
def _cli_check_ref_format(fmt):
    ''''''

    if fmt is None:
        return None

    fmt = fmt.lower()
    if not fmt in api.get_reference_formats():
        errstr = "Reference format '" + fmt + "' does not exist.\n"
        errstr += "For a complete list of formats, use the 'bse list-ref-formats' command"
        raise RuntimeError(errstr)

    return fmt
1269414
def _validate_format(req):
        '''
        
        '''
        #check for all required keys
        for key in SLOJSONRPC._min_keys:
            if not key in req:
                logging.debug('JSONRPC: Fmt Error: Need key "%s"' % key)
                raise SLOJSONRPCError(-32600)

        #check all keys if allowed
        for key in req.keys():
            if not key in SLOJSONRPC._allowed_keys:
                logging.debug('JSONRPC: Fmt Error: Not allowed key "%s"' % key)
                raise SLOJSONRPCError(-32600)

        #needs to be jsonrpc 2.0
        if req['jsonrpc'] != '2.0':
            logging.debug('JSONRPC: Fmt Error: "jsonrpc" needs to be "2.0"')
            raise SLOJSONRPCError(-32600)
324852
def check_crossrefs(self):
        
        broken = []
        for value in self.values():
            crossref = value.get('crossref')
            if crossref is not None:
                if crossref not in self:
                    broken.append(value)
        if len(broken):
            raise exceptions.BrokenCrossReferences('One or more cross reference could not'
                    ' be resolved', broken)
476311
def is_valid(self):
        
        return len(self.ref) == 1 and \
               len(self.alt) == 1 and \
               len(self.alt[0]) == 1
526280
def _CheckForExistingMappings(mapping_type, message_type,
                              python_name, json_name):
    """"""
    if mapping_type == 'field':
        getter = GetCustomJsonFieldMapping
    elif mapping_type == 'enum':
        getter = GetCustomJsonEnumMapping
    remapping = getter(message_type, python_name=python_name)
    if remapping is not None and remapping != json_name:
        raise exceptions.InvalidDataError(
            'Cannot add mapping for %s "%s", already mapped to "%s"' % (
                mapping_type, python_name, remapping))
    remapping = getter(message_type, json_name=json_name)
    if remapping is not None and remapping != python_name:
        raise exceptions.InvalidDataError(
            'Cannot add mapping for %s "%s", already mapped to "%s"' % (
                mapping_type, json_name, remapping))
283732
def check_header(filename, is_newly_created=False):
  """"""
  try:
    with open(filename, 'r') as pyfile:
      buf = ""
      for lineno in range(1,7):
        line = pyfile.readline()
        # Skip shebang line
        if lineno == 1 and line.startswith('#!'):
          line = pyfile.readline()
        # Check if the copyright year can be parsed as within the current century, or the current
        # year if it is a new file.
        if line.startswith("# Copyright"):
          year = line[12:16]
          if is_newly_created:
            if not year == _current_year:
              raise HeaderCheckFailure('{}: copyright year must be {} (was {})'
                                       .format(filename, _current_year, year))
          else:
            if not _current_century_regex.match(year):
              raise HeaderCheckFailure(
                "{}: copyright year must match '{}' (was {}): current year is {}"
                .format(filename, _current_century_regex.pattern, year, _current_year))
          line = "# Copyright YYYY" + line[16:]
        buf += line
      if buf != EXPECTED_HEADER:
        raise HeaderCheckFailure('{}: failed to parse header at all'
                                 .format(filename))
  except IOError as e:
    raise HeaderCheckFailure('{}: error while reading input ({})'
                             .format(filename, str(e)))
3249
private void checkForExistence(String fileName) throws IOException {
        File file = new File(fileName);
        if (!file.exists()) {
            throw new FileNotFoundException("File with name " + fileName + " does not exist.");
        }
        if (!file.isFile()) {
            throw new IOException("Provided string does not correspond to an actual file.");
        }

    }
646069
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException
   {
      // if node is in version storage - do not assign new id from jcr:uuid
      // property
      if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth()
         && currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3]
            .equals(Constants.JCR_FROZENNODE)
         && currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
      {
         return;
      }

      String identifier = validateUuidCollision(olUuid);

      if (identifier != null)
      {
         reloadChangesInfoAfterUC(currentNodeInfo, identifier);
      }
      else
      {
         currentNodeInfo.setIsNewIdentifer(true);
      }
      if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING)
      {
         NodeData parentNode = getParent();
         currentNodeInfo.setParentIdentifer(parentNode.getIdentifier());
         if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary())
         {
            // remove the temporary parent
            tree.pop();
         }
      }
   }
742289
def _pys_assert_version(self, line):
        """"""

        if float(line.strip()) > 1.0:
            # Abort if file version not supported
            msg = _("File version {version} unsupported (>1.0).").format(
                version=line.strip())
            raise ValueError(msg)
983337
def check_format(self, full_check=True):
        
        check_call(_LIB.MXNDArraySyncCheckFormat(self.handle, ctypes.c_bool(full_check)))
34926
private void checkL() throws DatatypeException, IOException {
        if (context.length() == 0) {
            appendToContext(current);
        }
        current = reader.read();
        appendToContext(current);
        skipSpaces();
        _checkL('L', true);
    }
1071589
def __raise_file_system_exception(self, item, directory):
        

        path = os.path.join(directory, item)
        if os.path.isfile(path):
            raise foundations.exceptions.FileExistsError(
                "{0} | A file with '{1}' name already exists in '{2}' directory!".format(self.__class__.__name__,
                                                                                         item,
                                                                                         directory))
        else:
            raise foundations.exceptions.DirectoryExistsError(
                "{0} | A directory with '{1}' name already exists in '{2}' directory!".format(self.__class__.__name__,
                                                                                              item,
                                                                                              directory))
984256
function assertion(keys) {
  var missing = keys.filter(isMissing);

  if (missing.length) {
    throw new ReferenceError(format(message, missing.join(', ')));
  }
}
1081346
def _bse_cli_list_ref_formats(args):
    ''''''
    all_refformats = api.get_reference_formats()

    if args.no_description:
        liststr = all_refformats.keys()
    else:
        liststr = format_columns(all_refformats.items())

    return '\n'.join(liststr)
712801
def handleException(self, exc_type, exc_param, exc_tb):
        ""
        self.writeline(''.join( traceback.format_exception(exc_type, exc_param, exc_tb) ))
        return True
996854
private void checkA() throws DatatypeException, IOException {
        if (context.length() == 0) {
            appendToContext(current);
        }
        current = reader.read();
        appendToContext(current);
        skipSpaces();
        boolean expectNumber = true;

        for (;;) {
            switch (current) {
                default:
                    if (expectNumber)
                        reportNonNumber('A', current);
                    return;

                case '+':
                case '-':
                case '.':
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    break;
            }

            checkArg('A', "rx radius");
            skipCommaSpaces();
            checkArg('A', "ry radius");
            skipCommaSpaces();
            checkArg('A', "x-axis-rotation");
            skipCommaSpaces();

            switch (current) {
                default:
                    reportUnexpected("\u201c0\u201d or \u201c1\u201d "
                            + "for large-arc-flag for \u201cA\u201d command",
                            current);
                    skipSubPath();
                    return;
                case '0':
                case '1':
                    break;
            }

            current = reader.read();
            appendToContext(current);
            skipCommaSpaces();

            switch (current) {
                default:
                    reportUnexpected("\u201c0\u201d or \u201c1\u201d "
                            + "for sweep-flag for \u201cA\u201d command",
                            current);
                    skipSubPath();
                    return;
                case '0':
                case '1':
                    break;
            }

            current = reader.read();
            appendToContext(current);
            skipCommaSpaces();

            checkArg('A', "x coordinate");
            skipCommaSpaces();
            checkArg('A', "y coordinate");

            expectNumber = skipCommaSpaces2();
        }
    }
53061
def _check(self, file):
        

        if not os.path.exists(file):
            raise Error("file \"{}\" not found".format(file))

        _, extension = os.path.splitext(file)
        try:
            check = self.extension_map[extension[1:]]
        except KeyError:
            magic_type = magic.from_file(file)
            for name, cls in self.magic_map.items():
                if name in magic_type:
                    check = cls
                    break
            else:
                raise Error("unknown file type \"{}\", skipping...".format(file))

        try:
            with open(file) as f:
                code = "\n".join(line.rstrip() for line in f)
        except UnicodeDecodeError:
            raise Error("file does not seem to contain text, skipping...")

        # Ensure we don't warn about adding trailing newline
        try:
            if code[-1] != '\n':
                code += '\n'
        except IndexError:
            pass

        return check(code)