summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Weller <ianweller@gmail.com>2008-10-06 21:08:32 -0500
committerIan Weller <ianweller@gmail.com>2008-10-06 21:08:32 -0500
commit05d8e7d7b1c485078b98e4aa8043f803965670a6 (patch)
tree437802d935666d02339c0eeb9b1ca1a20d2f4a10
parentaf022f88c9e5ad8a8973475d1d78aae60ca892a0 (diff)
downloadfedora-business-cards-05d8e7d7b1c485078b98e4aa8043f803965670a6.zip
fedora-business-cards-05d8e7d7b1c485078b98e4aa8043f803965670a6.tar.gz
fedora-business-cards-05d8e7d7b1c485078b98e4aa8043f803965670a6.tar.xz
Comply to PEP 8, make pylint happier
-rwxr-xr-xfedora-business-cards28
-rw-r--r--fedora_business_cards/__init__.py4
-rw-r--r--fedora_business_cards/export.py23
-rw-r--r--fedora_business_cards/frontend.py10
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 <ianweller@gmail.com>
+#
+# 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']