From 1097477a10a87eddf2cb7fabe10aa7a75ecc7017 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 8 Mar 2021 22:33:24 +0100 Subject: [PATCH] Removed .idea --- .gitignore | 1 + .idea/dictionaries/sven.xml | 3 - .idea/inspectionProfiles/Project_Default.xml | 17 ------ .../inspectionProfiles/profiles_settings.xml | 6 -- .idea/misc.xml | 4 -- .idea/modules.xml | 8 --- .idea/sh_common_py_lib.iml | 21 ------- .../shelved.patch | 61 ------------------- ..._26_11_2020_10_36__Default_Changelist_.xml | 4 -- .idea/vcs.xml | 6 -- 10 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 .idea/dictionaries/sven.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/sh_common_py_lib.iml delete mode 100644 .idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch delete mode 100644 .idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 7f0088a2..18dfc2c2 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ dmypy.json # IDE .vscode/ +.idea/ diff --git a/.idea/dictionaries/sven.xml b/.idea/dictionaries/sven.xml deleted file mode 100644 index 6b8908ae..00000000 --- a/.idea/dictionaries/sven.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index f9ea47c4..00000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da..00000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index d56657ad..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 3430c667..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/sh_common_py_lib.iml b/.idea/sh_common_py_lib.iml deleted file mode 100644 index 37a2d482..00000000 --- a/.idea/sh_common_py_lib.iml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch deleted file mode 100644 index bb3b0e06..00000000 --- a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36_[Default_Changelist]/shelved.patch +++ /dev/null @@ -1,61 +0,0 @@ -Index: src/tests/publishing/publisher.py -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP -<+>import os\r\nimport shutil\r\nimport unittest\r\n\r\nfrom sh_edraft.configuration import ApplicationHost\r\nfrom sh_edraft.logging import Logger\r\nfrom sh_edraft.logging.base import LoggerBase\r\nfrom sh_edraft.logging.model import LoggingSettings\r\nfrom sh_edraft.publishing import Publisher\r\nfrom sh_edraft.publishing.base import PublisherBase\r\nfrom sh_edraft.publishing.model import Template\r\nfrom sh_edraft.publishing.model.publish_settings_model import PublishSettingsModel\r\nfrom sh_edraft.source_code.model import Version\r\nfrom sh_edraft.time.model import TimeFormatSettings\r\n\r\n\r\nclass PublisherTest(unittest.TestCase):\r\n\r\n def _config(self):\r\n self._log_settings = LoggingSettings()\r\n self._log_settings.from_dict({\r\n \"Path\": \"logs/\",\r\n \"Filename\": \"log_$start_time.log\",\r\n \"ConsoleLogLevel\": \"TRACE\",\r\n \"FileLogLevel\": \"TRACE\"\r\n })\r\n\r\n self._time_format_settings = TimeFormatSettings()\r\n self._time_format_settings.from_dict({\r\n \"DateFormat\": \"%Y-%m-%d\",\r\n \"TimeFormat\": \"%H:%M:%S\",\r\n \"DateTimeFormat\": \"%Y-%m-%d %H:%M:%S.%f\",\r\n \"DateTimeLogFormat\": \"%Y-%m-%d_%H-%M-%S\"\r\n })\r\n\r\n self._version = Version(2020, 12, 5).to_dict()\r\n templates = [\r\n Template(\r\n '../../publish_templates/*_template.txt',\r\n '*',\r\n '',\r\n '',\r\n '2020',\r\n 'sh-edraft.de',\r\n 'MIT',\r\n ', see LICENSE for more details.',\r\n '',\r\n 'Sven Heidemann',\r\n self._version\r\n ),\r\n Template(\r\n '../../publish_templates/*_template.txt',\r\n 'sh_edraft',\r\n 'common python library',\r\n 'Library to share common classes and models used at sh-edraft.de',\r\n '2020',\r\n 'sh-edraft.de',\r\n 'MIT',\r\n ', see LICENSE for more details.',\r\n '',\r\n 'Sven Heidemann',\r\n self._version\r\n )\r\n ]\r\n\r\n self._source_path = '../'\r\n self._dist_path = '../../dist'\r\n\r\n self._publish_settings_model = PublishSettingsModel()\r\n self._publish_settings_model.from_dict({\r\n \"SourcePath\": self._source_path,\r\n \"DistPath\": self._dist_path,\r\n \"Templates\": templates,\r\n \"IncludedFiles\": [],\r\n \"ExcludedFiles\": [],\r\n \"TemplateEnding\": \"_template.txt\",\r\n })\r\n\r\n def setUp(self):\r\n self._config()\r\n\r\n self._app_host = ApplicationHost()\r\n self._logger = Logger(self._log_settings, self._time_format_settings, self._app_host)\r\n self._logger.create()\r\n\r\n def tearDown(self):\r\n if os.path.isdir(self._log_settings.path):\r\n shutil.rmtree(self._log_settings.path)\r\n\r\n def test_create(self):\r\n publisher: Publisher = Publisher(self._logger, self._publish_settings_model)\r\n self.assertIsNotNone(publisher)\r\n\r\n publisher.create()\r\n self.assertTrue(os.path.isdir(self._dist_path))\r\n -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== ---- src/tests/publishing/publisher.py (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369) -+++ src/tests/publishing/publisher.py (date 1606383223452) -@@ -36,8 +36,8 @@ - self._version = Version(2020, 12, 5).to_dict() - templates = [ - Template( -- '../../publish_templates/*_template.txt', -- '*', -+ '../../publish_templates/all_template.txt', -+ 'all', - '', - '', - '2020', -@@ -49,7 +49,7 @@ - self._version - ), - Template( -- '../../publish_templates/*_template.txt', -+ '../../publish_templates/all_template.txt', - 'sh_edraft', - 'common python library', - 'Library to share common classes and models used at sh-edraft.de', -Index: src/sh_edraft/publishing/publisher.py -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP -<+>import os\r\nimport shutil\r\nfrom string import Template as stringTemplate\r\n\r\nfrom sh_edraft.logging.base.logger_base import LoggerBase\r\nfrom sh_edraft.publishing.base.publisher_base import PublisherBase\r\nfrom sh_edraft.publishing.model.publish_settings_model import PublishSettingsModel\r\nfrom sh_edraft.publishing.model.template import Template\r\n\r\n\r\nclass Publisher(PublisherBase):\r\n\r\n def __init__(self, logger: LoggerBase, publish_settings: PublishSettingsModel):\r\n super().__init__(logger, publish_settings)\r\n\r\n @property\r\n def source_path(self) -> str:\r\n return self._publish_settings.source_path\r\n\r\n @property\r\n def dist_path(self):\r\n return self._publish_settings.dist_path\r\n\r\n def _get_template_output(self, t: Template, name: str, imports: str) -> str:\r\n self._logger.trace(__name__, f'Started {__name__}._get_template_output')\r\n try:\r\n if t.file_content == '':\r\n raise Exception(f'Template is empty: {t.template_path}')\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._get_template_output')\r\n return stringTemplate(t.file_content).substitute(\r\n Name=name,\r\n Description=t.description,\r\n LongDescription=t.long_description,\r\n CopyrightDate=t.copyright_date,\r\n CopyrightName=t.copyright_name,\r\n LicenseName=t.license_name,\r\n LicenseDescription=t.license_description,\r\n Title=t.title if t.title is not None and t.title != '' else name,\r\n Author=t.author,\r\n Version=t.version.to_str(),\r\n Major=t.version.major,\r\n Minor=t.version.minor,\r\n Micro=t.version.micro,\r\n Imports=imports\r\n )\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot read Template: {t.template_path}', e)\r\n self._logger.trace(__name__, f'Stopped {__name__}._get_template_output')\r\n\r\n def _read_source_path(self):\r\n self._logger.trace(__name__, f'Started {__name__}._read_source_path')\r\n for r, d, f in os.walk(self._publish_settings.source_path):\r\n for file in f:\r\n if file.endswith('.py') or file in self._publish_settings.included_files:\r\n self._publish_settings.included_files.append(os.path.join(r, file))\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._read_source_path')\r\n\r\n def _read_templates(self):\r\n self._logger.trace(__name__, f'Started {__name__}._read_templates')\r\n for t in self._publish_settings.templates:\r\n output_template: str = ''\r\n if not os.path.isfile(t.template_path):\r\n self._logger.fatal(__name__, f'Template not found: {t.template_path}')\r\n\r\n with open(t.template_path) as template:\r\n t.file_content = template.read()\r\n template.close()\r\n if t.file_content == '':\r\n self._logger.fatal(__name__, f'Template is empty: {t.template_path}')\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._read_templates')\r\n\r\n def _create_dist_path(self):\r\n self._logger.trace(__name__, f'Started {__name__}._create_dist_path')\r\n if os.path.isdir(self._publish_settings.dist_path):\r\n try:\r\n shutil.rmtree(self._publish_settings.dist_path)\r\n self._logger.info(__name__, f'Deleted {self._publish_settings.dist_path}')\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot delete old dist directory', e)\r\n\r\n if not os.path.isdir(self._publish_settings.dist_path):\r\n try:\r\n os.makedirs(self._publish_settings.dist_path)\r\n self._logger.debug(__name__, f'Created directories: {self._publish_settings.dist_path}')\r\n self._logger.info(__name__, f'Created dist directory')\r\n except Exception as e:\r\n self._logger.fatal(__name__, f'Cannot create dist directory', e)\r\n\r\n self._logger.trace(__name__, f'Stopped {__name__}._create_dist_path')\r\n\r\n @staticmethod\r\n def _get_template_name_from_dirs(file: str) -> str:\r\n dirs = os.path.dirname(file).split('/')\r\n for d in dirs:\r\n if d.__contains__('.'):\r\n dirs.remove(d)\r\n\r\n if len(dirs) == 0:\r\n return os.path.basename(file)\r\n else:\r\n return '.'.join(dirs)\r\n\r\n def _write_templates(self):\r\n self._logger.trace(__name__, f'Started {__name__}._write_templates')\r\n for template in self._publish_settings.templates:\r\n for file in self._publish_settings.included_files:\r\n if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:\r\n template_name = template.name\r\n if template.name == '*' or template.name == '':\r\n template_name = self._get_template_name_from_dirs(file)\r\n else:\r\n name = self._get_template_name_from_dirs(file)\r\n\r\n if name.__contains__('.'):\r\n if template.name != name.split('.')[len(name.split('.')) - 1]:\r\n continue\r\n\r\n else:\r\n if template.name != name:\r\n continue\r\n\r\n try:\r\n module_file_lines: list[str] = []\r\n module_py_lines: list[str] = []\r\n imports = ''\r\n with open(file, 'r') as py_file:\r\n module_file_lines = py_file.readlines()\r\n py_file.close()\r\n\r\n if len(module_file_lines) == 0:\r\n with open(file, 'w+') as py_file:\r\n py_file.write(self._get_template_output(template, template_name, '# imports:'))\r\n py_file.close()\r\n self._logger.debug(__name__, f'Written to {file}')\r\n else:\r\n is_started = False\r\n for line in module_file_lines:\r\n if line.__contains__('# imports'):\r\n is_started = True\r\n\r\n if (line.__contains__('from') or line.__contains__('import')) and is_started:\r\n module_py_lines.append(line.replace('\\n', ''))\r\n\r\n if len(module_py_lines) > 0:\r\n imports = '\\n'.join(module_py_lines)\r\n\r\n with open(file, 'w+') as py_file:\r\n py_file.write(self._get_template_output(template, template_name, imports))\r\n py_file.close()\r\n self._logger.debug(__name__, f'Written to {file}')\r\n\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot write to file: {file}', e)\r\n\r\n self._logger.info(__name__, f'Written to all included modules')\r\n self._logger.trace(__name__, f'Stopped {__name__}._write_templates')\r\n\r\n def _copy_all_included_files(self):\r\n self._logger.trace(__name__, f'Started {__name__}._copy_all_included_files')\r\n dist_path = self._publish_settings.dist_path\r\n if self._publish_settings.dist_path.endswith('/'):\r\n dist_path = dist_path[:len(dist_path) - 1]\r\n\r\n for file in self._publish_settings.included_files:\r\n is_file_excluded = False\r\n if file in self._publish_settings.excluded_files:\r\n is_file_excluded = True\r\n else:\r\n for excluded in self._publish_settings.excluded_files:\r\n if file.__contains__(excluded):\r\n is_file_excluded = True\r\n\r\n if not is_file_excluded:\r\n output_file = ''\r\n\r\n if file.startswith('..'):\r\n output_file = file.replace('..', '')\r\n elif file.startswith('.'):\r\n output_file = file.replace('.', '', 1)\r\n\r\n output_file = f'{dist_path}{output_file}'\r\n output_path = os.path.dirname(output_file)\r\n\r\n try:\r\n if not os.path.isdir(output_path):\r\n os.makedirs(output_path)\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot create directories: {output_path}', e)\r\n\r\n try:\r\n shutil.copy(file, output_file)\r\n except Exception as e:\r\n self._logger.error(__name__, f'Cannot copy file: {file} to {output_path}', e)\r\n\r\n self._logger.debug(__name__, f'Copied {file} to {output_path}')\r\n\r\n self._logger.info(__name__, f'Copied all included files')\r\n self._logger.trace(__name__, f'Stopped {__name__}._copy_all_included_files')\r\n\r\n def include(self, path: str):\r\n self._logger.trace(__name__, f'Started {__name__}.include')\r\n self._publish_settings.included_files.append(path)\r\n self._logger.trace(__name__, f'Stopped {__name__}.include')\r\n\r\n def exclude(self, path: str):\r\n self._logger.trace(__name__, f'Started {__name__}.exclude')\r\n self._publish_settings.excluded_files.append(path)\r\n self._logger.trace(__name__, f'Stopped {__name__}.exclude')\r\n\r\n def create(self):\r\n self._logger.trace(__name__, f'Started {__name__}.create')\r\n if not self._publish_settings.dist_path.endswith('/'):\r\n self._publish_settings.dist_path += '/'\r\n\r\n self._read_source_path()\r\n self._read_templates()\r\n self._create_dist_path()\r\n self._logger.trace(__name__, f'Stopped {__name__}.create')\r\n\r\n def publish(self):\r\n self._logger.trace(__name__, f'Started {__name__}.publish')\r\n self._write_templates()\r\n self._copy_all_included_files()\r\n self._logger.trace(__name__, f'Stopped {__name__}.publish')\r\n -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== ---- src/sh_edraft/publishing/publisher.py (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369) -+++ src/sh_edraft/publishing/publisher.py (date 1606383234093) -@@ -109,7 +109,7 @@ - for file in self._publish_settings.included_files: - if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files: - template_name = template.name -- if template.name == '*' or template.name == '': -+ if template.name == 'all' or template.name == '': - template_name = self._get_template_name_from_dirs(file) - else: - name = self._get_template_name_from_dirs(file) -Index: publish_templates/*_template.txt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP -<+># -*- coding: utf-8 -*-\r\n\r\n\"\"\"\r\n$Name $Description\r\n~~~~~~~~~~~~~~~~~~~\r\n\r\n$LongDescription\r\n\r\n:copyright: (c) $CopyrightDate $CopyrightName\r\n:license: $LicenseName$LicenseDescription\r\n\r\n\"\"\"\r\n\r\n__title__ = '$Title'\r\n__author__ = '$Author'\r\n__license__ = '$LicenseName'\r\n__copyright__ = 'Copyright (c) $CopyrightDate $CopyrightName'\r\n__version__ = '$Version'\r\n\r\nfrom collections import namedtuple\r\n\r\n$Imports\r\n\r\nVersionInfo = namedtuple('VersionInfo', 'major minor micro')\r\nversion_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro)\r\n -=================================================================== ---- publish_templates/*_template.txt (revision 9dbad20e9714ffa1546bb2d1b2f8b5ea8e854369) -+++ publish_templates/all_template.txt (date 1606383191684) -@@ -22,4 +22,4 @@ - $Imports - - VersionInfo = namedtuple('VersionInfo', 'major minor micro') --version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro) -+version_info = VersionInfo(major=$Major, minor=$Minor, micro=$Micro) -\ No newline at end of file diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml deleted file mode 100644 index 49edc74a..00000000 --- a/.idea/shelf/Uncommitted_changes_before_Update_at_26_11_2020_10_36__Default_Changelist_.xml +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file