Check if the given order book is valid.

        :param book: Order book name.
        :type book: str | unicode
        :raise InvalidOrderBookError: If an invalid order book is given.
322324
def _validate_order_book(self, book):
        
        if book not in self.order_books:
            raise InvalidOrderBookError(
                'Invalid order book \'{}\'. Choose from {}.'
                .format(book, tuple(self.order_books))
            )
661083
def bookable_must_be_bookable
        if bookable.present? && !bookable.class.bookable?
          errors.add(:bookable, T.er('booking.bookable_must_be_bookable', model: bookable.class.to_s))
        end
      end
532486
def check_valid(self):
		
		for k,input in self.inputs.items():
			if k in self.valid_opts:
				for param in self.valid_opts[k]:
					if param is None or input is None:
						return True
					elif type(param) is str and '+' in param:
						if re.search(r'^'+param,str(input)):
							return True
					elif type(param) is bool and type(input) is bool:
						return True
					elif type(param) is list and type(input) is list:
						return True
					else:
						if str(input).lower() == str(param):
							return True
				raise ValueError("Invalid input for '%s' parameter. Options are: %s" % (k,' '.join(["'%s'," % str(o) for o in self.valid_opts[k]]) ))
			else:
				raise ValueError("Invalid parameter for '%s'. Params are: %s" % (self.__class__.__name__,', '.join(["'%s'" % p for p in self.valid_opts.keys()]) ))
718146
def isbn10(self):
        '''
        
        '''
        if self._id[0:3] != '978':
            raise ISBNError("Invalid Bookland code: {}".format(self._id[0:3]))
        digit10 = _digit10(self._id[3:12])
        if digit10 == 10:
            return self._id[3:12] + 'X'
        else:
            return self._id[3:12] + str(digit10)
272879
def validate_read(self, kwargs):
        
        kwargs = super().validate_read(kwargs)
        if 'start' in kwargs or 'stop' in kwargs:
            raise NotImplementedError("start and/or stop are not supported "
                                      "in fixed Sparse reading")
        return kwargs
855112
def is_valid(self):
        
        if not self.text:
            return False

        try:
            pysrt.from_string(self.text, error_handling=pysrt.ERROR_RAISE)
        except pysrt.Error as e:
            if e.args[0] < 80:
                return False

        return True
637642
def normalizeISBN(isbn):
    
    try:
        return isbnlib.mask(isbnlib.canonical(isbn))
    except isbnlib.NotValidISBNError:
        return isbn
34861
def _augment_book(self, uuid, event):
        
        try:
            if not isbnmeta:
                self.log(
                    "No isbntools found! Install it to get full "
                    "functionality!",
                    lvl=warn)
                return

            new_book = objectmodels['book'].find_one({'uuid': uuid})
            try:
                if len(new_book.isbn) != 0:

                    self.log('Got a lookup candidate: ', new_book._fields)

                    try:
                        meta = isbnmeta(
                            new_book.isbn,
                            service=self.config.isbnservice
                        )

                        mapping = libraryfieldmapping[
                            self.config.isbnservice
                        ]

                        new_meta = {}

                        for key in meta.keys():
                            if key in mapping:
                                if isinstance(mapping[key], tuple):
                                    name, conv = mapping[key]
                                    try:
                                        new_meta[name] = conv(meta[key])
                                    except ValueError:
                                        self.log(
                                            'Bad value from lookup:',
                                            name, conv, key
                                        )
                                else:
                                    new_meta[mapping[key]] = meta[key]

                        new_book.update(new_meta)
                        new_book.save()

                        self._notify_result(event, new_book)
                        self.log("Book successfully augmented from ",
                                 self.config.isbnservice)
                    except Exception as e:
                        self.log("Error during meta lookup: ", e, type(e),
                                 new_book.isbn, lvl=error, exc=True)
                        error_response = {
                            'component': 'hfos.alert.manager',
                            'action': 'notify',
                            'data': {
                                'type': 'error',
                                'message': 'Could not look up metadata, sorry:' + str(e)
                            }
                        }
                        self.log(event, event.client, pretty=True)
                        self.fireEvent(send(event.client.uuid, error_response))

            except Exception as e:
                self.log("Error during book update.", e, type(e),
                         exc=True, lvl=error)

        except Exception as e:
            self.log("Book creation notification error: ", uuid, e, type(e),
                     lvl=error, exc=True)
