On Thu, Sep 14, 2023 at 12:16 PM Rusty Howell <rustyhowell@xxxxxxxxx> wrote: > > From 082a38a3de11701ea1edf40a2f3268ec5115c691 Mon Sep 17 00:00:00 2001 > From: Rusty Howell <rhowell@xxxxxxxxxxxx> > Date: Wed, 13 Sep 2023 11:13:19 -0600 > Subject: [PATCH] Correctly parse power with gain and eirp > > Parse a power entry like "(6, 20)" or "(20", or "(N/A, 20)". > Previously, the example ASCII file format show in this page would not parse. > https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb#mailing_list_for_regulatory_updates Antenna gain was removed from the database in commit e56cd96 ("wireless-regdb: remove antenna gain"). The wiki needs to be updated. ChenYu > --- > dbparse.py | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/dbparse.py b/dbparse.py > index 1e87813..b36ff9c 100755 > --- a/dbparse.py > +++ b/dbparse.py > @@ -264,16 +264,25 @@ class DBParser(object): > > def _parse_power_def(self, pname, line, dupwarn=True): > try: > - max_eirp = line > - if max_eirp == 'N/A': > - max_eirp = '0' > - max_ant_gain = float(0) > + max_eirp = '' > + max_ant_gain = '' > + if ',' in line: > + max_ant_gain, max_eirp = line.split(',') > + if max_ant_gain == 'N/A': > + max_ant_gain = '0' > + else: > + max_ant_gain = '0' > + max_eirp = line > + if max_eirp == 'N/A': > + max_eirp = 0.0 > + > def conv_pwr(pwr): > if pwr.endswith('mW'): > pwr = float(pwr[:-2]) > return 10.0 * math.log10(pwr) > else: > return float(pwr) > + max_ant_gain = float(max_ant_gain) > max_eirp = conv_pwr(max_eirp) > except ValueError: > self._syntax_error("invalid power data") > -- > 2.25.1 > > _______________________________________________ > wireless-regdb mailing list > wireless-regdb@xxxxxxxxxxxxxxxxxxx > http://lists.infradead.org/mailman/listinfo/wireless-regdb