From 4c1317623dff59a46f2330b0c0d7cbdc41f00801 Mon Sep 17 00:00:00 2001
From: "Mayr, Hannes" <hannes.mayr@stud.tu-darmstadt.de>
Date: Tue, 10 Jan 2023 17:06:52 +0100
Subject: [PATCH] Add version number to required_imports.txt

---
 plotid/publish.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/plotid/publish.py b/plotid/publish.py
index f67cf3e..2e38c25 100644
--- a/plotid/publish.py
+++ b/plotid/publish.py
@@ -13,6 +13,7 @@ import os
 import shutil
 import sys
 import warnings
+from importlib.metadata import version
 from typing import TypedDict, Any
 from plotid.save_plot import save_plot
 from plotid.plotoptions import PlotIDTransfer, validate_list
@@ -134,8 +135,7 @@ class PublishOptions:
                                 " – plot has already been published."
                             )
                             overwrite_dir = input(
-                                "Do you want to overwrite "
-                                "the existing folder? "
+                                "Do you want to overwrite the existing folder? "
                                 "(yes/no[default])\n"
                             )
                             if overwrite_dir in ("yes", "y", "Yes", "YES"):
@@ -155,10 +155,8 @@ class PublishOptions:
                         os.rename(dst_path_invisible, dst_path)
                     except FileExistsError as exc:
                         delete_dir = input(
-                            "There was an error while "
-                            "publishing the data. Should the "
-                            "partially copied data at "
-                            f"{dst_path_invisible} be"
+                            "There was an error while publishing the data. Should the "
+                            f"partially copied data at {dst_path_invisible} be"
                             " removed? (yes/no[default])\n"
                         )
                         if delete_dir in ("yes", "y", "Yes", "YES"):
@@ -287,7 +285,8 @@ class Analyzer(ast.NodeVisitor):
         # Write every item of the set to one line.
         with open(output_file, "w", encoding="utf-8") as output:
             for item in imports_as_set:
-                output.write(f"{item}\n")
+                module_version = version(item)
+                output.write(f"{item}=={module_version}\n")
             output.close()
 
 
-- 
GitLab