Skip to content

Commit 05f8b89

Browse files
committed
Use more pythonic way for dump_() functions
1 parent 7111934 commit 05f8b89

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

iptc/easy.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,26 +188,16 @@ def test_target(name, value, ipv6=False):
188188

189189
def dump_all(ipv6=False):
190190
""" Return a dictionary representation of all tables """
191-
d = {}
192-
for table in get_tables(ipv6):
193-
d[table] = dump_table(table, ipv6)
194-
return d
191+
return {table: dump_table(table, ipv6) for table in get_tables(ipv6)}
195192

196193
def dump_table(table, ipv6=False):
197194
""" Return a dictionary representation of a table """
198-
d = {}
199-
iptc_table = _iptc_gettable(table, ipv6)
200-
for iptc_chain in iptc_table.chains:
201-
d[iptc_chain.name] = dump_chain(iptc_table.name, iptc_chain.name, ipv6)
202-
return d
195+
return {chain: dump_chain(table, chain, ipv6) for chain in get_chains(table, ipv6)}
203196

204197
def dump_chain(table, chain, ipv6=False):
205198
""" Return a list with the dictionary representation of the rules of a table """
206-
l = []
207199
iptc_chain = _iptc_getchain(table, chain, ipv6)
208-
for i, iptc_rule in enumerate(iptc_chain.rules):
209-
l.append(_decode_iptc_rule(iptc_rule, ipv6))
210-
return l
200+
return [_decode_iptc_rule(iptc_rule, ipv6) for iptc_rule in iptc_chain.rules]
211201

212202

213203
def batch_begin(table = None, ipv6=False):

0 commit comments

Comments
 (0)