Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2022-01-02 12:28:49 +0100
committerGitHub <noreply@github.com>2022-01-02 12:28:49 +0100
commitb89408ab7ba89fe03b62c9ae7f3d32ce74ebc035 (patch)
tree6b539a4488b5fdd244ca21b6926de1c5f67e2f64 /examples
parente388537bc36534fe782e1e68a70ddcdb2e13e99a (diff)
Improved command line argument parsing (#725)
* An update to PR 715, making the handling of the *--mount-point* parameter less error prone. I added a synomym (accepting the name both with underscore and dash) and ignoring when no value specified I added it explicitly to the list to accept both the --parm value and --parm=value syntax DOES NOT check the contents of the parameter * Explicitly set all the know parameters * Define explictly all parameters. Make all non explicitly defined parameters behave as standard parameters, with on exception, names are not changed Some cleanup of the code In guided.py the reference to the dry_run parameter is updated to the standard naming convention for parameters * Linter with flake8. corrections * Linter with flake8. corrections (II) * Linter with flake8. corrections (and III) * Added --disk_layout argument. Was missing I moved its loading from guided.py to __init__.py as it happens to the other json related arguments * Better handling of errors during processing of the --disk_layouts parameter. I define a routine to read an store a JSON file or stream. Tested on disk_layout * Expand the former commit to all JSON file arguments * Moved the function we created to read json files/streams to general.py. Add some comments * flake8. A reference now unneded * The merge process for the dry-run argument was causing the issue, not solving it The del is just a cleanup for version upgrade without consequence (I hope) * flake8 warning * Correcting the last correction . Worked for old config files, but only for them * New parameter parsing algorithm. More flexible and accepts multiple arguments (optionallY) plus some documentation effort * flake8 warning. For once is significant ( != None to not None)
Diffstat (limited to 'examples')
-rw-r--r--examples/guided.py15
1 files changed, 1 insertions, 14 deletions
diff --git a/examples/guided.py b/examples/guided.py
index c394e596..6db06c7e 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,7 +1,6 @@
import json
import logging
import os
-import pathlib
import time
import archinstall
@@ -50,18 +49,6 @@ def load_config():
archinstall.storage['gfx_driver_packages'] = archinstall.AVAILABLE_GFX_DRIVERS.get(archinstall.arguments.get('gfx_driver', None), None)
if archinstall.arguments.get('servers', None) is not None:
archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None)
- if archinstall.arguments.get('disk_layouts', None) is not None:
- if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'):
- try:
- with open(dl_path) as fh:
- archinstall.storage['disk_layouts'] = json.load(fh)
- except Exception as e:
- raise ValueError(f"--disk_layouts does not contain a valid JSON format: {e}")
- else:
- try:
- archinstall.storage['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts'])
- except:
- raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.")
def ask_user_questions():
@@ -212,7 +199,7 @@ def perform_filesystem_operations():
disk_layout_file.write(user_disk_layout)
print()
- if archinstall.arguments.get('dry-run'):
+ if archinstall.arguments.get('dry_run'):
exit(0)
if not archinstall.arguments.get('silent'):