diff options
author | 2013-08-01 17:50:23 +0200 | |
---|---|---|
committer | 2013-08-01 17:50:23 +0200 | |
commit | 3dee515c81d7c7dd43b9abaf012bc38a2732b573 (patch) | |
tree | aaeb97fd7c35847385752b4e0319dbcadeff7df0 | |
parent | g-elpa.eclass fixed, it does not write to distdir now (diff) | |
download | gs-elpa-3dee515c81d7c7dd43b9abaf012bc38a2732b573.tar.gz gs-elpa-3dee515c81d7c7dd43b9abaf012bc38a2732b573.tar.bz2 gs-elpa-3dee515c81d7c7dd43b9abaf012bc38a2732b573.zip |
ELPA backend: Docstrings snd different fixes
-rw-r--r-- | gs_elpa/backend.py | 9 | ||||
-rw-r--r-- | gs_elpa/ebuild.py | 17 | ||||
-rw-r--r-- | gs_elpa/elpa_db.py | 54 | ||||
-rw-r--r-- | gs_elpa/fileutils.py | 12 |
4 files changed, 64 insertions, 28 deletions
diff --git a/gs_elpa/backend.py b/gs_elpa/backend.py index cad82c9..259fab6 100644 --- a/gs_elpa/backend.py +++ b/gs_elpa/backend.py @@ -19,14 +19,19 @@ from g_sorcery.eclass import EclassGenerator from g_sorcery.fileutils import get_pkgpath from .elpa_db import ElpaDBGenerator -from .ebuild import ElpaEbuildWithDigestGenerator, ElpaEbuildWithoutDigestGenerator +from .ebuild import ElpaEbuildWithDigestGenerator, \ + ElpaEbuildWithoutDigestGenerator class ElpaEclassGenerator(EclassGenerator): + """ + Implementation of eclass generator. Only specifies a data directory. + """ def __init__(self): super(ElpaEclassGenerator, self).__init__(os.path.join(get_pkgpath(__file__), 'data')) - + +#Backend instance to be loaded by g_sorcery instance = Backend(ElpaDBGenerator, ElpaEbuildWithDigestGenerator, ElpaEbuildWithoutDigestGenerator, ElpaEclassGenerator, MetadataGenerator) diff --git a/gs_elpa/ebuild.py b/gs_elpa/ebuild.py index 895ae5b..e7fd502 100644 --- a/gs_elpa/ebuild.py +++ b/gs_elpa/ebuild.py @@ -12,16 +12,18 @@ """ import collections -import os from g_sorcery.ebuild import DefaultEbuildGenerator -from g_sorcery.fileutils import get_pkgpath Layout = collections.namedtuple("Layout", - ["vars_before_inherit", "inherit", "vars_after_description", "vars_after_keywords"]) + ["vars_before_inherit", "inherit", + "vars_after_description", "vars_after_keywords"]) class ElpaEbuildWithDigestGenerator(DefaultEbuildGenerator): + """ + Implementation of ebuild generator with sources digesting. + """ def __init__(self, package_db): vars_before_inherit = \ @@ -35,11 +37,15 @@ class ElpaEbuildWithDigestGenerator(DefaultEbuildGenerator): vars_after_keywords = \ ["depend", "rdepend"] - layout = Layout(vars_before_inherit, inherit, vars_after_description, vars_after_keywords) + layout = Layout(vars_before_inherit, + inherit, vars_after_description, vars_after_keywords) super(ElpaEbuildWithDigestGenerator, self).__init__(package_db, layout) class ElpaEbuildWithoutDigestGenerator(DefaultEbuildGenerator): + """ + Implementation of ebuild generator without sources digesting. + """ def __init__(self, package_db): vars_before_inherit = \ @@ -53,6 +59,7 @@ class ElpaEbuildWithoutDigestGenerator(DefaultEbuildGenerator): vars_after_keywords = \ ["depend", "rdepend"] - layout = Layout(vars_before_inherit, inherit, vars_after_description, vars_after_keywords) + layout = Layout(vars_before_inherit, inherit, + vars_after_description, vars_after_keywords) super(ElpaEbuildWithoutDigestGenerator, self).__init__(package_db, layout) diff --git a/gs_elpa/elpa_db.py b/gs_elpa/elpa_db.py index 586d02a..b7ffefb 100644 --- a/gs_elpa/elpa_db.py +++ b/gs_elpa/elpa_db.py @@ -11,11 +11,9 @@ :license: GPL-2, see LICENSE for more details. """ -import os - import sexpdata -from g_sorcery.compatibility import py2k, TemporaryDirectory +from g_sorcery.compatibility import py2k if py2k: from urlparse import urljoin @@ -27,16 +25,40 @@ from g_sorcery.package_db import DBGenerator from g_sorcery.exceptions import SyncError class ElpaDBGenerator(DBGenerator): + """ + Implementation of database generator for ELPA backend. + """ def get_download_uries(self, common_config, config): + """ + Download database file from REPO_URI/archive-contents + and parse it with sexpdata. + + Args: + common_config: Backend config. + config: Repository config. + + Returns: + List with one URI entry. + """ ac_uri = urljoin(config["repo_uri"], 'archive-contents') return [{"uri" : ac_uri, "parser" : sexpdata.load}] def process_data(self, pkg_db, data, common_config, config): + """ + Process downloaded and parsed data and generate tree. + + Args: + pkg_db: Package database. + data: Dictionary with data, keys are file names. + common_config; Backend config. + config: Repository config. + """ archive_contents = data['archive-contents'] repo_uri = config["repo_uri"] if sexpdata.car(archive_contents) != 1: - raise SyncError('sync failed: ' + repo_uri + ' bad archive contents format') + raise SyncError('sync failed: ' \ + + repo_uri + ' bad archive contents format') pkg_db.add_category('app-emacs') @@ -49,7 +71,7 @@ class ElpaDBGenerator(DBGenerator): INFO_SRC_TYPE = 3 DEP_NAME = 0 - DEP_VERSION = 1 + #DEP_VERSION = 1 #we do not use it at the moment for entry in sexpdata.cdr(archive_contents): desc = entry[PKG_INFO].value() @@ -58,18 +80,21 @@ class ElpaDBGenerator(DBGenerator): if self.in_config([common_config, config], "exclude", realname): continue - pkg = Package("app-emacs", realname, '.'.join(map(str, desc[INFO_VERSION]))) + pkg = Package("app-emacs", realname, + '.'.join(map(str, desc[INFO_VERSION]))) source_type = desc[INFO_SRC_TYPE].value() - allowed_ords = set(range(ord('a'), ord('z'))) | set(range(ord('A'), ord('Z'))) | \ - set(range(ord('0'), ord('9'))) | set(list(map(ord, + allowed_ords = set(range(ord('a'), ord('z'))) \ + | set(range(ord('A'), ord('Z'))) | \ + set(range(ord('0'), ord('9'))) | set(list(map(ord, ['+', '_', '-', ' ', '.', '(', ')', '[', ']', '{', '}', ',']))) description = "".join([x for x in desc[INFO_DESCRIPTION] if ord(x) in allowed_ords]) deps = desc[INFO_DEPENDENCIES] dependencies = serializable_elist(separator="\n\t") for dep in deps: - dep = self.convert_dependency([common_config, config], dep[DEP_NAME].value(), external = False) + dep = self.convert_dependency([common_config, config], + dep[DEP_NAME].value(), external = False) if dep: dependencies.append(dep) @@ -91,4 +116,15 @@ class ElpaDBGenerator(DBGenerator): pkg_db.add_package(pkg, properties) def convert_internal_dependency(self, configs, dependency): + """ + At the moment we have only internal dependencies, each of them + is just a package name. + + Args: + configs: Backend and repo configs. + dependency: Package name. + + Returns: + Dependency instance with category="app-emacs", package="dependency". + """ return Dependency("app-emacs", dependency) diff --git a/gs_elpa/fileutils.py b/gs_elpa/fileutils.py deleted file mode 100644 index 035274c..0000000 --- a/gs_elpa/fileutils.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" - fileutils.py - ~~~~~~~~~~~~ - - file utilities - - :copyright: (c) 2013 by Jauhien Piatlicki - :license: GPL-2, see LICENSE for more details. -""" |