Commits

Ronny Pfannschmidt  committed ca9a644

rename files subpackage to storage

  • Participants
  • Parent commits 1a335bc

Comments (0)

Files changed (15)

File kij/files/__init__.py

Empty file removed.

File kij/files/dist.py

-"""
-    pu.files.dist
-    ~~~~~~~~~~~~~
-
-    Read and write pu distribution files.
-
-    :license: MIT/PSF (see LICENSE.txt file)
-    :copyright: pu Authors (see AUTHORS.txt file)
-
-    This is the primary configuration file for any Python distribution. It
-    aims to capture all the data required for distribution. The dist file is
-    presented as a Yaml file, with a number of keys, each corresponding to a
-    configuration directive for the distribution.
-
-    A very simple example can be seen::
-
-    name:    Blogatron
-    version: 1.0
-    author:  Ali Afshar
-    packages:
-        - blogatron
-
-    Although the specification will grow, certain fields are recognised, some
-    are required, and some optional. Other when present need to be of a
-    certain type. The recognised attributes are desribed:
-
-    name
-        The distribution name, usually the name of the project. *required*
-
-    version
-        The version of the distribution, should be a string of the numerical
-        version number.
-
-    summary
-        A short one-line summary of the distribution.
-
-    packages
-        A list of package descriptions to add to the distribution
-
-
-    Being Yaml, there is a certain degree of type expressivity over ini-based
-    systems. Addiitonally, the Yaml loading layer can be easily swapped out
-    for anything else.
-"""
-
-import yaml
-
-
-from py.path import local
-
-
-DIST_FILE_KEYS = set((
-    'packages', 'summary', 'scripts'
-))
-
-
-class DistFileError(ValueError):
-    """Error with Dist File"""
-
-
-class DistFile(object):
-
-    def __init__(self, path):
-        self.path = local(path)
-        self._load()
-
-    def _load(self):
-        # XXX Handle exceptions
-        try:
-            conf = yaml.load(self.path.open())
-        except Exception, e:
-            raise DistFileError('Error loading file %s %s' % (self.path, e))
-        self.name = conf.get('name')
-        if self.name is None:
-            raise DistFileError('Missing "name" key %s' % self.path)
-        # now the optional keys
-        for k in DIST_FILE_KEYS:
-            setattr(self, k, conf.get(k))
-        # now some validation
-        if self.packages and not isinstance(self.packages, list):
-            raise DistFileError('packages must be a list')
-        self._model = conf
-
-    def __str__(self):
-        return "<DistFile: %s>" % self.path

File kij/files/pth.py

-'''
-    kid.files.pth
-    ~~~~~~~~~~~~~
-
-    deals with reading, editing and writing pth files
-
-    :license: GNU GPL3
-    :copyright: 2010 by Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
-'''
-from py.path import local
-
-
-class PthFile(object):
-    def __init__(self, path):
-        self.path = local(path)
-        self.entries = []
-        if not self.path.check():
-            return
-        with self.path.open() as f:
-            for entry in f:
-                entry = entry.strip()
-                if entry[0] == '.':
-                    self.append(self.path.dirpath().join(entry))
-                else:
-                    self.append(local(entry))
-
-    def append(self, path):
-        if path not in self.entries:
-            self.entries.append(path)
-
-    def remove(self, path):
-        self.entries.remove(path)
-
-    def save(self):
-        with self.path.open('w') as f:
-            for path in self.entries:
-                rel = path.relto(self.path.dirpath())
-                if rel:
-                    f.write('./%s\n' % rel)
-                else:
-                    f.write('%s\n' % path)

File kij/storage/__init__.py

Empty file added.

File kij/storage/dist.py

+"""
+    pu.files.dist
+    ~~~~~~~~~~~~~
+
+    Read and write pu distribution files.
+
+    :license: MIT/PSF (see LICENSE.txt file)
+    :copyright: pu Authors (see AUTHORS.txt file)
+
+    This is the primary configuration file for any Python distribution. It
+    aims to capture all the data required for distribution. The dist file is
+    presented as a Yaml file, with a number of keys, each corresponding to a
+    configuration directive for the distribution.
+
+    A very simple example can be seen::
+
+    name:    Blogatron
+    version: 1.0
+    author:  Ali Afshar
+    packages:
+        - blogatron
+
+    Although the specification will grow, certain fields are recognised, some
+    are required, and some optional. Other when present need to be of a
+    certain type. The recognised attributes are desribed:
+
+    name
+        The distribution name, usually the name of the project. *required*
+
+    version
+        The version of the distribution, should be a string of the numerical
+        version number.
+
+    summary
+        A short one-line summary of the distribution.
+
+    packages
+        A list of package descriptions to add to the distribution
+
+
+    Being Yaml, there is a certain degree of type expressivity over ini-based
+    systems. Addiitonally, the Yaml loading layer can be easily swapped out
+    for anything else.
+"""
+
+import yaml
+
+
+from py.path import local
+
+
+DIST_FILE_KEYS = set((
+    'packages', 'summary', 'scripts'
+))
+
+
+class DistFileError(ValueError):
+    """Error with Dist File"""
+
+
+class DistFile(object):
+
+    def __init__(self, path):
+        self.path = local(path)
+        self._load()
+
+    def _load(self):
+        # XXX Handle exceptions
+        try:
+            conf = yaml.load(self.path.open())
+        except Exception, e:
+            raise DistFileError('Error loading file %s %s' % (self.path, e))
+        self.name = conf.get('name')
+        if self.name is None:
+            raise DistFileError('Missing "name" key %s' % self.path)
+        # now the optional keys
+        for k in DIST_FILE_KEYS:
+            setattr(self, k, conf.get(k))
+        # now some validation
+        if self.packages and not isinstance(self.packages, list):
+            raise DistFileError('packages must be a list')
+        self._model = conf
+
+    def __str__(self):
+        return "<DistFile: %s>" % self.path

