def __init__(self, parsed_json): self._product_id = parse_int(parsed_json.get("id")) self._name = parsed_json.get("name") self._amount_missing = parse_float(parsed_json.get("amount_missing")) self._is_partly_in_stock = bool( parse_int(parsed_json.get("is_partly_in_stock")) )
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get('id')) self._product_id = parse_int(parsed_json.get('product_id')) self._note = parsed_json.get('note',None) self._amount = parse_float(parsed_json.get('amount'),0) self._row_created_timestamp = parse_date(parsed_json.get('row_created_timestamp', None)) self._shopping_list_id = parse_int(parsed_json.get('shopping_list_id')) self._done = parse_int(parsed_json.get('done'))
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._product_id = parse_int(parsed_json.get("product_id", None)) self._note = parsed_json.get("note", None) self._amount = parse_float(parsed_json.get("amount"), 0) self._row_created_timestamp = parse_date( parsed_json.get("row_created_timestamp", None)) self._shopping_list_id = parse_int(parsed_json.get("shopping_list_id")) self._done = parse_int(parsed_json.get("done"))
def __init__(self, parsed_json): self.id = parse_int(parsed_json.get("id")) self.name = parsed_json.get("name") self.description = parsed_json.get("description") self.due_date = parse_date(parsed_json.get("due_date")) self.done = parse_int(parsed_json.get("done")) self.done_timestamp = parse_date(parsed_json.get("done_timestamp")) self.category_id = parse_int(parsed_json.get("category_id")) self.assigned_to_user_id = parse_int(parsed_json.get("assigned_to_user_id")) self.userfields = parsed_json.get("userfields")
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._name = parsed_json.get("name") self._description = parsed_json.get("description") self._base_servings = parse_int(parsed_json.get("base_servings")) self._desired_servings = parse_int(parsed_json.get("desired_servings")) self._picture_file_name = parsed_json.get("picture_file_name") self._row_created_timestamp = parse_date( parsed_json.get("row_created_timestamp")) self._userfields = parsed_json.get("userfields")
def __init__(self, parsed_json): self.id = parse_int(parsed_json.get('id')) self.name = parsed_json.get('name') self.description = parsed_json.get('description') self.due_date = parse_date(parsed_json.get('due_date')) self.done = parse_int(parsed_json.get('done')) self.done_timestamp = parse_date(parsed_json.get('done_timestamp')) self.category_id = parse_int(parsed_json.get('category_id')) self.assigned_to_user_id = parse_int( parsed_json.get('assigned_to_user_id')) self.userfields = parsed_json.get('userfields')
def __init__(self, parsed_json): self._last_purchased = parse_date(parsed_json.get('last_purchased')) self._last_used = parse_date(parsed_json.get('last_used')) self._stock_amount = parse_int(parsed_json.get('stock_amount')) self._stock_amount_opened = parse_int(parsed_json.get('stock_amount_opened')) self._next_best_before_date = parse_date(parsed_json.get('next_best_before_date')) self._last_price = parse_float(parsed_json.get('last_price')) self._product = ProductData(parsed_json.get('product')) self._quantity_unit_purchase = QuantityUnitData(parsed_json.get('quantity_unit_purchase')) self._quantity_unit_stock = QuantityUnitData(parsed_json.get('quantity_unit_stock')) self._location = LocationData(parsed_json.get('location'))
def __init__(self, parsed_json): self.id = parse_int(parsed_json.get('id')) self.name = parsed_json.get('name') self.description = parsed_json.get('description') self.period_type = parsed_json.get('period_type') self.period_config = parsed_json.get('period_config') self.period_days = parse_int(parsed_json.get('period_days')) self.track_date_only = parsed_json.get('track_date_only') self.rollover = parsed_json.get('rollover') self.assignment_type = parsed_json.get('assignment_type') self.assignment_config = parsed_json.get('assignment_config') self.next_execution_assigned_to_user_id = parse_int( 'next_execution_assigned_to_user_id') self.userfields = parsed_json.get('userfields')
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._day = parse_date(parsed_json.get("day")) self._type = parsed_json.get("type") self._recipe_id = parse_int(parsed_json.get("recipe_id")) self._recipe_servings = parse_int(parsed_json.get("recipe_servings")) self._note = parsed_json.get("note", None) self._product_id = parsed_json.get("product_id") self._product_amount = parse_float(parsed_json.get("product_amount"), 0) self._product_qu_id = parsed_json.get("product_qu_id") self._row_created_timestamp = parse_date( parsed_json.get("row_created_timestamp")) self._userfields = parsed_json.get("userfields")
def __init__(self, parsed_json): self.id = parse_int(parsed_json.get("id")) self.name = parsed_json.get("name") self.description = parsed_json.get("description") self.period_type = parsed_json.get("period_type") self.period_config = parsed_json.get("period_config") self.period_days = parse_int(parsed_json.get("period_days")) self.track_date_only = parsed_json.get("track_date_only") self.rollover = parsed_json.get("rollover") self.assignment_type = parsed_json.get("assignment_type") self.assignment_config = parsed_json.get("assignment_config") self.next_execution_assigned_to_user_id = parse_int( "next_execution_assigned_to_user_id") self.userfields = parsed_json.get("userfields")
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get('id')) self._username = parsed_json.get('username') self._first_name = parsed_json.get('first_name') self._last_name = parsed_json.get('last_name') self._display_name = parsed_json.get('display_name')
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get('id')) self._name = parsed_json.get('name') self._name_plural = parsed_json.get('name_plural') self._description = parsed_json.get('description') self._row_created_timestamp = parse_date( parsed_json.get('row_created_timestamp'))
def __init__(self, parsed_json): self._product_id = parse_int(parsed_json.get('product_id')) self._amount = parse_float(parsed_json.get('amount')) self._best_before_date = parse_date( parsed_json.get('best_before_date')) self._amount_opened = parse_float(parsed_json.get('amount_opened')) self._product = ProductData(parsed_json.get('product'))
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._username = parsed_json.get("username") self._first_name = parsed_json.get("first_name") self._last_name = parsed_json.get("last_name") self._display_name = parsed_json.get("display_name")
def __init__(self, parsed_json): self._product_id = parse_int(parsed_json.get("product_id")) self._amount = parse_float(parsed_json.get("amount")) self._best_before_date = parse_date( parsed_json.get("best_before_date")) self._amount_opened = parse_float(parsed_json.get("amount_opened")) self._product = ProductData(parsed_json.get("product"))
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._name = parsed_json.get("name") self._name_plural = parsed_json.get("name_plural") self._description = parsed_json.get("description") self._row_created_timestamp = parse_date( parsed_json.get("row_created_timestamp"))
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get('id')) self._name = parsed_json.get('name') self._description = parsed_json.get('description', None) self._location_id = parse_int(parsed_json.get('location_id', None)) self._product_group_id = parse_int( parsed_json.get('product_group_id', None)) self._qu_id_stock = parse_int(parsed_json.get('qu_id_stock', None)) self._qu_id_purchase = parse_int( parsed_json.get('qu_id_purchsase', None)) self._qu_factor_purchase_to_stock = parse_float( parsed_json.get('qu_factor_purchase_to_stock', None)) self._picture_file_name = parsed_json.get('picture_file_name', None) self._allow_partial_units_in_stock = bool( parsed_json.get('allow_partial_units_in_stock', None) == "true") self._row_created_timestamp = parse_date( parsed_json.get('row_created_timestamp', None)) self._min_stock_amount = parse_int( parsed_json.get('min_stock_amount', None), 0) self._default_best_before_days = parse_int( parsed_json.get('default_best_before_days', None)) barcodes_raw = parsed_json.get('barcode', "") if barcodes_raw is None: self._barcodes = None else: self._barcodes = barcodes_raw.split(",")
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get("id")) self._name = parsed_json.get("name") self._description = parsed_json.get("description", None) self._location_id = parse_int(parsed_json.get("location_id", None)) self._product_group_id = parse_int( parsed_json.get("product_group_id", None)) self._qu_id_stock = parse_int(parsed_json.get("qu_id_stock", None)) self._qu_id_purchase = parse_int( parsed_json.get("qu_id_purchsase", None)) self._qu_factor_purchase_to_stock = parse_float( parsed_json.get("qu_factor_purchase_to_stock", None)) self._picture_file_name = parsed_json.get("picture_file_name", None) self._allow_partial_units_in_stock = bool( parsed_json.get("allow_partial_units_in_stock", None) == "true") self._row_created_timestamp = parse_date( parsed_json.get("row_created_timestamp", None)) self._min_stock_amount = parse_int( parsed_json.get("min_stock_amount", None), 0) self._default_best_before_days = parse_int( parsed_json.get("default_best_before_days", None)) barcodes_raw = parsed_json.get("barcode", "") if barcodes_raw is None: self._barcodes = None else: self._barcodes = barcodes_raw.split(",")
def shopping_list_item_to_str(item: ShoppingListProduct) -> str: """ Converts a shopping list item object into a string representation :param item: the shopping list item :return: a text representation """ from pygrocy.utils import parse_int amount = parse_int(item.amount, item.amount) return f"{amount}x {item.product.name}"
def product_to_str(item: Product) -> str: from pygrocy.utils import parse_int amount = parse_int(item.available_amount, 0) text = f"{amount}x\t{item.name}" if item.best_before_date is not None and item.best_before_date.date( ) < NEVER_EXPIRES_DATE: expire_date = datetime_fmt_date_only(item.best_before_date) text += f" (Exp: {expire_date})" return text
def __init__(self, parsed_json): self._last_purchased = parse_date(parsed_json.get("last_purchased")) self._last_used = parse_date(parsed_json.get("last_used")) self._stock_amount = parse_int(parsed_json.get("stock_amount")) self._stock_amount_opened = parse_int(parsed_json.get("stock_amount_opened")) self._next_best_before_date = parse_date( parsed_json.get("next_best_before_date") ) self._last_price = parse_float(parsed_json.get("last_price")) self._product = ProductData(parsed_json.get("product")) self._quantity_unit_purchase = QuantityUnitData( parsed_json.get("quantity_unit_purchase") ) self._quantity_unit_stock = QuantityUnitData( parsed_json.get("quantity_unit_stock") ) self._location = LocationData(parsed_json.get("location"))
def __init__(self, parsed_json): self._chore = ChoreData(parsed_json.get("chore")) self._last_tracked = parse_date(parsed_json.get("last_tracked")) self._next_estimated_execution_time = parse_date( parsed_json.get("next_estimated_execution_time")) self._track_count = parse_int(parsed_json.get("track_count")) next_user = parsed_json.get("next_execution_assigned_user") if next_user is not None: self._next_execution_assigned_user = UserDto(next_user) else: self._next_execution_assigned_user = None if self._last_tracked is None: self._last_done_by = None else: self._last_done_by = UserDto(parsed_json.get("last_done_by"))
def test_parse_int_valid(self): int_str = "2" int_number = utils.parse_int(int_str) assert isinstance(int_number, int)
def test_parse_int_error(self): int_str = "string" int_number = utils.parse_int(int_str, -1) assert int_number == -1
def __init__(self, parsed_json): self._product_id = parse_int(parsed_json.get('id')) self._name = parsed_json.get('name') self._amount_missing = parse_float(parsed_json.get('amount_missing')) self._is_partly_in_stock = bool( parse_int(parsed_json.get('is_partly_in_stock')))
def __init__(self, parsed_json): self._chore_id = parse_int(parsed_json.get("chore_id"), None) self._last_tracked_time = parse_date( parsed_json.get("last_tracked_time")) self._next_estimated_execution_time = parse_date( parsed_json.get("next_estimated_execution_time"))
def __init__(self, parsed_json): self._id = parse_int(parsed_json.get('id')) self._name = parsed_json.get('name')
def test_parse_int_no_data(self): int_str = None int_number = utils.parse_int(int_str, -1) assert int_number == -1