summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Weller <ianweller@gmail.com>2008-08-03 19:29:06 -0500
committerIan Weller <ianweller@gmail.com>2008-08-03 19:29:06 -0500
commit40c3dd6517f7ad8ba396c74708e69c3b2e59606a (patch)
tree30a80ba680816518ab7a630c736bd87fe985a191
downloadfedora-business-cards-40c3dd6517f7ad8ba396c74708e69c3b2e59606a.zip
fedora-business-cards-40c3dd6517f7ad8ba396c74708e69c3b2e59606a.tar.gz
fedora-business-cards-40c3dd6517f7ad8ba396c74708e69c3b2e59606a.tar.xz
Import code and template, add .gitignore
-rw-r--r--.gitignore5
-rw-r--r--front-template.svg230
-rw-r--r--generate.py192
3 files changed, 427 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0feaad5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+*~
+*.swp
+*.pyc
+*.pyo
+*out.svg
diff --git a/front-template.svg b/front-template.svg
new file mode 100644
index 0000000..c2a7a98
--- /dev/null
+++ b/front-template.svg
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:i="http://ns.adobe.com/AdobeIllustrator/10.0/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.0"
+ width="315"
+ height="180"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="bizcard07-foundations.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:export-filename="/home/ianweller/art/fedora-business-cards/bizcard07-foundations.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata42">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ inkscape:window-height="480"
+ inkscape:window-width="640"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="3.5277778"
+ inkscape:cx="157.5"
+ inkscape:cy="90"
+ inkscape:current-layer="svg2"
+ showguides="true"
+ units="in"
+ inkscape:document-units="in"
+ inkscape:guide-bbox="true"
+ inkscape:snap-nodes="true"
+ inkscape:snap-bbox="false">
+ <sodipodi:guide
+ orientation="1,0"
+ position="18,209.02957"
+ id="guide4103" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="-27.948244,18"
+ id="guide4105" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="-20.961183,162"
+ id="guide4107" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="279,112.95749"
+ id="guide4109" />
+ </sodipodi:namedview>
+ <defs
+ id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 90 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="315 : 90 : 1"
+ inkscape:persp3d-origin="157.5 : 60 : 1"
+ id="perspective44" />
+ <foreignObject
+ requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/"
+ x="0"
+ y="0"
+ width="1"
+ height="1"
+ id="foreignObject8">
+ <i:pgfRef
+ xlink:href="#adobe_illustrator_pgf" />
+ </foreignObject>
+ </defs>
+ <rect
+ style="fill:#3c6eb4;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect3330"
+ y="0"
+ x="297"
+ height="180"
+ width="18" />
+ <g
+ id="g3974"
+ transform="translate(0,-35.732645)">
+ <text
+ sodipodi:linespacing="125%"
+ style="font-size:13px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna"
+ xml:space="preserve"
+ id="fullname"
+ y="63.477001"
+ x="18"></text>
+ <text
+ sodipodi:linespacing="125%"
+ style="font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:50.04000092;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna"
+ xml:space="preserve"
+ id="title"
+ y="75.477005"
+ x="18"></text>
+ <text
+ sodipodi:linespacing="100%"
+ id="text3534"
+ y="93.010002"
+ x="18"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ xml:space="preserve"><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="93.010002"
+ x="18"
+ sodipodi:role="line"
+ id="line1"></tspan><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="103.01"
+ x="18"
+ sodipodi:role="line"
+ id="line2"></tspan><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="113.01"
+ x="18"
+ sodipodi:role="line"
+ id="line3"></tspan><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="123.01"
+ x="18"
+ sodipodi:role="line"
+ id="line4"></tspan><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="133.01001"
+ x="18"
+ sodipodi:role="line"
+ id="line5"></tspan><tspan
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:MgOpen Moderna;-inkscape-font-specification:MgOpen Moderna"
+ y="143.01001"
+ x="18"
+ sodipodi:role="line"
+ id="line6"></tspan></text>
+ </g>
+ <text
+ xml:space="preserve"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:100%;writing-mode:lr-tb;text-anchor:end;opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.89999998;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;font-family:MgOpen Modata;-inkscape-font-specification:MgOpen Modata"
+ x="280.56329"
+ y="162"
+ id="text4036"
+ sodipodi:linespacing="100%"><tspan
+ sodipodi:role="line"
+ id="tspan4038"
+ x="280.56329"
+ y="162">freedom | friends | features | first</tspan></text>
+ <g
+ id="g4521"
+ transform="matrix(0.1003765,0,0,0.1003765,15.719178,139.50001)">
+ <g
+ id="g4505">
+ <g
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="g15">
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path17"
+ d="M 171.913,178.874 C 171.913,178.874 171.913,178.874 101.597,178.874 C 102.735,194.117 115.023,205.497 131.406,205.497 C 143.011,205.497 153.025,200.718 160.989,192.983 C 162.583,191.384 164.403,190.93 166.45,190.93 C 169.181,190.93 171.913,192.298 173.732,194.574 C 174.871,196.167 175.554,197.988 175.554,199.806 C 175.554,202.31 174.415,205.039 172.366,207.089 C 162.808,217.327 146.652,224.155 130.721,224.155 C 101.822,224.155 78.612,200.945 78.612,172.044 C 78.612,143.146 101.14,119.935 130.039,119.935 C 158.712,119.935 180.102,142.235 180.102,171.588 C 180.104,175.914 176.236,178.874 171.913,178.874 z M 130.04,138.595 C 114.794,138.595 104.327,148.607 102.052,163.166 C 136.412,163.166 158.03,163.166 158.03,163.166 C 155.982,149.29 145.059,138.595 130.04,138.595 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path19"
+ d="M 372.838,224.156 C 343.939,224.156 320.73,200.946 320.73,172.045 C 320.73,143.147 343.939,119.936 372.838,119.936 C 401.74,119.936 424.949,143.147 424.949,172.045 C 424.95,200.946 401.741,224.156 372.838,224.156 z M 372.838,139.731 C 354.635,139.731 342.8,154.297 342.8,172.044 C 342.8,189.791 354.635,204.356 372.838,204.356 C 391.043,204.356 402.879,189.791 402.879,172.044 C 402.879,154.297 391.043,139.731 372.838,139.731 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path21"
+ d="M 500.19,119.935 C 484.922,119.935 474.823,124.451 465.907,135.786 L 465.084,130.514 L 465.084,130.514 C 464.392,125.01 459.697,120.76 454.013,120.76 C 447.846,120.76 442.845,125.754 442.845,131.924 C 442.845,131.932 442.845,131.941 442.845,131.949 L 442.845,131.949 L 442.845,131.959 L 442.845,131.959 L 442.845,212.095 C 442.845,218.239 447.85,223.246 453.995,223.246 C 460.139,223.246 465.146,218.238 465.146,212.095 L 465.146,169.088 C 465.146,149.519 482.212,139.732 500.19,139.732 C 505.652,139.732 509.973,135.181 509.973,129.719 C 509.973,124.257 505.652,119.935 500.19,119.935 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path23"
+ d="M 617.836,172.044 C 618.065,144.056 598.037,119.935 565.724,119.935 C 536.824,119.935 513.385,143.146 513.385,172.044 C 513.385,200.945 536.141,224.155 563.677,224.155 C 577.419,224.155 589.787,217.081 595.305,209.691 L 598.022,216.587 L 598.022,216.587 C 599.48,220.461 603.217,223.219 607.6,223.219 C 613.249,223.219 617.829,218.643 617.836,212.998 L 617.836,212.998 L 617.836,186.27 L 617.836,186.27 L 617.836,172.044 L 617.836,172.044 z M 565.724,204.357 C 547.518,204.357 535.686,189.792 535.686,172.045 C 535.686,154.298 547.518,139.732 565.724,139.732 C 583.928,139.732 595.762,154.298 595.762,172.045 C 595.762,189.792 583.928,204.357 565.724,204.357 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path25"
+ d="M 302.833,78.744 C 302.833,72.602 297.828,67.822 291.685,67.822 C 285.541,67.822 280.532,72.602 280.532,78.744 L 280.532,137.456 C 274.845,126.989 262.557,119.935 247.992,119.935 C 218.41,119.935 198.613,142.235 198.613,172.044 C 198.613,201.856 219.093,224.155 247.992,224.155 C 260.883,224.155 272.06,218.835 278.754,209.587 L 281.23,215.866 C 282.764,220.178 286.876,223.262 291.708,223.262 C 297.824,223.262 302.834,218.283 302.834,212.142 C 302.834,212.125 302.834,212.111 302.834,212.094 L 302.834,212.094 L 302.834,78.744 L 302.833,78.744 z M 250.722,204.357 C 232.519,204.357 220.913,189.792 220.913,172.045 C 220.913,154.298 232.518,139.732 250.722,139.732 C 268.928,139.732 280.532,153.613 280.532,172.045 C 280.532,190.473 268.928,204.357 250.722,204.357 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path27"
+ d="M 70.718,68.496 C 68.684,68.195 66.611,68.043 64.552,68.043 C 41.508,68.043 22.759,86.793 22.759,109.838 L 22.759,122.893 L 9.104,122.893 C 4.098,122.893 0,126.99 0,131.994 C 0,137.003 4.098,142.051 9.104,142.051 L 22.758,142.051 L 22.758,212.096 C 22.758,218.24 27.765,223.247 33.907,223.247 C 40.053,223.247 45.059,218.239 45.059,212.096 L 45.059,142.051 L 60.156,142.051 C 65.161,142.051 69.257,137.003 69.257,131.994 C 69.257,126.99 65.162,122.893 60.156,122.893 L 45.066,122.893 L 45.066,109.838 C 45.066,99.093 53.807,88.904 64.552,88.904 C 65.52,88.904 66.495,88.976 67.451,89.117 C 73.546,90.019 79.215,87.259 80.119,81.163 C 81.019,75.07 76.812,69.4 70.718,68.496 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path29"
+ d="M 622.661,209.697 L 622.661,213.106 L 621.965,213.106 L 621.965,209.697 L 620.8,209.697 L 620.8,209.01 L 623.824,209.01 L 623.824,209.697 L 622.661,209.697 z M 627.505,213.106 L 627.505,210.944 C 627.505,210.8 627.505,210.623 627.505,210.476 C 627.453,210.6 627.389,210.746 627.339,210.882 L 626.318,213.232 L 625.318,210.882 C 625.268,210.745 625.205,210.6 625.155,210.486 C 625.165,210.632 625.165,210.809 625.165,210.944 L 625.165,213.106 L 624.5,213.106 L 624.5,209.01 L 625.196,209.01 L 626.124,211.13 C 626.195,211.309 626.278,211.536 626.34,211.692 C 626.402,211.525 626.486,211.319 626.559,211.13 L 627.463,209.01 L 628.169,209.01 L 628.169,213.106 L 627.505,213.106 L 627.505,213.106 z" />
+ </g>
+ <g
+ id="g4498">
+ <path
+ style="fill:#294172;fill-opacity:1"
+ id="path35"
+ d="M 737.644,62.432 C 737.644,27.952 709.693,0 675.213,0 C 640.749,0 612.809,27.929 612.784,62.388 L 612.782,62.386 L 612.782,110.698 L 612.784,110.7 C 612.803,118.524 619.148,124.858 626.977,124.858 C 626.999,124.858 627.021,124.856 627.044,124.856 L 627.048,124.858 L 675.237,124.858 L 675.237,124.858 C 709.707,124.844 737.644,96.902 737.644,62.432 z" />
+ <g
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="g37">
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path39"
+ d="M 693.543,14.799 C 677.36,14.799 664.242,27.917 664.242,44.1 C 664.242,44.106 664.242,44.113 664.242,44.121 L 664.242,59.63 L 648.782,59.63 C 648.779,59.63 648.779,59.63 648.777,59.63 C 632.593,59.63 619.476,72.684 619.476,88.865 C 619.476,105.048 632.593,118.167 648.777,118.167 C 664.959,118.167 678.078,105.047 678.078,88.865 C 678.078,88.86 678.078,88.852 678.078,88.846 L 678.078,73.271 L 693.537,73.271 C 693.54,73.271 693.542,73.271 693.543,73.271 C 709.725,73.271 722.844,60.283 722.844,44.1 C 722.844,27.917 709.725,14.799 693.543,14.799 z M 664.243,88.891 C 664.229,97.42 657.309,104.332 648.778,104.332 C 640.237,104.332 633.249,97.407 633.249,88.866 C 633.249,80.324 640.237,73.27 648.778,73.27 C 648.786,73.27 648.793,73.272 648.799,73.272 L 662.05,73.272 C 662.054,73.272 662.057,73.27 662.06,73.27 C 663.266,73.27 664.245,74.246 664.245,75.452 C 664.245,75.453 664.244,75.455 664.244,75.457 L 664.244,88.891 L 664.243,88.891 z M 693.542,59.629 C 693.537,59.629 693.532,59.629 693.527,59.629 L 680.267,59.629 C 680.265,59.629 680.261,59.629 680.261,59.629 C 679.053,59.629 678.077,58.651 678.077,57.445 L 678.077,57.443 L 678.077,44.074 C 678.092,35.542 685.01,28.633 693.541,28.633 C 702.083,28.633 709.072,35.557 709.072,44.1 C 709.074,52.641 702.084,59.629 693.542,59.629 z" />
+ </g>
+ <path
+ style="fill:#ffffff"
+ id="path41"
+ d="M 664.243,59.629 L 664.243,44.12 C 664.243,44.112 664.243,44.105 664.243,44.099 C 664.243,27.916 677.361,14.798 693.544,14.798 C 696,14.798 697.744,15.073 700.018,15.669 C 703.331,16.537 706.038,19.252 706.039,22.413 C 706.04,26.233 703.267,29.01 699.123,29.01 C 697.148,29.01 696.435,28.632 693.543,28.632 C 685.012,28.632 678.094,35.541 678.079,44.073 L 678.079,57.442 L 678.079,57.444 C 678.079,58.65 679.055,59.628 680.263,59.628 C 680.263,59.628 680.267,59.628 680.269,59.628 L 690.424,59.628 C 694.209,59.628 697.264,62.656 697.267,66.45 C 697.267,70.247 694.208,73.269 690.424,73.269 L 678.079,73.269 L 678.079,88.844 C 678.079,88.85 678.079,88.858 678.079,88.865 C 678.079,105.046 664.96,118.165 648.778,118.165 C 646.323,118.165 644.578,117.888 642.305,117.294 C 638.992,116.427 636.284,113.71 636.283,110.55 C 636.283,106.73 639.055,103.952 643.2,103.952 C 645.173,103.952 645.888,104.331 648.778,104.331 C 657.309,104.331 664.229,97.421 664.244,88.89 C 664.244,88.89 664.244,75.452 664.244,75.452 C 664.244,74.248 663.265,73.272 662.059,73.272 C 662.057,73.272 662.056,73.272 662.053,73.272 L 651.899,73.27 C 648.114,73.27 645.055,70.25 645.055,66.455 C 645.053,62.636 648.145,59.629 651.971,59.629 L 664.243,59.629 L 664.243,59.629 z" />
+ <path
+ style="fill:#3c6eb4;fill-opacity:1"
+ id="path43"
+ d="M 722.026,110.643 L 722.026,114.053 L 721.331,114.053 L 721.331,110.643 L 720.166,110.643 L 720.166,109.957 L 723.19,109.957 L 723.19,110.643 L 722.026,110.643 z M 726.872,114.053 L 726.872,111.891 C 726.872,111.746 726.872,111.569 726.872,111.422 C 726.821,111.547 726.758,111.693 726.706,111.83 L 725.686,114.178 L 724.687,111.83 C 724.637,111.693 724.573,111.547 724.522,111.432 C 724.532,111.58 724.532,111.756 724.532,111.891 L 724.532,114.053 L 723.867,114.053 L 723.867,109.957 L 724.564,109.957 L 725.489,112.077 C 725.562,112.255 725.644,112.485 725.706,112.639 C 725.768,112.473 725.853,112.266 725.924,112.077 L 726.83,109.957 L 727.536,109.957 L 727.536,114.053 L 726.872,114.053 L 726.872,114.053 z" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/generate.py b/generate.py
new file mode 100644
index 0000000..154bc63
--- /dev/null
+++ b/generate.py
@@ -0,0 +1,192 @@
+###
+# generate.py - 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.
+###
+
+"""
+Use this script to render yourself business cards in popular shapes, sizes, and
+formats. Only run it from within the git repository, since it has some
+templates that this script requires.
+
+You'll need mgopen-fonts, python-fedora, and pygpgme from yum.
+"""
+
+from fedora.accounts.fas2 import AccountSystem
+from optparse import OptionParser
+import gpgme
+import re
+import subprocess
+from getpass import getpass
+from xml.dom import minidom
+
+VALID_INFO = ['email', 'phone', 'irc', 'url', 'gpgid', 'gpgfingerprint',
+ 'blank']
+
+
+class BusinessCardError(ValueError):
+ """
+ Possible problems:
+ info>6
+ notinfo (1 arg)
+ pgpfp (1 arg)
+ noirc (1 arg)
+ nogpg (1 arg)
+ """
+
+ def __init__(self, problem, args=[]):
+ ValueError.__init__(self)
+ self.problem = problem
+ self.args = args
+
+ def __str__(self):
+ if self.problem == "info>6":
+ return "--info count can't be greater than 6"
+ if self.problem == "notinfo":
+ return "%s not valid for --info" % self.args[0]
+ if self.problem == "pgpfp":
+ return "Couldn't get PGP fingerprint for key %s" % self.args[0]
+ if self.problem == "noirc":
+ return "No IRC nick for %s, use override" % self.args[0]
+ if self.problem == "nogpg":
+ return "No GPG key ID for %s, use override" % self.args[0]
+
+
+def get_gpg_fingerprint(keyid):
+ """
+ Gets the GPG fingerprint from the key ID.
+ """
+ ctx = gpgme.Context()
+ try:
+ key = ctx.get_key(keyid)
+ except gpgme.GpgmeError:
+ # fetch keys from subkeys.pgp.net
+ subprocess.Popen('gpg --keyserver subkeys.pgp.net --recv-key %s' %
+ keyid, shell=True)
+ try:
+ key = ctx.get_key(keyid)
+ except gpgme.GpgmeError:
+ raise BusinessCardError('pgpfp', keyid)
+ fpr = key.subkeys[0].fpr
+ return ' '.join([i for i in re.split('([A-Z0-9]{4})', fpr) if i])
+
+
+def find_node(doc_node, tag_name, attribute_name, attribute_value):
+ """
+ Finds a node based on tag name, attribute name, and attribute value.
+
+ Thanks, mizmo!
+ """
+ # thanks, mizmo
+ elements = doc_node.getElementsByTagName(tag_name)
+ for element in elements:
+ if element.hasAttribute(attribute_name):
+ if element.getAttribute(attribute_name) == attribute_value:
+ return element
+
+
+def gen_front(name, title, lines, outfile):
+ """
+ Generates the front side of the business card based off of the given
+ name, title, and 6 lines in a list. Also requires an outfile variable.
+ """
+ dom = minidom.parse('front-template.svg')
+ namenode = find_node(dom, 'text', 'id', 'fullname')
+ namenode.appendChild(dom.createTextNode(name))
+ titlenode = find_node(dom, 'text', 'id', 'title')
+ titlenode.appendChild(dom.createTextNode(title))
+ for i in range(6):
+ node = find_node(dom, 'tspan', 'id', 'line%d' % (i+1))
+ node.appendChild(dom.createTextNode(lines[i]))
+ out = file(outfile, "w")
+ out.write(dom.toxml())
+ out.close()
+
+
+def main():
+ # set up parser
+ parser = OptionParser()
+ parser.add_option("-i", "--info", dest="info",
+ default="email,phone,irc,url,blank,gpgid", help="Order"+\
+ " of information on card. Valid options are email, "+\
+ "phone, irc, url, gpgid, gpgfingerprint, and blank.")
+ overrides = ['username', 'name', 'title'] + VALID_INFO
+ for i in overrides:
+ if i != "blank":
+ parser.add_option("--override-%s" % i, dest="override%s" % i,
+ default="", help="Override for %s" % i)
+ # parse
+ options = parser.parse_args()[0]
+ # check --info
+ info = options.info.split(',')
+ if len(info) > 6:
+ raise BusinessCardError('info>6')
+ for i in info:
+ if i not in VALID_INFO:
+ raise BusinessCardError('notinfo', [i])
+ # FAS login
+ print "Login to FAS"
+ print "Username:",
+ username = raw_input()
+ password = getpass()
+ fas = AccountSystem(username=username, password=password)
+ # and go!
+ if options.overrideusername != "":
+ username = options.overrideusername
+ overrides = {'email': options.overrideemail,
+ 'phone': options.overridephone,
+ 'blank': '',
+ 'name': options.overridename,
+ 'title': options.overridetitle,
+ 'irc': options.overrideirc,
+ 'url': options.overrideurl,
+ 'gpgid': options.overridegpgid,
+ 'gpgfingerprint': options.overridegpgfingerprint}
+ userinfo = fas.person_by_username(username)
+ infodict = {}
+ infodict['name'] = userinfo["human_name"]
+ infodict['title'] = "Fedora Project Contributor"
+ infodict['email'] = "%s@fedoraproject.org" % username
+ infodict['phone'] = "(919) 424-0063 x 5%s" % userinfo['id']
+ infodict['url'] = 'fedoraproject.org'
+ infodict['blank'] = ''
+ if not options.overrideirc:
+ if 'irc' in options.info:
+ if userinfo['ircnick'] == "":
+ raise BusinessCardError('noirc', username)
+ else:
+ infodict['irc'] = '%s on irc.freenode.net' % \
+ userinfo['ircnick']
+ if not options.overridegpgid:
+ if 'gpg' in options.info:
+ if userinfo['gpg_keyid'] == "":
+ raise BusinessCardError('nogpg', username)
+ else:
+ infodict['gpgid'] = 'GPG key ID: %s' % userinfo['gpg_keyid']
+ infodict['gpgfingerprint'] = get_gpg_fingerprint(
+ userinfo['gpg_keyid'])
+ else:
+ if not options.overridegpgfingerprint:
+ infodict['gpgfingerprint'] = get_gpg_fingerprint(
+ options.overridegpgid)
+ lines = []
+ for i in info:
+ lines.append(overrides[i] or infodict[i])
+ gen_front(overrides['name'] or infodict['name'], overrides['title'] or
+ infodict['title'], lines, 'out.svg')
+
+if __name__ == "__main__":
+ main()