def __init__(self, name, sid): """ @param name: The radio station name. @param sid: The broadcast service identifier (SId). """ RadioStation.__init__(self, "amss", name) if re.match('^[0-9A-F]{6}$', sid, re.IGNORECASE): self._sid = sid else: raise RuntimeError, "Invalid sid"
def __init__(self, name, ecc = None, country = None, pi = None, freq = None): """ @param name: The radio station name. @param ecc: The broadcast RDS extended country code. @param country: An ISO country code, if a broadcast ECC is unavailable. @param pi: The broadcast programme identification (PI) code. @param freq: The frequency on which the service is received, in 0.01 MHz units, e.g, 98.8 MHz would be represented as 9880. """ RadioStation.__init__(self, "fm", name) # Programme identification (PI) code is 4 hex digits. if pi is not None and re.match('^[0-9A-F]{4}$', pi, re.IGNORECASE): self._pi = pi else: raise ValueError, "Invalid pi" if country is not None: # Check for 2-letter ISO country code. if re.match('^[A-Z]{2}$', country, re.IGNORECASE): self._country = country else: raise ValueError, "Invalid country" if ecc is not None: raise ValueError, "country and ecc are mutually exclusive" elif ecc is not None: # Check for 2-hex-digit extended country code, and concatenate # with the first character of the RDS PI code. if re.match('^[0-9A-F]{2}$', ecc, re.IGNORECASE): self._country = self._pi[0] + ecc else: raise ValueError, "Invalid extended country code" try: freq = int(freq) except (ValueError, TypeError): raise ValueError, "Invalid freq" if freq >= 0 and freq <= 99999: self._freq = "%05u" % freq else: raise ValueError, "Invalid freq"
def __init__(self, name, ecc=None, country=None, pi=None, freq=None): """ @param name: The radio station name. @param ecc: The broadcast RDS extended country code. @param country: An ISO country code, if a broadcast ECC is unavailable. @param pi: The broadcast programme identification (PI) code. @param freq: The frequency on which the service is received, in 0.01 MHz units, e.g, 98.8 MHz would be represented as 9880. """ RadioStation.__init__(self, "fm", name) # Programme identification (PI) code is 4 hex digits. if pi is not None and re.match('^[0-9A-F]{4}$', pi, re.IGNORECASE): self._pi = pi else: raise ValueError, "Invalid pi" if country is not None: # Check for 2-letter ISO country code. if re.match('^[A-Z]{2}$', country, re.IGNORECASE): self._country = country else: raise ValueError, "Invalid country" if ecc is not None: raise ValueError, "country and ecc are mutually exclusive" elif ecc is not None: # Check for 2-hex-digit extended country code, and concatenate # with the first character of the RDS PI code. if re.match('^[0-9A-F]{2}$', ecc, re.IGNORECASE): self._country = self._pi[0] + ecc else: raise ValueError, "Invalid extended country code" try: freq = int(freq) except (ValueError, TypeError): raise ValueError, "Invalid freq" if freq >= 0 and freq <= 99999: self._freq = "%05u" % freq else: raise ValueError, "Invalid freq"
def __init__(self, name, tx, cc): """ @param name: The radio station name. @param tx: The broadcast transmitter identifier. @param cc: The broadcast country code. """ RadioStation.__init__(self, "hd", name) if re.match('^[0-9A-F]{5}$', tx, re.IGNORECASE): self._tx = tx else: raise ValueError, "Invalid tx" if re.match('^[0-9A-F]{3}$', cc, re.IGNORECASE): self._cc = cc else: raise ValueError, "Invalid cc"
def __init__(self): RadioStation.__init__(self, 'test', 'Test')
def __init__(self, name, ecc, eid, sid, scids, appty = None, uatype = None, pa = None): """ @param name: The radio station name. @param ecc: The broadcast extended country code (ECC). @param eid: The broadcast ensemble identifier (EId). @param sid: The broadcast service identifier (SId). @param scids: The broadcast service component identifier within the service (SCIdS). @param appty: The broadcast X-PAD application type (AppTy), if the audio service is delivered as data via X-PAD. @param uatype: The broadcast user application type (UAType). If AppTy is specified, UAType must also be specified. @param pa: The broadcast packet address, which is mandatory if the audio service is delivered as data in an independent service component. """ RadioStation.__init__(self, "dab", name) if re.match('^[0-9A-F]{3}$', ecc, re.IGNORECASE): self._ecc = ecc else: raise ValueError, "Invalid ecc" if re.match('^[0-9A-F]{4}$', eid, re.IGNORECASE): self._eid = eid else: raise ValueError, "Invalid eid" if re.match('^[0-9A-F]{4}$', sid, re.IGNORECASE) \ or re.match('^[0-9A-F]{8}$', sid, re.IGNORECASE): self._sid = sid else: raise ValueError, "Invalid sid" if re.match('^[0-9A-F]{1}$', scids, re.IGNORECASE) \ or re.match('^[0-9A-F]{3}$', scids, re.IGNORECASE): self._scids = scids else: raise ValueError, "Invalid scids" if appty is not None: if re.match('^[0-9A-F]{2}$', appty, re.IGNORECASE): self._appty_uatype = appty else: raise ValueError, "Invalid appty" if uatype is not None: if re.match('^[0-9A-F]{3}$', uatype, re.IGNORECASE): self._appty_uatype += "-" + uatype else: raise ValueError, "Invalid uatype" else: raise ValueError, "Both appty and uatype must be specified" if pa is not None: raise ValueError, "pa and appty-uatype are mutually exclusive" else: if uatype is not None: raise ValueError, "Both appty and uatype must be specified" self._appty_uatype = None if pa is not None: try: pa = int(pa) except (ValueError, TypeError): raise ValueError, "Invalid pa" if pa >= 0 and pa <= 1023: self._pa = pa else: raise ValueError, "Invalid pa" if appty is not None or uatype is not None: raise ValueError, "pa and appty-uatype are mutually exclusive" else: self._pa = None
def __init__(self, name, ecc, eid, sid, scids, appty=None, uatype=None, pa=None): """ @param name: The radio station name. @param ecc: The broadcast extended country code (ECC). @param eid: The broadcast ensemble identifier (EId). @param sid: The broadcast service identifier (SId). @param scids: The broadcast service component identifier within the service (SCIdS). @param appty: The broadcast X-PAD application type (AppTy), if the audio service is delivered as data via X-PAD. @param uatype: The broadcast user application type (UAType). If AppTy is specified, UAType must also be specified. @param pa: The broadcast packet address, which is mandatory if the audio service is delivered as data in an independent service component. """ RadioStation.__init__(self, "dab", name) if re.match('^[0-9A-F]{3}$', ecc, re.IGNORECASE): self._ecc = ecc else: raise ValueError, "Invalid ecc" if re.match('^[0-9A-F]{4}$', eid, re.IGNORECASE): self._eid = eid else: raise ValueError, "Invalid eid" if re.match('^[0-9A-F]{4}$', sid, re.IGNORECASE) \ or re.match('^[0-9A-F]{8}$', sid, re.IGNORECASE): self._sid = sid else: raise ValueError, "Invalid sid" if re.match('^[0-9A-F]{1}$', scids, re.IGNORECASE) \ or re.match('^[0-9A-F]{3}$', scids, re.IGNORECASE): self._scids = scids else: raise ValueError, "Invalid scids" if appty is not None: if re.match('^[0-9A-F]{2}$', appty, re.IGNORECASE): self._appty_uatype = appty else: raise ValueError, "Invalid appty" if uatype is not None: if re.match('^[0-9A-F]{3}$', uatype, re.IGNORECASE): self._appty_uatype += "-" + uatype else: raise ValueError, "Invalid uatype" else: raise ValueError, "Both appty and uatype must be specified" if pa is not None: raise ValueError, "pa and appty-uatype are mutually exclusive" else: if uatype is not None: raise ValueError, "Both appty and uatype must be specified" self._appty_uatype = None if pa is not None: try: pa = int(pa) except (ValueError, TypeError): raise ValueError, "Invalid pa" if pa >= 0 and pa <= 1023: self._pa = pa else: raise ValueError, "Invalid pa" if appty is not None or uatype is not None: raise ValueError, "pa and appty-uatype are mutually exclusive" else: self._pa = None