cmds.projects.CmdCreateFile: Fix spurious trailing newline
create-file and create-pkg-config both print the rendered template with a newline appended over the original template, owed to using print() instead of sys.stdout.write(). Fix that. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
61280e4695
commit
174c6fba16
2 changed files with 13 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import sys
|
||||
|
||||
from argparse import ArgumentParser, ArgumentTypeError, Namespace
|
||||
from enum import Enum, auto
|
||||
from typing import override
|
||||
|
|
@ -132,4 +134,4 @@ class CmdCreateFile(Cmd): # export
|
|||
method = getattr(self, 'render_' + args.format, None)
|
||||
if method is None: # Should be prevented by choices=[] but keeps linter happy
|
||||
raise Exception(f'Unsupported output format {args.format}')
|
||||
print(method(args.module, args.field))
|
||||
sys.stdout.write(method(args.module, args.field))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from typing import TYPE_CHECKING, override
|
||||
|
||||
from .Cmd import Cmd, Parent
|
||||
|
|
@ -74,16 +76,19 @@ class CmdCreatePkgConfig(Cmd): # export
|
|||
]
|
||||
)
|
||||
|
||||
extra: list[str] = []
|
||||
if args.cflags is not None:
|
||||
contents += f'Cflags: {args.cflags}\n'
|
||||
extra.append(f'Cflags: {args.cflags}')
|
||||
if args.libflags is not None:
|
||||
contents += f'Libs: {args.libflags}\n'
|
||||
extra.append(f'Libs: {args.libflags}')
|
||||
val = merged.get('requires_run')
|
||||
if val is not None:
|
||||
contents += f'Requires: {self.__cleanup_requires(val)}'
|
||||
extra.append(f'Requires: {self.__cleanup_requires(val)}')
|
||||
val = merged.get('requires_build')
|
||||
if val is not None:
|
||||
contents += (f'Requires.private: {self.__cleanup_requires(val)}')
|
||||
extra.append(f'Requires.private: {self.__cleanup_requires(val)}')
|
||||
# not sure what to do with requires_devel
|
||||
|
||||
print(contents)
|
||||
if extra:
|
||||
contents += '\n'.join(extra)
|
||||
sys.stdout.write(contents)
|
||||
|
|
|
|||
Loading…
Reference in a new issue