Skip to content

illagrenan/misc-filename-utils

Repository files navigation

Misc filename utils

Travis CI Badge   Coverage Status   Requirements Status

Installation

This package is not yet on PyPI.

pip install --upgrade git+git://github.com/illagrenan/misc-filename-utils.git#egg=misc-filename-utils

You can add this package to requirements.txt:

-e git+git://github.com/illagrenan/misc-filename-utils.git#egg=misc-filename-utils

Usage

get_safe_path_name

from misc_filename_utils.funcs import get_safe_path_name
>>> get_safe_path_name("\&FoO-bAr##.PDF")
u'foo-bar_.pdf'

upload_path (generic usage)

from misc_filename_utils.funcs import upload_path

class Person(object):
	pass

>>> upload_path(Person, "IMAGE.pdf")
u'person\\image.pdf'

>>> upload_path(Person(), "IMAGE.pdf")
u'person\\image.pdf'

upload_path (Django example)

from django.db import models
from misc_filename_utils.funcs import upload_path

class Person(models.Model):
	# Files will be uploaded to MEDIA_ROOT/person/some_file.ext
    image = models.FileField(upload_to=upload_path)

get_filename_from_url

from misc_filename_utils.funcs import get_filename_from_url

>>> get_filename_from_url("http://www.example.com/some_directory/HOW_TO_FOO.pdf")
u'how_to_foo.pdf'

About

Three small py functions for easier filename manipulation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages