Fixes #5329.
# Save location
if form.location.data and user.location is None:
- user.get_location = Location(name=unicode(form.location.data))
+ user.get_location = Location(name=six.text_type(form.location.data))
elif form.location.data:
location = user.get_location
- location.name = unicode(form.location.data)
+ location.name = six.text_type(form.location.data)
location.save()
user.save()
def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):
# csv.py doesn't do Unicode; encode temporarily as UTF-8:
+ # TODO: this probably won't be necessary in Python 3
csv_reader = csv.reader(utf_8_encoder(unicode_csv_data),
dialect=dialect, **kwargs)
for row in csv_reader:
# decode UTF-8 back to Unicode, cell by cell:
- yield [unicode(cell, 'utf-8') for cell in row]
+ yield [six.text_type(cell, 'utf-8') for cell in row]
def utf_8_encoder(unicode_csv_data):
for line in unicode_csv_data:
#TODO: Lets trust admins this do not validate Emails :)
commands_util.setup_app(args)
- args.username = unicode(commands_util.prompt_if_not_set(args.username, "Username:"))
+ args.username = six.text_type(commands_util.prompt_if_not_set(args.username, "Username:"))
args.password = commands_util.prompt_if_not_set(args.password, "Password:",True)
args.email = commands_util.prompt_if_not_set(args.email, "Email:")
import logging
import os
+import six
+
from mediagoblin import mg_globals as mgg
from mediagoblin.processing import (
BadMediaFail, FilenameBuilder,
try:
data = discover(media_file.name)
except Exception as e:
- _log.info(unicode(e))
+ _log.info(six.text_type(e))
return None
if data and data.get_audio_streams() and not data.get_video_streams():
return MEDIA_TYPE
import logging
import datetime
+import six
+
from mediagoblin import mg_globals as mgg
from mediagoblin.processing import (
FilenameBuilder, BaseProcessingFail,
data = transcoders.discover(media_file.name)
except Exception as e:
# this is usually GLib.GError, but we don't really care which one
- _log.warning(u'GStreamer: {0}'.format(unicode(e)))
- raise MissingComponents(u'GStreamer: {0}'.format(unicode(e)))
+ _log.warning(u'GStreamer: {0}'.format(six.text_type(e)))
+ raise MissingComponents(u'GStreamer: {0}'.format(six.text_type(e)))
_log.debug('Discovered: {0}'.format(data))
if not data.get_video_streams():
dt.get_microsecond()).isoformat()
for k, v in tags.items():
# types below are accepted by json; others must not present
- if not isinstance(v, (dict, list, basestring, int, float, bool,
+ if not isinstance(v, (dict, list, six.string_types, int, float, bool,
type(None))):
del tags[k]
return dict(tags)
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import six
+
from mediagoblin.db.models import MediaEntry, User
from mediagoblin.plugins.archivalook.models import FeaturedMedia
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
who uploaded the piece of media, slug is
the media entry's url slug.
"""
- url = unicode(url)
+ url = six.text_type(url)
u_end, m_start, m_end, end = (url.find('/u/') + 3,
url.find('/m/'),
url.find('/m/') + 3,
or tertiary)
"""
- featured_media = unicode(featured_media)
+ featured_media = six.text_type(featured_media)
featured_media_list = featured_media.split("\n")
display_type = 0
media_already_featured = []