From 8cdfaacd3c1cf4a1ecb15562934086a5b89a888b Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 11 May 2019 00:40:29 -0400 Subject: Move comment_find in --- delivery_merge/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/delivery_merge/utils.py b/delivery_merge/utils.py index 2f23e0e..705eaf2 100644 --- a/delivery_merge/utils.py +++ b/delivery_merge/utils.py @@ -3,6 +3,21 @@ from contextlib import contextmanager from subprocess import run +def comment_find(s, delims=[';', '#']): + """ Find the first occurence of a comment in a string + + :param s: string + :param delims: list: of comment delimiters + :returns: integer: index of first match + """ + for delim in delims: + index = s.find(delim) + if index != -1: + break + + return index + + def sh(prog, *args): """ Execute a program with arguments :param prog: str: path to program -- cgit