File kij/storage/pth.py

+'''
+    kid.files.pth
+    ~~~~~~~~~~~~~
+
+    deals with reading, editing and writing pth files
+
+    :license: GNU GPL3
+    :copyright: 2010 by Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
+'''
+from py.path import local
+
+
+class PthFile(object):
+    def __init__(self, path):
+        self.path = local(path)
+        self.entries = []
+        if not self.path.check():
+            return
+        with self.path.open() as f:
+            for entry in f:
+                entry = entry.strip()
+                if entry[0] == '.':
+                    self.append(self.path.dirpath().join(entry))
+                else:
+                    self.append(local(entry))
+
+    def append(self, path):
+        if path not in self.entries:
+            self.entries.append(path)
+
+    def remove(self, path):
+        self.entries.remove(path)
+
+    def save(self):
+        with self.path.open('w') as f:
+            for path in self.entries:
+                rel = path.relto(self.path.dirpath())
+                if rel:
+                    f.write('./%s\n' % rel)
+                else:
+                    f.write('%s\n' % path)

File kij/tasks/install.py

-from kij.files.pth import PthFile
+from kij.storage.pth import PthFile
 
 
 class LinkTask(object):

File kij/tasks/metadata.py

 from . import TaskBase
-from kij.files.dist import DistFile
+from kij.storage.dist import DistFile
 
 
 def find_packages(base, start):

File tests/files/__init__.py

Empty file removed.

File tests/files/test_dist.py

-import py
-from kij.files.dist import DistFile, DistFileError
-
-
-def pytest_funcarg__distfile(request):
-    return request.getfuncargvalue('tmpdir').join('test-kij.yml')
-
-
-def pytest_funcarg__distfilegen(request):
-    distfile = request.getfuncargvalue('distfile')
-
-    def _create_file(s, distfile=distfile):
-        f = distfile.open('w')
-        f.write(s)
-        f.close()
-        return DistFile(distfile)
-    return _create_file
-
-
-d = """
-name: Kij
-summary: Python packaging utilities
-packages:
-    - anyvc.*
-"""
-
-
-def test_name(distfilegen):
-    df = distfilegen(d)
-    assert df.name == 'Kij'
-
-e = """
-packages:
-    - anyvc.*
-"""
-
-
-def test_missing_name(distfilegen):
-    py.test.raises(DistFileError, distfilegen, e)
-
-
-def test_summary(distfilegen):
-    df = distfilegen(d)
-    assert df.summary == 'Python packaging utilities'
-
-
-def test_packages(distfilegen):
-    df = distfilegen(d)
-    assert df.packages[0] == 'anyvc.*'
-    assert len(df.packages) == 1
-
-
-f = """
-name: banana
-"""
-
-
-def test_missing_packages_ok(distfilegen):
-    df = distfilegen(f)
-    assert df.packages is None
-
-
-g = """
-name: banana
-packages: manana
-"""
-
-
-def test_bad_packages(distfilegen):
-    py.test.raises(DistFileError, distfilegen, g)

File tests/files/test_pth.py