469908
def valid? number
      raise_on_type_mismatch number
      num, check = split_isbn_number(number)
      convert_number_to_digits(num).length == 9 && self.of(num) == check
    end
1300652
public static OrderBook adaptOrderBook(
      BitcoindeOrderbookWrapper bitcoindeOrderbookWrapper, CurrencyPair currencyPair) {

    // System.out.println("bitcoindeOrderbookWrapper = " +
    // bitcoindeOrderbookWrapper);
    // System.out.println("credits = " + bitcoindeOrderbookWrapper.getCredits());

    List<LimitOrder> asks =
        createOrders(
            currencyPair,
            Order.OrderType.ASK,
            bitcoindeOrderbookWrapper.getBitcoindeOrders().getAsks());
    List<LimitOrder> bids =
        createOrders(
            currencyPair,
            Order.OrderType.BID,
            bitcoindeOrderbookWrapper.getBitcoindeOrders().getBids());

    Collections.sort(bids, BID_COMPARATOR);
    Collections.sort(asks, ASK_COMPARATOR);
    return new OrderBook(null, asks, bids);
  }
1074172
def is_valid(self, name=None, debug=False):
        
        valid_tags = self.action_tree
        invalid = False
        for item in self.current_tree:
            try:
                if item in valid_tags or self.ALL_TAGS in valid_tags:
                    valid_tags = valid_tags[item if item in valid_tags else self.ALL_TAGS]
                else:
                    valid_tags = None
                    invalid = True
                    break
            except (KeyError, TypeError) as e:  # object is either missing the key or is not a dictionary type
                invalid = True
                break
        if debug:
            print name, not invalid and valid_tags is not None
        return not invalid and valid_tags is not None
1364715
def _is_valid_position(self, position):
        '''
        
        '''
        row, col = position
        valid_r = row in self.row_labels
        valid_c = col in self.col_labels
        return valid_r and valid_c
1268903
def open_book(self, for_writing=False) -> piecash.Book:
        
        filename = None

        # check if the file path is already a URL.
        file_url = urllib.parse.urlparse(self.filename)
        if file_url.scheme == "file" or file_url.scheme == "sqlite":
            filename = file_url.path[1:]
        else:
            filename = self.filename

        if not os.path.isfile(filename):
            log(WARN, "Database %s requested but not found. Creating an in-memory book.", filename)
            return self.create_book()

        access_type = "read/write" if for_writing else "readonly"
        log(INFO, "Using %s in %s mode.", filename, access_type)
        # file_path = path.relpath(self.filename)
        file_path = path.abspath(filename)

        if not for_writing:
            book = piecash.open_book(file_path, open_if_lock=True)
        else:
            book = piecash.open_book(file_path, open_if_lock=True, readonly=False)
        # book = create_book()
        return book
106585
def book_name(self, number):
        ''''''
        try:
            name = self.cur.execute("SELECT name FROM book WHERE number = ?;", [number]).fetchone()
        except:
            self.error("cannot look up name of book number %s" % number)
        return(str(name[0]))
57176
def process_orders(self, orderbook):
        '''  '''
        for stock, alloc in orderbook.iteritems():
            self.logger.info('{}: Ordered {} {} stocks'.format(
                self.datetime, stock, alloc))
            if isinstance(alloc, int):
                self.order(stock, alloc)
            elif isinstance(alloc, float) and \
                    alloc >= -1 and alloc <= 1:
                self.order_percent(stock, alloc)
            else:
                self.logger.warning(
                    '{}: invalid order for {}: {})'
                    .format(self.datetime, stock, alloc))
50832
def get_books(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.BookList(self._results, runtime=self._runtime)
1057438
def checkValid(cls, reason):
        
        if reason not in cls.__VALID_REASONS:
            raise ValueError("reason must be one of {}, got {}".format(cls.__VALID_REASONS, reason))