1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-15 00:36:11 +01:00
Commit Graph

165 Commits

Author SHA1 Message Date
556c97d7ee Move xml_indent, xml_quote and xml_unquote to osc.util.xml module 2024-02-12 09:27:30 +01:00
8a38a9da82 Implement get_callback that allows modifying returned value to the Field class 2024-01-24 15:47:37 +01:00
7903ade2b4 Add support for List[BaseModel] type to Field class 2024-01-23 20:05:38 +01:00
ea0bf1bb60 Report class name when reporting an error during instantiating BaseModel object 2024-01-23 20:05:33 +01:00
b4a1b29f57 Fix exporting an empty model field in BaseModel.dict() 2024-01-23 20:05:28 +01:00
3baeb4b64e Fix initializing a sub-model instance from a dictionary 2024-01-23 20:05:24 +01:00
35433fc341 Implement 'Enum' support in models 2024-01-23 20:05:17 +01:00
86e06a341f Fix Field.origin_type for Optional types 2024-01-23 20:05:11 +01:00
b8d6c949c9 Drop unused 'exclude_unset' argument from BaseModel.dict() method 2024-01-04 10:20:58 +01:00
16cdc067a5 Store cached model defaults in self._defaults, avoid sharing references to mutable defaults 2024-01-03 21:22:30 +01:00
587c094f61 Limit model attributes to predefined fields by forbidding creating new attributes on fly 2024-01-03 21:21:38 +01:00
3c733387af Store model values in self._values dict instead of private attributes 2024-01-03 21:21:29 +01:00
31059f0f92
Merge pull request #1452 from adrianschroeter/productcompose
productcompose: Support building with updateinfo.xml data
2024-01-02 08:05:25 +01:00
608fc76cd2 docs: Update models to avoid including lazy defaults in the rendered man pages
Lazy defaults may return different results under different circumstances
and we always want man pages rendered consistently.
2023-12-01 16:22:13 +01:00
7434a31a89 productcompose: Support building with updateinfo.xml data 2023-11-24 15:47:12 +01:00
930b7a8a4e Add 'osc.util.models' module implementing an alternative pydantic-like data validation 2023-09-11 21:11:05 +02:00
54d1884e1d Add 'osc.util.xdg' module for handling XDG paths 2023-09-11 21:11:05 +02:00
Rainer Müller
241b34d645 Refactor tar open functions to return early 2022-09-30 15:51:06 +02:00
Rainer Müller
395df87fa1 Remove workarounds for python2 compatibility 2022-09-30 15:48:36 +02:00
Rainer Müller
bcdc3b1835 Replace double with single underscores to avoid name mangling 2022-09-30 15:47:46 +02:00
Rainer Müller
a6fd4f88d3 Refactor extracting control from Debian package
Use separate functions for each compression type instead of a
cascade of conditionals.
2022-09-30 15:45:57 +02:00
Rainer Müller
5a13baf2ab Handle uncompressed Debian packages
Debian packages can also be uncompressed in which case the archive
contains a control.tar file.
2022-09-30 15:44:14 +02:00
959d054ec8 Fix whitespace issues in osc.util 2022-09-12 15:44:27 +02:00
b511be20ff Always import at the toplevel 2022-09-12 13:45:19 +02:00
6d891d7488 Remove superfluous parens 2022-09-12 13:45:19 +02:00
3296fd8d89 User super() instead of referencing parent classes explicitly 2022-09-12 13:45:19 +02:00
ee39653dc7 Fix indentation 2022-09-09 09:33:51 +02:00
ff63226c2f Properly test for None 2022-09-09 09:33:51 +02:00
8acad28cc0 git_version: Return version from the source code if there's no matching tag 2022-08-22 11:08:34 +02:00
Anatoli Babenia
0bc142df91 Move format_table to util.helper 2022-08-02 14:45:23 +03:00
feb53212dd Modernize code with pyupgrade
pyupgrade --keep-percent-format --py36-plus `find -name '*.py'`
2022-07-28 19:14:12 +02:00
229913a77f Clean imports up, drop python 2 fallbacks 2022-07-28 13:17:43 +02:00
69f75a0278 Open osc 1.0 development
Upcoming changes:
- drop python2 support
- replace M2Crypto with cryptography
- replace cmdln.py/optparse with argparse
- various cleanups
2022-07-27 10:46:55 +02:00
2aaefb7c79 Fix detecting version from git in archives from GitHub
There seem to be a bug in how GitHub generates archives.
"Format:" and "$" characters get removed from the version string,
setting it to:

    version = "%(describe:tags=true)"
