From 05d8e7d7b1c485078b98e4aa8043f803965670a6 Mon Sep 17 00:00:00 2001 From: Ian Weller Date: Mon, 6 Oct 2008 21:08:32 -0500 Subject: Comply to PEP 8, make pylint happier --- fedora-business-cards | 28 ++++++++++++++++++++++++++-- fedora_business_cards/__init__.py | 4 ++-- fedora_business_cards/export.py | 23 ++++++++++++----------- fedora_business_cards/frontend.py | 10 +++++++--- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/fedora-business-cards b/fedora-business-cards index f59725d..5f7183f 100755 --- a/fedora-business-cards +++ b/fedora-business-cards @@ -1,11 +1,35 @@ #!/usr/bin/python +### +# fedora-business-cards - for rendering Fedora contributor business cards +# Copyright (C) 2008 Ian Weller +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +### + +""" +Executable program to load the default frontend for the fedora_business_cards +module. +""" + import sys try: from fedora_business_cards import frontend frontend.cmdline() except ImportError: print >> sys.stderr, """\ -There was a problem importing the fedora_business_cards module. Please make sure -that you have fedora-business-cards installed properly. +There was a problem importing the fedora_business_cards module. Please make +sure that you have fedora-business-cards installed properly. """ sys.exit(1) diff --git a/fedora_business_cards/__init__.py b/fedora_business_cards/__init__.py index 07a90f4..3546a94 100644 --- a/fedora_business_cards/__init__.py +++ b/fedora_business_cards/__init__.py @@ -19,8 +19,8 @@ """ The Fedora business cards generator will generate business cards for Fedora -contributors. It connects to FAS to retrieve user information and lays it out on -a SVG, then exports that to a PDF and PNG. Different templates are/will be +contributors. It connects to FAS to retrieve user information and lays it out +on a SVG, then exports that to a PDF and PNG. Different templates are/will be available for different business card sizes, or different requirements by different companies. """ diff --git a/fedora_business_cards/export.py b/fedora_business_cards/export.py index 655ccc6..baff368 100644 --- a/fedora_business_cards/export.py +++ b/fedora_business_cards/export.py @@ -28,11 +28,12 @@ def svg_to_file(xmlstring, filename): """ Write an SVG to a file. """ - f = file(filename, 'w') - f.write(xmlstring.encode('utf-8')) - f.close() + handle = file(filename, 'w') + handle.write(xmlstring.encode('utf-8')) + handle.close() return True + def svg_to_pdf_png(xmlstring, filename, format='png', dpi=300): """ Export an SVG to either a PDF or PNG. @@ -44,16 +45,16 @@ def svg_to_pdf_png(xmlstring, filename, format='png', dpi=300): stdin = xmlstring.encode('utf-8') command = ['inkscape', '-C -z -d', str(dpi), '-e', filename, '/dev/stdin'] if format == 'png': - sp = subprocess.Popen(' '.join(command), shell=True, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - sp.communicate(stdin) + proc = subprocess.Popen(' '.join(command), shell=True, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.communicate(stdin) elif format == 'pdf': command[3] = '-A' - sp = subprocess.Popen(' '.join(command), shell=True, - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - sp.communicate(stdin) + proc = subprocess.Popen(' '.join(command), shell=True, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.communicate(stdin) else: raise Exception("Invalid file format requested") return True diff --git a/fedora_business_cards/frontend.py b/fedora_business_cards/frontend.py index 5306e69..bb7764f 100644 --- a/fedora_business_cards/frontend.py +++ b/fedora_business_cards/frontend.py @@ -35,6 +35,9 @@ import export def cmdline_card_line(data): + """ + Print a line of the business card for the cmdline frontend. + """ return "| %s%s |" % (data, ' '*(59-len(data))) @@ -49,8 +52,8 @@ def cmdline(): parser.add_option("-d", "--dpi", dest="dpi", default=300, type="int", help="DPI of exported file") parser.add_option("-t", "--template", dest="template", - default="northamerica", help="Name of template to use, "+\ - "run with --list-templates to see a list") + default="northamerica", help="Name of template to use,"+\ + " run with --list-templates to see a list") parser.add_option("--list-templates", action="store_true", default=False, dest="listtemplates", help="List available templates") parser.add_option("-u", "--username", dest="username", default="", @@ -98,7 +101,8 @@ def cmdline(): password = getpass() if options.username == "": options.username = username - infodict = information.get_information(username, password, options.username) + infodict = information.get_information(username, password, + options.username) # setup default content name = infodict['name'] title = infodict['title'] -- cgit