Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing hints #2877

Merged
merged 4 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions docs/pkglistgen.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Package List Generator

pkglistgen.py is a self contained script to generate and update OBS products for openSUSE and SLE.
pkglistgen.py is a self contained script to generate and update OBS products for openSUSE and SLE.
It works on the products and its staging projects and ports.

The main input is a package named 000package-groups and it will update the content of other packages
from that. For that it will read [YAML](https://en.wikipedia.org/wiki/YAML) input from e.g. 000package-groups/groups.yml and generate .group files into 000product. The rest of 000package-groups is copied into 000product as well and it runs the OBS product converter service (See [OBS Documentation](https://en.opensuse.org/openSUSE:Build_Service_product_definition) for details)
The generated release spec files are split into 000release-packages to avoid needless rebuilds.
The generated release spec files are split into 000release-packages to avoid needless rebuilds.

## Input

The package list generator reads several files. The most important are group*.yml (tradionally only groups.yml) within 000package-groups.
The package list generator reads several files. The most important are group*.yml (traditionally only groups.yml) within 000package-groups.

### supportstatus.txt
The file lists the packages and their support level. It's only necessary to list packages here that have a different level than the default level specificied in the groups. The format is plain text: <package name> <level> - the level is handed over 1:1 to KIWI file. Currently used values are: unsupported, l2 and l3

### group*.yml
The file is a list of package lists and the special hash 'OUTPUT'. OUTPUT contains an entry for every group file that needs to be written out. The group name of it needs to exist as package list as well. OUTPUT also contains flags for the groups.

We currently support:
* default-support
Sets the support level in case there is no explicitly entry in [supportstatus.txt](#supportstatus.txt), defaults to 'unsupported'
Sets the support level in case there is no explicitly entry in [supportstatus.txt](#supportstatustxt), defaults to 'unsupported'
* recommends
If the solver should take recommends into account when solving the package list, defaults to false.
* includes
Expand All @@ -31,7 +31,7 @@ We currently support:

Be aware that group names must not contain a '-'.

You can also adapt the solving on a package level by putting a hash into the package list. Normally the package name is a string, in case it's a hash the key needs to be the package name and the value is a list of following modifiers:
You can also adapt the solving on a package level by putting a hash into the package list. Normally the package name is a string, in case it's a hash the key needs to be the package name and the value is a list of following modifiers:

* recommended
Evaluate also 'Recommends' in package to determine dependencies. Otherwise only 'required' are considered. Used mainly for patterns in SLE. It can not be combined with platforms, For architecture specific recommends, use patterns.
Expand All @@ -46,7 +46,7 @@ You can also adapt the solving on a package level by putting a hash into the pac
* required
If the package is missing or is uninstallable, don't leave a comment but put the error as package entry for OBS to create unresolvable error to avoid building a DVD

Note that you can write yaml lists in 2 ways. You can put the modifier lists as multiple lines starting with -, but it's recommended to put them as [M1,M2] behind the package name. See the difference between pkg4 and pkg5 in the example.
Note that you can write yaml lists in 2 ways. You can put the modifier lists as multiple lines starting with -, but it's recommended to put them as [M1,M2] behind the package name. See the difference between pkg4 and pkg5 in the example.

#### Example:

Expand All @@ -68,32 +68,32 @@ OUTPUT:
- group3:
includes:
- list2

group1:
- pkg1

group2:
- pkg2: [locked]
- pkg3

group3:
- pkg4: [x86_64]

list1:
- pkg5:
- x86_64

list2:
- pkg6: [recommended]
```
```

## Overlap calculcation
TODO
## Overlap calculation
TODO

## Handling in staging workflow
If 000package-groups contains a file named summary-staging.txt, the bot will trigger a diff mode on staging projects.
If 000package-groups contains a file named summary-staging.txt, the bot will trigger a diff mode on staging projects.
It will create an equal summary-staging.txt in 000product and create a comment with a human readable diff in the staging
project. This comment can be replied to. If the reply starts with 'approve', staging accept will apply the diff to this
txt file. If the reply starts with 'ignore', the bot will continue with the pipeline and do nothing on staging accept.

This way simple changes to the summary can be accepted without a submit request (of which there can only be one at a time).
This way simple changes to the summary can be accepted without a submit request (of which there can only be one at a time).
16 changes: 12 additions & 4 deletions osclib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
from lxml import etree as ET
from urllib.error import HTTPError
from typing import Optional

from osc.core import create_submit_request
from osc.core import get_binarylist
Expand Down Expand Up @@ -413,7 +414,7 @@ def package_list_kind_filtered(apiurl, project, kinds_allowed=['source']):
yield package


def attribute_value_load(apiurl, project, name, namespace='OSRT', package=None):
def attribute_value_load(apiurl: str, project: str, name: str, namespace='OSRT', package: Optional[str] = None):
path = list(filter(None, ['source', project, package, '_attribute', namespace + ':' + name]))
url = makeurl(apiurl, path)

Expand Down Expand Up @@ -444,7 +445,14 @@ def attribute_value_load(apiurl, project, name, namespace='OSRT', package=None):
# Remember to create for both OBS and IBS as necessary.


def attribute_value_save(apiurl, project, name, value, namespace='OSRT', package=None):
def attribute_value_save(
apiurl: str,
project: str,
name: str,
value: str,
namespace='OSRT',
package: Optional[str] = None
):
root = ET.Element('attributes')

attribute = ET.SubElement(root, 'attribute')
Expand All @@ -463,13 +471,13 @@ def attribute_value_save(apiurl, project, name, value, namespace='OSRT', package
raise e


def attribute_value_delete(apiurl, project, name, namespace='OSRT', package=None):
def attribute_value_delete(apiurl: str, project: str, name: str, namespace='OSRT', package: Optional[str] = None):
http_DELETE(makeurl(
apiurl, list(filter(None, ['source', project, package, '_attribute', namespace + ':' + name]))))


@memoize(session=True)
def repository_path_expand(apiurl, project, repo, visited_repos=None):
def repository_path_expand(apiurl: str, project: str, repo: str, visited_repos: Optional[set] = None):
"""Recursively list underlying projects."""
if visited_repos is None:
visited_repos = set()
Expand Down
Loading