diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-11 00:40:29 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-05-11 00:40:29 -0400 | 
| commit | 8cdfaacd3c1cf4a1ecb15562934086a5b89a888b (patch) | |
| tree | bac42930a6407b064f76f18c57399a89bf370bb6 | |
| parent | c3e27b17abc58e0b64d8863faa3e91a88f810d6e (diff) | |
| download | delivery_merge-8cdfaacd3c1cf4a1ecb15562934086a5b89a888b.tar.gz | |
Move comment_find in
| -rw-r--r-- | delivery_merge/utils.py | 15 | 
1 files changed, 15 insertions, 0 deletions
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  | 
