• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

msiemens / PyGitUp / 11195840649

05 Oct 2024 07:42PM UTC coverage: 93.035% (+0.6%) from 92.424%
11195840649

push

github

msiemens
chore: drop Python 3.7 support

374 of 402 relevant lines covered (93.03%)

5.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/PyGitUp/utils.py
1
"""
2
Some simple, generic useful methods.
3
"""
4
import subprocess
6✔
5
import sys
6✔
6

7
from subprocess import DEVNULL
6✔
8

9

10
def find(seq, test):
6✔
11
    """ Return first item in sequence where test(item) == True """
12
    for item in seq:
6✔
13
        if test(item):
6✔
14
            return item
6✔
15

16

17
def uniq(seq):
6✔
18
    """ Return a copy of seq without duplicates. """
19
    seen = set()
6✔
20
    return [x for x in seq if str(x) not in seen and not seen.add(str(x))]
6✔
21

22

23
def execute(cmd, cwd=None):
6✔
24
    """ Execute a command and return it's output. """
25
    try:
6✔
26
        lines = subprocess \
6✔
27
            .check_output(cmd, cwd=cwd, stderr=DEVNULL) \
28
            .splitlines()
29
    except subprocess.CalledProcessError:
6✔
30
        return None
6✔
31
    else:
32
        if lines:
6✔
33
            return decode(lines[0].strip())
6✔
34
        else:
35
            return None
×
36

37

38
def decode(s):
6✔
39
    """
40
    Decode a string using the system encoding if needed (ie byte strings)
41
    """
42
    if isinstance(s, bytes):
6✔
43
        return s.decode(sys.getdefaultencoding())
6✔
44
    else:
45
        return s
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc