Changeset - 5ea06f5ce235
[Not reviewed]
0 12 0
Lance Edgar (lance) - 7 years ago 2017-07-06 16:50:47
lance@edbob.org
Cleanup some unicode stuff per py3k effort
12 files changed with 55 insertions and 38 deletions:
0 comments (0 inline, 0 general)
rattail/batch/labels.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2016 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -29,6 +29,7 @@ from __future__ import unicode_literals, absolute_import
 
import csv
 
import logging
 

	
 
import six
 
import sqlalchemy as sa
 
from sqlalchemy import orm
 

	
 
@@ -160,7 +161,7 @@ class LabelBatchHandler(BatchHandler):
 
            return
 

	
 
        product = row.product
 
        row.brand_name = unicode(product.brand or '')
 
        row.brand_name = six.text_type(product.brand or '')
 
        row.description = product.description
 
        row.size = product.size
 
        department = product.department
rattail/batch/pricing.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
@@ -26,6 +26,7 @@ Handler for pricing batches
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import six
 
from sqlalchemy import orm
 

	
 
from rattail.db import model
 
@@ -64,7 +65,7 @@ class PricingBatchHandler(BatchHandler):
 
        product = row.product
 
        assert product
 

	
 
        row.brand_name = unicode(product.brand or '')
 
        row.brand_name = six.text_type(product.brand or '')
 
        row.description = product.description
 
        row.size = product.size
 
        department = product.department
rattail/batch/purchase.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2016 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -26,6 +26,7 @@ Handler for purchase order batches
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import six
 
from sqlalchemy import orm
 

	
 
from rattail.db import model, api
 
@@ -100,7 +101,7 @@ class PurchaseBatchHandler(BatchHandler):
 
        cost = row.product.cost_for_vendor(batch.vendor) or row.product.cost
 
        row.upc = product.upc
 
        row.item_id = product.item_id
 
        row.brand_name = unicode(product.brand or '')
 
        row.brand_name = six.text_type(product.brand or '')
 
        row.description = product.description
 
        row.size = product.size
 
        if product.department:
rattail/bouncer/handler.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2015 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -24,12 +24,13 @@
 
Email Bounce Handlers
 
"""
 

	
 
from __future__ import unicode_literals
 
from __future__ import unicode_literals, absolute_import
 

	
 
import os
 
import datetime
 
from email.utils import parsedate_tz, mktime_tz
 

	
 
import six
 
from sqlalchemy import orm
 
from flufl.bounce import all_failures
 

	
 
@@ -136,12 +137,12 @@ class BounceHandler(object):
 
        emails = session.query(model.CustomerEmailAddress).filter_by(address=recipient)
 
        for email in emails:
 
            yield self.make_link(type="Rattail Customer",
 
                                 title=unicode(email.customer),
 
                                 title=six.text_type(email.customer),
 
                                 url=url.format(uuid=email.parent_uuid))
 

	
 
        url = self.config.require('tailbone', 'url.person')
 
        emails = session.query(model.PersonEmailAddress).filter_by(address=recipient)
 
        for email in emails:
 
            yield self.make_link(type="Rattail Person",
 
                                 title=unicode(email.person),
 
                                 title=six.text_type(email.person),
 
                                 url=url.format(uuid=email.parent_uuid))
rattail/data/new-batch/webview.py
Show inline comments
 
@@ -6,6 +6,8 @@ Views for ${model_title} batches
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import six
 

	
 
from rattail.db import model
 

	
 
from tailbone.views.batch import FileBatchMasterView
 
@@ -26,7 +28,7 @@ class ${model_name}View(FileBatchMasterView):
 
    url_prefix = '/batch/${table_name.replace('_', '-')}'
 

	
 
    def get_instance_title(self, batch):
 
        return unicode(batch.vendor)
 
        return six.text_type(batch.vendor)
 

	
 
    def configure_grid(self, g):
 
        g.joiners['vendor'] = lambda q: q.join(model.Vendor)
rattail/importing/handlers.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2016 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -29,6 +29,7 @@ from __future__ import unicode_literals, absolute_import
 
import sys
 
import logging
 

	
 
import six
 
import humanize
 

	
 
from rattail.time import make_utc
 
@@ -374,7 +375,7 @@ class RecordRenderer(object):
 
        return label(record)
 

	
 
    def label(self, record):
 
        return unicode(record)
 
        return six.text_type(record)
 

	
 
    def get_url(self, record):
 
        """
rattail/importing/postgresql.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2016 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -30,6 +30,8 @@ import os
 
import datetime
 
import logging
 

	
 
import six
 

	
 
from rattail.importing import BulkImporter, ToSQLAlchemy
 
from rattail.time import make_utc
 

	
 
@@ -81,7 +83,7 @@ class BulkToPostgreSQL(BulkImporter, ToSQLAlchemy):
 
            value = value.replace('\n', '\\n')
 
            value = value.replace('\t', '\\t') # TODO: add test for this
 

	
 
        return unicode(value)
 
        return six.text_type(value)
 

	
 
    def flush_create_update(self):
 
        pass
