Coverage for functions \ flipdare \ util \ firebase_util.py: 100%
19 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
3#
4# This file is part of Flipdare's proprietary software and contains
5# confidential and copyrighted material. Unauthorised copying,
6# modification, distribution, or use of this file is strictly
7# prohibited without prior written permission from Flipdare Pty Ltd.
8#
9# This software includes third-party components licensed under MIT,
10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
11#
12from __future__ import annotations
13from dataclasses import dataclass
15__all__ = ["FirebaseUtil", "FirebaseFileParts"]
18@dataclass(frozen=True, slots=True, kw_only=True)
19class FirebaseFileParts:
20 gs_url: str
21 path: str # gs_url minus gs://bucket_name/
22 bucket_name: str
23 name: str
26class FirebaseUtil:
27 @staticmethod
28 def gs_url_parts(gs_url: str) -> FirebaseFileParts:
29 if gs_url.startswith("gs://"):
30 path_only = gs_url.replace("gs://", "", 1)
31 else:
32 path_only = gs_url
33 gs_url = f"gs://{gs_url}"
35 bucket_name, _, blob_path = path_only.partition("/")
36 name = blob_path.split("/")[-1]
38 return FirebaseFileParts(
39 gs_url=gs_url,
40 path=blob_path,
41 bucket_name=bucket_name,
42 name=name,
43 )