From b31c0dd23cfc4ae65805fec64c144460a02b519a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 Nov 2020 00:10:52 +0100 Subject: [PATCH] Fixed publisher publish relative path error --- src/sh_edraft/__init__.py | 4 ++-- src/sh_edraft/publish/publisher.py | 12 ++++++++++-- src/tests/__init__.py | 25 +++++++++++++++++++++++++ src/{test.py => tests/publisher.py} | 12 ++++++------ 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 src/tests/__init__.py rename src/{test.py => tests/publisher.py} (76%) diff --git a/src/sh_edraft/__init__.py b/src/sh_edraft/__init__.py index 58fb4bac..d64c519d 100644 --- a/src/sh_edraft/__init__.py +++ b/src/sh_edraft/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ -sh_edraft common python library +sh_edraft ~~~~~~~~~~~~~~~~~~~ -Library to share common classes and models used at sh-edraft.de + :copyright: (c) 2020 sh-edraft.de :license: MIT, see LICENSE for more details. diff --git a/src/sh_edraft/publish/publisher.py b/src/sh_edraft/publish/publisher.py index 75c90ce4..f7e5dc7c 100644 --- a/src/sh_edraft/publish/publisher.py +++ b/src/sh_edraft/publish/publisher.py @@ -153,10 +153,18 @@ class Publisher(PublisherBase): dist_path = dist_path[:len(dist_path) - 1] for file in self._included_files: - if file not in self._excluded_files: + is_file_excluded = False + if file in self._excluded_files: + is_file_excluded = True + else: + for excluded in self._excluded_files: + if file.__contains__(excluded): + is_file_excluded = True + + if not is_file_excluded: output_file = '' if file.startswith('..'): - output_file = file.replace('..', '', 1) + output_file = file.replace('..', '') elif file.startswith('.'): output_file = file.replace('.', '', 1) diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 00000000..ce54614e --- /dev/null +++ b/src/tests/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +tests +~~~~~~~~~~~~~~~~~~~ + + + +:copyright: (c) 2020 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'tests' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2020 sh-edraft.de' +__version__ = '2020.12.0.1' + +from collections import namedtuple + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major=2020, minor=12, micro=0.1) diff --git a/src/test.py b/src/tests/publisher.py similarity index 76% rename from src/test.py rename to src/tests/publisher.py index 6bc8e8d0..b12719fc 100644 --- a/src/test.py +++ b/src/tests/publisher.py @@ -5,7 +5,7 @@ from sh_edraft.publish.model import Template if __name__ == '__main__': templates = [ Template( - '../publish_templates/*_template.txt', + '../../publish_templates/*_template.txt', '*', '', '', @@ -18,7 +18,7 @@ if __name__ == '__main__': Version(2020, 12, 0.1).to_dict() ), Template( - '../publish_templates/*_template.txt', + '../../publish_templates/*_template.txt', 'sh_edraft', 'common python library', 'Library to share common classes and models used at sh-edraft.de', @@ -32,11 +32,11 @@ if __name__ == '__main__': ) ] - publisher = Publisher('./', '../dist', templates) + publisher = Publisher('../', '../../dist', templates) - publisher.exclude('./test.py') - publisher.include('../LICENSE') - publisher.include('../README.md') + publisher.exclude('../tests/') + publisher.include('../../LICENSE') + publisher.include('../../README.md') publisher.create() publisher.publish()