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_tm
rattail[db,bouncer]
six
sa-filters
simplejson
transaction

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -890,7 +890,7 @@
% if request.user:
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
</script>

View file

@ -236,7 +236,7 @@
% if input_file_template_settings is not Undefined:
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_file']}']) {
if (!this.inputFileTemplateUploads['${tmpl['key']}']) {

View file

@ -347,7 +347,7 @@
}
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}

View file

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

View file

@ -73,7 +73,7 @@
<div class="grid">
<table class="order-form">
<% 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>
<tr>
<th class="department" colspan="${column_count}">Department
@ -84,7 +84,7 @@
% endif
</th>
</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>
<th class="subdepartment" colspan="${column_count}">Subdepartment
% 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]):
<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>
% for key, label in group:
${self.simple_flag(key, label)}

View file

@ -30,7 +30,7 @@
${render_deform_field(form, dform['description'])}
${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}'">
% for field in pform.make_deform_form():
${render_deform_field(pform, field)}

View file

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

View file

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

View file

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

View file

@ -8,7 +8,7 @@
<%def name="page_content()">
<br />
% if six.text_type(next_year) not in trainwreck_engines:
% if str(next_year) not in trainwreck_engines:
<b-notification type="is-warning">
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.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2024 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,12 +24,8 @@
Poser Report Views
"""
from __future__ import unicode_literals, absolute_import
import os
import six
from rattail.util import simple_error
import colander
@ -95,7 +91,7 @@ class PoserReportView(PoserMasterView):
return self.poser_handler.get_all_reports(ignore_errors=False)
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_name'] = g.make_simple_sorter('report_name', foldcase=True)
@ -157,7 +153,7 @@ class PoserReportView(PoserMasterView):
return report
def configure_form(self, f):
super(PoserReportView, self).configure_form(f)
super().configure_form(f)
report = f.model_instance
# report_key
@ -179,7 +175,7 @@ class PoserReportView(PoserMasterView):
f.set_helptext('flavor', "Determines the type of sample code to generate.")
flavors = self.poser_handler.get_supported_report_flavors()
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_validator('flavor', colander.OneOf(flavors))
if flavors:
@ -231,7 +227,7 @@ class PoserReportView(PoserMasterView):
return report
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)

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2024 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,10 +24,6 @@
Poser Views for Views...
"""
from __future__ import unicode_literals, absolute_import
import six
import colander
from .master import PoserMasterView
@ -68,7 +64,7 @@ class PoserViewView(PoserMasterView):
return self.make_form({})
def configure_form(self, f):
super(PoserViewView, self).configure_form(f)
super().configure_form(f)
view = f.model_instance
# key
@ -224,28 +220,28 @@ class PoserViewView(PoserMasterView):
},
}}
for key, views in six.iteritems(everything['rattail']):
for vkey, view in six.iteritems(views):
for key, views in everything['rattail'].items():
for vkey, view in views.items():
view['options'] = [vkey]
providers = get_all_providers(self.rattail_config)
for provider in six.itervalues(providers):
for provider in providers.values():
# 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
topgroup = everything.setdefault(topkey, {})
# 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
if key not in topgroup:
topgroup[key] = views
# also must init the options for group
for vkey, view in six.iteritems(views):
for vkey, view in views.items():
view['options'] = [vkey]
else: # otherwise must "update" existing group
@ -254,7 +250,7 @@ class PoserViewView(PoserMasterView):
stdgroup = topgroup[key]
# 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
if vkey not in stdgroup:
@ -270,8 +266,8 @@ class PoserViewView(PoserMasterView):
settings = []
view_settings = self.collect_available_view_settings()
for topgroup in six.itervalues(view_settings):
for view_section, section_settings in six.iteritems(topgroup):
for topgroup in view_settings.values():
for view_section, section_settings in topgroup.items():
for key in section_settings:
settings.append({'section': 'tailbone.includes',
'option': key})
@ -282,25 +278,25 @@ class PoserViewView(PoserMasterView):
input_file_templates=True):
# first get normal context
context = super(PoserViewView, self).configure_get_context(
context = super().configure_get_context(
simple_settings=simple_settings,
input_file_templates=input_file_templates)
# first add available options
view_settings = self.collect_available_view_settings()
view_options = {}
for topgroup in six.itervalues(view_settings):
for key, views in six.iteritems(topgroup):
for vkey, view in six.iteritems(views):
for topgroup in view_settings.values():
for key, views in topgroup.items():
for vkey, view in views.items():
view_options[vkey] = view['options']
context['view_options'] = view_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):
settings = topgroup[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])
topgroup[key] = settings
context['view_settings'] = view_settings
@ -308,7 +304,7 @@ class PoserViewView(PoserMasterView):
return context
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')

View file

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

View file

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

View file

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