Skip to content
Snippets Groups Projects
Commit 183e5220 authored by Dylan Aïssi's avatar Dylan Aïssi
Browse files

import-debian-package: do not use Path objects as a context manager


pathlib.Path.__enter__() is deprecated and scheduled for removal
in Python 3.13. Some warnings are generated with Python 3.11:

import-debian-package:281: DeprecationWarning: pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-op
  with Path(".git/info/attributes") as f:
import-debian-package:225: DeprecationWarning: pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-op
  with Path('debian/apertis/component') as f:
import-debian-package:169: DeprecationWarning: pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-op
  with Path("debian/changelog") as f:

Signed-off-by: default avatarDylan Aïssi <dylan.aissi@collabora.com>
parent b9176678
No related branches found
No related tags found
3 merge requests!74Merge changes from apertis/v2024-updates into apertis/v2024,!73Backport v2024 <- v2025dev2: Release apertis-dev-tools version 0.2024.2,!69import-debian-package: do not use Path objects as a context manager
......@@ -166,23 +166,23 @@ def ensure_dir_or_none(path: Optional[str]):
return None
def bump_version(args, distribution: str, version: Version):
with Path("debian/changelog") as f:
ch = Changelog(f.read_text())
if version <= ch.version:
raise VersionError("The new version must be greater than the last one.")
ch.new_block(package=ch.package,
version=version,
distributions=distribution,
urgency='medium',
author=('%s <%s>' % (args.maint_name, args.maint_email)),
date=format_date())
ch.add_change('')
ch.add_change(f' * Import from Debian {args.upstream}.')
ch.add_change(f' * Set component to {args.component}.')
ch.add_change(f' * {args.reason}.')
ch.add_change('')
f.write_text(str(ch))
git.add('-f', f)
f_dch = Path("debian/changelog")
ch = Changelog(f_dch.read_text())
if version <= ch.version:
raise VersionError("The new version must be greater than the last one.")
ch.new_block(package=ch.package,
version=version,
distributions=distribution,
urgency='medium',
author=('%s <%s>' % (args.maint_name, args.maint_email)),
date=format_date())
ch.add_change('')
ch.add_change(f' * Import from Debian {args.upstream}.')
ch.add_change(f' * Set component to {args.component}.')
ch.add_change(f' * {args.reason}.')
ch.add_change('')
f_dch.write_text(str(ch))
git.add('-f', f_dch)
def import_debian_dsc(args, dsc_file: Path, upstream: str, downstream: str, version: Version):
upstream_release = upstream.split('/')[-1]
......@@ -222,10 +222,10 @@ def import_debian_dsc(args, dsc_file: Path, upstream: str, downstream: str, vers
force_branch(downstream, commit)
git.checkout(f'{downstream}')
logging.info('Adding Apertis delta')
with Path('debian/apertis/component') as f:
f.parent.mkdir(exist_ok=True)
f.write_text(args.component + "\n")
git.add('-f', f)
f_compo = Path('debian/apertis/component')
f_compo.parent.mkdir(exist_ok=True)
f_compo.write_text(args.component + "\n")
git.add('-f', f_compo)
git.commit('--no-edit', '--no-gpg-sign', '-m', f'Import Apertis version {version}')
# now create the tag
# git.tag('-a', '-m', f'Apertis version {version}', apertis_tag)
......@@ -278,9 +278,9 @@ def do_import(args):
git.init()
configure_user_email(args.maint_name, args.maint_email)
with Path(".git/info/attributes") as f:
f.parent.mkdir(exist_ok=True)
f.write_text("* -text -eol -crlf -ident -filter -working-tree-encoding -export-subst\n")
f_attrib = Path(".git/info/attributes")
f_attrib.parent.mkdir(exist_ok=True)
f_attrib.write_text("* -text -eol -crlf -ident -filter -working-tree-encoding -export-subst\n")
package, downstream, upstream = args.package, args.downstreams.pop(0), args.upstream
if upstream == "unstable":
......@@ -355,10 +355,10 @@ def do_import(args):
'--no-pristine-tar',
args.dsc.name]) == 0: # success
logging.info('Re-adding Apertis delta')
with Path('debian/apertis/component') as f:
f.parent.mkdir(exist_ok=True)
f.write_text(args.component)
git.add('-f', f)
f_compo = Path('debian/apertis/component')
f_compo.parent.mkdir(exist_ok=True)
f_compo.write_text(args.component)
git.add('-f', f_compo)
git.commit('--amend', '--no-edit', '--no-gpg-sign', '-m', f'Import Apertis version {overlay_version}')
new_tag = DebianGitRepository.version_to_tag("apertis/%(version)s", str(overlay_version))
# git.tag('-a', '-m', f'Apertis version {overlay_version}', new_tag)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment