Skip to content

Commit

Permalink
Switch 'osc.conf.config' from dict to Options class with type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Sep 4, 2023
1 parent 4501ea8 commit c82d18c
Show file tree
Hide file tree
Showing 7 changed files with 1,318 additions and 560 deletions.
32 changes: 31 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
#
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
import textwrap

TOPDIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(TOPDIR, ".."))

import osc.conf


# -- Project information -----------------------------------------------------
Expand Down Expand Up @@ -52,6 +57,23 @@
master_doc = 'index'


# -- Generate documents -------------------------------------------------

osc.conf._model_to_rst(
cls=osc.conf.Options,
title="Configuration file",
description=textwrap.dedent(
"""
The configuration file path is ``$XDG_CONFIG_HOME/osc/oscrc``, which usually translates into ``~/.config/osc/oscrc``.
"""
),
sections={
"Host options": osc.conf.HostOptions,
},
output_file=os.path.join(TOPDIR, "oscrc.rst"),
)


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand All @@ -64,3 +86,11 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Options for MAN output -------------------------------------------------

# (source start file, name, description, authors, manual section).
man_pages = [
("oscrc", "oscrc", "openSUSE Commander configuration file", "openSUSE project <[email protected]>", 5),
]
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ API:

api/modules
plugins/index
oscrc



Expand Down
5 changes: 1 addition & 4 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,7 @@ def post_argparse(self):
except oscerr.NoConfigfile as e:
print(e.msg, file=sys.stderr)
print('Creating osc configuration file %s ...' % e.file, file=sys.stderr)
apiurl = conf.DEFAULTS['apiurl']
if self.options.apiurl:
apiurl = self.options.apiurl
conf.interactive_config_setup(e.file, apiurl)
conf.interactive_config_setup(e.file, self.options.apiurl)

Check warning on line 1081 in osc/commandline.py

View check run for this annotation

Codecov / codecov/patch

osc/commandline.py#L1081

Added line #L1081 was not covered by tests
print('done', file=sys.stderr)
self.post_argparse()
except oscerr.ConfigMissingApiurl as e:
Expand Down
Loading

0 comments on commit c82d18c

Please sign in to comment.