2018-10-06 16:03:18

by Hauke Mehrtens

[permalink] [raw]
Subject: [PATCH] wireless-regdb: remove dependency to python attr

Commit 8607edfdb6568 ("wireless-regdb: Parse wmm rule data") introduced
a dependency to the python module attr which is not included by default
in all python installations. Replace the code with manually coding the
constructor instead of using attr. This makes the code also work on
systems without attr.

I would like to avoid an additional dependency in OpenWrt where we
compile the regulatory database inside of the build system.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
dbparse.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/dbparse.py b/dbparse.py
index 5fe752b..993f757 100755
--- a/dbparse.py
+++ b/dbparse.py
@@ -5,7 +5,6 @@ from functools import total_ordering
import sys, math
from math import ceil, log
from collections import defaultdict, OrderedDict
-import attr

# must match <linux/nl80211.h> enum nl80211_reg_rule_flags

@@ -32,16 +31,17 @@ dfs_regions = {

@total_ordering

[email protected](frozen=True, cmp=False)
class WmmRule(object):
- vo_c = attr.ib()
- vi_c = attr.ib()
- be_c = attr.ib()
- bk_c = attr.ib()
- vo_ap = attr.ib()
- vi_ap = attr.ib()
- be_ap = attr.ib()
- bk_ap = attr.ib()
+
+ def __init__(self, vo_c, vi_c, be_c, bk_c, vo_ap, vi_ap, be_ap, bk_ap):
+ self.vo_c = vo_c
+ self.vi_c = vi_c
+ self.be_c = be_c
+ self.bk_c = bk_c
+ self.vo_ap = vo_ap
+ self.vi_ap = vi_ap
+ self.be_ap = be_ap
+ self.bk_ap = bk_ap

def _as_tuple(self):
return (self.vo_c, self.vi_c, self.be_c, self.bk_c,
--
2.11.0



2018-10-24 14:07:51

by Seth Forshee

[permalink] [raw]
Subject: Re: [PATCH] wireless-regdb: remove dependency to python attr

Please remember to Cc [email protected] for regdb
changes, adding now.

On Sat, Oct 06, 2018 at 06:02:54PM +0200, Hauke Mehrtens wrote:
> Commit 8607edfdb6568 ("wireless-regdb: Parse wmm rule data") introduced
> a dependency to the python module attr which is not included by default
> in all python installations. Replace the code with manually coding the
> constructor instead of using attr. This makes the code also work on
> systems without attr.
>
> I would like to avoid an additional dependency in OpenWrt where we
> compile the regulatory database inside of the build system.
>
> Signed-off-by: Hauke Mehrtens <[email protected]>

I had wonderd if this would turn out to be a problem for someone.
Applied, thanks!

> ---
> dbparse.py | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/dbparse.py b/dbparse.py
> index 5fe752b..993f757 100755
> --- a/dbparse.py
> +++ b/dbparse.py
> @@ -5,7 +5,6 @@ from functools import total_ordering
> import sys, math
> from math import ceil, log
> from collections import defaultdict, OrderedDict
> -import attr
>
> # must match <linux/nl80211.h> enum nl80211_reg_rule_flags
>
> @@ -32,16 +31,17 @@ dfs_regions = {
>
> @total_ordering
>
> [email protected](frozen=True, cmp=False)
> class WmmRule(object):
> - vo_c = attr.ib()
> - vi_c = attr.ib()
> - be_c = attr.ib()
> - bk_c = attr.ib()
> - vo_ap = attr.ib()
> - vi_ap = attr.ib()
> - be_ap = attr.ib()
> - bk_ap = attr.ib()
> +
> + def __init__(self, vo_c, vi_c, be_c, bk_c, vo_ap, vi_ap, be_ap, bk_ap):
> + self.vo_c = vo_c
> + self.vi_c = vi_c
> + self.be_c = be_c
> + self.bk_c = bk_c
> + self.vo_ap = vo_ap
> + self.vi_ap = vi_ap
> + self.be_ap = be_ap
> + self.bk_ap = bk_ap
>
> def _as_tuple(self):
> return (self.vo_c, self.vi_c, self.be_c, self.bk_c,
> --
> 2.11.0
>