aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-13 17:07:12 +0200
committerJauhien Piatlicki (jauhien) <piatlicki@gmail.com>2013-07-13 17:07:12 +0200
commit4bda8acf022c698d18edb07686d579d8a0e2cb4a (patch)
tree2318a8618336fcc06dcd2762b5f47881af845a9b
parentget_pkgpath modified as suggested by Brian Dolbec (diff)
downloadg-sorcery-4bda8acf022c698d18edb07686d579d8a0e2cb4a.tar.gz
g-sorcery-4bda8acf022c698d18edb07686d579d8a0e2cb4a.tar.bz2
g-sorcery-4bda8acf022c698d18edb07686d579d8a0e2cb4a.zip
g_sorcery/collections -> g_sorcery/g_collections
-rw-r--r--g_elpa/elpa_db.py2
-rw-r--r--g_sorcery/backend.py2
-rw-r--r--g_sorcery/fileutils.py2
-rw-r--r--g_sorcery/g_collections.py47
-rw-r--r--g_sorcery/package_db.py2
5 files changed, 51 insertions, 4 deletions
diff --git a/g_elpa/elpa_db.py b/g_elpa/elpa_db.py
index 59f30a1..82f0a3a 100644
--- a/g_elpa/elpa_db.py
+++ b/g_elpa/elpa_db.py
@@ -22,7 +22,7 @@ if py2k:
else:
from urllib.parse import urljoin
-from g_sorcery.collections import Package
+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
diff --git a/g_sorcery/backend.py b/g_sorcery/backend.py
index 65d7e90..d077d30 100644
--- a/g_sorcery/backend.py
+++ b/g_sorcery/backend.py
@@ -16,7 +16,7 @@ import glob
import os
import sys
-from .collections import Package
+from .g_collections import Package
from .exceptions import DependencyError, DigestError
class Backend(object):
diff --git a/g_sorcery/fileutils.py b/g_sorcery/fileutils.py
index 1db9dc9..478570d 100644
--- a/g_sorcery/fileutils.py
+++ b/g_sorcery/fileutils.py
@@ -14,7 +14,7 @@
import json, os, shutil
from .exceptions import FileJSONError
-from .collections import Package, elist
+from .g_collections import Package, elist
class FileJSON(object):
"""
diff --git a/g_sorcery/g_collections.py b/g_sorcery/g_collections.py
new file mode 100644
index 0000000..3ecc373
--- /dev/null
+++ b/g_sorcery/g_collections.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ g_collections.py
+ ~~~~~~~~~~~~~~~~
+
+ Customized classes of standard python data types
+ for use withing g-sorcery for custom formatted string output
+ substitution in our ebuild templates.
+
+ :copyright: (c) 2013 by Brian Dolbec
+ :copyright: (c) 2013 by Jauhien Piatlicki
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import collections
+
+class elist(list):
+ '''Custom list type which adds a customized __str__()
+ and takes an optional separator argument
+
+ elist() -> new empty elist
+ elist(iterable) -> new elist initialized from iterable's items
+ elist(separator='\\n\\t') -> new empty elist with
+ newline & tab indented str(x) output
+ elist(iterable, ' ') -> new elist initialized from iterable's items
+ with space separated str(x) output
+ '''
+
+ __slots__ = ('_sep_')
+
+ def __init__(self, iterable=None, separator=' '):
+ '''
+ iterable: initialize from iterable's items
+ separator: string used to join list members with for __str__()
+ '''
+ list.__init__(self, iterable or [])
+ self._sep_ = separator
+
+ def __str__(self):
+ '''Custom output function
+ 'x.__str__() <==> str(separator.join(x))'
+ '''
+ return self._sep_.join(self)
+
+Package = collections.namedtuple("Package", "category name version")
diff --git a/g_sorcery/package_db.py b/g_sorcery/package_db.py
index 4e0b46a..f8155dc 100644
--- a/g_sorcery/package_db.py
+++ b/g_sorcery/package_db.py
@@ -26,7 +26,7 @@ from .exceptions import DBStructureError, IntegrityError, \
from .fileutils import FileJSON, FilePkgDesc, hash_file, copy_all, wget
-from .collections import Package
+from .g_collections import Package
class PackageDB(object):
"""