summaryrefslogtreecommitdiff
path: root/qutebrowser/qutebrowser.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-02-03 19:12:54 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-02-03 19:18:31 +0100
commite7cafd34cc79df759f2ad9a13a7dc6f84e923f0b (patch)
tree18717cd66d47dcd722ad493f88fad525f6e982af /qutebrowser/qutebrowser.py
parent985c711e49d9503e52964766fceda78802aae656 (diff)
downloadqutebrowser-e7cafd34cc79df759f2ad9a13a7dc6f84e923f0b.tar.gz
qutebrowser-e7cafd34cc79df759f2ad9a13a7dc6f84e923f0b.zip
Move json args loading to function
Needed to write tests.
Diffstat (limited to 'qutebrowser/qutebrowser.py')
-rw-r--r--qutebrowser/qutebrowser.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py
index 038421e98..fe8d824ec 100644
--- a/qutebrowser/qutebrowser.py
+++ b/qutebrowser/qutebrowser.py
@@ -183,17 +183,23 @@ def debug_flag_error(flag):
.format(', '.join(valid_flags)))
+def _unpack_json_args(args):
+ """Restore arguments from --json-args after a restart.
+
+ When restarting, we serialize the argparse namespace into json, and
+ construct a "fake" argparse.Namespace here based on the data loaded
+ from json.
+ """
+ data = json.loads(args.json_args)
+ return argparse.Namespace(**data)
+
+
def main():
parser = get_argparser()
argv = sys.argv[1:]
args = parser.parse_args(argv)
if args.json_args is not None:
- # Restoring after a restart.
- # When restarting, we serialize the argparse namespace into json, and
- # construct a "fake" argparse.Namespace here based on the data loaded
- # from json.
- data = json.loads(args.json_args)
- args = argparse.Namespace(**data)
+ args = _unpack_json_args(args)
earlyinit.early_init(args)
# We do this imports late as earlyinit needs to be run first (because of
# version checking and other early initialization)