Use black with -l 120 param.

This commit is contained in:
grossmj committed 2021-04-13 18:46:50 +09:30
1 parent f928738bd5
commit c021e21309
194 files changed
+6034 -4564

No files matched your search

+18 -6
View File
@@ -32,6 +32,7 @@ from .export_project import export_project
from .import_project import import_project
import logging
log = logging.getLogger(__name__)
@@ -48,17 +49,26 @@ class Snapshot:
assert filename or name, "You need to pass a name or a filename"
self._id = str(uuid.uuid4()) # We don't need to keep id between project loading because they are use only as key for operation like delete, update.. but have no impact on disk
self._id = str(
uuid.uuid4()
) # We don't need to keep id between project loading because they are use only as key for operation like delete, update.. but have no impact on disk
self._project = project
if name:
self._name = name
self._created_at = datetime.now().timestamp()
filename = self._name + "_" + datetime.utcfromtimestamp(self._created_at).replace(tzinfo=None).strftime(FILENAME_TIME_FORMAT) + ".gns3project"
filename = (
self._name
+ "_"
+ datetime.utcfromtimestamp(self._created_at).replace(tzinfo=None).strftime(FILENAME_TIME_FORMAT)
+ ".gns3project"
)
else:
self._name = filename.split("_")[0]
datestring = filename.replace(self._name + "_", "").split(".")[0]
try:
self._created_at = datetime.strptime(datestring, FILENAME_TIME_FORMAT).replace(tzinfo=timezone.utc).timestamp()
self._created_at = (
datetime.strptime(datestring, FILENAME_TIME_FORMAT).replace(tzinfo=timezone.utc).timestamp()
)
except ValueError:
self._created_at = datetime.utcnow().timestamp()
self._path = os.path.join(project.path, "snapshots", filename)
@@ -99,7 +109,7 @@ class Snapshot:
# Do not compress the snapshots
with aiozipstream.ZipFile(compression=zipfile.ZIP_STORED) as zstream:
await export_project(zstream, self._project, tmpdir, keep_compute_id=True, allow_all_nodes=True)
async with aiofiles.open(self.path, 'wb') as f:
async with aiofiles.open(self.path, "wb") as f:
async for chunk in zstream:
await f.write(chunk)
log.info(f"Snapshot '{self.name}' created in {time.time() - begin:.4f} seconds")
@@ -121,7 +131,9 @@ class Snapshot:
if os.path.exists(project_files_path):
await wait_run_in_executor(shutil.rmtree, project_files_path)
with open(self._path, "rb") as f:
project = await import_project(self._project.controller, self._project.id, f, location=self._project.path)
project = await import_project(
self._project.controller, self._project.id, f, location=self._project.path
)
except (OSError, PermissionError) as e:
raise ControllerError(str(e))
await project.open()
@@ -133,5 +145,5 @@ class Snapshot:
"snapshot_id": self._id,
"name": self._name,
"created_at": int(self._created_at),
"project_id": self._project.id
"project_id": self._project.id,
}