From d1a90d894e74fc79d02b281d7287f0e6abb2804c Mon Sep 17 00:00:00 2001 From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org> Date: Wed, 31 May 2023 21:50:21 +0200 Subject: [PATCH] Adding dockerfile for pandocfilter image --- .gitlab-ci.yml | 16 +++++++++++++++- pandocFilter/dockerfile | 7 +++++++ pandocFilter/pandocFilter.py | 11 ++++++----- pandocFilter/setup.py | 6 +++++- 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 pandocFilter/dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7794a27..c61060c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,12 +8,26 @@ workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_TAG + - if: $CI_PIPELINE_SOURCE == "push" variables: stages: - generation - publication + - build + +Build pythonForPandocFilter docker image: + stage: build + before_script: cd pandocFilter + script: docker build --tag pandocFilter:latest -f dockerfile . + rules: + - if: $CI_PIPELINE_SOURCE == "push" + changes: + - pandocFilter/dockerfile + - pandocFilter/setup.py + - pandocFilter/requirements.txt + Word CR text: stage: generation @@ -44,7 +58,7 @@ Publish spec: - tags before_script: - | - curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=publication" >> publish_spec.sh + curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_spec%2Esh/raw?ref=master" >> publish_spec.sh - chmod +x publish_spec.sh #- | # curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/onem2m_spec_template%2Edocx/raw?ref=master" >> onem2m_coversheet_template.docx diff --git a/pandocFilter/dockerfile b/pandocFilter/dockerfile new file mode 100644 index 0000000..7f39a11 --- /dev/null +++ b/pandocFilter/dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9-slim-bullseye + +ADD . /pandocFilter/ +RUN apt-get update -y && \ + rm -rf /var/lib/apt/lists/* &&\ + pip install -e pandocFilter/ &&\ + pip install -r pandocFilter/requirements.txt diff --git a/pandocFilter/pandocFilter.py b/pandocFilter/pandocFilter.py index 65c65e7..c8e3032 100644 --- a/pandocFilter/pandocFilter.py +++ b/pandocFilter/pandocFilter.py @@ -86,8 +86,8 @@ def replaceTableCaptions(progress:Progress, mdLines:list[str]) -> list[str]: _idx = len(_lines) - 1 while _idx >= 0 and _lines[_idx].startswith('|'): _idx -= 1 - if _idx > 0: - _lines.insert(_idx+1, f'Table: {matches[0]}\n') + #if _idx > 0: + # _lines.insert(_idx+1, f'Table: {matches[0]}\n') _lines.insert(_idx+1, f'Table: {matches[0]}\n') else: _lines.append(line) @@ -104,9 +104,7 @@ def process(document:str, outDirectory:str) -> None: mdLines = replaceTableCaptions(progress, mdLines) writeMDFile(progress, mdLines, document, outDirectory) - - -if __name__ == '__main__': +def main(args=None): # Parse command line arguments parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--outdir', '-o', action='store', dest='outDirectory', default = 'out', metavar = '<output directory>', help = 'specify output directory') @@ -117,3 +115,6 @@ if __name__ == '__main__': os.makedirs(args.outDirectory, exist_ok = True) process(args.document, args.outDirectory) + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file diff --git a/pandocFilter/setup.py b/pandocFilter/setup.py index 589119e..7d47e52 100644 --- a/pandocFilter/setup.py +++ b/pandocFilter/setup.py @@ -9,5 +9,9 @@ setup( packages=find_packages(), install_requires=[ 'rich', - ] + ], + entry_points= { + 'console_scripts' : ['pandocFilter=pandocFilter:main'] + } + ) -- GitLab