rattail/mail.py
Show inline comments
 
@@ -179,7 +179,7 @@ class Email(object):
 
        """
 
        Returns the value for the message's ``From:`` header.
 

	
 
        :rtype: unicode
 
        :rtype: str
 
        """
 
        sender = self.config.get('rattail.mail', '{0}.from'.format(self.key))
 
        if not sender:
 
@@ -221,7 +221,7 @@ class Email(object):
 
        """
 
        Returns a string to be used as the subject prefix for the message.
 

	
 
        :rtype: unicode
 
        :rtype: str
 
        """
 
        prefix = self.config.get('rattail.mail', '{0}.prefix'.format(self.key))
 
        if not prefix:
 
@@ -236,7 +236,7 @@ class Email(object):
 
        Returns the base value for the message's subject header, i.e. minus
 
        prefix.
 

	
 
        :rtype: unicode
 
        :rtype: str
 
        """
 
        subject = self.config.get('rattail.mail', '{0}.subject'.format(self.key),
 
                                  default=self.default_subject)
 
@@ -253,7 +253,7 @@ class Email(object):
 
        complete subject also, in which case the prefix and base subject are
 
        not considered.
 

	
 
        :rtype: unicode
 
        :rtype: str
 
        """
 
        return "{} {}".format(self.get_prefix(data), self.get_subject(data, render=render))
 

	
rattail/tests/importing/test_rattail.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from unittest import TestCase
 

	
 
import six
 
import sqlalchemy as sa
 
from mock import patch
 
from fixture import TempIO
 
@@ -24,7 +25,7 @@ class DualRattailMixin(RattailMixin):
 

	
 
        self.host_engine = self.config.rattail_engines['host']
 
        self.config.setdefault('rattail.db', 'keys', 'default, host')
 
        self.config.setdefault('rattail.db', 'host.url', unicode(self.host_engine.url))
 
        self.config.setdefault('rattail.db', 'host.url', six.text_type(self.host_engine.url))
 
        model = self.get_rattail_model()
 
        model.Base.metadata.create_all(bind=self.host_engine)
 
        self.host_session = Session(bind=self.host_engine)
rattail/tests/importing/test_sqlalchemy.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from unittest import TestCase
 

	
 
import six
 
from mock import patch
 

	
 
import sqlalchemy as sa
 
@@ -38,7 +39,7 @@ class TestFromSQLAlchemy(TestCase):
 
        session = Session()
 
        importer = saimport.FromSQLAlchemy(host_session=session,
 
                                           host_model_class=Widget)
 
        self.assertEqual(unicode(importer.query()),
 
        self.assertEqual(six.text_type(importer.query()),
 
                         "SELECT widgets.id AS widgets_id, widgets.description AS widgets_description \n"
 
                         "FROM widgets")
 

	
rattail/vendors/catalogs.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2015 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -24,10 +24,12 @@
 
Vendor Catalogs
 
"""
 

	
 
from __future__ import unicode_literals
 
from __future__ import unicode_literals, absolute_import
 

	
 
from decimal import Decimal
 

	
 
import six
 

	
 
from rattail.exceptions import RattailError
 
from rattail.util import load_entry_points
 

	
 
@@ -89,6 +91,7 @@ class CatalogParser(object):
 
        return int(value)
 

	
 

	
 
@six.python_2_unicode_compatible
 
class CatalogParserNotFound(RattailError):
 
    """
 
    Exception raised when a vendor catalog parser is required, but cannot be
 
@@ -98,8 +101,8 @@ class CatalogParserNotFound(RattailError):
 
    def __init__(self, key):
 
        self.key = key
 

	
 
    def __unicode__(self):
 
        return "Vendor catalog parser with key {0} cannot be located.".format(self.key)
 
    def __str__(self):
 
        return "Vendor catalog parser with key {} cannot be located.".format(self.key)
 

	
 

	
 
def get_catalog_parsers():
rattail/vendors/invoices.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2015 Lance Edgar
 
#  Copyright © 2010-2017 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -24,10 +24,12 @@
 
Vendor Invoices
 
"""
 

	
 
from __future__ import unicode_literals
 
from __future__ import unicode_literals, absolute_import
 

	
 
from decimal import Decimal
 

	
 
import six
 

	
 
from rattail.exceptions import RattailError
 
from rattail.util import load_entry_points
 

	
 
@@ -87,6 +89,7 @@ class InvoiceParser(object):
 
        return int(value)
 

	
 

	
 
@six.python_2_unicode_compatible
 
class InvoiceParserNotFound(RattailError):
 
    """
 
    Exception raised when a vendor invoice parser is required, but cannot be
 
@@ -96,8 +99,8 @@ class InvoiceParserNotFound(RattailError):
 
    def __init__(self, key):
 
        self.key = key
 

	
 
    def __unicode__(self):
 
        return "Vendor invoice parser with key {0} cannot be located.".format(self.key)
 
    def __str__(self):
 
        return "Vendor invoice parser with key {} cannot be located.".format(self.key)
 

	
 

	
 
def get_invoice_parsers():
0 comments (0 inline, 0 general)