Format code using black
This commit is contained in:
parent
2ad0c8dbc7
commit
59136050fb
14 changed files with 809 additions and 413 deletions
|
|
@ -6,17 +6,15 @@ from photologue.models import PhotoSize
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = ('Creates a new Photologue photo size interactively.')
|
||||
help = "Creates a new Photologue photo size interactively."
|
||||
requires_model_validation = True
|
||||
can_import_settings = True
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('name',
|
||||
type=str,
|
||||
help='Name of the new photo size')
|
||||
parser.add_argument("name", type=str, help="Name of the new photo size")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
create_photosize(options['name'])
|
||||
create_photosize(options["name"])
|
||||
|
||||
|
||||
def get_response(msg, func=int, default=None):
|
||||
|
|
@ -27,10 +25,12 @@ def get_response(msg, func=int, default=None):
|
|||
try:
|
||||
return func(resp)
|
||||
except Exception:
|
||||
print('Invalid input.')
|
||||
print("Invalid input.")
|
||||
|
||||
|
||||
def create_photosize(name, width=0, height=0, crop=False, pre_cache=False, increment_count=False):
|
||||
def create_photosize(
|
||||
name, width=0, height=0, crop=False, pre_cache=False, increment_count=False
|
||||
):
|
||||
try:
|
||||
size = PhotoSize.objects.get(name=name)
|
||||
exists = True
|
||||
|
|
@ -38,15 +38,20 @@ def create_photosize(name, width=0, height=0, crop=False, pre_cache=False, incre
|
|||
size = PhotoSize(name=name)
|
||||
exists = False
|
||||
if exists:
|
||||
msg = 'A "%s" photo size already exists. Do you want to replace it? (yes, no):' % name
|
||||
if not get_response(msg, lambda inp: inp == 'yes', False):
|
||||
msg = (
|
||||
'A "%s" photo size already exists. Do you want to replace it? (yes, no):'
|
||||
% name
|
||||
)
|
||||
if not get_response(msg, lambda inp: inp == "yes", False):
|
||||
return
|
||||
print('\nWe will now define the "%s" photo size:\n' % size)
|
||||
w = get_response('Width (in pixels):', lambda inp: int(inp), width)
|
||||
h = get_response('Height (in pixels):', lambda inp: int(inp), height)
|
||||
c = get_response('Crop to fit? (yes, no):', lambda inp: inp == 'yes', crop)
|
||||
p = get_response('Pre-cache? (yes, no):', lambda inp: inp == 'yes', pre_cache)
|
||||
i = get_response('Increment count? (yes, no):', lambda inp: inp == 'yes', increment_count)
|
||||
w = get_response("Width (in pixels):", lambda inp: int(inp), width)
|
||||
h = get_response("Height (in pixels):", lambda inp: int(inp), height)
|
||||
c = get_response("Crop to fit? (yes, no):", lambda inp: inp == "yes", crop)
|
||||
p = get_response("Pre-cache? (yes, no):", lambda inp: inp == "yes", pre_cache)
|
||||
i = get_response(
|
||||
"Increment count? (yes, no):", lambda inp: inp == "yes", increment_count
|
||||
)
|
||||
size.width = w
|
||||
size.height = h
|
||||
size.crop = c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue