fix: remove references, dependency for six package

This commit is contained in:
Lance Edgar 2024-07-01 17:01:01 -05:00
parent 6f8b825b0b
commit 2feb07e1d3
31 changed files with 105 additions and 181 deletions

View file

@ -56,7 +56,6 @@ install_requires =
pyramid_retry pyramid_retry
pyramid_tm pyramid_tm
rattail[db,bouncer] rattail[db,bouncer]
six
sa-filters sa-filters
simplejson simplejson
transaction transaction

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Web API - Label Batches Tailbone Web API - Label Batches
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from tailbone.api.batch import APIBatchView, APIBatchRowView from tailbone.api.batch import APIBatchView, APIBatchRowView
@ -56,10 +52,10 @@ class LabelBatchRowViews(APIBatchRowView):
def normalize(self, row): def normalize(self, row):
batch = row.batch batch = row.batch
data = super(LabelBatchRowViews, self).normalize(row) data = super().normalize(row)
data['item_id'] = row.item_id data['item_id'] = row.item_id
data['upc'] = six.text_type(row.upc) data['upc'] = str(row.upc)
data['upc_pretty'] = row.upc.pretty() if row.upc else None data['upc_pretty'] = row.upc.pretty() if row.upc else None
data['brand_name'] = row.brand_name data['brand_name'] = row.brand_name
data['description'] = row.description data['description'] = row.description

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Web API - Customer Views Tailbone Web API - Customer Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from tailbone.api import APIMasterView from tailbone.api import APIMasterView
@ -46,7 +42,7 @@ class CustomerView(APIMasterView):
def normalize(self, customer): def normalize(self, customer):
return { return {
'uuid': customer.uuid, 'uuid': customer.uuid,
'_str': six.text_type(customer), '_str': str(customer),
'id': customer.id, 'id': customer.id,
'number': customer.number, 'number': customer.number,
'name': customer.name, 'name': customer.name,

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Web API - Person Views Tailbone Web API - Person Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from tailbone.api import APIMasterView from tailbone.api import APIMasterView
@ -45,7 +41,7 @@ class PersonView(APIMasterView):
def normalize(self, person): def normalize(self, person):
return { return {
'uuid': person.uuid, 'uuid': person.uuid,
'_str': six.text_type(person), '_str': str(person),
'first_name': person.first_name, 'first_name': person.first_name,
'last_name': person.last_name, 'last_name': person.last_name,
'display_name': person.display_name, 'display_name': person.display_name,

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Web API - Upgrade Views Tailbone Web API - Upgrade Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from tailbone.api import APIMasterView from tailbone.api import APIMasterView
@ -53,7 +49,7 @@ class UpgradeView(APIMasterView):
data['status_code'] = None data['status_code'] = None
else: else:
data['status_code'] = self.enum.UPGRADE_STATUS.get(upgrade.status_code, data['status_code'] = self.enum.UPGRADE_STATUS.get(upgrade.status_code,
six.text_type(upgrade.status_code)) str(upgrade.status_code))
return data return data

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Web API - Vendor Views Tailbone Web API - Vendor Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from tailbone.api import APIMasterView from tailbone.api import APIMasterView
@ -44,7 +40,7 @@ class VendorView(APIMasterView):
def normalize(self, vendor): def normalize(self, vendor):
return { return {
'uuid': vendor.uuid, 'uuid': vendor.uuid,
'_str': six.text_type(vendor), '_str': str(vendor),
'id': vendor.id, 'id': vendor.id,
'name': vendor.name, 'name': vendor.name,
} }

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,12 +24,8 @@
Tailbone Web API - Work Order Views Tailbone Web API - Work Order Views
""" """
from __future__ import unicode_literals, absolute_import
import datetime import datetime
import six
from rattail.db.model import WorkOrder from rattail.db.model import WorkOrder
from cornice import Service from cornice import Service
@ -44,19 +40,19 @@ class WorkOrderView(APIMasterView):
object_url_prefix = '/workorder' object_url_prefix = '/workorder'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(WorkOrderView, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
app = self.get_rattail_app() app = self.get_rattail_app()
self.workorder_handler = app.get_workorder_handler() self.workorder_handler = app.get_workorder_handler()
def normalize(self, workorder): def normalize(self, workorder):
data = super(WorkOrderView, self).normalize(workorder) data = super().normalize(workorder)
data.update({ data.update({
'customer_name': workorder.customer.name, 'customer_name': workorder.customer.name,
'status_label': self.enum.WORKORDER_STATUS[workorder.status_code], 'status_label': self.enum.WORKORDER_STATUS[workorder.status_code],
'date_submitted': six.text_type(workorder.date_submitted or ''), 'date_submitted': str(workorder.date_submitted or ''),
'date_received': six.text_type(workorder.date_received or ''), 'date_received': str(workorder.date_received or ''),
'date_released': six.text_type(workorder.date_released or ''), 'date_released': str(workorder.date_released or ''),
'date_delivered': six.text_type(workorder.date_delivered or ''), 'date_delivered': str(workorder.date_delivered or ''),
}) })
return data return data
@ -87,7 +83,7 @@ class WorkOrderView(APIMasterView):
if 'status_code' in data: if 'status_code' in data:
data['status_code'] = int(data['status_code']) data['status_code'] = int(data['status_code'])
return super(WorkOrderView, self).update_object(workorder, data) return super().update_object(workorder, data)
def status_codes(self): def status_codes(self):
""" """

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Tailbone Exceptions Tailbone Exceptions
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.exceptions import RattailError from rattail.exceptions import RattailError
@ -37,7 +33,6 @@ class TailboneError(RattailError):
""" """
@six.python_2_unicode_compatible
class TailboneJSONFieldError(TailboneError): class TailboneJSONFieldError(TailboneError):
""" """
Error raised when JSON serialization of a form field results in an error. Error raised when JSON serialization of a form field results in an error.

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,9 +24,6 @@
Tailbone Handler Tailbone Handler
""" """
from __future__ import unicode_literals, absolute_import
import six
from mako.lookup import TemplateLookup from mako.lookup import TemplateLookup
from rattail.app import GenericHandler from rattail.app import GenericHandler
@ -41,7 +38,7 @@ class TailboneHandler(GenericHandler):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(TailboneHandler, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# TODO: make templates dir configurable? # TODO: make templates dir configurable?
templates = [resource_path('rattail:templates/web')] templates = [resource_path('rattail:templates/web')]
@ -67,7 +64,7 @@ class TailboneHandler(GenericHandler):
Returns an iterator over all registered Tailbone providers. Returns an iterator over all registered Tailbone providers.
""" """
providers = get_all_providers(self.config) providers = get_all_providers(self.config)
return six.itervalues(providers) return providers.values()
def write_model_view(self, data, path, **kwargs): def write_model_view(self, data, path, **kwargs):
""" """

View file

@ -24,7 +24,6 @@
Event Subscribers Event Subscribers
""" """
import six
import json import json
import datetime import datetime
import logging import logging
@ -177,7 +176,6 @@ def before_render(event):
renderer_globals['tailbone'] = tailbone renderer_globals['tailbone'] = tailbone
renderer_globals['model'] = request.rattail_config.get_model() renderer_globals['model'] = request.rattail_config.get_model()
renderer_globals['enum'] = request.rattail_config.get_enum() renderer_globals['enum'] = request.rattail_config.get_enum()
renderer_globals['six'] = six
renderer_globals['json'] = json renderer_globals['json'] = json
renderer_globals['datetime'] = datetime renderer_globals['datetime'] = datetime
renderer_globals['colander'] = colander renderer_globals['colander'] = colander

View file

@ -890,7 +890,7 @@
% if request.user: % if request.user:
FeedbackFormData.userUUID = ${json.dumps(request.user.uuid)|n} FeedbackFormData.userUUID = ${json.dumps(request.user.uuid)|n}
FeedbackFormData.userName = ${json.dumps(six.text_type(request.user))|n} FeedbackFormData.userName = ${json.dumps(str(request.user))|n}
% endif % endif
</script> </script>

View file

@ -236,7 +236,7 @@
% if input_file_template_settings is not Undefined: % if input_file_template_settings is not Undefined:
ThisPage.methods.validateInputFileTemplateSettings = function() { ThisPage.methods.validateInputFileTemplateSettings = function() {
% for tmpl in six.itervalues(input_file_templates): % for tmpl in input_file_templates.values():
if (this.inputFileTemplateSettings['${tmpl['setting_mode']}'] == 'hosted') { if (this.inputFileTemplateSettings['${tmpl['setting_mode']}'] == 'hosted') {
if (!this.inputFileTemplateSettings['${tmpl['setting_file']}']) { if (!this.inputFileTemplateSettings['${tmpl['setting_file']}']) {
if (!this.inputFileTemplateUploads['${tmpl['key']}']) { if (!this.inputFileTemplateUploads['${tmpl['key']}']) {

View file

@ -347,7 +347,7 @@
} }
ThisPageData.orderItemStatuses = ${json.dumps(enum.CUSTORDER_ITEM_STATUS)|n} ThisPageData.orderItemStatuses = ${json.dumps(enum.CUSTORDER_ITEM_STATUS)|n}
ThisPageData.orderItemStatusOptions = ${json.dumps([dict(key=k, label=v) for k, v in six.iteritems(enum.CUSTORDER_ITEM_STATUS)])|n} ThisPageData.orderItemStatusOptions = ${json.dumps([dict(key=k, label=v) for k, v in enum.CUSTORDER_ITEM_STATUS.items()])|n}
ThisPageData.oldStatusCode = ${instance.status_code} ThisPageData.oldStatusCode = ${instance.status_code}

View file

@ -296,7 +296,7 @@
% endfor % endfor
} }
% for key, form in six.iteritems(feature_forms): % for key, form in feature_forms.items():
<% safekey = key.replace('-', '_') %> <% safekey = key.replace('-', '_') %>
ThisPageData.${safekey} = { ThisPageData.${safekey} = {
<% dform = feature_forms[key].make_deform_form() %> <% dform = feature_forms[key].make_deform_form() %>

View file

@ -73,7 +73,7 @@
<div class="grid"> <div class="grid">
<table class="order-form"> <table class="order-form">
<% column_count = 8 + len(header_columns) + (0 if ignore_cases else 1) + int(capture(self.extra_count)) %> <% column_count = 8 + len(header_columns) + (0 if ignore_cases else 1) + int(capture(self.extra_count)) %>
% for department in sorted(six.itervalues(departments), key=lambda d: d.name if d else ''): % for department in sorted(departments.values(), key=lambda d: d.name if d else ''):
<thead> <thead>
<tr> <tr>
<th class="department" colspan="${column_count}">Department <th class="department" colspan="${column_count}">Department
@ -84,7 +84,7 @@
% endif % endif
</th> </th>
</tr> </tr>
% for subdepartment in sorted(six.itervalues(department._order_subdepartments), key=lambda s: s.name if s else ''): % for subdepartment in sorted(department._order_subdepartments.values(), key=lambda s: s.name if s else ''):
<tr> <tr>
<th class="subdepartment" colspan="${column_count}">Subdepartment <th class="subdepartment" colspan="${column_count}">Subdepartment
% if subdepartment.number or subdepartment.name: % if subdepartment.number or subdepartment.name:

View file

@ -9,7 +9,7 @@
% for topkey, topgroup in sorted(view_settings.items(), key=lambda itm: 'aaaa' if itm[0] == 'rattail' else itm[0]): % for topkey, topgroup in sorted(view_settings.items(), key=lambda itm: 'aaaa' if itm[0] == 'rattail' else itm[0]):
<h3 class="block is-size-3">Views for:&nbsp; ${topkey}</h3> <h3 class="block is-size-3">Views for:&nbsp; ${topkey}</h3>
% for group_key, group in six.iteritems(topgroup): % for group_key, group in topgroup.items():
<h4 class="block is-size-4">${group_key.capitalize()}</h4> <h4 class="block is-size-4">${group_key.capitalize()}</h4>
% for key, label in group: % for key, label in group:
${self.simple_flag(key, label)} ${self.simple_flag(key, label)}

View file

@ -30,7 +30,7 @@
${render_deform_field(form, dform['description'])} ${render_deform_field(form, dform['description'])}
${render_deform_field(form, dform['notes'])} ${render_deform_field(form, dform['notes'])}
% for key, pform in six.iteritems(params_forms): % for key, pform in params_forms.items():
<div v-show="field_model_batch_type == '${key}'"> <div v-show="field_model_batch_type == '${key}'">
% for field in pform.make_deform_form(): % for field in pform.make_deform_form():
${render_deform_field(pform, field)} ${render_deform_field(pform, field)}

View file

@ -57,7 +57,7 @@
<div class="field-wrapper employee"> <div class="field-wrapper employee">
<label>Employee</label> <label>Employee</label>
<div class="field"> <div class="field">
${dform['employee'].serialize(text=six.text_type(employee), selected_callback='employee_selected')|n} ${dform['employee'].serialize(text=str(employee), selected_callback='employee_selected')|n}
</div> </div>
</div> </div>
% endif % endif
@ -152,7 +152,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
% for emp in sorted(employees, key=six.text_type): % for emp in sorted(employees, key=str):
<tr data-employee-uuid="${emp.uuid}"> <tr data-employee-uuid="${emp.uuid}">
<td class="employee"> <td class="employee">
## TODO: add link to single employee schedule / timesheet here... ## TODO: add link to single employee schedule / timesheet here...

View file

@ -421,7 +421,7 @@
referrer: null, referrer: null,
% if request.user: % if request.user:
userUUID: ${json.dumps(request.user.uuid)|n}, userUUID: ${json.dumps(request.user.uuid)|n},
userName: ${json.dumps(six.text_type(request.user))|n}, userName: ${json.dumps(str(request.user))|n},
% else: % else:
userUUID: null, userUUID: null,
userName: null, userName: null,

View file

@ -33,7 +33,7 @@
The selected DBs will be hidden from the DB picker when viewing The selected DBs will be hidden from the DB picker when viewing
Trainwreck data. Trainwreck data.
</p> </p>
% for key, engine in six.iteritems(trainwreck_engines): % for key, engine in trainwreck_engines.items():
<b-field> <b-field>
<b-checkbox name="hidedb_${key}" <b-checkbox name="hidedb_${key}"
v-model="hiddenDatabases['${key}']" v-model="hiddenDatabases['${key}']"

View file

@ -8,7 +8,7 @@
<%def name="page_content()"> <%def name="page_content()">
<br /> <br />
% if six.text_type(next_year) not in trainwreck_engines: % if str(next_year) not in trainwreck_engines:
<b-notification type="is-warning"> <b-notification type="is-warning">
You do not have a database configured for next year (${next_year}).&nbsp; You do not have a database configured for next year (${next_year}).&nbsp;
You should be sure to configure it before next year rolls around. You should be sure to configure it before next year rolls around.

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,9 +24,6 @@
Tween Factories Tween Factories
""" """
from __future__ import unicode_literals, absolute_import
import six
from sqlalchemy.exc import OperationalError from sqlalchemy.exc import OperationalError
@ -64,7 +61,7 @@ def sqlerror_tween_factory(handler, registry):
mark_error_retryable(error) mark_error_retryable(error)
raise error raise error
else: else:
raise TransientError(six.text_type(error)) raise TransientError(str(error))
# if connection was *not* invalid, raise original error # if connection was *not* invalid, raise original error
raise raise

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Views for label batches Views for label batches
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from deform import widget as dfwidget from deform import widget as dfwidget
@ -123,7 +119,7 @@ class LabelBatchView(BatchMasterView):
] ]
def configure_form(self, f): def configure_form(self, f):
super(LabelBatchView, self).configure_form(f) super().configure_form(f)
# handheld_batches # handheld_batches
if self.creating: if self.creating:
@ -142,7 +138,7 @@ class LabelBatchView(BatchMasterView):
f.replace('label_profile', 'label_profile_uuid') f.replace('label_profile', 'label_profile_uuid')
# TODO: should restrict somehow? just allow override? # TODO: should restrict somehow? just allow override?
profiles = self.Session.query(model.LabelProfile) profiles = self.Session.query(model.LabelProfile)
values = [(p.uuid, six.text_type(p)) values = [(p.uuid, str(p))
for p in profiles] for p in profiles]
require_profile = False require_profile = False
if not require_profile: if not require_profile:
@ -159,7 +155,7 @@ class LabelBatchView(BatchMasterView):
return HTML.tag('ul', c=items) return HTML.tag('ul', c=items)
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(LabelBatchView, self).configure_row_grid(g) super().configure_row_grid(g)
# short labels # short labels
g.set_label('brand_name', "Brand") g.set_label('brand_name', "Brand")
@ -171,7 +167,7 @@ class LabelBatchView(BatchMasterView):
return 'warning' return 'warning'
def configure_row_form(self, f): def configure_row_form(self, f):
super(LabelBatchView, self).configure_row_form(f) super().configure_row_form(f)
# readonly fields # readonly fields
f.set_readonly('sequence') f.set_readonly('sequence')
@ -219,7 +215,7 @@ class LabelBatchView(BatchMasterView):
profiles = self.Session.query(model.LabelProfile)\ profiles = self.Session.query(model.LabelProfile)\
.filter(model.LabelProfile.visible == True)\ .filter(model.LabelProfile.visible == True)\
.order_by(model.LabelProfile.ordinal) .order_by(model.LabelProfile.ordinal)
profile_values = [(p.uuid, six.text_type(p)) profile_values = [(p.uuid, str(p))
for p in profiles] for p in profiles]
f.set_widget('label_profile_uuid', forms.widgets.JQuerySelectWidget(values=profile_values)) f.set_widget('label_profile_uuid', forms.widgets.JQuerySelectWidget(values=profile_values))

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Views for pricing batches Views for pricing batches
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from rattail.time import localtime from rattail.time import localtime
@ -155,7 +151,7 @@ class PricingBatchView(BatchMasterView):
return self.batch_handler.allow_future() return self.batch_handler.allow_future()
def configure_form(self, f): def configure_form(self, f):
super(PricingBatchView, self).configure_form(f) super().configure_form(f)
app = self.get_rattail_app() app = self.get_rattail_app()
batch = f.model_instance batch = f.model_instance
@ -192,7 +188,7 @@ class PricingBatchView(BatchMasterView):
f.set_required('input_filename', False) f.set_required('input_filename', False)
def get_batch_kwargs(self, batch, **kwargs): def get_batch_kwargs(self, batch, **kwargs):
kwargs = super(PricingBatchView, self).get_batch_kwargs(batch, **kwargs) kwargs = super().get_batch_kwargs(batch, **kwargs)
kwargs['start_date'] = batch.start_date kwargs['start_date'] = batch.start_date
kwargs['min_diff_threshold'] = batch.min_diff_threshold kwargs['min_diff_threshold'] = batch.min_diff_threshold
kwargs['min_diff_percent'] = batch.min_diff_percent kwargs['min_diff_percent'] = batch.min_diff_percent
@ -213,7 +209,7 @@ class PricingBatchView(BatchMasterView):
return kwargs return kwargs
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(PricingBatchView, self).configure_row_grid(g) super().configure_row_grid(g)
g.set_joiner('vendor_id', lambda q: q.outerjoin(model.Vendor)) g.set_joiner('vendor_id', lambda q: q.outerjoin(model.Vendor))
g.set_sorter('vendor_id', model.Vendor.id) g.set_sorter('vendor_id', model.Vendor.id)
@ -241,13 +237,13 @@ class PricingBatchView(BatchMasterView):
if row.subdepartment_number: if row.subdepartment_number:
if row.subdepartment_name: if row.subdepartment_name:
return HTML.tag('span', title=row.subdepartment_name, return HTML.tag('span', title=row.subdepartment_name,
c=six.text_type(row.subdepartment_number)) c=str(row.subdepartment_number))
return row.subdepartment_number return row.subdepartment_number
def render_true_margin(self, row, field): def render_true_margin(self, row, field):
margin = row.true_margin margin = row.true_margin
if margin: if margin:
margin = six.text_type(margin) margin = str(margin)
else: else:
margin = HTML.literal('&nbsp;') margin = HTML.literal('&nbsp;')
if row.old_true_margin is not None: if row.old_true_margin is not None:
@ -295,7 +291,7 @@ class PricingBatchView(BatchMasterView):
return HTML.tag('span', title=title, c=text) return HTML.tag('span', title=title, c=text)
def configure_row_form(self, f): def configure_row_form(self, f):
super(PricingBatchView, self).configure_row_form(f) super().configure_row_form(f)
# readonly fields # readonly fields
f.set_readonly('product') f.set_readonly('product')
@ -328,7 +324,7 @@ class PricingBatchView(BatchMasterView):
return tags.link_to(text, url) return tags.link_to(text, url)
def get_row_csv_fields(self): def get_row_csv_fields(self):
fields = super(PricingBatchView, self).get_row_csv_fields() fields = super().get_row_csv_fields()
if 'vendor_uuid' in fields: if 'vendor_uuid' in fields:
i = fields.index('vendor_uuid') i = fields.index('vendor_uuid')
@ -344,7 +340,7 @@ class PricingBatchView(BatchMasterView):
# TODO: this is the same as xlsx row! should merge/share somehow? # TODO: this is the same as xlsx row! should merge/share somehow?
def get_row_csv_row(self, row, fields): def get_row_csv_row(self, row, fields):
csvrow = super(PricingBatchView, self).get_row_csv_row(row, fields) csvrow = super().get_row_csv_row(row, fields)
vendor = row.vendor vendor = row.vendor
if 'vendor_id' in fields: if 'vendor_id' in fields:
@ -358,7 +354,7 @@ class PricingBatchView(BatchMasterView):
# TODO: this is the same as csv row! should merge/share somehow? # TODO: this is the same as csv row! should merge/share somehow?
def get_row_xlsx_row(self, row, fields): def get_row_xlsx_row(self, row, fields):
xlrow = super(PricingBatchView, self).get_row_xlsx_row(row, fields) xlrow = super().get_row_xlsx_row(row, fields)
vendor = row.vendor vendor = row.vendor
if 'vendor_id' in fields: if 'vendor_id' in fields:

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Views for maintaining vendor invoices Views for maintaining vendor invoices
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
@ -89,10 +85,10 @@ class VendorInvoiceView(FileBatchMasterView):
] ]
def get_instance_title(self, batch): def get_instance_title(self, batch):
return six.text_type(batch.vendor) return str(batch.vendor)
def configure_grid(self, g): def configure_grid(self, g):
super(VendorInvoiceView, self).configure_grid(g) super().configure_grid(g)
# vendor # vendor
g.set_joiner('vendor', lambda q: q.join(model.Vendor)) g.set_joiner('vendor', lambda q: q.join(model.Vendor))
@ -118,7 +114,7 @@ class VendorInvoiceView(FileBatchMasterView):
g.set_link('executed', False) g.set_link('executed', False)
def configure_form(self, f): def configure_form(self, f):
super(VendorInvoiceView, self).configure_form(f) super().configure_form(f)
# vendor # vendor
if self.creating: if self.creating:
@ -167,7 +163,7 @@ class VendorInvoiceView(FileBatchMasterView):
# raise formalchemy.ValidationError(unicode(error)) # raise formalchemy.ValidationError(unicode(error))
def get_batch_kwargs(self, batch): def get_batch_kwargs(self, batch):
kwargs = super(VendorInvoiceView, self).get_batch_kwargs(batch) kwargs = super().get_batch_kwargs(batch)
kwargs['parser_key'] = batch.parser_key kwargs['parser_key'] = batch.parser_key
return kwargs return kwargs
@ -183,7 +179,7 @@ class VendorInvoiceView(FileBatchMasterView):
return True return True
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(VendorInvoiceView, self).configure_row_grid(g) super().configure_row_grid(g)
g.set_label('upc', "UPC") g.set_label('upc', "UPC")
g.set_label('brand_name', "Brand") g.set_label('brand_name', "Brand")
g.set_label('shipped_cases', "Cases") g.set_label('shipped_cases', "Cases")

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,13 +24,9 @@
Master class for generic export history views Master class for generic export history views
""" """
from __future__ import unicode_literals, absolute_import
import os import os
import shutil import shutil
import six
from pyramid.response import FileResponse from pyramid.response import FileResponse
from webhelpers2.html import tags from webhelpers2.html import tags
@ -83,7 +79,7 @@ class ExportMasterView(MasterView):
return self.get_file_path(export) return self.get_file_path(export)
def configure_grid(self, g): def configure_grid(self, g):
super(ExportMasterView, self).configure_grid(g) super().configure_grid(g)
model = self.model model = self.model
# id # id
@ -106,7 +102,7 @@ class ExportMasterView(MasterView):
return export.id_str return export.id_str
def configure_form(self, f): def configure_form(self, f):
super(ExportMasterView, self).configure_form(f) super().configure_form(f)
export = f.model_instance export = f.model_instance
# NOTE: we try to handle the 'creating' scenario even though this class # NOTE: we try to handle the 'creating' scenario even though this class
@ -149,7 +145,7 @@ class ExportMasterView(MasterView):
f.set_renderer('filename', self.render_downloadable_file) f.set_renderer('filename', self.render_downloadable_file)
def objectify(self, form, data=None): def objectify(self, form, data=None):
obj = super(ExportMasterView, self).objectify(form, data=data) obj = super().objectify(form, data=data)
if self.creating: if self.creating:
obj.created_by = self.request.user obj.created_by = self.request.user
return obj return obj
@ -158,7 +154,7 @@ class ExportMasterView(MasterView):
user = export.created_by user = export.created_by
if not user: if not user:
return "" return ""
text = six.text_type(user) text = str(user)
if self.request.has_perm('users.view'): if self.request.has_perm('users.view'):
url = self.request.route_url('users.view', uuid=user.uuid) url = self.request.route_url('users.view', uuid=user.uuid)
return tags.link_to(text, url) return tags.link_to(text, url)
@ -175,12 +171,8 @@ class ExportMasterView(MasterView):
export = self.get_instance() export = self.get_instance()
path = self.get_file_path(export) path = self.get_file_path(export)
response = FileResponse(path, request=self.request) response = FileResponse(path, request=self.request)
if six.PY3:
response.headers['Content-Length'] = str(os.path.getsize(path)) response.headers['Content-Length'] = str(os.path.getsize(path))
response.headers['Content-Disposition'] = 'attachment; filename="{}"'.format(export.filename) response.headers['Content-Disposition'] = 'attachment; filename="{}"'.format(export.filename)
else:
response.headers[b'Content-Length'] = six.binary_type(os.path.getsize(path))
response.headers[b'Content-Disposition'] = b'attachment; filename="{}"'.format(export.filename)
return response return response
def delete_instance(self, export): def delete_instance(self, export):
@ -195,4 +187,4 @@ class ExportMasterView(MasterView):
shutil.rmtree(dirname) shutil.rmtree(dirname)
# continue w/ normal deletion # continue w/ normal deletion
super(ExportMasterView, self).delete_instance(export) super().delete_instance(export)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,12 +24,8 @@
Poser Report Views Poser Report Views
""" """
from __future__ import unicode_literals, absolute_import
import os import os
import six
from rattail.util import simple_error from rattail.util import simple_error
import colander import colander
@ -95,7 +91,7 @@ class PoserReportView(PoserMasterView):
return self.poser_handler.get_all_reports(ignore_errors=False) return self.poser_handler.get_all_reports(ignore_errors=False)
def configure_grid(self, g): def configure_grid(self, g):
super(PoserReportView, self).configure_grid(g) super().configure_grid(g)
g.sorters['report_key'] = g.make_simple_sorter('report_key', foldcase=True) g.sorters['report_key'] = g.make_simple_sorter('report_key', foldcase=True)
g.sorters['report_name'] = g.make_simple_sorter('report_name', foldcase=True) g.sorters['report_name'] = g.make_simple_sorter('report_name', foldcase=True)
@ -157,7 +153,7 @@ class PoserReportView(PoserMasterView):
return report return report
def configure_form(self, f): def configure_form(self, f):
super(PoserReportView, self).configure_form(f) super().configure_form(f)
report = f.model_instance report = f.model_instance
# report_key # report_key
@ -179,7 +175,7 @@ class PoserReportView(PoserMasterView):
f.set_helptext('flavor', "Determines the type of sample code to generate.") f.set_helptext('flavor', "Determines the type of sample code to generate.")
flavors = self.poser_handler.get_supported_report_flavors() flavors = self.poser_handler.get_supported_report_flavors()
values = [(key, flavor['description']) values = [(key, flavor['description'])
for key, flavor in six.iteritems(flavors)] for key, flavor in flavors.items()]
f.set_widget('flavor', dfwidget.SelectWidget(values=values)) f.set_widget('flavor', dfwidget.SelectWidget(values=values))
f.set_validator('flavor', colander.OneOf(flavors)) f.set_validator('flavor', colander.OneOf(flavors))
if flavors: if flavors:
@ -231,7 +227,7 @@ class PoserReportView(PoserMasterView):
return report return report
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(PoserReportView, self).configure_row_grid(g) super().configure_row_grid(g)
g.set_renderer('id', self.render_id_str) g.set_renderer('id', self.render_id_str)

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Poser Views for Views... Poser Views for Views...
""" """
from __future__ import unicode_literals, absolute_import
import six
import colander import colander
from .master import PoserMasterView from .master import PoserMasterView
@ -68,7 +64,7 @@ class PoserViewView(PoserMasterView):
return self.make_form({}) return self.make_form({})
def configure_form(self, f): def configure_form(self, f):
super(PoserViewView, self).configure_form(f) super().configure_form(f)
view = f.model_instance view = f.model_instance
# key # key
@ -224,28 +220,28 @@ class PoserViewView(PoserMasterView):
}, },
}} }}
for key, views in six.iteritems(everything['rattail']): for key, views in everything['rattail'].items():
for vkey, view in six.iteritems(views): for vkey, view in views.items():
view['options'] = [vkey] view['options'] = [vkey]
providers = get_all_providers(self.rattail_config) providers = get_all_providers(self.rattail_config)
for provider in six.itervalues(providers): for provider in providers.values():
# loop thru provider top-level groups # loop thru provider top-level groups
for topkey, groups in six.iteritems(provider.get_provided_views()): for topkey, groups in provider.get_provided_views().items()):
# get or create top group # get or create top group
topgroup = everything.setdefault(topkey, {}) topgroup = everything.setdefault(topkey, {})
# loop thru provider view groups # loop thru provider view groups
for key, views in six.iteritems(groups): for key, views in groups.items():
# add group to top group, if it's new # add group to top group, if it's new
if key not in topgroup: if key not in topgroup:
topgroup[key] = views topgroup[key] = views
# also must init the options for group # also must init the options for group
for vkey, view in six.iteritems(views): for vkey, view in views.items():
view['options'] = [vkey] view['options'] = [vkey]
else: # otherwise must "update" existing group else: # otherwise must "update" existing group
@ -254,7 +250,7 @@ class PoserViewView(PoserMasterView):
stdgroup = topgroup[key] stdgroup = topgroup[key]
# loop thru views within provider group # loop thru views within provider group
for vkey, view in six.iteritems(views): for vkey, view in views.items():
# add view to group if it's new # add view to group if it's new
if vkey not in stdgroup: if vkey not in stdgroup:
@ -270,8 +266,8 @@ class PoserViewView(PoserMasterView):
settings = [] settings = []
view_settings = self.collect_available_view_settings() view_settings = self.collect_available_view_settings()
for topgroup in six.itervalues(view_settings): for topgroup in view_settings.values():
for view_section, section_settings in six.iteritems(topgroup): for view_section, section_settings in topgroup.items():
for key in section_settings: for key in section_settings:
settings.append({'section': 'tailbone.includes', settings.append({'section': 'tailbone.includes',
'option': key}) 'option': key})
@ -282,25 +278,25 @@ class PoserViewView(PoserMasterView):
input_file_templates=True): input_file_templates=True):
# first get normal context # first get normal context
context = super(PoserViewView, self).configure_get_context( context = super().configure_get_context(
simple_settings=simple_settings, simple_settings=simple_settings,
input_file_templates=input_file_templates) input_file_templates=input_file_templates)
# first add available options # first add available options
view_settings = self.collect_available_view_settings() view_settings = self.collect_available_view_settings()
view_options = {} view_options = {}
for topgroup in six.itervalues(view_settings): for topgroup in view_settings.values():
for key, views in six.iteritems(topgroup): for key, views in topgroup.items():
for vkey, view in six.iteritems(views): for vkey, view in views.items():
view_options[vkey] = view['options'] view_options[vkey] = view['options']
context['view_options'] = view_options context['view_options'] = view_options
# then add all available settings as sorted (key, label) options # then add all available settings as sorted (key, label) options
for topkey, topgroup in six.iteritems(view_settings): for topkey, topgroup in view_settings.items():
for key in list(topgroup): for key in list(topgroup):
settings = topgroup[key] settings = topgroup[key]
settings = [(key, setting.get('label', key)) settings = [(key, setting.get('label', key))
for key, setting in six.iteritems(settings)] for key, setting in settings.items()]
settings.sort(key=lambda itm: itm[1]) settings.sort(key=lambda itm: itm[1])
topgroup[key] = settings topgroup[key] = settings
context['view_settings'] = view_settings context['view_settings'] = view_settings
@ -308,7 +304,7 @@ class PoserViewView(PoserMasterView):
return context return context
def configure_flash_settings_saved(self): def configure_flash_settings_saved(self):
super(PoserViewView, self).configure_flash_settings_saved() super().configure_flash_settings_saved()
self.request.session.flash("Please restart the web app!", 'warning') self.request.session.flash("Please restart the web app!", 'warning')

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Progress Views Progress Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from tailbone.progress import get_progress_session from tailbone.progress import get_progress_session
@ -44,7 +40,7 @@ def progress(request):
bits = session.get('extra_session_bits') bits = session.get('extra_session_bits')
if bits: if bits:
for key, value in six.iteritems(bits): for key, value in bits.items():
request.session[key] = value request.session[key] = value
elif session.get('error'): elif session.get('error'):

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,11 +24,9 @@
Views for tempmon appliances Views for tempmon appliances
""" """
from __future__ import unicode_literals, absolute_import import io
import os import os
import six
from PIL import Image from PIL import Image
from rattail_tempmon.db import model as tempmon from rattail_tempmon.db import model as tempmon
@ -68,7 +66,7 @@ class TempmonApplianceView(MasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(TempmonApplianceView, self).configure_grid(g) super().configure_grid(g)
# name # name
g.set_sort_defaults('name') g.set_sort_defaults('name')
@ -94,7 +92,7 @@ class TempmonApplianceView(MasterView):
return HTML.tag('div', class_='image-frame', c=[helper, image]) return HTML.tag('div', class_='image-frame', c=[helper, image])
def configure_form(self, f): def configure_form(self, f):
super(TempmonApplianceView, self).configure_form(f) super().configure_form(f)
# name # name
f.set_validator('name', self.unique_name) f.set_validator('name', self.unique_name)
@ -122,7 +120,7 @@ class TempmonApplianceView(MasterView):
f.remove_field('probes') f.remove_field('probes')
def template_kwargs_view(self, **kwargs): def template_kwargs_view(self, **kwargs):
kwargs = super(TempmonApplianceView, self).template_kwargs_view(**kwargs) kwargs = super().template_kwargs_view(**kwargs)
appliance = kwargs['instance'] appliance = kwargs['instance']
kwargs['probes_data'] = self.normalize_probes(appliance.probes) kwargs['probes_data'] = self.normalize_probes(appliance.probes)
@ -176,13 +174,13 @@ class TempmonApplianceView(MasterView):
im = Image.open(f) im = Image.open(f)
im.thumbnail((600, 600), Image.ANTIALIAS) im.thumbnail((600, 600), Image.ANTIALIAS)
data = six.BytesIO() data = io.BytesIO()
im.save(data, 'JPEG') im.save(data, 'JPEG')
appliance.image_normal = data.getvalue() appliance.image_normal = data.getvalue()
data.close() data.close()
im.thumbnail((150, 150), Image.ANTIALIAS) im.thumbnail((150, 150), Image.ANTIALIAS)
data = six.BytesIO() data = io.BytesIO()
im.save(data, 'JPEG') im.save(data, 'JPEG')
appliance.image_thumbnail = data.getvalue() appliance.image_thumbnail = data.getvalue()
data.close() data.close()

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2024 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,10 +24,6 @@
Vendor Views Vendor Views
""" """
from __future__ import unicode_literals, absolute_import
import six
from rattail.db import model from rattail.db import model
from webhelpers2.html import tags from webhelpers2.html import tags
@ -158,7 +154,7 @@ class VendorView(MasterView):
person = vendor.contact person = vendor.contact
if not person: if not person:
return "" return ""
text = six.text_type(person) text = str(person)
url = self.request.route_url('people.view', uuid=person.uuid) url = self.request.route_url('people.view', uuid=person.uuid)
return tags.link_to(text, url) return tags.link_to(text, url)
@ -198,7 +194,7 @@ class VendorView(MasterView):
data, **kwargs) data, **kwargs)
supported_vendor_settings = self.configure_get_supported_vendor_settings() supported_vendor_settings = self.configure_get_supported_vendor_settings()
for setting in six.itervalues(supported_vendor_settings): for setting in supported_vendor_settings.values():
name = 'rattail.vendor.{}'.format(setting['key']) name = 'rattail.vendor.{}'.format(setting['key'])
settings.append({'name': name, settings.append({'name': name,
'value': data[name]}) 'value': data[name]})
@ -211,7 +207,7 @@ class VendorView(MasterView):
names = [] names = []
supported_vendor_settings = self.configure_get_supported_vendor_settings() supported_vendor_settings = self.configure_get_supported_vendor_settings()
for setting in six.itervalues(supported_vendor_settings): for setting in supported_vendor_settings.values():
names.append('rattail.vendor.{}'.format(setting['key'])) names.append('rattail.vendor.{}'.format(setting['key']))
if names: if names:
@ -236,7 +232,7 @@ class VendorView(MasterView):
settings[key] = { settings[key] = {
'key': key, 'key': key,
'value': vendor.uuid if vendor else None, 'value': vendor.uuid if vendor else None,
'label': six.text_type(vendor) if vendor else None, 'label': str(vendor) if vendor else None,
} }
return settings return settings