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

SPF-OST / pytrnsys_gui / 11482354319

23 Oct 2024 02:43PM UTC coverage: 67.591% (+0.7%) from 66.906%
11482354319

push

github

web-flow
Merge pull request #554 from SPF-OST/548-open-recent-projects

expanded on open recent functionality

144 of 197 new or added lines in 8 files covered. (73.1%)

5 existing lines in 2 files now uncovered.

10413 of 15406 relevant lines covered (67.59%)

0.68 hits per line

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

80.65
/trnsysGUI/recentProjectsHandler.py
1
import pathlib as _pl
1✔
2
import typing as _tp
1✔
3
from collections import deque as _deque
1✔
4

5
from trnsysGUI import settings as _settings
1✔
6

7

8
class RecentProjectsHandler:
1✔
9

10
    NUMBER_OF_RECENT_PROJECTS = 15
1✔
11

12
    recentProjects: _tp.Deque[_pl.Path] = _deque(maxlen=NUMBER_OF_RECENT_PROJECTS)
1✔
13

14
    @classmethod
1✔
15
    def initWithExistingRecentProjects(cls):
1✔
16
        """Initialize the deque with recent projects saved in the settings.json"""
17
        cls.recentProjects.clear()
1✔
18
        recentProjectsFromFile = _settings.Settings.load().recentProjects
1✔
19
        cls.recentProjects.extend(_pl.Path(p) for p in recentProjectsFromFile)
1✔
20

21
    @classmethod
1✔
22
    def addProject(cls, projectToAdd: _pl.Path):
1✔
23
        """Add a project to the deque. If it already exists, move it to the most recent."""
24
        if projectToAdd in cls.recentProjects:
1✔
25
            cls.recentProjects.remove(projectToAdd)
1✔
26
        cls.recentProjects.appendleft(projectToAdd)
1✔
27
        cls.save()
1✔
28

29
    @classmethod
1✔
30
    def removeProject(cls, projectToRemove: _pl.Path):
1✔
NEW
31
        cls.recentProjects.remove(projectToRemove)
×
NEW
32
        cls.save()
×
33

34
    @classmethod
1✔
35
    def save(cls):
1✔
NEW
36
        validPathsToSave = _deque([p.as_posix() for p in cls.recentProjects])
×
NEW
37
        settings = _settings.Settings.load()
×
NEW
38
        settings.recentProjects = validPathsToSave
×
NEW
39
        settings.save()
×
40

41
    @classmethod
1✔
42
    def getLengthOfLongestFileName(cls) -> int:
1✔
43
        return max((len(recentProject.stem) for recentProject in cls.recentProjects), default=0)
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