Verified Commit 1fc8a825 authored by Adam Mercer's avatar Adam Mercer 💬

consistent quote usage

parent fe282289
......@@ -55,8 +55,8 @@ def download_spec_sources(spec, outdir, logger=None):
spectool = find_executable('spectool')
cmd = [
spectool,
"--get-files",
"--directory",
'--get-files',
'--directory',
str(outdir),
str(spec),
]
......@@ -91,15 +91,15 @@ def build_src_rpm(source, *extra_rpmbuild_args, outdir=os.path.curdir,
with tempfile.TemporaryDirectory() as tmpdir:
tmppath = pathlib.Path(tmpdir)
sourcepath = tmppath / "SOURCES"
sourcepath = tmppath / 'SOURCES'
sourcepath.mkdir()
# run spectool to download sources
if type_ == "spec":
if type_ == 'spec':
download_spec_sources(source, sourcepath, logger=logger)
# run rpmbuild
rpmcmd = "-bs" if type_ == "spec" else "-ts"
rpmcmd = '-bs' if type_ == 'spec' else '-ts'
cmd = _rpmbuild_args(*extra_rpmbuild_args + (rpmcmd, str(source)),
tmpdir=tmpdir)
resp = logged_check_output(cmd, logger=logger).strip().decode('utf-8')
......
......@@ -28,7 +28,7 @@ def _koji_call(
*args,
**kwargs,
):
koji = find_executable("koji")
koji = find_executable('koji')
if koji is None:
raise FileNotFoundError("No such file or directory: 'koji'")
cmd = (koji,) + args
......@@ -36,12 +36,12 @@ def _koji_call(
def moshimoshi(*args, **kwargs):
return _koji_call("moshimoshi", *args, **kwargs)
return _koji_call('moshimoshi', *args, **kwargs)
def list_pkgs(*args, **kwargs):
return _koji_call("list-pkgs", *args, **kwargs)
return _koji_call('list-pkgs', *args, **kwargs)
def add_pkg(*args, **kwargs):
return _koji_call("add-pkg", *args, **kwargs)
return _koji_call('add-pkg', *args, **kwargs)
......@@ -29,49 +29,49 @@ from . import __version__
# metadata
#
DEFAULT_TARGET = "sandox"
DEFAULT_TARGET = 'sandox'
def parse_options():
# define option parser
parser = argparse.ArgumentParser(description='Build RPMs using Koji')
parser = argparse.ArgumentParser(description="Build RPMs using Koji")
parser.add_argument(
'-V', '--version',
action='version',
version=__version__,
help='show version number and exit'
help="show version number and exit"
)
parser.add_argument(
'-v', '--verbose',
action='count',
default=2,
help='show verbose output, give once for INFO, give twice for DEBUG'
help="show verbose output, give once for INFO, give twice for DEBUG"
)
# koji options
koji_options = parser.add_argument_group('Koji Options')
koji_options = parser.add_argument_group("Koji Options")
koji_options.add_argument(
'--target',
default=DEFAULT_TARGET,
help='koji tag to tag (default: %(default)s)'
help="koji tag to tag (default: %(default)s)"
)
koji_options.add_argument(
'--owner',
help='koji package owner'
help="koji package owner"
)
koji_options.add_argument(
'--scratch',
action='store_true',
default=False,
help='perform a scratch build (default: %(default)s)'
help="perform a scratch build (default: %(default)s)"
)
# source options
source_options = parser.add_argument_group('Source Options')
source_options = parser.add_argument_group("Source Options")
source_options.add_argument(
'source',
type=pathlib.Path,
help='source to build with Koji',
help="source to build with Koji"
)
source_types = source_options.add_mutually_exclusive_group()
source_types.add_argument(
......@@ -79,28 +79,28 @@ def parse_options():
action='store_const',
const='tarball',
dest='source_type',
help='source is a tarball',
help="source is a tarball"
)
source_types.add_argument(
'--git',
action='store_const',
const='git',
dest='source_type',
help='source is a git repo',
help="source is a git repo"
)
source_types.add_argument(
'--src-rpm',
action='store_const',
const='srcrpm',
dest='source_type',
help='source is a src.rpm',
help="source is a src.rpm"
)
source_types.add_argument(
'--spec',
action='store_const',
const='spec',
dest='source_type',
help='source is an RPM spec file',
help="source is an RPM spec file"
)
# parse options
......
......@@ -43,7 +43,7 @@ LOGGER_FORMAT = "[%(asctime)-15s] %(name)s | %(levelname)+8s | %(message)s"
LOGGER_DATEFMT = "%Y-%m-%d %H:%M:%S"
logging.basicConfig(format=LOGGER_FORMAT, datefmt=LOGGER_DATEFMT)
logger = logging.getLogger("gwkoji")
logger = logging.getLogger('gwkoji')
try:
import coloredlogs
except ImportError:
......@@ -68,9 +68,9 @@ def main():
set_logger_level(10 * max(5 - args.verbose, 0))
# print info
logger.info('-- gwkoji-packager -----')
logger.info('source = %s' % args.source)
logger.info('target tag = %s' % args.target)
logger.info("-- gwkoji-packager -----")
logger.info("source = %s" % args.source)
logger.info("target tag = %s" % args.target)
# determine source type
if not args.source_type:
......@@ -78,12 +78,12 @@ def main():
logger.info("source type = {!r}".format(args.source_type))
# check that source exists
if args.source_type != "git" and not args.source.is_file():
if args.source_type != 'git' and not args.source.is_file():
raise FileNotFoundError(
"No such file or directory: '{0}'".format(args.source),
)
if args.source_type not in ("srcrpm", "git"):
if args.source_type not in ('srcrpm', 'git'):
logger.info("generating src.rpm...")
tmpdir = tempfile.mkdtemp()
atexit.register(shutil.rmtree, tmpdir)
......@@ -92,9 +92,9 @@ def main():
# get pkg name from source rpm
try:
if args.source_type != "git":
if args.source_type != 'git':
pkg_name = rpm.get_package_name_from_source_rpm(args.source)
logger.info('package name = %s' % pkg_name)
logger.info("package name = %s" % pkg_name)
# how do we determine this when source is from git?
except subprocess.CalledProcessError as e:
logger.critical("unable to determine package name, %s" % e)
......@@ -108,22 +108,23 @@ def main():
raise
# determine if the package is already registered with koji
if args.source_type != "git":
if args.source_type != 'git':
try:
koji.list_pkgs("--quiet", "--package", pkg_name, logger=logger)
koji.list_pkgs('--quiet', '--package', pkg_name, logger=logger)
except subprocess.CalledProcessError:
pass
# register package with koji
if args.owner is None:
logger.critical('owner not specified')
logger.critical("owner not specified")
sys.exit(1)
try:
koji.add_pkg(args.owner, pkg_name, logger=logger)
except subprocess.CalledProcessError as e:
logger.critical('unable to regsiter package: %s' % e)
logger.critical("unable to regsiter package: %s" % e)
raise
logger.info('-- Complete -----')
logger.info("-- Complete -----")
#
......
......@@ -40,7 +40,7 @@ def _logged_call(func):
kwargs.setdefault('stdout', sys.stderr)
# log the command
logger.log(loglevel, '$ {0}'.format(' '.join(cmd)))
logger.log(loglevel, "$ {0}".format(" ".join(cmd)))
# run it
return func(cmd, *args, **kwargs)
......@@ -78,13 +78,13 @@ def source_type(source):
source = pathlib.Path(source)
name = source.name
if name.endswith(".src.rpm"):
return "srcrpm"
return 'srcrpm'
if name.endswith(".spec"):
return "spec"
return 'spec'
if name.endswith(".tar") or source.stem.endswith(".tar"):
return "tarball"
return 'tarball'
if str(source).startswith(("git+https", "git+ssh")):
return "git"
return 'git'
raise ValueError(
"failed to determine source type for '{0}'".format(source),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment