Spaces:
Sleeping
Sleeping
| def extract_code_from_mrbts(mrbts): | |
| """ | |
| Extracts the code from a MRBTS (Mobile Radio Base Transceiver Station) string. | |
| Args: | |
| mrbts (int or str): The MRBTS string to extract the code from. | |
| Returns: | |
| int: The extracted code from the MRBTS string. | |
| Raises: | |
| None. | |
| Notes: | |
| This function handles MRBTS strings that start with '10' and have a length greater than 5, | |
| as well as MRBTS strings that start with '1', '2', or '3'. For MRBTS strings that do not | |
| meet these criteria, the entire MRBTS string is returned as an integer. | |
| """ | |
| str_mrbts = str(mrbts) | |
| if len(str_mrbts) > 5 and str_mrbts.startswith("10"): | |
| # For MRBTS starting with '10' and having length greater than 5 | |
| return int(str_mrbts[2:]) | |
| elif len(str_mrbts) > 4 and str_mrbts.startswith("1"): | |
| return int(str_mrbts[1:]) | |
| elif len(str_mrbts) > 4 and str_mrbts.startswith("2"): | |
| # For MRBTS starting with '2' (like 20000 + code) | |
| return int(str_mrbts[1:]) | |
| elif len(str_mrbts) > 4 and str_mrbts.startswith("3"): | |
| # For MRBTS starting with '3' (like 30000 + code) | |
| return int(str_mrbts[1:]) | |
| else: | |
| # Default case | |
| return int(str_mrbts) | |