consistent quote usage

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