euscan: move version type helpers to euscan.version
Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
parent
6f9e575bbc
commit
8743e9d1e1
@ -8,14 +8,12 @@ from xml.etree.ElementTree import iterparse, ParseError
|
|||||||
from django.db.transaction import commit_on_success
|
from django.db.transaction import commit_on_success
|
||||||
from django.core.management.color import color_style
|
from django.core.management.color import color_style
|
||||||
|
|
||||||
from euscan.helpers import get_version_type
|
from euscan.version import get_version_type
|
||||||
|
|
||||||
from djeuscan.processing import FakeLogger
|
from djeuscan.processing import FakeLogger
|
||||||
from djeuscan.models import Package, Version, VersionLog
|
from djeuscan.models import Package, Version, VersionLog
|
||||||
|
|
||||||
|
PORTDB = None
|
||||||
PORTDB = portage.db[portage.root]["porttree"].dbapi
|
|
||||||
|
|
||||||
|
|
||||||
class ScanPortage(object):
|
class ScanPortage(object):
|
||||||
def __init__(self, logger=None, no_log=False, purge_packages=False,
|
def __init__(self, logger=None, no_log=False, purge_packages=False,
|
||||||
@ -25,6 +23,10 @@ class ScanPortage(object):
|
|||||||
self.purge_packages = purge_packages
|
self.purge_packages = purge_packages
|
||||||
self.purge_versions = purge_versions
|
self.purge_versions = purge_versions
|
||||||
|
|
||||||
|
if not PORTDB: # Lazy loading for portdb
|
||||||
|
global PORTDB
|
||||||
|
PORTDB = portage.db[portage.root]["porttree"].dbapi
|
||||||
|
|
||||||
self.style = color_style()
|
self.style = color_style()
|
||||||
|
|
||||||
self._cache = {'packages': {}, 'versions': {}}
|
self._cache = {'packages': {}, 'versions': {}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
<table id="table" class="display">
|
<table id="table" class="display">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
<table id="table" class="display">
|
<table id="table" class="display">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
<table id="table" class="display">
|
<table id="table" class="display">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load mul %}
|
{% load mul %}
|
||||||
{% load sub %}
|
{% load sub %}
|
||||||
{% load div %}
|
{% load div %}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load sub %}
|
{% load sub %}
|
||||||
{% load div %}
|
{% load div %}
|
||||||
{% load mul %}
|
{% load mul %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - Watched categories
|
{{ block.super }} - Watched categories
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - Watched herds
|
{{ block.super }} - Watched herds
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - Watched maintainers
|
{{ block.super }} - Watched maintainers
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - Watched packages
|
{{ block.super }} - Watched packages
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - Overlay: {{ overlay }}
|
{{ block.super }} - Overlay: {{ overlay }}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load sub %}
|
{% load sub %}
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
{% load url from future %}
|
{% load url from future %}
|
||||||
|
|
||||||
{% block meta %}
|
{% block meta %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% extends "euscan/_datatable.html" %}
|
{% extends "euscan/_datatable.html" %}
|
||||||
|
|
||||||
{% load euscan_tags %}
|
{% load djeuscan_helpers %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{{ block.super }} - World Scan
|
{{ block.super }} - World Scan
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
from django import template
|
from django import template
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from euscan import helpers
|
from euscan.version import is_version_type_stable, get_version_type
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('euscan/_packages.html', takes_context=True)
|
@register.inclusion_tag('euscan/_packages.html', takes_context=True)
|
||||||
def packages(context, pkgs):
|
def packages(context, pkgs):
|
||||||
context['packages'] = pkgs
|
context['packages'] = pkgs
|
||||||
@ -61,9 +60,9 @@ def overlays_table(overlays):
|
|||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def is_stable(version_type):
|
def is_stable(version_type):
|
||||||
return helpers.is_version_type_stable(version_type)
|
return is_version_type_stable(version_type)
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def version_type(version):
|
def version_type(version):
|
||||||
return helpers.get_version_type(version)
|
return get_version_type(version)
|
@ -239,6 +239,7 @@ CELERYD_CONCURRENCY = 4
|
|||||||
TASKS_UPSTREAM_GROUPS = 32
|
TASKS_UPSTREAM_GROUPS = 32
|
||||||
|
|
||||||
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
|
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
|
||||||
|
CELERYBEAT_SCHEDULE = {}
|
||||||
|
|
||||||
# LDAP authentication
|
# LDAP authentication
|
||||||
# TODO: Test data - change me!
|
# TODO: Test data - change me!
|
||||||
|
@ -33,27 +33,6 @@ VERSION_CMP_PACKAGE_QUIRKS = {
|
|||||||
_v_end = '((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)'
|
_v_end = '((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)'
|
||||||
_v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(' + _v_end + '*))'
|
_v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(' + _v_end + '*))'
|
||||||
|
|
||||||
|
|
||||||
def is_version_stable(version):
|
|
||||||
return is_version_type_stable(get_version_type(version))
|
|
||||||
|
|
||||||
|
|
||||||
def is_version_type_stable(version_type):
|
|
||||||
return version_type not in ("alpha", "beta", "pre", "rc")
|
|
||||||
|
|
||||||
|
|
||||||
def get_version_type(version):
|
|
||||||
types = []
|
|
||||||
gentoo_types = ("alpha", "beta", "pre", "rc", "p")
|
|
||||||
|
|
||||||
for token in re.findall("[\._-]([a-zA-Z]+)", version):
|
|
||||||
if token in gentoo_types:
|
|
||||||
types.append(token)
|
|
||||||
if types:
|
|
||||||
return types[0] # TODO: consider returning all types
|
|
||||||
return "release"
|
|
||||||
|
|
||||||
|
|
||||||
# Stolen from g-pypi
|
# Stolen from g-pypi
|
||||||
def gentoo_mangle_version(up_pv):
|
def gentoo_mangle_version(up_pv):
|
||||||
"""Convert PV to MY_PV if needed
|
"""Convert PV to MY_PV if needed
|
||||||
|
@ -170,7 +170,7 @@ class EuscanOutput(object):
|
|||||||
raise TypeError("Invalid output format")
|
raise TypeError("Invalid output format")
|
||||||
|
|
||||||
def result(self, cp, version, urls, handler, confidence):
|
def result(self, cp, version, urls, handler, confidence):
|
||||||
from euscan.helpers import get_version_type
|
from euscan.version import get_version_type
|
||||||
|
|
||||||
cpv = '%s-%s' % (cp, version)
|
cpv = '%s-%s' % (cp, version)
|
||||||
urls = ' '.join(transform_url(self.config, cpv, url) for url in urls.split())
|
urls = ' '.join(transform_url(self.config, cpv, url) for url in urls.split())
|
||||||
|
@ -13,7 +13,8 @@ from gentoolkit.package import Package
|
|||||||
|
|
||||||
from euscan import CONFIG, BLACKLIST_PACKAGES
|
from euscan import CONFIG, BLACKLIST_PACKAGES
|
||||||
from euscan import handlers, output
|
from euscan import handlers, output
|
||||||
from euscan.helpers import version_blacklisted, is_version_stable
|
from euscan.helpers import version_blacklisted,
|
||||||
|
from euscan.version import is_version_stable
|
||||||
from euscan.ebuild import package_from_ebuild
|
from euscan.ebuild import package_from_ebuild
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,22 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
def is_version_type_stable(version_type):
|
||||||
|
return version_type not in ("alpha", "beta", "pre", "rc")
|
||||||
|
|
||||||
|
def is_version_stable(version):
|
||||||
|
return is_version_type_stable(get_version_type(version))
|
||||||
|
|
||||||
|
def get_version_type(version):
|
||||||
|
types = []
|
||||||
|
gentoo_types = ("alpha", "beta", "pre", "rc", "p")
|
||||||
|
|
||||||
|
for token in re.findall("[\._-]([a-zA-Z]+)", version):
|
||||||
|
if token in gentoo_types:
|
||||||
|
types.append(token)
|
||||||
|
if types:
|
||||||
|
return types[0] # TODO: consider returning all types
|
||||||
|
return "release"
|
||||||
|
|
||||||
# Stolen from pkg_resources, but importing it is not a good idea
|
# Stolen from pkg_resources, but importing it is not a good idea
|
||||||
|
|
||||||
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
|
component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE)
|
||||||
|
Loading…
Reference in New Issue
Block a user