Browse Source

Added travis ci

test_fixup
Travis Cunningham 10 years ago
parent
commit
5b97a9d780
5 changed files with 43 additions and 63 deletions
  1. +10
    -0
      .travis.yml
  2. +13
    -0
      Makefile
  3. +3
    -0
      README.rst
  4. +16
    -37
      libarchive/tar.py
  5. +1
    -26
      libarchive/zip.py

+ 10
- 0
.travis.yml View File

@@ -0,0 +1,10 @@
language: python
python:
- "2.7"
env:
- DJANGO=1.3
- DJANGO=1.4
install:
- pip install --timeout=30 -q -e . --use-mirrors
script:
- make test

+ 13
- 0
Makefile View File

@@ -0,0 +1,13 @@
test:
python tests.py

verify:
pyflakes libarchive
pep8 --exclude=migrations --ignore=E501,E225 libarchive

install:
python setup.py install

publish:
python setup.py register
python setup.py sdist upload

+ 3
- 0
README.rst View File

@@ -1,3 +1,6 @@
.. image:: https://travis-ci.org/smartfile/python-libarchive.svg
:target: https://travis-ci.org/smartfile/python-libarchive

A `SmartFile`_ Open Source project. `Read more`_ about how SmartFile
uses and contributes to Open Source software.



+ 16
- 37
libarchive/tar.py View File

@@ -1,32 +1,8 @@
# Copyright (c) 2011, SmartFile <btimby@smartfile.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the organization nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import time
import os
from libarchive import is_archive, Entry, SeekableArchive
from tarfile import DEFAULT_FORMAT, USTAR_FORMAT, GNU_FORMAT, PAX_FORMAT, ENCODING
from tarfile import REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE
from tarfile import DEFAULT_FORMAT, USTAR_FORMAT, GNU_FORMAT, PAX_FORMAT, \
ENCODING
from tarfile import REGTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, CHRTYPE, BLKTYPE

FORMAT_CONVERSION = {
USTAR_FORMAT: 'tar',
@@ -76,7 +52,13 @@ class TarInfo(Entry):


class TarFile(SeekableArchive):
def __init__(self, name=None, mode='r', fileobj=None, format=DEFAULT_FORMAT, tarinfo=TarInfo, encoding=ENCODING):
getmember = SeekableArchive.getentry
list = SeekableArchive.printlist
extract = SeekableArchive.readpath
extractfile = SeekableArchive.readstream

def __init__(self, name=None, mode='r', fileobj=None,
format=DEFAULT_FORMAT, tarinfo=TarInfo, encoding=ENCODING):
if name:
f = name
elif fileobj:
@@ -85,12 +67,8 @@ class TarFile(SeekableArchive):
format = FORMAT_CONVERSION.get(format)
except KeyError:
raise Exception('Invalid tar format: %s' % format)
super(TarFile, self).__init__(f, mode=mode, format=format, entry_class=tarinfo, encoding=encoding)

getmember = SeekableArchive.getentry
list = SeekableArchive.printlist
extract = SeekableArchive.readpath
extractfile = SeekableArchive.readstream
super(TarFile, self).__init__(f, mode=mode, format=format,
entry_class=tarinfo, encoding=encoding)

def getmembers(self):
return list(self)
@@ -99,6 +77,7 @@ class TarFile(SeekableArchive):
return list(self.iterpaths)

def next(self):
raise NotImplementedError
pass # TODO: how to do this?

def extract(self, member, path=None):
@@ -113,10 +92,10 @@ class TarFile(SeekableArchive):
def add(self, name, arcname, recursive=True, exclude=None, filter=None):
pass # TODO: implement this.

def addfile(tarinfo, fileobj):
def addfile(self, tarinfo, fileobj):
return self.writepath(fileobj, tarinfo)

def gettarinfo(name=None, arcname=None, fileobj=None):
def gettarinfo(self, name=None, arcname=None, fileobj=None):
if name:
f = name
elif fileobj:


+ 1
- 26
libarchive/zip.py View File

@@ -1,28 +1,3 @@
# Copyright (c) 2011, SmartFile <btimby@smartfile.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the organization nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os, time
from libarchive import is_archive, Entry, SeekableArchive
from zipfile import ZIP_STORED, ZIP_DEFLATED
@@ -48,7 +23,7 @@ class ZipEntry(Entry):
return self.size

def set_file_size(self, value):
assert isinstance(size, (int, long)), 'Please provide size as int or long.'
assert isinstance(value, (int, long)), 'Please provide size as int or long.'
self.size = value

file_size = property(get_file_size, set_file_size)


Loading…
Cancel
Save