Skip to content

Commit

Permalink
Use the new Flask 0.11/1.0 extension naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Jun 3, 2016
1 parent 15086aa commit 1e03e69
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Quick start
.. code-block:: python
from flask import Flask
from flask.ext import fs
import flask_fs as fs
app = Flask(__name__)
fs.init_app(app)
Expand Down
2 changes: 1 addition & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Given a storage declared like this:

.. code-block:: python
from flask.ext import fs
import flask_fs as fs
avatars = fs.Storage('avatars', fs.IMAGES)
Expand Down
10 changes: 5 additions & 5 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Flask-FS need to be initialized with an application:
.. code-block:: python
from flask import Flask
from flask.ext import fs
import flask_fs as fs
app = Flask(__name__)
fs.init_app(app)
Expand All @@ -24,7 +24,7 @@ You need to declare some storages before being able to read or write files.

.. code-block:: python
from flask.ext import fs
import flask_fs as fs
images = fs.Storage('images')
uploads = fs.Storage('uploads')
Expand All @@ -34,7 +34,7 @@ You can limit the allowed file types.

.. code-block:: python
from flask.ext import fs
import flask_fs as fs
images = fs.Storage('images', fs.IMAGES)
custom = fs.Storage('custom', ('bat', 'sh'))
Expand All @@ -43,7 +43,7 @@ You can also specify allowed extensions by exclusion:

.. code-block:: python
from flask.ext import fs
import flask_fs as fs
WITHOUT_SCRIPTS = fs.AllExcept(fs.SCRIPTS + fs.EXECUTABLES)
store = fs.Storage('store', WITHOUT_SCRIPTS)
Expand All @@ -55,7 +55,7 @@ You can allow overwriting with the `overwrite` parameter in :class:`Storage` cl

.. code-block:: python
from flask.ext import fs
import flask_fs as fs
store = fs.Storage('store', overwrite=True)
Expand Down
8 changes: 4 additions & 4 deletions flask_fs/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@


BUILTIN_BACKENDS = {
'local': 'flask.ext.fs.backends.local.LocalBackend',
's3': 'flask.ext.fs.backends.s3.S3Backend',
'swift': 'flask.ext.fs.backends.swift.SwiftBackend',
'grids': 'flask.ext.fs.backends.gridfs.GridFsBackend',
'local': 'flask_fs.backends.local.LocalBackend',
's3': 'flask_fs.backends.s3.S3Backend',
'swift': 'flask_fs.backends.swift.SwiftBackend',
'grids': 'flask_fs.backends.gridfs.GridFsBackend',
}

DEFAULT_BACKEND = 'local'
Expand Down
10 changes: 6 additions & 4 deletions flask_fs/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ def exists(self, filename):

def file_allowed(self, storage, basename):
'''
This tells whether a file is allowed. It should return `True` if the
given `werkzeug.FileStorage` object can be saved with the given
basename, and `False` if it can't. The default implementation just
checks the extension, so you can override this if you want.
This tells whether a file is allowed.
It should return `True` if the given :class:`~werkzeug.FileStorage` object
can be saved with the given basename, and `False` if it can't.
The default implementation just checks the extension,
so you can override this if you want.
:param storage: The `werkzeug.FileStorage` to check.
:param basename: The basename it will be saved under.
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setUp(self):
self.client = self.app.test_client()

def configure(self, *storages, **configs):
from flask.ext import fs
import flask_fs as fs
for key, value in configs.items():
self.app.config[key] = value
fs.init_app(self.app, *storages)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_backend_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
class BackendTestMixin(object):

def put_file(self, filename, content):
raise NotImplementedError('You should implement this method')
raise NotImplementedError('You must implement this method')

def get_file(self, filename):
raise NotImplementedError('You should implement this method')
raise NotImplementedError('You must implement this method')

def file_exists(self, filename):
raise NotImplementedError('You should implement this method')
raise NotImplementedError('You must implement this method')

def assert_bin_equal(self, filename, expected):
data = self.get_file(filename)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from flask import url_for

from flask.ext.fs import Storage, DEFAULTS
from flask.ext.fs.backends.local import LocalBackend
from flask_fs import Storage, DEFAULTS
from flask_fs.backends.local import LocalBackend

from . import TestCase

Expand Down
2 changes: 1 addition & 1 deletion tests/test_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from flask.ext.fs import files
from flask_fs import files

from . import TestCase

Expand Down
4 changes: 2 additions & 2 deletions tests/test_gridfs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from . import TestCase, fake
from .test_backend_mixin import BackendTestMixin

from flask.ext.fs.backends.gridfs import GridFsBackend
from flask.ext.fs.storage import Config
from flask_fs.backends.gridfs import GridFsBackend
from flask_fs.storage import Config

TEST_DB = 'fstest'

Expand Down
4 changes: 2 additions & 2 deletions tests/test_local_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from . import TestCase
from .test_backend_mixin import BackendTestMixin

from flask.ext.fs.backends.local import LocalBackend
from flask.ext.fs.storage import Config
from flask_fs.backends.local import LocalBackend
from flask_fs.storage import Config


class LocalBackendTest(BackendTestMixin, TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mongoengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from PIL import Image

from flask.ext import fs
from flask.ext.fs.mongo import FileField, ImageField
from flask.ext.mongoengine import MongoEngine
import flask_fs as fs
from flask_fs.mongo import FileField, ImageField
from flask_mongoengine import MongoEngine

from . import TestCase, BIN_FILE

Expand Down
4 changes: 2 additions & 2 deletions tests/test_s3_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from . import TestCase
from .test_backend_mixin import BackendTestMixin

from flask.ext.fs.backends.s3 import S3Backend
from flask.ext.fs.storage import Config
from flask_fs.backends.s3 import S3Backend
from flask_fs.storage import Config

import boto3

Expand Down
2 changes: 1 addition & 1 deletion tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from . import TestCase, fake

from flask.ext import fs
import flask_fs as fs


class MockBackend(fs.BaseBackend):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_swift_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from . import TestCase
from .test_backend_mixin import BackendTestMixin

from flask.ext.fs.backends.swift import SwiftBackend
from flask.ext.fs.storage import Config
from flask_fs.backends.swift import SwiftBackend
from flask_fs.storage import Config

USER = 'test:tester'
KEY = 'testing'
Expand Down
4 changes: 1 addition & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import shutil
import tempfile

from os.path import join

from flask import url_for

from . import TestCase

from flask.ext import fs
import flask_fs as fs


class MockBackend(fs.BaseBackend):
Expand Down

0 comments on commit 1e03e69

Please sign in to comment.