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

msiemens / PyGitUp / 11213045688

05 Oct 2024 07:59PM UTC coverage: 93.284%. Remained the same
11213045688

push

github

msiemens
chore: release v2.3.0

375 of 402 relevant lines covered (93.28%)

13.79 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
15✔
5
import sys
15✔
6

7
from subprocess import DEVNULL
15✔
8

9

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

16

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

22

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

37

38
def decode(s):
15✔
39
    """
40
    Decode a string using the system encoding if needed (ie byte strings)
41
    """
42
    if isinstance(s, bytes):
15✔
43
        return s.decode(sys.getdefaultencoding())
15✔
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

© 2025 Coveralls, Inc