Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
settings.DEFAULT_TEMPLATE),
metavar='TEMPLATE')
@click.option('-o',
help='Default distro whose conversion rules to use '
'(default:"{0}"). Default templates have their rules associated '
'and ignore this.'.format(settings.DEFAULT_DISTRO),
type=click.Choice(settings.KNOWN_DISTROS),
default=settings.DEFAULT_DISTRO)
@click.option('-b',
help='Base Python version to package for (fedora '
'default: "{0}").'.format(settings.DEFAULT_PYTHON_VERSION),
default=None,
metavar='BASE_PYTHON')
@click.option('-p',
help='Additional Python versions to include in the specfile '
'(e.g -p2 for python2 subpackage). Can be specified multiple '
'times. Specify additional version or use -b explicitly to '
def __init__(self, package=None, version=None, prerelease=False,
save_dir=None,
template=settings.DEFAULT_TEMPLATE,
distro=settings.DEFAULT_DISTRO,
base_python_version=settings.DEFAULT_PYTHON_VERSION,
python_versions=[],
rpm_name=None, proxy=None, venv=True, autonc=False):
self.package = package
self.version = version
self.prerelease = prerelease
self.save_dir = save_dir
self.base_python_version = base_python_version
self.python_versions = list(python_versions)
self.template = template
self.distro = distro
if not self.template.endswith('.spec'):
self.template = '{0}.spec'.format(self.template)
self.rpm_name = rpm_name
self.proxy = proxy
def get_default_py_version(cls):
try:
return settings.DEFAULT_PYTHON_VERSIONS[cls.distro][0]
except KeyError:
logger.error('Default python versions for template {0} are '
'missing in settings, using versions of template '
'{1}.'.format(cls.distro,
settings.DEFAULT_TEMPLATE))
return settings.DEFAULT_PYTHON_VERSIONS[
settings.DEFAULT_TEMPLATE][0]
if t and os.path.splitext(t)[0] in settings.KNOWN_DISTROS:
distro = t
if not distro and not (b or p):
raise click.UsageError("Default python versions for template {0} are "
"missing in settings, add them or use flags "
"-b/-p to set python versions.".format(t))
logger = logging.getLogger(__name__)
logger.info('Pyp2rpm initialized.')
convertor = Convertor(package=package,
version=v,
prerelease=prerelease,
save_dir=d,
template=t or settings.DEFAULT_TEMPLATE,
distro=distro,
base_python_version=b,
python_versions=p,
rpm_name=r,
proxy=proxy,
venv=venv,
autonc=autonc)
logger.debug(
'Convertor: {0} created. Trying to convert.'.format(convertor))
converted = convertor.convert()
logger.debug('Convertor: {0} succesfully converted.'.format(convertor))
if sclize:
converted = convert_to_scl(converted, scl_kwargs)
def get_default_py_version(cls):
try:
return settings.DEFAULT_PYTHON_VERSIONS[cls.distro][0]
except KeyError:
logger.error('Default python versions for template {0} are '
'missing in settings, using versions of template '
'{1}.'.format(cls.distro,
settings.DEFAULT_TEMPLATE))
return settings.DEFAULT_PYTHON_VERSIONS[
settings.DEFAULT_TEMPLATE][0]
import logging
import re
try:
import dnf
except ImportError:
dnf = None
from pkg_resources import safe_name
from pyp2rpm import settings
logger = logging.getLogger(__name__)
class NameConvertor(object):
distro = settings.DEFAULT_TEMPLATE
def __init__(self, distro):
self.distro = distro
self.reg_start = re.compile(r'^[Pp]ython(\d*|)-(.*)')
self.reg_end = re.compile(r'(.*)-(python)(\d*|)$')
@classmethod
def get_default_py_version(cls):
try:
return settings.DEFAULT_PYTHON_VERSIONS[cls.distro][0]
except KeyError:
logger.error('Default python versions for template {0} are '
'missing in settings, using versions of template '
'{1}.'.format(cls.distro,
settings.DEFAULT_TEMPLATE))
return settings.DEFAULT_PYTHON_VERSIONS[