This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This is an extended version of Python’s builtin glob module (http://docs.python.org/library/glob.html) which adds:

  • The ability to capture the text matched by glob patterns, and return those matches alongside the filenames.
  • A recursive ‘**’ globbing syntax, akin for example to the globstar option of the bash shell.
  • The ability to replace the filesystem functions used, in order to glob on virtual filesystems.
  • Compatible with Python 2 and Python 3 (tested with 3.3).

It’s currently based on the glob code from Python 3.3.1.

Examples

Matches being returned:

import glob2

for filename, (version,) in glob2.iglob('./binaries/project-*.zip', with_matches=True):
    print version

Recursive glob:

>>> import glob2
>>> all_header_files = glob2.glob('src/**/*.h')
['src/fs.h', 'src/media/mp3.h', 'src/media/mp3/frame.h', ...]

Note that ** must appear on it’s own as a directory element to have its special meaning. **h will not have the desired effect.

** will match “.”, so **/*.py returns Python files in the current directory. If this is not wanted, */**/*.py should be used instead.

Custom Globber:

from glob2 import Globber

class VirtualStorageGlobber(Globber):
    def __init__(self, storage):
        self.storage = storage
    def listdir(self, path):
        # Must raise os.error if path is not a directory
        return self.storage.listdir(path)
    def exists(self, path):
        return self.storage.exists(path)
    def isdir(self, path):
        # Used only for trailing slash syntax (``foo/``).
        return self.storage.isdir(path)
    def islink(self, path):
        # Used only for recursive glob (``**``).
        return self.storage.islink(path)

globber = VirtualStorageGlobber(sftp_storage)
globber.glob('/var/www/**/*.js')

If isdir and/or islink cannot be implemented for a storage, you can make them return a fixed value, with the following consequences:

  • If isdir returns True, a glob expression ending with a slash will return all items, even non-directories, if it returns False, the same glob expression will return nothing.
  • Return islink True, the recursive globbing syntax ** will follow all links. If you return False, it will not work at all.
Release History

Release History

0.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
glob2-0.5-py2.py3-none-any.whl (8.6 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Nov 4, 2016
glob2-0.5.tar.gz (10.1 kB) Copy SHA256 Checksum SHA256 Source Nov 4, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting