Run black on entire project

This commit is contained in:
Sumner Evans
2020-04-23 20:17:45 -06:00
parent e5b3e659ff
commit 0ed2c266d8
52 changed files with 2603 additions and 2917 deletions

View File

@@ -1,7 +1,8 @@
from typing import Any, List, Optional, Tuple
import gi
gi.require_version('Gtk', '3.0')
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
TextFieldDescription = Tuple[str, str, bool]
@@ -25,25 +26,22 @@ class EditFormDialog(Gtk.Dialog):
"""
Gets the friendly object name. Can be overridden.
"""
return obj.name if obj else ''
return obj.name if obj else ""
def get_default_object(self):
return None
def __init__(self, parent: Any, existing_object: Any = None):
editing = existing_object is not None
title = getattr(self, 'title', None)
title = getattr(self, "title", None)
if not title:
if editing:
title = f'Edit {self.get_object_name(existing_object)}'
title = f"Edit {self.get_object_name(existing_object)}"
else:
title = f'Create New {self.entity_name}'
title = f"Create New {self.entity_name}"
Gtk.Dialog.__init__(
self,
title=title,
transient_for=parent,
flags=0,
self, title=title, transient_for=parent, flags=0,
)
if not existing_object:
existing_object = self.get_default_object()
@@ -55,22 +53,18 @@ class EditFormDialog(Gtk.Dialog):
content_area = self.get_content_area()
content_grid = Gtk.Grid(
column_spacing=10,
row_spacing=5,
margin_left=10,
margin_right=10,
column_spacing=10, row_spacing=5, margin_left=10, margin_right=10,
)
# Add the text entries to the content area.
i = 0
for label, value_field_name, is_password in self.text_fields:
entry_label = Gtk.Label(label=label + ':')
entry_label = Gtk.Label(label=label + ":")
entry_label.set_halign(Gtk.Align.START)
content_grid.attach(entry_label, 0, i, 1, 1)
entry = Gtk.Entry(
text=getattr(existing_object, value_field_name, ''),
hexpand=True,
text=getattr(existing_object, value_field_name, ""), hexpand=True,
)
if is_password:
entry.set_visibility(False)
@@ -80,7 +74,7 @@ class EditFormDialog(Gtk.Dialog):
i += 1
for label, value_field_name, options in self.option_fields:
entry_label = Gtk.Label(label=label + ':')
entry_label = Gtk.Label(label=label + ":")
entry_label.set_halign(Gtk.Align.START)
content_grid.attach(entry_label, 0, i, 1, 1)
@@ -105,22 +99,27 @@ class EditFormDialog(Gtk.Dialog):
# Add the boolean entries to the content area.
for label, value_field_name in self.boolean_fields:
entry_label = Gtk.Label(label=label + ':')
entry_label = Gtk.Label(label=label + ":")
entry_label.set_halign(Gtk.Align.START)
content_grid.attach(entry_label, 0, i, 1, 1)
# Put the checkbox in the right box. Note we have to pad here
# since the checkboxes are smaller than the text fields.
checkbox = Gtk.CheckButton(
active=getattr(existing_object, value_field_name, False))
active=getattr(existing_object, value_field_name, False)
)
self.data[value_field_name] = checkbox
content_grid.attach(checkbox, 1, i, 1, 1)
i += 1
# Add the spin button entries to the content area.
for (label, value_field_name, range_config,
default_value) in self.numeric_fields:
entry_label = Gtk.Label(label=label + ':')
for (
label,
value_field_name,
range_config,
default_value,
) in self.numeric_fields:
entry_label = Gtk.Label(label=label + ":")
entry_label.set_halign(Gtk.Align.START)
content_grid.attach(entry_label, 0, i, 1, 1)
@@ -128,7 +127,8 @@ class EditFormDialog(Gtk.Dialog):
# since the checkboxes are smaller than the text fields.
spin_button = Gtk.SpinButton.new_with_range(*range_config)
spin_button.set_value(
getattr(existing_object, value_field_name, default_value))
getattr(existing_object, value_field_name, default_value)
)
self.data[value_field_name] = spin_button
content_grid.attach(spin_button, 1, i, 1, 1)
i += 1