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

About

goldfinch is simple package which removes invalid filename characters from a filename. Pass in a string or unicode (with or without invalid characters) and get valid filename returned (as unicode).

In general, goldfinch will remove invalid filename characters like <>:”/|?* and characters above the 0-255 character set. The default is is to attempt to convert to ascii characters using _unicodedata_.

Install

pip install goldfinch or easy_install -U goldfinch

Why use goldfinch

The only real usecase for this package is when one creates filenames on the fly and there is no way of knowing what exactly will be passed as the filename. I find it particularly useful when I scrape websites.

So, instead of this happening:
>>> fileName = 'this is a filename with some invalid characters in it <>:"/\|?*'
>>> file = open(fileName,"w")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'this is a filename with some invalid characters in it <>:"/\\|?*'
Do this:
>>> from goldfinch import validFileName as vfn
>>> fileName = 'this is a filename with some invalid characters in it <>:"/\|?*'
>>> file = open(vfn(fileName),"w")

Examples

There are three (space, initCap, and ascii) options available when normalizing a filename.

The default is ‘space=”underscore”, initCap=True, ascii=True’.

  • For space the options are underscore, remove, and keep. The default is underscore which will replace a space with an underscore (_).
  • initCap is a True & False option. True which is the default will convert the first character in a word to cap and leave all others lowercase.
  • ascii is also a True & False option. Once again True is the default which will convert something like this ÅåÄäÖ to this AaAaO. False will leave characters as-is.
Use default setting:
>>> fileName = 'THIS IS a filename with ÅåÄäÖ some characters that will not work like these: <>:"/\|?*'
>>> vfn(fileName)
'This_Is_A_Filename_With_Aaaao_Some_Characters_That_Will_Not_Work_Like_These'
Default with unicode input:
>>> fileName = u'THIS IS a filename with ÅåÄäÖ some characters that will not work like these: <>:"/\|?*'
>>> vfn(fileName)
'This_Is_A_Filename_With_Aaaao_Some_Characters_That_Will_Not_Work_Like_These'
With initCap = False:
>>> vfn(fileName, initCap = False)
'THIS_IS_a_filename_with_AaAaO_some_characters_that_will_not_work_like_these_'
With space = ‘remove’:
>>> vfn(fileName, space = 'remove')
'ThisIsAFilenameWithAaaaoSomeCharactersThatWillNotWorkLikeThese'
Release History

Release History

0.4

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.3.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.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

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.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

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
goldfinch-0.4.tar.gz (2.8 kB) Copy SHA256 Checksum SHA256 Source Oct 4, 2014

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