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

thht / plus_sync / 212

04 May 2026 07:00AM UTC coverage: 64.842% (-27.2%) from 92.008%
212

Pull #32

gitlab-ci

update deps
Pull Request #32: update deps

616 of 950 relevant lines covered (64.84%)

0.65 hits per line

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

38.1
/src/plus_sync/hashing.py
1
import hashlib
×
2
import re
×
3

4
from attrs import define
×
5

6
import plus_sync.config
×
7

8

9
@define(kw_only=True)
×
10
class SubjectIDHasher:
×
11
    subject_id_regex: str = r'[12][0-9]{7}[a-zA-Z]{4}'
×
12
    project_name: str
13

14
    @classmethod
×
15
    def from_config(cls, config: 'plus_sync.config.Config') -> 'SubjectIDHasher':
×
16
        return cls(subject_id_regex=config.subject_id_regex, project_name=config.project_name)
1✔
17

18
    @classmethod
×
19
    def from_cmdargs(cls) -> 'SubjectIDHasher':
×
20
        config = plus_sync.config.Config.from_cmdargs()
1✔
21

22
        return cls.from_config(config)
1✔
23

24
    def hash_subject_id(self, subject_id: str) -> str:
×
25
        h = hashlib.sha256()
1✔
26
        h.update(subject_id.encode())
1✔
27
        h.update(self.project_name.encode())
1✔
28

29
        return h.hexdigest()[:12]
1✔
30

31
    def replace_subject_ids(self, text: str) -> str:
×
32
        return re.sub(self.subject_id_regex, lambda x: self.hash_subject_id(x.group()), text)
1✔
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