if product:
            is_pack = product.is_pack()
        else:
            is_pack = False
425471
def form_valid(self, form):
        # lb = SalesLines.objects.filter(pk=self.__line_pk).first()

        # product_old = lb.product_final
        product_pk = self.request.POST.get("product_final", None)
        quantity = self.request.POST.get("quantity", None)
        product_final = ProductFinal.objects.filter(pk=product_pk).first()
        
        if product_final and quantity:
            reason = form.data['reason']
            if reason:
                reason_obj = ReasonModification.objects.filter(pk=reason).first()
                if reason_obj:
                    try:
                        with transaction.atomic():
                            result = super(LinesUpdateModalBasket, self).form_valid(form)

                            reason_basket = ReasonModificationLineBasket()
                            reason_basket.basket = self.object.basket
                            reason_basket.reason = reason_obj
                            reason_basket.line = self.object
                            reason_basket.user = get_current_user()
                            reason_basket.quantity = self.object.quantity
                            reason_basket.save()
                            return result
                    except ValidationError as e:
                        errors = form._errors.setdefault("product_final", ErrorList())
                        errors.append(e)
                        return super(LinesUpdateModalBasket, self).form_invalid(form)
                else:
                    errors = form._errors.setdefault("reason", ErrorList())
                    errors.append(_("Reason of modification invalid"))
                    return super(LinesUpdatelOrder, self).form_invalid(form)
            else:
                errors = form._errors.setdefault("reason", ErrorList())
                errors.append(_("Reason of modification invalid"))
                return super(LinesUpdatelOrder, self).form_invalid(form)

            """
            if is_pack:
                options = product.productfinals_option.filter(active=True)
                options_pack = []
                for option in options:
                    field = 'packs[{}]'.format(option.pk)
                    opt = self.request.POST.get(field, None)
                    if opt:
                        opt_product = ProductFinal.objects.filter(pk=opt).first()
                        if opt_product:
                            options_pack.append({
                                'product_option': option,
                                'product_final': opt_product,
                                'quantity': quantity
                            })
                        else:
                            errors = form._errors.setdefault(field, ErrorList())
                            errors.append(_("Product Option invalid"))
                            return super(LinesUpdateModalBasket, self).form_invalid(form)
                    else:
                        errors = form._errors.setdefault(field, ErrorList())
                        errors.append(_("Option invalid"))
                        return super(LinesUpdateModalBasket, self).form_invalid(form)
            """
        else:
            errors = form._errors.setdefault("product_final", ErrorList())
            errors.append((_("Product invalid"), quantity, product_final))
            return super(LinesUpdateModalBasket, self).form_invalid(form)

        """
        ret = super(LinesUpdateModalBasket, self).form_valid(form)
        if product_old != self.object.product:
            self.object.remove_options()
        if is_pack:
            self.object.set_options(options_pack)
        return ret
        """
982243
public final boolean isPacked() {
    OptionElement packedOption = OptionElement.findByName(options(), "packed");
    return packedOption != null && "true".equals(packedOption.value());
  }
466727
def booleanize(truthy):
    '''
    
    '''
    if truthy is None:
        return False
    elif isinstance(truthy, basestring):
        if truthy:
            try:
                return bool(distutils.util.strtobool(truthy))
            except ValueError:
                return True
        else:
            return False
    elif is_collection(truthy):
        return not is_empty(truthy)
    else:
        return bool(truthy)
348499
def is_valid(self, qstr=None):
        """"""
        if qstr is None:
            qstr = self.currentText()
        return is_module_or_package(to_text_string(qstr))
497191
def are_in(items, collection):
    
    if not isinstance(items, (list, tuple)):
        items = (items, )
    return map(lambda x: x in collection, items)
750808
def __x_product (property_sets):
    
    assert is_iterable_typed(property_sets, property_set.PropertySet)
    x_product_seen = set()
    return __x_product_aux (property_sets, x_product_seen)[0]
896397
def is_variable(tup):
    
    name, item = tup
    if callable(item):
        # function or class
        return False

    if isinstance(item, types.ModuleType):
        # imported module
        return False

    if name.startswith("_"):
        # private property
        return False

    return True
121155
function isItemTag (tagName, prefix, local, feedType) {
  return tagName === 'item' || tagName === 'entry'
    || (local === 'item' && (prefix === '' || feedType === 'rdf'))
    || (local === 'entry' && (prefix === '' || feedType === 'atom'));
}
887347
def is_bool_matrix(l):
    

    """
    if isinstance(l, np.ndarray):
        if l.ndim == 2 and (l.dtype == bool):
            return True
    return False
424394
def version_is_valid(version_str):
    
    try:
        packaging.version.Version(version_str)
    except packaging.version.InvalidVersion:
        return False
    return True
695719
function tryPackErrorKeys(object, results) {
            if (object instanceof Error) {
                results.push(packValue("message"), packValue("stack"));
                return true;
            }
        }
1155144
def pack(self, value=None):
        
        if value is None:
            value = self._value

        if hasattr(value, 'pack') and callable(value.pack):
            return value.pack()
        elif isinstance(value, bytes):
            return value
        elif value is None:
            return b''
        else:
            raise ValueError(f"BinaryData can't be {type(value)} = '{value}'")
411630
def is_list_of_list(item):
    
    if (
        type(item) in (list, tuple)
        and len(item)
        and isinstance(item[0], (list, tuple))
    ):
        return True
    return False
175464
def _is_list(arg):
    """"""
    if isinstance(arg, dict):
        return False
    if isinstance(arg, str): # Python 3-only, as str has __iter__
        return False
    return (not _has_method(arg, "strip")
            and _has_method(arg, "__getitem__")
            or _has_method(arg, "__iter__"))
552982
def _has_z(self, kwargs):
        '''
        
        '''
        return ((self._type == 1 or self._type ==2) and
                (('z' in kwargs) or (self._element_z in kwargs)))
648818
function isList(opts: Options, node: Node): boolean {
    return opts.types.includes(node.type);
}
662732
def is_package(name):
    
    name = name.lower()  # compare package name against lowercase name
    packages = pkg_resources.working_set.by_key.keys()
    for package in packages:
        if package.lower().replace('-', '_') == name:
            return True
    return False