| |
@@ -31,22 +31,20 @@
|
| |
import importlib.resources as pkg_resources
|
| |
import argparse
|
| |
from decimal import Decimal
|
| |
- from getpass import getpass
|
| |
from xml.dom import minidom
|
| |
from builtins import input
|
| |
|
| |
- from fedora_business_cards import __version__
|
| |
from fedora_business_cards import common
|
| |
from fedora_business_cards.generators import BaseGenerator
|
| |
from fedora_business_cards import templates # relative-import the *package* containing the card templates
|
| |
|
| |
- AccountSystem = \
|
| |
- common.recursive_import('fedora.client.fas2', True).AccountSystem
|
| |
-
|
| |
FEDORA_LOGO_VIEWBOX = '100 100 707.776 215.080'
|
| |
|
| |
|
| |
class FedoraVerticalGenerator(BaseGenerator):
|
| |
+ _gen_name = 'fedora-vertical'
|
| |
+ _gen_desc = 'Fedora vertical business cards'
|
| |
+
|
| |
rgb_to_cmyk = {
|
| |
(60, 110, 180): (1, .46, 0, 0),
|
| |
(41, 65, 114): (1, .57, 0, .38),
|
| |
@@ -54,33 +52,14 @@
|
| |
(255, 255, 255): (0, 0, 0, 0),
|
| |
}
|
| |
|
| |
- @staticmethod
|
| |
- def extra_options(parser):
|
| |
- option_group = parser.add_parser('fedora-vertical', help='Fedora vertical business cards')
|
| |
- option_group.add_argument('-u', '--username', dest='username',
|
| |
- default='', help='If set, use a different name'
|
| |
- ' than the one logged in with to fill out'
|
| |
- ' business card information')
|
| |
- return option_group
|
| |
-
|
| |
def collect_information(self):
|
| |
- # ask for FAS login
|
| |
- print("Login to FAS:")
|
| |
- username = input("Username: ")
|
| |
- password = getpass()
|
| |
-
|
| |
- # get information from FAS
|
| |
- fas = AccountSystem(username=username, password=password,
|
| |
- useragent='fedora-business-cards/%s' % __version__)
|
| |
- if self.options.username:
|
| |
- username = self.options.username
|
| |
- userinfo = fas.person_by_username(username)
|
| |
+ userinfo = self.collect_fas_information()
|
| |
|
| |
# set business card fields
|
| |
self.fields['name'] = userinfo["human_name"]
|
| |
self.fields['title'] = "Fedora Project Contributor"
|
| |
self.fields['lines'] = [''] * 5
|
| |
- self.fields['lines'][0] = '%s@fedoraproject.org' % username
|
| |
+ self.fields['lines'][0] = '%s@fedoraproject.org' % userinfo['username']
|
| |
self.fields['lines'][1] = 'fedoraproject.org'
|
| |
next_line = 2
|
| |
if userinfo['ircnick']:
|
| |
@@ -100,7 +79,8 @@
|
| |
def cmdline_card_line(data):
|
| |
return "| %s%s |" % (data, ' ' * (35 - len(data)))
|
| |
|
| |
- done_editing = False
|
| |
+ # don't prompt user to edit in test mode
|
| |
+ done_editing = self.options.test
|
| |
while not done_editing:
|
| |
print("Current business card layout:")
|
| |
print("Vertical cards don't hold much data ...:")
|
| |
This implements test mode (so
fedora-business-cards
can be tested without hitting FAS) in three diffs (the first diff just fixes a typo so is not significant):collect_information
methods make use ofcollect_information
can be further refactored but that should probably be in a further PR.Tested by running all three generators in normal, test mode, and test mode with username overridden.
Implements #5