# Path: airy/utils/encoding.py
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a bytestring version of 's', encoded as specified in 'encoding'.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if strings_only and isinstance(s, (types.NoneType, int)):
#         return s
#     if isinstance(s, Promise):
#         return unicode(s).encode(encoding, errors)
#     elif not isinstance(s, basestring):
#         try:
#             return str(s)
#         except UnicodeEncodeError:
#             if isinstance(s, Exception):
#                 # An Exception subclass containing non-ASCII data that doesn't
#                 # know how to print itself properly. We shouldn't raise a
#                 # further exception.
#                 return ' '.join([smart_str(arg, encoding, strings_only,
#                         errors) for arg in s])
#             return unicode(s).encode(encoding, errors)
#     elif isinstance(s, unicode):
#         return s.encode(encoding, errors)
#     elif s and encoding != 'utf-8':
#         return s.decode('utf-8', errors).encode(encoding, errors)
#     else:
#         return s
# 
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)


import os
    from cStringIO import StringIO
    from StringIO import StringIO
from airy.utils.encoding import smart_str, smart_unicode
from airy.core.files.utils import FileProxyMixin
        return smart_str(self.name or '')

    def __unicode__(self):
        return smart_unicode(self.name or u'')

    def __repr__(self):
        return "<%s: %s>" % (self.__class__.__name__, self or "None")

    def __nonzero__(self):
        return bool(self.name)

    def __len__(self):
        return self.size

    def _get_size(self):
        if not hasattr(self, '_size'):
            if hasattr(self.file, 'size'):
                self._size = self.file.size
            elif os.path.exists(self.file.name):
                self._size = os.path.getsize(self.file.name)
            else:
                raise AttributeError("Unable to determine the file's size.")
        return self._size

    def _set_size(self, size):
        self._size = size

    size = property(_get_size, _set_size)

    def _get_closed(self):

# Path: airy/utils/encoding.py
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a bytestring version of 's', encoded as specified in 'encoding'.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if strings_only and isinstance(s, (types.NoneType, int)):
#         return s
#     if isinstance(s, Promise):
#         return unicode(s).encode(encoding, errors)
#     elif not isinstance(s, basestring):
#         try:
#             return str(s)
#         except UnicodeEncodeError:
#             if isinstance(s, Exception):
#                 # An Exception subclass containing non-ASCII data that doesn't
#                 # know how to print itself properly. We shouldn't raise a
#                 # further exception.
#                 return ' '.join([smart_str(arg, encoding, strings_only,
#                         errors) for arg in s])
#             return unicode(s).encode(encoding, errors)
#     elif isinstance(s, unicode):
#         return s.encode(encoding, errors)
#     elif s and encoding != 'utf-8':
#         return s.decode('utf-8', errors).encode(encoding, errors)
#     else:
#         return s
# 
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)


# Path: airy/core/files/base.py
import os
    from cStringIO import StringIO
    from StringIO import StringIO
from airy.utils.encoding import smart_str, smart_unicode
from airy.core.files.utils import FileProxyMixin

        return smart_str(self.name or '')

    def __unicode__(self):
        return smart_unicode(self.name or u'')

    def __repr__(self):
        return "<%s: %s>" % (self.__class__.__name__, self or "None")

    def __nonzero__(self):
        return bool(self.name)

    def __len__(self):
        return self.size

    def _get_size(self):
        if not hasattr(self, '_size'):
            if hasattr(self.file, 'size'):
                self._size = self.file.size
            elif os.path.exists(self.file.name):
                self._size = os.path.getsize(self.file.name)
            else:
                raise AttributeError("Unable to determine the file's size.")
        return self._size

    def _set_size(self, size):
        self._size = size

    size = property(_get_size, _set_size)

    def _get_closed(self):

        return not self.file or self.file.closed