diff options
author | Jauhien Piatlicki <piatlicki@gmail.com> | 2013-07-16 19:11:31 +0200 |
---|---|---|
committer | Jauhien Piatlicki <jpiatlicki@zertisa.com> | 2013-07-16 19:11:31 +0200 |
commit | 91605f417bd7c912cbb5502a91da3872ed3e88d2 (patch) | |
tree | cb0de72272afd5d8b31efc1b6387defbcfaf7627 | |
parent | g_sorcery/package_db: better variable name, g_elpa/elpa_db: meaningful variab... (diff) | |
download | g-sorcery-91605f417bd7c912cbb5502a91da3872ed3e88d2.tar.gz g-sorcery-91605f417bd7c912cbb5502a91da3872ed3e88d2.tar.bz2 g-sorcery-91605f417bd7c912cbb5502a91da3872ed3e88d2.zip |
gs-ctan: initial commit
-rw-r--r-- | g_sorcery/g_sorcery.py | 4 | ||||
-rw-r--r-- | gs-ctan-overlays.xml | 14 | ||||
-rw-r--r-- | gs-ctan.json | 8 | ||||
-rw-r--r-- | gs_ctan/__init__.py | 2 | ||||
-rw-r--r-- | gs_ctan/backend.py | 32 | ||||
-rw-r--r-- | gs_ctan/ctan_db.py | 36 |
6 files changed, 95 insertions, 1 deletions
diff --git a/g_sorcery/g_sorcery.py b/g_sorcery/g_sorcery.py index 690f4cf..6beb565 100644 --- a/g_sorcery/g_sorcery.py +++ b/g_sorcery/g_sorcery.py @@ -70,9 +70,11 @@ def main(): def get_backend(package): + logger = Logger() try: module = importlib.import_module(package + '.backend') - except ImportError: + except ImportError as error: + logger.error("error importing backend: " + str(error)) return None return module diff --git a/gs-ctan-overlays.xml b/gs-ctan-overlays.xml new file mode 100644 index 0000000..0faceb6 --- /dev/null +++ b/gs-ctan-overlays.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE repositories SYSTEM "/dtd/repositories.dtd"> +<repositories xmlns="" version="1.0"> +<repo quality="experimental" status="unofficial"> + <name>ctan</name> + <description>CTAN packages</description> + <homepage>http://www.ctan.org/</homepage> + <owner> + <email>piatlicki@gmail.com</email> + <name>Jauhien Piatlicki</name> + </owner> + <source type="g-sorcery">gs-ctan ctan</source> +</repo> +</repositories> diff --git a/gs-ctan.json b/gs-ctan.json new file mode 100644 index 0000000..0bee1a2 --- /dev/null +++ b/gs-ctan.json @@ -0,0 +1,8 @@ +{ + "package": "gs_ctan", + "repositories": { + "ctan": { + "repo_uri": "http://mirror.ctan.org/systems/texlive/tlnet/" + } + } +} diff --git a/gs_ctan/__init__.py b/gs_ctan/__init__.py new file mode 100644 index 0000000..cf529d7 --- /dev/null +++ b/gs_ctan/__init__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python + diff --git a/gs_ctan/backend.py b/gs_ctan/backend.py new file mode 100644 index 0000000..a9d0581 --- /dev/null +++ b/gs_ctan/backend.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + backend.py + ~~~~~~~~~~ + + CTAN backend + + :copyright: (c) 2013 by Jauhien Piatlicki + :license: GPL-2, see LICENSE for more details. +""" + +import os + +from g_sorcery.backend import Backend +from g_sorcery.metadata import MetadataGenerator +from g_sorcery.ebuild import EbuildGenerator +from g_sorcery.eclass import EclassGenerator +from g_sorcery.fileutils import get_pkgpath + +from .ctan_db import CtanDB + + +class CtanEclassGenerator(EclassGenerator): + def __init__(self): + super(CtanEclassGenerator, self).__init__(os.path.join(get_pkgpath(__file__), 'data')) + + +instance = Backend(CtanDB, + EbuildGenerator, EbuildGenerator, + CtanEclassGenerator, MetadataGenerator, sync_db=False) diff --git a/gs_ctan/ctan_db.py b/gs_ctan/ctan_db.py new file mode 100644 index 0000000..0014c6c --- /dev/null +++ b/gs_ctan/ctan_db.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + ctan_db.py + ~~~~~~~~~~ + + CTAN package database + + :copyright: (c) 2013 by Jauhien Piatlicki + :license: GPL-2, see LICENSE for more details. +""" + +import os + +from g_sorcery.compatibility import TemporaryDirectory +from g_sorcery.g_collections import Package +from g_sorcery.package_db import PackageDB +from g_sorcery.fileutils import wget +from g_sorcery.exceptions import SyncError + +class CtanDB(PackageDB): + def __init__(self, directory, repo_uri="", db_uri=""): + super(CtanDB, self).__init__(directory, repo_uri, db_uri) + + def generate_tree(self): + tempdir = TemporaryDirectory() + + print(self.repo_uri) + tlpdb_uri = self.repo_uri + '/tlpkg/texlive.tlpdb.xz' + if wget(tlpdb_uri, tempdir.name): + raise SyncError('sync failed: ' + self.repo_uri) + + del tempdir + + print("works") |