2022-07-04 14:43:21 +02:00
fec667c70d Fix crash in determining git version when git command is not available 2022-06-24 12:24:53 +02:00
40067dce0a Auto-generate git versions compatible with PEP 440
`git archive` is configured to set osc version according to the git tag
via .gitattributes/export-subst
2022-06-08 08:48:50 +02:00
dec6f7135d
Merge pull request #1043 from dirkmueller/download_url_quoting
Fix quoting of download urls
2022-06-02 13:28:59 +02:00
1715163166
Merge pull request #994 from dmach/update-sphinx-configuration
Update Sphinx configuration
2022-06-02 10:09:38 +02:00
Dirk Müller
b7ed6534eb
trailing whitespace cleanup 2022-05-20 12:00:44 +02:00
Dirk Müller
3ed913c007
Whitespace fixes as expected by pycodestyle/pep8 2022-04-27 14:13:18 +02:00
1385297978 Fix several issues in HTML doc rendering, improve output 2022-03-16 15:19:24 +01:00
fe311c7ae5
support zst compressed control files in deb archives
eg. some packages Ubuntu 21.10
2021-10-26 07:29:43 +02:00
b5d337d037
fix hdmrd5 check of local cached files
Current OBS is delivering hdrmd5 in buildinfo. It turns out
that osc has already code for validating cached files, but it
invalidates all local files atm with python 3.x
2021-10-12 10:54:20 +02:00
Marcus Huewe
1933da5bcc Use os.getcwdb() instead of os.getcwd().encode() in util.cpio.CpioRead
Using os.getcwd() in combination with a subsequent .encode() is error
prone:

marcus@linux:~> mkdir illegal_utf-8_encoding_$'\xff'_dir
marcus@linux:~> cd illegal_utf-8_encoding_$'\xff'_dir/
marcus@linux:~/illegal_utf-8_encoding_ÿ_dir> python3
Python 3.8.6 (default, Nov 09 2020, 12:09:06) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd().encode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 36: surrogates not allowed
>>>

Hence, use os.getcwdb(), which returns a bytes, instead of
os.getcwd().encode().

