From 63d3e889e5e7f2a77e909002cb10e9243a0e61f7 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 8 Jul 2019 16:34:15 +0700 Subject: [PATCH] :hammer: improve min_requirements template Discard extra requirements when a dependency contains multiple constraints with a comma. Refactor also to simplify and improve style. Closes https://github.com/moremoban/pypi-mobans/issues/88 --- templates/min_requirements.txt.jj2 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/templates/min_requirements.txt.jj2 b/templates/min_requirements.txt.jj2 index 773961b..35e112e 100644 --- a/templates/min_requirements.txt.jj2 +++ b/templates/min_requirements.txt.jj2 @@ -1,7 +1,14 @@ {% for dependency in dependencies: %} -{% if ';' in dependency: %} -{{dependency.split(';')[0].replace('>=', '==').replace('>', '==') + ';' + dependency.split(';')[1]}} -{% else: %} -{{dependency.replace('>=', '==').replace('>', '==')}} -{% endif %} +{% if ';' in dependency %} +{% set dependency, marker = dependency.split(';') %} +{% else %} +{% set marker = None %} +{% endif %} +{% set dependency = dependency.split(',')[0] %} +{% set dependency = dependency.replace('>=', '==').replace('>', '==') %} +{% if marker %} +{{dependency + ';' + marker }} +{% else: %} +{{dependency}} +{% endif %} {% endfor %}