-import py
-from kij.files.pth import PthFile
-
-
-def pytest_funcarg__pthfile(request):
-    return request.getfuncargvalue('tmpdir').join('test.pth')
-
-
-def pytest_funcarg__pth(request):
-    return PthFile(request.getfuncargvalue('pthfile'))
-
-
-def pytest_funcarg__item(request):
-    tmpdir = request.getfuncargvalue('tmpdir')
-    return tmpdir.join('test-1.3.zip')
-
-
-def test_instanciate(tmpdir):
-    PthFile(tmpdir.join('test.pthfail'))
-
-
-def test_create_pth(tmpdir):
-    file = tmpdir.join('test.pth')
-    pth = PthFile(file)
-    assert not pth.entries
-
-
-def test_append(pth, tmpdir, item):
-
-    pth.append(item)
-    assert pth.entries == [item]
-
-    # dont get double entries
-    pth.append(item)
-    assert pth.entries == [item]
-
-
-def test_remove(pth, tmpdir, item):
-
-    pth.append(item)
-    assert pth.entries == [item]
-
-    # dont get double entries
-    pth.remove(item)
-    assert pth.entries == []
-
-
-def test_save_relative(pth, pthfile, tmpdir, item):
-    pth.append(item)
-    pth.save()
-    assert pthfile.read() == './test-1.3.zip\n'
-
-
-def test_save_absolute(pth, pthfile):
-    pth.append(py.path.local('/usr/local/lib'))
-    pth.save()
-    assert pthfile.read() == '/usr/local/lib\n'
-
-
-def test_parse_relative(pthfile, item):
-    pthfile.write('./test-1.3.zip')
-    pth = PthFile(pthfile)
-    assert pth.entries == [item]
-
-
-def test_parse_absolute(pthfile):
-    pthfile.write('/usr/local/bin/test')
-    pth = PthFile(pthfile)
-    assert pth.entries == ['/usr/local/bin/test']

File tests/storage/__init__.py

Empty file added.

File tests/storage/test_dist.py

+import py
+from kij.storage.dist import DistFile, DistFileError
+
+
+def pytest_funcarg__distfile(request):
+    return request.getfuncargvalue('tmpdir').join('test-kij.yml')
+
+
+def pytest_funcarg__distfilegen(request):
+    distfile = request.getfuncargvalue('distfile')
+
+    def _create_file(s, distfile=distfile):
+        f = distfile.open('w')
+        f.write(s)
+        f.close()
+        return DistFile(distfile)
+    return _create_file
+
+
+d = """
+name: Kij
+summary: Python packaging utilities
+packages:
+    - anyvc.*
+"""
+
+
+def test_name(distfilegen):
+    df = distfilegen(d)
+    assert df.name == 'Kij'
+
+e = """
+packages:
+    - anyvc.*
+"""
+
+
+def test_missing_name(distfilegen):
+    py.test.raises(DistFileError, distfilegen, e)
+
+
+def test_summary(distfilegen):
+    df = distfilegen(d)
+    assert df.summary == 'Python packaging utilities'
+
+
+def test_packages(distfilegen):
+    df = distfilegen(d)
+    assert df.packages[0] == 'anyvc.*'
+    assert len(df.packages) == 1
+
+
+f = """
+name: banana
+"""
+
+
+def test_missing_packages_ok(distfilegen):
+    df = distfilegen(f)
+    assert df.packages is None
+
+
+g = """
+name: banana
+packages: manana
+"""
+
+
+def test_bad_packages(distfilegen):
+    py.test.raises(DistFileError, distfilegen, g)

File tests/storage/test_pth.py

+import py
+from kij.storage.pth import PthFile
+
+
+def pytest_funcarg__pthfile(request):
+    return request.getfuncargvalue('tmpdir').join('test.pth')
+
+
+def pytest_funcarg__pth(request):
+    return PthFile(request.getfuncargvalue('pthfile'))
+
+
+def pytest_funcarg__item(request):
+    tmpdir = request.getfuncargvalue('tmpdir')
+    return tmpdir.join('test-1.3.zip')
+
+
+def test_instanciate(tmpdir):
+    PthFile(tmpdir.join('test.pthfail'))
+
+
+def test_create_pth(tmpdir):
+    file = tmpdir.join('test.pth')
+    pth = PthFile(file)
+    assert not pth.entries
+
+
+def test_append(pth, tmpdir, item):
+
+    pth.append(item)
+    assert pth.entries == [item]
+
+    # dont get double entries
+    pth.append(item)
+    assert pth.entries == [item]
+
+
+def test_remove(pth, tmpdir, item):
+
+    pth.append(item)
+    assert pth.entries == [item]
+
+    # dont get double entries
+    pth.remove(item)
+    assert pth.entries == []
+
+
+def test_save_relative(pth, pthfile, tmpdir, item):
+    pth.append(item)
+    pth.save()
+    assert pthfile.read() == './test-1.3.zip\n'
+
+
+def test_save_absolute(pth, pthfile):
+    pth.append(py.path.local('/usr/local/lib'))
+    pth.save()
+    assert pthfile.read() == '/usr/local/lib\n'
+
+
+def test_parse_relative(pthfile, item):
+    pthfile.write('./test-1.3.zip')
+    pth = PthFile(pthfile)
+    assert pth.entries == [item]
+
+
+def test_parse_absolute(pthfile):
+    pthfile.write('/usr/local/bin/test')
+    pth = PthFile(pthfile)
+    assert pth.entries == ['/usr/local/bin/test']

File tests/tasks/test_develop.py

 from kij.tasks.install import LinkPTH, UnlinkPTH
-from kij.files.pth import PthFile
+from kij.storage.pth import PthFile
 
 
 def test_enable(site, source):