Fixes: commit 36f7b8ffe9 ("Fix a
potential TypeError in CpioRead.copyin and CpioRead.copyin_file")
2020-11-22 17:39:54 +01:00
Marcus Huewe
674ea78815 Avoid a potential TypeError in util.ArFile.saveTo
If no dir is passed to util.ArFile.saveTo, dir is set to os.getcwd(),
which returns a str. Since self.name is a bytes, the subsequent
os.path.join(dir, self.name) results in a TypeError.
To fix this, use os.getcwdb(), which returns a bytes instead of a
str.
2020-11-22 17:36:17 +01:00
Marcus Huewe
36f7b8ffe9 Fix a potential TypeError in CpioRead.copyin and CpioRead.copyin_file
If no "dest" argument is specified when calling CpioRead.copyin or
CpioRead.copyin_file, a TypeError occurs in CpioRead._copyin_file
because os.getcwd(), which returns a str, is used as dest and, hence,
the subsequent os.path.join(...) fails (because it tries to join a
str and a bytes).
In order to avoid this, encode the result of os.getcwd().

Note that the existing

archive.copyin_file(hdr.filename,
                    os.path.dirname(tmpfile),
                    os.path.basename(tmpfile))

was OK because CpioRead._copyin_file os.path.join()s "dest" and
"new_fn", which are both str. It is just changed to stress that
CpioRead is a bytes-only API.

Fixes: #865 ("Traceback in osc/util/cpio.py line 128: TypeError:
Can't mix strings and bytes in path components")
2020-11-20 09:55:09 +01:00
Marcus Huewe
d85030b72d Fix python2 regression in util.helper.decode_it
In commit 276d6e2439 ("Do not use the
chardet module in util.helper.decode_it") util.helper.decode_it was
changed to always decode the passed object if it has a decode method.
Since a python2 str has a decode method, the new code tries to utf-8
decode the passed str. As a result, a unicode object is returned (if
the decoding worked). Since a unicode object is not an instance of
type str, all subsequent isinstance(decoded_obj, str) checks evaluate
to False, which break some codepaths.
In order to fix this, restore the old python2 behavior (that is, if
the passed object is a str, it is not decode it). This change does not
affect the python3 codepaths.

Fixes: #814 ("osc log | fails")
2020-06-25 15:38:14 +02:00
Marcus Huewe
276d6e2439 Do not use the chardet module in util.helper.decode_it
In general, decode_it is used to get a str from an arbitrary bytes
instance. For this, decode_it used the chardet module (if present)
to detect the underlying encoding (if the bytes instance corresponds
to a "supported" encoding). The drawback of this detection is that
it can take quite some time in case of a large bytes instance, which
represents no "supported" encoding (see #669 and #746).
Instead of doing a potentially "time consuming" detection, either
assume an utf-8 encoding or a latin-1 encoding. Rationale: it is just
not worth the effort to detect a _potential_ encoding because we have
no clue what the _correct_ encoding is. For instance, consider the
following bytes instance:

b'This character group is not supported: [abc\xc3\xbf]'

It represents a valid utf-8 and latin-1 encoding. What is the "correct"
one? We don't know... Even if you interpret the bytes instance as a
human you cannot give a definite answer (implicit assumption: there is
no additional context available).
That is, if we cannot give a definite answer in case of two potential
encodings, there is no point in bringing even more potential encodings
into play. Hence, do not use the chardet module.

Note: the rationale for trying utf-8 first is that utf-8 is pretty
much in vogue these days and, hence, the chances are "high" that we
guess the "correct" encoding.

Fixes: #669 ("check in huge shell archives is insanely slow")
Fixes: #746 ("Very slow local buildlog parsing")
2020-06-04 13:12:22 +02:00
Adam Williamson
13a13a87c4 Fix ElementTree imports for Python 3.9
Importing `cElementTree` has been deprecated since Python 3.3 -
importing `ElementTree` automatically uses the fastest
implementation available - and is finally removed in Python 3.9.
Importing cElementTree directly (not as part of xml) is an even
older relic, it's for Ye Time Before ElementTree Was Added To
Python and it was instead an external module...which was before
Python 2.5.

We still need to work with Python 2.7 for now, so we use a try/
except to handle both 2.7 and 3.9 cases. Also, let's not repeat
this import 12 times in one file for some reason.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2020-06-02 15:13:10 -07:00
Marcus Huewe
55aef1a014 Convert repodata.RepoDataQueryResult to a bytes API
The repodata.RepoDataQueryResult is supposed to be a bytes API and
that's what our users (see build module) expect.
Note that the repodata.RepoDataQueryResult.path method still returns
a str. That's what the rpmquery.RpmQuery, debquery.DebQuery, and
archquery.ArchQuery classes also do (if the "path" was initially
passed as a str).

Fixes: #760 ("osc build fails when called with --prefer-pkgs where the
       passed directory is a repodata repository or a subdirectory of one")
2020-03-15 18:30:28 +01:00