Skip to content

Commit 70c97e8

Browse files
Felix Kloftfkloft
authored andcommitted
always set bag_info on namespace
attribute wouldn't be set without any metadata args. also removes the need to check for AttributeError
1 parent f46aafe commit 70c97e8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

bagit.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,17 +1443,14 @@ def force_unicode_py2(s):
14431443
class BagArgumentParser(argparse.ArgumentParser):
14441444
def __init__(self, *args, **kwargs):
14451445
argparse.ArgumentParser.__init__(self, *args, **kwargs)
1446+
self.set_defaults(bag_info={})
14461447

14471448

14481449
class BagHeaderAction(argparse.Action):
14491450
def __call__(self, parser, namespace, values, option_string=None):
14501451
opt = option_string.lstrip("--")
14511452
opt_caps = "-".join([o.capitalize() for o in opt.split("-")])
1452-
parser.bag_info[opt_caps] = values
1453-
try:
1454-
namespace.bag_info[opt_caps] = values
1455-
except AttributeError:
1456-
namespace.bag_info = {opt_caps: values}
1453+
namespace.bag_info[opt_caps] = values
14571454

14581455

14591456
def _make_parser():

0 commit comments

Comments
 (0)