Source code for libka.package_info

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# vim: expandtab ts=4

############################################################################
#   Copyright © 2015-2016 José Manuel Santamaría Lema <panfaust@gmail.com> #
#                                                                          #
#   This program is free software; you can redistribute it and/or modify   #
#   it under the terms of the GNU General Public License as published by   #
#   the Free Software Foundation; either version 2 of the License, or      #
#   (at your option) any later version.                                    #
############################################################################

from libka.kde_ftp import *

import re
import codecs
from debian.changelog import Changelog

[docs] def upstreamNameFromWatch(): f = open("debian/watch", "r") for line in f: if re.match(r'.*download\.kde\.org', line) or re.match(r'.*download\.qt\.io', line): upstream_name = re.sub(r'.*\/', '', line) upstream_name = re.sub(r'-\(.*', '', upstream_name) upstream_name = upstream_name.strip() if "@PACKAGE@" not in upstream_name: return upstream_name #If we didn't find 'download.kde.org' or 'download.qt.io' in the watch file, #fall back to the source package name changelog = Changelog() changelog.parse_changelog(codecs.open('./debian/changelog', 'r', 'utf-8')) src_package_name = changelog.get_package() return src_package_name
[docs] def upstreamGitName(): upstream_tarball_name = upstreamNameFromWatch() kde_git_map = readJsonDataFile('name-conversions/kde-tarball-to-kde-git.json') if upstream_tarball_name in kde_git_map: return kde_git_map[upstream_tarball_name] else: return upstream_tarball_name
#Find out the release type for a given package #Returns the release type string: "frameworks", "plasma", "applications", "qt" or "other" #If the parameter upstream_name isn't given, it tries to find it out dynamically
[docs] def getReleaseType(upstream_name=None): if upstream_name is None: try: upstream_name = upstreamNameFromWatch() except: return "other" release_types_to_check = ["frameworks", "plasma", "applications", "qt"] for rt in release_types_to_check: if upstream_name in getFtpVersionMap(rt): return rt return "other"
#Check if the package is a native package
[docs] def isNativePackage(): try: with open('debian/source/format', 'r') as content_file: content = content_file.read().strip() if content == "3.0 (native)": return True else: return False except: return False