try: return parse_decimal_string(s) except: return None GARMENT_SIZES = ("XXXS", "XXS", "XS", "S", "M", "L", "XL", "XXL", "XXXL") def get_string_sort_order(s): """ Return a sorting order value for a string that contains a garment size. :param s: Input value (string or number) :type s: str :return: Sorting tuple :rtype: tuple """ # See if it's one of the predefined sizes for i, size in enumerate(GARMENT_SIZES): if size in s: return (10 + i, s) try: # If not, see if it looks enough like a decimal return (5, parse_decimal_string(s)) except: # Otherwise just sort as a string return (1, s) update_module_attributes(__all__, __name__)
# -*- coding: utf-8 -*- # This file is part of Shoop. # # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved. # # This source code is licensed under the AGPLv3 license found in the # LICENSE file in the root directory of this source tree. from shoop.utils import update_module_attributes from ._creator import OrderCreator from ._modifier import OrderModifier from ._source import OrderSource, SourceLine, TaxesNotCalculated from ._source_modifier import ( get_order_source_modifier_modules, is_code_usable, OrderSourceModifierModule ) __all__ = [ "get_order_source_modifier_modules", "is_code_usable", "OrderCreator", "OrderModifier", "OrderSource", "OrderSourceModifierModule", "SourceLine", "TaxesNotCalculated" ] update_module_attributes(__all__, __name__)