summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore16
-rw-r--r--.travis.yml8
-rw-r--r--MANIFEST.in6
-rw-r--r--PKG-INFO26
-rw-r--r--README.rst21
-rw-r--r--debian/changelog7
-rw-r--r--debian/clean1
-rw-r--r--debian/compat2
-rw-r--r--debian/control30
-rw-r--r--debian/copyright2
-rw-r--r--debian/gbp.conf9
-rw-r--r--debian/patches/distribute.patch13
-rw-r--r--debian/patches/series1
-rwxr-xr-xdebian/rules5
-rw-r--r--distribute_setup.py485
-rw-r--r--fswrap.egg-info/PKG-INFO26
-rw-r--r--fswrap.egg-info/SOURCES.txt16
-rw-r--r--fswrap.egg-info/dependency_links.txt1
-rw-r--r--fswrap.egg-info/top_level.txt1
-rw-r--r--fswrap.py38
-rw-r--r--setup.cfg5
-rwxr-xr-x[-rw-r--r--]setup.py18
-rw-r--r--tests/test_fswrap.py28
-rw-r--r--tox.ini10
24 files changed, 160 insertions, 615 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..03bb2f8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,16 @@
+*~
+*.pyc
+.DS_Store
+*.cprof
+*.profile
+*.log
+pylint*
+*.tmproj
+.tmproperties
+build
+MANIFEST
+dist
+*egg*
+*gz
+.coverage
+.tox
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..eb64a48
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+sudo: false
+language: python
+python:
+ - "2.7"
+ - "3.3"
+ - "3.4"
+install: pip install tox-travis
+script: tox
diff --git a/MANIFEST.in b/MANIFEST.in
index 0277787..f88210d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,4 @@
-include setup.py
include distribute_setup.py
-include fswrap.py
include LICENSE
-include README.markdown
-recursive-include tests *.py *.txt *.html *.png *.xml \ No newline at end of file
+include README.rst
+recursive-include tests *.py *.txt *.html *.png *.xml
diff --git a/PKG-INFO b/PKG-INFO
deleted file mode 100644
index 5902203..0000000
--- a/PKG-INFO
+++ /dev/null
@@ -1,26 +0,0 @@
-Metadata-Version: 1.1
-Name: fswrap
-Version: 0.1.1
-Summary: An opinionated wrapper on file system and path functions
-Home-page: http://github.com/lakshmivyas/fswrap
-Author: Lakshmi Vyas
-Author-email: lakshmi.vyas@gmail.com
-License: MIT
-Description: Version 0.1.1
-
- Unified object oriented interface for interacting with file system objects.
- File system operations in python are distributed across modules: os, os.path,
- fnmatch, shutil and distutils. This module attempts to make the right choices
- for common operations to provide a single interface.
-
- This was extracted from the `hyde project`_ with minor changes.
-
-
- .. _hyde project: http://github.com/hyde/hyde
-Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Topic :: Software Development
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..cf48fbc
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,21 @@
+Version 1.0.1
+
+Unified object oriented interface for interacting with file system
+objects. File system operations in python are distributed across
+modules: os, os.path, fnmatch, shutil and distutils. This module
+attempts to make the right choices for common operations to provide a
+single interface.
+
+This was extracted from the `hyde project`_ with minor changes.
+
+
+.. _hyde project: http://github.com/hyde/hyde
+
+Contributors
+-------------
+
+* Laurent Bachelier (laurentb)
+ - Fix packaging issues. (#2)
+
+* Jon Banafato (jonafato)
+ - Python 2 and 3 compatibility (#3)
diff --git a/debian/changelog b/debian/changelog
index eeccb82..22d49e3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+python-fswrap (1.0.1-0.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * New upstream version.
+
+ -- Andrew Shadura <andrewsh@debian.org> Mon, 31 Jul 2017 07:58:55 -0400
+
python-fswrap (0.1.1-1.1) unstable; urgency=medium
* Non-maintainer upload.
diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..45149aa
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1 @@
+*.egg-info/*
diff --git a/debian/compat b/debian/compat
index 45a4fb7..ec63514 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-8
+9
diff --git a/debian/control b/debian/control
index 6809312..785f6ff 100644
--- a/debian/control
+++ b/debian/control
@@ -2,17 +2,37 @@ Source: python-fswrap
Section: python
Priority: extra
Maintainer: Julien Danjou <acid@debian.org>
-Build-Depends: debhelper (>= 8.0.0), python-all,
- python-setuptools, python-pkg-resources, python-nose
-Standards-Version: 3.9.4
-Homepage: https://github.com/lakshmivyas/fswrap
+Build-Depends: debhelper (>= 9),
+ python-all,
+ python-nose,
+ python-pkg-resources,
+ python-setuptools,
+ python3-all,
+ python3-nose,
+ python3-pkg-resources,
+ python3-setuptools
+Standards-Version: 4.0.0
+Homepage: https://github.com/hyde/fswrap
Vcs-Git: git://git.debian.org/collab-maint/python-fswrap.git
Vcs-Browser: http://git.debian.org/?p=collab-maint/python-fswrap.git;a=summary
Package: python-fswrap
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}
-Description: Unified object oriented interface for interacting with file system objects
+Provides: ${python:Provides}
+Description: unified object oriented interface to file system objects
File system operations in Python are distributed across modules: os,
os.path, fnmatch, shutil and distutils. This module attempts to make the
right choices for common operations to provide a single interface.
+ .
+ This package is for Python 2.
+
+Package: python3-fswrap
+Architecture: all
+Depends: ${misc:Depends}, ${python3:Depends}
+Description: unified object oriented interface to file system objects (Python 3)
+ File system operations in Python are distributed across modules: os,
+ os.path, fnmatch, shutil and distutils. This module attempts to make the
+ right choices for common operations to provide a single interface.
+ .
+ This package is for Python 3.
diff --git a/debian/copyright b/debian/copyright
index 1c391ca..e58565b 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -3,7 +3,7 @@ Upstream-Name: python-fswrap
Source: https://github.com/lakshmivyas/fswrap
Files: *
-Copyright: 2012 Lakshmi Vyasarajan, Ringce.com
+Copyright: 2012—2015 Lakshmi Vyasarajan, Ringce.com
License: MIT
Files: debian/*
diff --git a/debian/gbp.conf b/debian/gbp.conf
index cfff8c1..47a5c12 100644
--- a/debian/gbp.conf
+++ b/debian/gbp.conf
@@ -1,8 +1,5 @@
-[git-buildpackage]
-debian-branch = debian/unstable
+[DEFAULT]
+debian-branch = debian/master
+upstream-branch = upstream/master
pristine-tar = True
-
-[git-import-orig]
-debian-branch = debian/unstable
sign-tags = True
-pristine-tar = True
diff --git a/debian/patches/distribute.patch b/debian/patches/distribute.patch
deleted file mode 100644
index bafead3..0000000
--- a/debian/patches/distribute.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Description: Do not download distribute from the internet
-Author: Sebastian Ramacher <sramacher@debian.org>
-Bug-Debian: http://bugs.debian.org/735825
-Last-Update: 2014-02-05
-
---- python-fswrap-0.1.1.orig/setup.py
-+++ python-fswrap-0.1.1/setup.py
-@@ -1,5 +1,3 @@
--from distribute_setup import use_setuptools
--use_setuptools()
- from setuptools import setup
-
- try:
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index fc1cc3b..0000000
--- a/debian/patches/series
+++ /dev/null
@@ -1 +0,0 @@
-distribute.patch
diff --git a/debian/rules b/debian/rules
index 9f1a88b..941b5ad 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,7 +1,10 @@
#!/usr/bin/make -f
# -*- makefile -*-
+
+export PYBUILD_NAME=fswrap
+
%:
- dh $@ --with python2
+ dh $@ --with python2,python3 --buildsystem=pybuild
override_dh_auto_test:
python setup.py test
diff --git a/distribute_setup.py b/distribute_setup.py
deleted file mode 100644
index 3ea2e66..0000000
--- a/distribute_setup.py
+++ /dev/null
@@ -1,485 +0,0 @@
-#!python
-"""Bootstrap distribute installation
-
-If you want to use setuptools in your package's setup.py, just include this
-file in the same directory with it, and add this to the top of your setup.py::
-
- from distribute_setup import use_setuptools
- use_setuptools()
-
-If you want to require a specific version of setuptools, set a download
-mirror, or use an alternate download directory, you can do so by supplying
-the appropriate options to ``use_setuptools()``.
-
-This file can also be run as a script to install or upgrade setuptools.
-"""
-import os
-import sys
-import time
-import fnmatch
-import tempfile
-import tarfile
-from distutils import log
-
-try:
- from site import USER_SITE
-except ImportError:
- USER_SITE = None
-
-try:
- import subprocess
-
- def _python_cmd(*args):
- args = (sys.executable,) + args
- return subprocess.call(args) == 0
-
-except ImportError:
- # will be used for python 2.3
- def _python_cmd(*args):
- args = (sys.executable,) + args
- # quoting arguments if windows
- if sys.platform == 'win32':
- def quote(arg):
- if ' ' in arg:
- return '"%s"' % arg
- return arg
- args = [quote(arg) for arg in args]
- return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-
-DEFAULT_VERSION = "0.6.14"
-DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
-SETUPTOOLS_FAKED_VERSION = "0.6c11"
-
-SETUPTOOLS_PKG_INFO = """\
-Metadata-Version: 1.0
-Name: setuptools
-Version: %s
-Summary: xxxx
-Home-page: xxx
-Author: xxx
-Author-email: xxx
-License: xxx
-Description: xxx
-""" % SETUPTOOLS_FAKED_VERSION
-
-
-def _install(tarball):
- # extracting the tarball
- tmpdir = tempfile.mkdtemp()
- log.warn('Extracting in %s', tmpdir)
- old_wd = os.getcwd()
- try:
- os.chdir(tmpdir)
- tar = tarfile.open(tarball)
- _extractall(tar)
- tar.close()
-
- # going in the directory
- subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
- os.chdir(subdir)
- log.warn('Now working in %s', subdir)
-
- # installing
- log.warn('Installing Distribute')
- if not _python_cmd('setup.py', 'install'):
- log.warn('Something went wrong during the installation.')
- log.warn('See the error message above.')
- finally:
- os.chdir(old_wd)
-
-
-def _build_egg(egg, tarball, to_dir):
- # extracting the tarball
- tmpdir = tempfile.mkdtemp()
- log.warn('Extracting in %s', tmpdir)
- old_wd = os.getcwd()
- try:
- os.chdir(tmpdir)
- tar = tarfile.open(tarball)
- _extractall(tar)
- tar.close()
-
- # going in the directory
- subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
- os.chdir(subdir)
- log.warn('Now working in %s', subdir)
-
- # building an egg
- log.warn('Building a Distribute egg in %s', to_dir)
- _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
-
- finally:
- os.chdir(old_wd)
- # returning the result
- log.warn(egg)
- if not os.path.exists(egg):
- raise IOError('Could not build the egg.')
-
-
-def _do_download(version, download_base, to_dir, download_delay):
- egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
- % (version, sys.version_info[0], sys.version_info[1]))
- if not os.path.exists(egg):
- tarball = download_setuptools(version, download_base,
- to_dir, download_delay)
- _build_egg(egg, tarball, to_dir)
- sys.path.insert(0, egg)
- import setuptools
- setuptools.bootstrap_install_from = egg
-
-
-def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
- to_dir=os.curdir, download_delay=15, no_fake=True):
- # making sure we use the absolute path
- to_dir = os.path.abspath(to_dir)
- was_imported = 'pkg_resources' in sys.modules or \
- 'setuptools' in sys.modules
- try:
- try:
- import pkg_resources
- if not hasattr(pkg_resources, '_distribute'):
- if not no_fake:
- _fake_setuptools()
- raise ImportError
- except ImportError:
- return _do_download(version, download_base, to_dir, download_delay)
- try:
- pkg_resources.require("distribute>="+version)
- return
- except pkg_resources.VersionConflict:
- e = sys.exc_info()[1]
- if was_imported:
- sys.stderr.write(
- "The required version of distribute (>=%s) is not available,\n"
- "and can't be installed while this script is running. Please\n"
- "install a more recent version first, using\n"
- "'easy_install -U distribute'."
- "\n\n(Currently using %r)\n" % (version, e.args[0]))
- sys.exit(2)
- else:
- del pkg_resources, sys.modules['pkg_resources'] # reload ok
- return _do_download(version, download_base, to_dir,
- download_delay)
- except pkg_resources.DistributionNotFound:
- return _do_download(version, download_base, to_dir,
- download_delay)
- finally:
- if not no_fake:
- _create_fake_setuptools_pkg_info(to_dir)
-
-def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
- to_dir=os.curdir, delay=15):
- """Download distribute from a specified location and return its filename
-
- `version` should be a valid distribute version number that is available
- as an egg for download under the `download_base` URL (which should end
- with a '/'). `to_dir` is the directory where the egg will be downloaded.
- `delay` is the number of seconds to pause before an actual download
- attempt.
- """
- # making sure we use the absolute path
- to_dir = os.path.abspath(to_dir)
- try:
- from urllib.request import urlopen
- except ImportError:
- from urllib2 import urlopen
- tgz_name = "distribute-%s.tar.gz" % version
- url = download_base + tgz_name
- saveto = os.path.join(to_dir, tgz_name)
- src = dst = None
- if not os.path.exists(saveto): # Avoid repeated downloads
- try:
- log.warn("Downloading %s", url)
- src = urlopen(url)
- # Read/write all in one block, so we don't create a corrupt file
- # if the download is interrupted.
- data = src.read()
- dst = open(saveto, "wb")
- dst.write(data)
- finally:
- if src:
- src.close()
- if dst:
- dst.close()
- return os.path.realpath(saveto)
-
-def _no_sandbox(function):
- def __no_sandbox(*args, **kw):
- try:
- from setuptools.sandbox import DirectorySandbox
- if not hasattr(DirectorySandbox, '_old'):
- def violation(*args):
- pass
- DirectorySandbox._old = DirectorySandbox._violation
- DirectorySandbox._violation = violation
- patched = True
- else:
- patched = False
- except ImportError:
- patched = False
-
- try:
- return function(*args, **kw)
- finally:
- if patched:
- DirectorySandbox._violation = DirectorySandbox._old
- del DirectorySandbox._old
-
- return __no_sandbox
-
-def _patch_file(path, content):
- """Will backup the file then patch it"""
- existing_content = open(path).read()
- if existing_content == content:
- # already patched
- log.warn('Already patched.')
- return False
- log.warn('Patching...')
- _rename_path(path)
- f = open(path, 'w')
- try:
- f.write(content)
- finally:
- f.close()
- return True
-
-_patch_file = _no_sandbox(_patch_file)
-
-def _same_content(path, content):
- return open(path).read() == content
-
-def _rename_path(path):
- new_name = path + '.OLD.%s' % time.time()
- log.warn('Renaming %s into %s', path, new_name)
- os.rename(path, new_name)
- return new_name
-
-def _remove_flat_installation(placeholder):
- if not os.path.isdir(placeholder):
- log.warn('Unkown installation at %s', placeholder)
- return False
- found = False
- for file in os.listdir(placeholder):
- if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
- found = True
- break
- if not found:
- log.warn('Could not locate setuptools*.egg-info')
- return
-
- log.warn('Removing elements out of the way...')
- pkg_info = os.path.join(placeholder, file)
- if os.path.isdir(pkg_info):
- patched = _patch_egg_dir(pkg_info)
- else:
- patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
-
- if not patched:
- log.warn('%s already patched.', pkg_info)
- return False
- # now let's move the files out of the way
- for element in ('setuptools', 'pkg_resources.py', 'site.py'):
- element = os.path.join(placeholder, element)
- if os.path.exists(element):
- _rename_path(element)
- else:
- log.warn('Could not find the %s element of the '
- 'Setuptools distribution', element)
- return True
-
-_remove_flat_installation = _no_sandbox(_remove_flat_installation)
-
-def _after_install(dist):
- log.warn('After install bootstrap.')
- placeholder = dist.get_command_obj('install').install_purelib
- _create_fake_setuptools_pkg_info(placeholder)
-
-def _create_fake_setuptools_pkg_info(placeholder):
- if not placeholder or not os.path.exists(placeholder):
- log.warn('Could not find the install location')
- return
- pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
- setuptools_file = 'setuptools-%s-py%s.egg-info' % \
- (SETUPTOOLS_FAKED_VERSION, pyver)
- pkg_info = os.path.join(placeholder, setuptools_file)
- if os.path.exists(pkg_info):
- log.warn('%s already exists', pkg_info)
- return
-
- log.warn('Creating %s', pkg_info)
- f = open(pkg_info, 'w')
- try:
- f.write(SETUPTOOLS_PKG_INFO)
- finally:
- f.close()
-
- pth_file = os.path.join(placeholder, 'setuptools.pth')
- log.warn('Creating %s', pth_file)
- f = open(pth_file, 'w')
- try:
- f.write(os.path.join(os.curdir, setuptools_file))
- finally:
- f.close()
-
-_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info)
-
-def _patch_egg_dir(path):
- # let's check if it's already patched
- pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
- if os.path.exists(pkg_info):
- if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
- log.warn('%s already patched.', pkg_info)
- return False
- _rename_path(path)
- os.mkdir(path)
- os.mkdir(os.path.join(path, 'EGG-INFO'))
- pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
- f = open(pkg_info, 'w')
- try:
- f.write(SETUPTOOLS_PKG_INFO)
- finally:
- f.close()
- return True
-
-_patch_egg_dir = _no_sandbox(_patch_egg_dir)
-
-def _before_install():
- log.warn('Before install bootstrap.')
- _fake_setuptools()
-
-
-def _under_prefix(location):
- if 'install' not in sys.argv:
- return True
- args = sys.argv[sys.argv.index('install')+1:]
- for index, arg in enumerate(args):
- for option in ('--root', '--prefix'):
- if arg.startswith('%s=' % option):
- top_dir = arg.split('root=')[-1]
- return location.startswith(top_dir)
- elif arg == option:
- if len(args) > index:
- top_dir = args[index+1]
- return location.startswith(top_dir)
- if arg == '--user' and USER_SITE is not None:
- return location.startswith(USER_SITE)
- return True
-
-
-def _fake_setuptools():
- log.warn('Scanning installed packages')
- try:
- import pkg_resources
- except ImportError:
- # we're cool
- log.warn('Setuptools or Distribute does not seem to be installed.')
- return
- ws = pkg_resources.working_set
- try:
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools',
- replacement=False))
- except TypeError:
- # old distribute API
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools'))
-
- if setuptools_dist is None:
- log.warn('No setuptools distribution found')
- return
- # detecting if it was already faked
- setuptools_location = setuptools_dist.location
- log.warn('Setuptools installation detected at %s', setuptools_location)
-
- # if --root or --preix was provided, and if
- # setuptools is not located in them, we don't patch it
- if not _under_prefix(setuptools_location):
- log.warn('Not patching, --root or --prefix is installing Distribute'
- ' in another location')
- return
-
- # let's see if its an egg
- if not setuptools_location.endswith('.egg'):
- log.warn('Non-egg installation')
- res = _remove_flat_installation(setuptools_location)
- if not res:
- return
- else:
- log.warn('Egg installation')
- pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
- if (os.path.exists(pkg_info) and
- _same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
- log.warn('Already patched.')
- return
- log.warn('Patching...')
- # let's create a fake egg replacing setuptools one
- res = _patch_egg_dir(setuptools_location)
- if not res:
- return
- log.warn('Patched done.')
- _relaunch()
-
-
-def _relaunch():
- log.warn('Relaunching...')
- # we have to relaunch the process
- # pip marker to avoid a relaunch bug
- if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']:
- sys.argv[0] = 'setup.py'
- args = [sys.executable] + sys.argv
- sys.exit(subprocess.call(args))
-
-
-def _extractall(self, path=".", members=None):
- """Extract all members from the archive to the current working
- directory and set owner, modification time and permissions on
- directories afterwards. `path' specifies a different directory
- to extract to. `members' is optional and must be a subset of the
- list returned by getmembers().
- """
- import copy
- import operator
- from tarfile import ExtractError
- directories = []
-
- if members is None:
- members = self
-
- for tarinfo in members:
- if tarinfo.isdir():
- # Extract directories with a safe mode.
- directories.append(tarinfo)
- tarinfo = copy.copy(tarinfo)
- tarinfo.mode = 448 # decimal for oct 0700
- self.extract(tarinfo, path)
-
- # Reverse sort directories.
- if sys.version_info < (2, 4):
- def sorter(dir1, dir2):
- return cmp(dir1.name, dir2.name)
- directories.sort(sorter)
- directories.reverse()
- else:
- directories.sort(key=operator.attrgetter('name'), reverse=True)
-
- # Set correct owner, mtime and filemode on directories.
- for tarinfo in directories:
- dirpath = os.path.join(path, tarinfo.name)
- try:
- self.chown(tarinfo, dirpath)
- self.utime(tarinfo, dirpath)
- self.chmod(tarinfo, dirpath)
- except ExtractError:
- e = sys.exc_info()[1]
- if self.errorlevel > 1:
- raise
- else:
- self._dbg(1, "tarfile: %s" % e)
-
-
-def main(argv, version=DEFAULT_VERSION):
- """Install or upgrade setuptools and EasyInstall"""
- tarball = download_setuptools()
- _install(tarball)
-
-
-if __name__ == '__main__':
- main(sys.argv[1:])
diff --git a/fswrap.egg-info/PKG-INFO b/fswrap.egg-info/PKG-INFO
deleted file mode 100644
index 5902203..0000000
--- a/fswrap.egg-info/PKG-INFO
+++ /dev/null
@@ -1,26 +0,0 @@
-Metadata-Version: 1.1
-Name: fswrap
-Version: 0.1.1
-Summary: An opinionated wrapper on file system and path functions
-Home-page: http://github.com/lakshmivyas/fswrap
-Author: Lakshmi Vyas
-Author-email: lakshmi.vyas@gmail.com
-License: MIT
-Description: Version 0.1.1
-
- Unified object oriented interface for interacting with file system objects.
- File system operations in python are distributed across modules: os, os.path,
- fnmatch, shutil and distutils. This module attempts to make the right choices
- for common operations to provide a single interface.
-
- This was extracted from the `hyde project`_ with minor changes.
-
-
- .. _hyde project: http://github.com/hyde/hyde
-Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Topic :: Software Development
diff --git a/fswrap.egg-info/SOURCES.txt b/fswrap.egg-info/SOURCES.txt
deleted file mode 100644
index 3fafc43..0000000
--- a/fswrap.egg-info/SOURCES.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-LICENSE
-MANIFEST.in
-distribute_setup.py
-fswrap.py
-setup.py
-fswrap.egg-info/PKG-INFO
-fswrap.egg-info/SOURCES.txt
-fswrap.egg-info/dependency_links.txt
-fswrap.egg-info/top_level.txt
-tests/atextfile.xml
-tests/logo.png
-tests/test_fswrap.py
-tests/arootfolder/afolder/helpers.html
-tests/arootfolder/afolder/index.html
-tests/arootfolder/afolder/index_expected.html
-tests/arootfolder/afolder/layout.html \ No newline at end of file
diff --git a/fswrap.egg-info/dependency_links.txt b/fswrap.egg-info/dependency_links.txt
deleted file mode 100644
index 8b13789..0000000
--- a/fswrap.egg-info/dependency_links.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/fswrap.egg-info/top_level.txt b/fswrap.egg-info/top_level.txt
deleted file mode 100644
index e007457..0000000
--- a/fswrap.egg-info/top_level.txt
+++ /dev/null
@@ -1 +0,0 @@
-fswrap
diff --git a/fswrap.py b/fswrap.py
index a1254f3..de7fc2e 100644
--- a/fswrap.py
+++ b/fswrap.py
@@ -15,6 +15,7 @@ from distutils import dir_util
import functools
import fnmatch
import logging
+import sys
logger = logging.getLogger('fswrap')
@@ -24,6 +25,20 @@ logger = logging.getLogger('fswrap')
__all__ = ['File', 'Folder']
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+ unicode = str
+
+ def hash_update(hsh, chunk):
+ hsh.update(chunk.encode())
+
+else:
+ def hash_update(hsh, chunk):
+ hsh.update(chunk)
+
+
+
class FS(object):
"""
The base file system object
@@ -56,10 +71,10 @@ class FS(object):
normpath, normcase, expandvars and expanduser).
"""
return os.path.abspath(
- os.path.normpath(
- os.path.normcase(
- os.path.expandvars(
- os.path.expanduser(self.path)))))
+ os.path.normpath(
+ os.path.normcase(
+ os.path.expandvars(
+ os.path.expanduser(self.path)))))
@property
def exists(self):
@@ -121,8 +136,8 @@ class FS(object):
return ''
ancestors = self.ancestors(stop=root)
return functools.reduce(lambda f, p: Folder(p.name).child(f),
- ancestors,
- self.name)
+ ancestors,
+ self.name)
def get_mirror(self, target_root, source_root=None):
"""
@@ -151,7 +166,8 @@ class FS(object):
Returns a File or Folder object that would represent this entity
if it were copied or moved to `destination`.
"""
- if isinstance(destination, File) or os.path.isfile(unicode(destination)):
+ if isinstance(destination,
+ File) or os.path.isfile(unicode(destination)):
return destination
else:
return FS.file_or_folder(Folder(destination).child(self.name))
@@ -211,7 +227,7 @@ class File(FS):
CHUNKSIZE = 1024
while 1:
chunk = fin.read(CHUNKSIZE)
- if '\0' in chunk:
+ if b'\0' in chunk:
return True
if len(chunk) < CHUNKSIZE:
break
@@ -309,7 +325,7 @@ class File(FS):
with open(self.path) as fin:
chunk = fin.read(CHUNKSIZE)
while chunk:
- hash.update(chunk)
+ hash_update(hash, chunk)
chunk = fin.read(CHUNKSIZE)
return hash.hexdigest()
@@ -375,8 +391,8 @@ class FolderWalker(FSVisitor):
yield folder
if walk_files:
for a_file in a_files:
- if (not self.pattern or
- fnmatch.fnmatch(a_file, self.pattern)):
+ if (not self.pattern or fnmatch.fnmatch(a_file,
+ self.pattern)):
yield File(folder.child(a_file))
def walk_all(self):
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 861a9f5..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-[egg_info]
-tag_build =
-tag_date = 0
-tag_svn_revision = 0
-
diff --git a/setup.py b/setup.py
index 8241f7d..7af6cc2 100644..100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
-from distribute_setup import use_setuptools
-use_setuptools()
+#!/usr/bin/env python
+
from setuptools import setup
try:
@@ -9,15 +9,15 @@ except IOError:
setup(
name='fswrap',
- version='0.1.1',
- author='Lakshmi Vyas',
- author_email='lakshmi.vyas@gmail.com',
- url='http://github.com/lakshmivyas/fswrap',
+ version='1.0.1',
+ author='fswrap contributors',
+ author_email='navilan@folds.in',
+ url='http://github.com/hyde/fswrap',
description='An opinionated wrapper on file system and path functions',
long_description=long_description,
license='MIT',
classifiers=[
- 'Development Status :: 3 - Alpha',
+ 'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
@@ -27,6 +27,6 @@ setup(
py_modules=['fswrap'],
tests_require=(
'nose',
- ),
+ ),
test_suite='nose.collector',
-) \ No newline at end of file
+)
diff --git a/tests/test_fswrap.py b/tests/test_fswrap.py
index d426cdb..43cd8a9 100644
--- a/tests/test_fswrap.py
+++ b/tests/test_fswrap.py
@@ -9,9 +9,15 @@ from fswrap import FS, File, Folder
import codecs
import os
import shutil
+import sys
from nose.tools import with_setup, nottest
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+ unicode = str
+
def test_representation():
f = FS(__file__)
@@ -207,9 +213,13 @@ def test_is_descendant_of():
def test_get_relative_path():
- assert INDEX.get_relative_path(ROOT_FOLDER) == Folder(AFOLDER.name).child(INDEX.name)
+ assert INDEX.get_relative_path(ROOT_FOLDER) == Folder(
+ AFOLDER.name).child(INDEX.name)
+
assert INDEX.get_relative_path(ROOT_FOLDER.parent) == Folder(
- ROOT_FOLDER.name).child_folder(AFOLDER.name).child(INDEX.name)
+ ROOT_FOLDER.name).child_folder(
+ AFOLDER.name).child(INDEX.name)
+
assert AFOLDER.get_relative_path(AFOLDER) == ""
@@ -217,7 +227,8 @@ def test_get_mirror():
mirror = AFOLDER.get_mirror(DATA_ROOT, source_root=ROOT_FOLDER)
assert mirror == DATA_ROOT.child_folder(AFOLDER.name)
mirror = AFOLDER.get_mirror(DATA_ROOT, source_root=ROOT_FOLDER.parent)
- assert mirror == DATA_ROOT.child_folder(ROOT_FOLDER.name).child_folder(AFOLDER.name)
+ assert mirror == DATA_ROOT.child_folder(
+ ROOT_FOLDER.name).child_folder(AFOLDER.name)
def test_mimetype():
@@ -532,6 +543,17 @@ def test_etag_same():
assert etag1 == etag3
+def test_etag_unicode_same():
+ f1 = File.make_temp(u"\x80\x81")
+ etag1 = f1.etag
+ f2 = File(f1.path)
+ etag2 = f2.etag
+ assert etag1 == etag2
+ f3 = File.make_temp(u"\x80\x81")
+ etag3 = f3.etag
+ assert etag1 == etag3
+
+
def test_etag_different():
f1 = File.make_temp("I am new")
etag1 = f1.etag
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..9c8e04a
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,10 @@
+[tox]
+envlist = py27,py33,py34
+
+[testenv]
+deps =
+ coverage
+ nose
+commands =
+ python -m coverage run -m nose
+ python -m coverage report -m --include="fswrap.py"