Coverage for sources/emcdproj/website/locations.py: 91%

21 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-14 22:01 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Publication filesystem locations. ''' 

22 

23 

24from . import __ 

25 

26 

27class Locations( __.immut.DataclassObject ): 

28 ''' Locations associated with website maintenance. ''' 

29 

30 project: __.Path 

31 auxiliary: __.Path 

32 publications: __.Path 

33 archive: __.Path 

34 artifacts: __.Path 

35 website: __.Path 

36 coverage: __.Path 

37 index: __.Path 

38 versions: __.Path 

39 templates: __.Path 

40 

41 @classmethod 

42 def from_project_anchor( 

43 selfclass, 

44 auxdata: __.Globals, 

45 anchor: __.Absential[ __.Path ] = __.absent, 

46 ) -> __.typx.Self: 

47 ''' Produces locations from project anchor, if provided. 

48 

49 If project anchor is not given, then attempt to discover it. 

50 ''' 

51 if __.is_absent( anchor ): 51 ↛ 54line 51 didn't jump to line 54 because the condition on line 51 was never true

52 # TODO: Discover missing anchor via directory traversal, 

53 # seeking VCS markers. 

54 project = __.Path( ).resolve( strict = True ) 

55 else: project = anchor.resolve( strict = True ) 

56 auxiliary = project / '.auxiliary' 

57 publications = auxiliary / 'publications' 

58 templates = auxdata.distribution.provide_data_location( 'templates' ) 

59 return selfclass( 

60 project = project, 

61 auxiliary = auxiliary, 

62 publications = publications, 

63 archive = publications / 'website.tar.xz', 

64 artifacts = auxiliary / 'artifacts', 

65 website = auxiliary / 'artifacts/website', 

66 coverage = auxiliary / 'artifacts/website/coverage.svg', 

67 index = auxiliary / 'artifacts/website/index.html', 

68 versions = auxiliary / 'artifacts/website/versions.json', 

69 templates = templates )