YCast/ycast/generic.py

34 lines
844 B
Python
Raw Normal View History

2019-08-19 11:57:35 +00:00
import logging
USER_AGENT = 'YCast'
class Directory:
def __init__(self, name, item_count):
self.name = name
self.item_count = item_count
2019-08-19 11:57:35 +00:00
def generate_stationid_with_prefix(uid, prefix):
if not prefix or len(prefix) != 2:
logging.error("Invalid station prefix length (must be 2)")
return None
if not uid:
logging.error("Missing station id for full station id generation")
return None
return str(prefix) + '_' + str(uid)
def get_stationid_prefix(uid):
if len(uid) < 4:
logging.error("Could not extract stationid (Invalid station id length)")
return None
return uid[:2]
def get_stationid_without_prefix(uid):
if len(uid) < 4:
logging.error("Could not extract stationid (Invalid station id length)")
return None
return uid[3:]