Permalink
Browse files

Project-wide PEP8ification.

  • Loading branch information...
1 parent 40c2668 commit 25f7d447623422a413a7731c5f5d34bda396f8dd @chmarr committed Mar 17, 2013
View
@@ -6,76 +6,74 @@
"""
cli_defaults = {
- 'lpi': 10,
- }
+ 'lpi': 10,
+}
cli_usage = "%prog infile"
cli_description = """\
Read in a PDF file and overlay a 0.1" grid on top of it. Writes to stdout.
"""
+import optparse
+import sys
+
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.units import inch
-from reportlab.lib.styles import getSampleStyleSheet, TA_CENTER, ParagraphStyle
-from reportlab.platypus import Paragraph, Frame
from reportlab.lib.pagesizes import letter
-
from pdfrw import PdfReader
from pdfrw.buildxobj import pagexobj
from pdfrw.toreportlab import makerl
-import optparse
-import sys
-def grid_overlay ( infile, outfile=sys.stdout, pagesize=letter, lpi=10 ):
-
- """Read PDF file 'infile'. Generates a new PDF file to 'outfile'
- containing the first page (only) of infile, with a 'lpi' grid
- overlaid.
- """
-
- c = Canvas ( outfile, pagesize=pagesize )
-
- pdf = PdfReader ( infile )
- xobj = pagexobj ( pdf.pages[0] )
- rlobj = makerl ( c, xobj )
-
- c.doForm ( rlobj )
-
- xmax = 9
- ymax = 12
-
- thickline = 0.5
- thinline = 0.1
-
- for x in range( 0, xmax ):
- c.setLineWidth ( thickline )
- for xx in range ( 0, lpi ):
- x0 = (x+(float(xx)/lpi))*inch
- c.line ( x0, 0, x0, ymax*inch )
- c.setLineWidth ( thinline )
-
- for y in range( 0, ymax ):
- c.setLineWidth ( thickline )
- for yy in range ( 0, lpi ):
- y0 = (y+(float(yy)/lpi))*inch
- c.line ( 0, y0, xmax*inch, y0 )
- c.setLineWidth ( thinline )
-
- c.showPage ()
- c.save ()
-
-
-def get_options ():
- parser = optparse.OptionParser ( usage=cli_usage, description=cli_description )
- parser.set_defaults ( **cli_defaults )
- parser.add_option ( "--lpi", type="int", help="lines per inch [%default]")
- opts, args = parser.parse_args ()
- try:
- opts.file = args[0]
- except IndexError:
- raise parser.error ( "Missing argument" )
- return opts
-
+def grid_overlay(infile, outfile=sys.stdout, pagesize=letter, lpi=10):
+ """Read PDF file 'infile'. Generates a new PDF file to 'outfile'
+ containing the first page (only) of infile, with a 'lpi' grid
+ overlaid.
+ """
+
+ c = Canvas(outfile, pagesize=pagesize)
+
+ pdf = PdfReader(infile)
+ xobj = pagexobj(pdf.pages[0])
+ rlobj = makerl(c, xobj)
+
+ c.doForm(rlobj)
+
+ xmax = 9
+ ymax = 12
+
+ thickline = 0.5
+ thinline = 0.1
+
+ for x in range(0, xmax):
+ c.setLineWidth(thickline)
+ for xx in range(0, lpi):
+ x0 = (x + (float(xx) / lpi)) * inch
+ c.line(x0, 0, x0, ymax * inch)
+ c.setLineWidth(thinline)
+
+ for y in range(0, ymax):
+ c.setLineWidth(thickline)
+ for yy in range(0, lpi):
+ y0 = (y + (float(yy) / lpi)) * inch
+ c.line(0, y0, xmax * inch, y0)
+ c.setLineWidth(thinline)
+
+ c.showPage()
+ c.save()
+
+
+def get_options():
+ parser = optparse.OptionParser(usage=cli_usage, description=cli_description)
+ parser.set_defaults(**cli_defaults)
+ parser.add_option("--lpi", type="int", help="lines per inch [%default]")
+ opts, args = parser.parse_args()
+ try:
+ opts.file = args[0]
+ except IndexError:
+ raise parser.error("Missing argument")
+ return opts
+
+
if __name__ == "__main__":
- opts = get_options ()
- grid_overlay ( opts.file, lpi=opts.lpi )
+ opts = get_options()
+ grid_overlay(opts.file, lpi=opts.lpi)
View
@@ -1,6 +1,8 @@
from south.signals import post_migrate
-def update_permissions_after_migration(app,**kwargs):
+
+# noinspection PyUnusedLocal
+def update_permissions_after_migration(app, **kwargs):
"""
Update app permission just after every migration.
This is based on app django_extensions update_permissions management command.
@@ -11,4 +13,5 @@ def update_permissions_after_migration(app,**kwargs):
create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 0)
+
post_migrate.connect(update_permissions_after_migration)
View
@@ -12,19 +12,20 @@
import email1
import processbatchscan
from django.core.mail import send_mail
-import smtplib, datetime, decimal
+import smtplib
+import datetime
+import decimal
from django.http import HttpResponse
from ajax_select import make_ajax_form
from ajax_select.admin import AjaxSelectAdmin
from ajax_select.fields import AutoCompleteSelectMultipleField, AutoCompleteSelectField
from django.db.models import Max
-
class ArtistAccessInline(admin.TabularInline):
model = ArtistAccess
extra = 0
- raw_id_fields = ( 'user', )
+ raw_id_fields = ('user', )
class AllocationInlineForm(forms.ModelForm):
@@ -45,7 +46,7 @@ class AllocationInline(admin.TabularInline):
class PieceInlineForm(forms.ModelForm):
class Meta:
model = Piece
- fields = ( "pieceid", "name", "media", "adult", "not_for_sale", "min_bid", "buy_now", "location",
+ fields = ("pieceid", "name", "media", "adult", "not_for_sale", "min_bid", "buy_now", "location",
"voice_auction", "status")
widgets = {
'pieceid': forms.TextInput(attrs={'size': 3}),
@@ -60,7 +61,7 @@ class Meta:
class PieceInline(admin.TabularInline):
form = PieceInlineForm
fields = ("pieceid", "name", "media", "adult", "not_for_sale", "min_bid", "buy_now", "location", "voice_auction",
- "status")
+ "status")
model = Piece
extra = 5
ordering = ('pieceid',)
@@ -118,10 +119,10 @@ class ArtistAdmin(AjaxSelectAdmin):
def requested_spaces(self, artist):
return ", ".join("%s:%s" % (al.space.shortname, al.requested) for al in artist.allocation_set.all())
- def allocated_spaces( self, artist ):
+ def allocated_spaces(self, artist):
return ", ".join("%s:%s" % (al.space.shortname, al.allocated) for al in artist.allocation_set.all())
- def person_name( self, artist ):
+ def person_name(self, artist):
return artist.person.name
person_name.short_description = "name"
@@ -138,7 +139,7 @@ def person_mailing_label(self, artist):
person_mailing_label.short_description = "mailing address"
person_mailing_label.allow_tags = True
- def send_email( self, request, queryset ):
+ def send_email(self, request, queryset):
opts = self.model._meta
app_label = opts.app_label
emails = []
@@ -193,8 +194,7 @@ def print_bidsheets(self, request, queryset):
import bidsheets
response = HttpResponse(mimetype="application/pdf")
- bidsheets.generate_bidsheets_for_artists(template_pdf=settings.ARTSHOW_BLANK_BID_SHEET, output=response,
- artists=queryset)
+ bidsheets.generate_bidsheets_for_artists(output=response, artists=queryset)
self.message_user(request, "Bid sheets printed.")
return response
@@ -214,8 +214,7 @@ def print_control_forms( self, request, artists ):
import bidsheets
response = HttpResponse(mimetype="application/pdf")
- bidsheets.generate_control_forms(template_pdf=settings.ARTSHOW_BLANK_CONTROL_FORM, output=response,
- artists=artists)
+ bidsheets.generate_control_forms(output=response, artists=artists)
self.message_user(request, "Control Forms printed.")
return response
@@ -274,7 +273,8 @@ def apply_winnings_and_commission(self, request, artists):
date=datetime.datetime.now())
payment.save()
- def create_cheques( self, request, artists):
+ # noinspection PyUnusedLocal
+ def create_cheques(self, request, artists):
pt_paymentsent = PaymentType.objects.get(pk=settings.ARTSHOW_PAYMENT_SENT_PK)
for a in artists:
balance = a.payment_set.aggregate(balance=Sum('amount'))['balance']
@@ -284,6 +284,7 @@ def create_cheques( self, request, artists):
chq.clean()
chq.save()
+ # noinspection PyUnusedLocal
def allocate_spaces(self, request, artists):
artists = artists.order_by('reservationdate', 'artistid')
spaces_remaining = {}
@@ -400,14 +401,15 @@ def set_scanned_flag(self, request, pieces):
pieces.exclude(status=Piece.StatusNotInShow).update(bidsheet_scanned=True)
self.message_user(request, "Bidsheet_scanned flags have been set if the piece is or was in show.")
- def clear_won_status( self, request, pieces ):
+ def clear_won_status(self, request, pieces):
pieces.filter(status=Piece.StatusWon).update(status=Piece.StatusInShow)
self.message_user(request, "Pieces marked as 'Won' have been returned to 'In Show'.")
- def apply_won_status( self, request, pieces ):
+ def apply_won_status(self, request, pieces):
# This code is duplicated in the management code
for p in pieces.filter(status=Piece.StatusInShow, voice_auction=False):
try:
+ # noinspection PyUnusedLocal
top_bid = p.top_bid()
except Bid.DoesNotExist:
pass
@@ -420,6 +422,7 @@ def apply_won_status( self, request, pieces ):
def apply_won_status_incl_voice_auction(self, request, pieces):
for p in pieces.filter(status=Piece.StatusInShow):
try:
+ # noinspection PyUnusedLocal
top_bid = p.top_bid()
except Bid.DoesNotExist:
pass
@@ -436,7 +439,7 @@ def print_bidsheets(self, request, queryset):
import bidsheets
response = HttpResponse(mimetype="application/pdf")
- bidsheets.generate_bidsheets(template_pdf=settings.ARTSHOW_BLANK_BID_SHEET, output=response, pieces=queryset)
+ bidsheets.generate_bidsheets(output=response, pieces=queryset)
self.message_user(request, "Bid sheets printed.")
return response
@@ -648,6 +651,7 @@ class ChequePaymentAdmin(admin.ModelAdmin):
def cheque_amount(self, obj):
return -obj.amount
+ # noinspection PyUnusedLocal
def print_cheques(self, request, cheqs):
import cheques
Oops, something went wrong.

0 comments on commit 25f7d44

Please sign in to comment.