aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-02 10:40:34 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-02 10:40:34 +0200
commitd4797acf20d73a5564e9eae78c9804e89f49ca2b (patch)
tree6ac9cc294a31a492d216c4382f26305aca93c101
parentg_sorcery/fileutils: wget (diff)
downloadg-sorcery-d4797acf20d73a5564e9eae78c9804e89f49ca2b.tar.gz
g-sorcery-d4797acf20d73a5564e9eae78c9804e89f49ca2b.tar.bz2
g-sorcery-d4797acf20d73a5564e9eae78c9804e89f49ca2b.zip
g_elpa/elpa_db: initial commit
-rw-r--r--g_elpa/elpa_db.py35
-rw-r--r--tests/test_elpa_db.py32
2 files changed, 67 insertions, 0 deletions
diff --git a/g_elpa/elpa_db.py b/g_elpa/elpa_db.py
new file mode 100644
index 0000000..e25ac60
--- /dev/null
+++ b/g_elpa/elpa_db.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ elpa_db.py
+ ~~~~~~~~~~
+
+ ELPA package database
+
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os, tempfile, urllib.parse
+
+from g_sorcery.package_db import PackageDB
+from g_sorcery.fileutils import wget
+
+class ElpaDB(PackageDB):
+ def __init__(self, directory, repo_uri="", db_uri=""):
+ super().__init__(directory, repo_uri, db_uri)
+
+ def generate_tree(self):
+ tempdir = tempfile.TemporaryDirectory()
+
+ ac_uri = urllib.parse.urljoin(self.repo_uri, 'archive-contents')
+ wget(ac_uri, tempdir.name)
+
+ os.system('ls -l ' + tempdir.name)
+ os.system('less ' + tempdir.name + '/archive-contents')
+
+ del tempdir
+
+ def get_parser(self):
+ pass
diff --git a/tests/test_elpa_db.py b/tests/test_elpa_db.py
new file mode 100644
index 0000000..dfbe34a
--- /dev/null
+++ b/tests/test_elpa_db.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ test_elpa_db.py
+ ~~~~~~~~~~~~~~~
+
+ ELPA package database test suite
+
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import http.server, tempfile, threading, unittest
+
+from g_elpa import elpa_db
+
+class TestElpaDB(unittest.TestCase):
+ def setUp(self):
+ self.tempdir = tempfile.TemporaryDirectory()
+
+ def tearDown(self):
+ del self.tempdir
+
+ def test_generate(self):
+ edb = elpa_db.ElpaDB(self.tempdir.name, repo_uri = 'http://elpa.gnu.org/packages/')
+ edb.generate_tree()
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(TestElpaDB('test_generate'))
+ return suite