python类FileSystemStorage()的实例源码

collectstatic.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:trydjango18 作者: lucifer-yqh 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
storage.py 文件源码 项目:django-cra-helper 作者: MasterKale 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, file_permissions_mode=None,
                 directory_permissions_mode=None):
        self._file_path = ''
        self._file_name = ''

        if os.path.isfile(location):
            # Separate the path from the filename
            self._file_path, self._file_name = os.path.split(location)
        else:
            # This class won't work if `location` doesn't point to an actual file
            raise IOError('Path should point to an existing file')

        # Pass in the folder so this acts like a typical FileSystemStorage that needs a path
        super().__init__(
            self._file_path,
            base_url,
            file_permissions_mode,
            directory_permissions_mode
        )
collectstatic.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:trydjango18 作者: wei0104 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
collectstatic_js_choices.py 文件源码 项目:django-js-choices 作者: lorinkoz 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle(self, *args, **options):
        locale = options['locale']
        location = self.get_location()
        file = 'choices-{}.js'.format(locale)
        fs = FileSystemStorage(location=location)
        if fs.exists(file):
            fs.delete(file)
        content = generate_js(locale)
        fs.save(file, ContentFile(content))
        if len(sys.argv) > 1 and sys.argv[1] in ['collectstatic_js_choices']:
            self.stdout.write('{0} file written to {1}'.format(file, location))
collectstatic.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:ims 作者: ims-team 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
collectstatic.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:lifesoundtrack 作者: MTG 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
tests.py 文件源码 项目:django-icekit 作者: ic-labs 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_iiif_image_api_storage(self, _getter):
        # Enable file storage engine for this test
        from icekit.plugins.iiif import views
        views.iiif_storage = FileSystemStorage(location=tempfile.gettempdir())

        # Generate image at 10% size, manually specified
        canonical_url = reverse(
            'iiif_image_api',
            args=[self.ik_image.pk,
                  'full', '20,', '0', 'default', 'jpg'])
        image = self.mock_image(return_from=_getter)
        response = self.app.get(canonical_url, user=self.superuser)
        self.assertEqual(image.mock_calls, [
            call.resize((20, 30)),
            call.resize().convert('RGB'),
            call.resize().convert().save(ANY, format='jpeg')
        ])
        self.assertEqual(200, response.status_code)
        self.FileResponse.assert_called_with(
            ANY, content_type='image/jpeg')
        # Generate image at 10% size using pct:10, confirm we get redirected
        # to the expected canonical URL path and that image loaded from storage
        # instead of generated
        image = self.mock_image(return_from=_getter)
        response = self.app.get(
            reverse(
                'iiif_image_api',
                args=[self.ik_image.pk,
                      'full', 'pct:10', '0', 'default', 'jpg']),
            user=self.superuser,
        )
        # Redirected to canonical URL?
        self.assertEqual(302, response.status_code)
        self.assertTrue(response['location'].endswith(canonical_url))
        response = response.follow()
        self.assertEqual(200, response.status_code)
        self.assertEqual(image.mock_calls, [])  # No calls on image
        self.FileResponse.assert_called_with(
            ANY, content_type='image/jpeg')
collectstatic.py 文件源码 项目:django-open-lecture 作者: DmLitov4 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:django-open-lecture 作者: DmLitov4 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
collectstatic.py 文件源码 项目:travlr 作者: gauravkulkarni96 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:travlr 作者: gauravkulkarni96 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
finders.py 文件源码 项目:c3nav 作者: c3nav 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def list(self, ignore_patterns):
        result = []
        for prefix, path in logo_paths.items():
            if not path:
                continue
            basedir, filename = os.path.split(path)
            storage = FileSystemStorage(location=basedir)
            storage.prefix = prefix
            result.append((filename, storage))
        return result
collectstatic.py 文件源码 项目:logo-gen 作者: jellene4eva 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:logo-gen 作者: jellene4eva 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None
collectstatic.py 文件源码 项目:gmail_scanner 作者: brandonhub 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def is_local_storage(self):
        return isinstance(self.storage, FileSystemStorage)
storage.py 文件源码 项目:gmail_scanner 作者: brandonhub 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, location=None, base_url=None, *args, **kwargs):
        if location is None:
            location = settings.STATIC_ROOT
        if base_url is None:
            base_url = settings.STATIC_URL
        check_settings(base_url)
        super(StaticFilesStorage, self).__init__(location, base_url,
                                                 *args, **kwargs)
        # FileSystemStorage fallbacks to MEDIA_ROOT when location
        # is empty, so we restore the empty value.
        if not location:
            self.base_location = None
            self.location = None


问题


面经


文章

微信
公众号

扫码关注公众号