Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | registry_path |
subroutine load_registry_from_path(registry_path) character(len=*), intent(in) :: registry_path integer :: unit, iostat character(len=512) :: line character(len=128) :: current_package logical :: in_package n_packages = 0 if (allocated(packages)) deallocate (packages) allocate (packages(10)) ! Start with space for 10 packages open (newunit=unit, file=registry_path, status='old', iostat=iostat) if (iostat /= 0) then print *, 'Warning: Cannot open registry at ', trim(registry_path) return end if in_package = .false. current_package = '' do read (unit, '(a)', iostat=iostat) line if (iostat /= 0) exit line = adjustl(line) ! Skip empty lines and comments if (len_trim(line) == 0) cycle if (line(1:1) == '#') cycle ! Check for package section if (line(1:10) == '[packages.') then ! Extract package name n_packages = n_packages + 1 current_package = extract_between(line, '[packages.', ']') packages(n_packages)%name = current_package packages(n_packages)%git_url = '' packages(n_packages)%prefix = '' packages(n_packages)%version = '' in_package = .true. else if (in_package) then ! Parse package properties if (index(line, 'git =') > 0) then packages(n_packages)%git_url = extract_quoted(line) else if (index(line, 'prefix =') > 0) then packages(n_packages)%prefix = extract_quoted(line) else if (index(line, 'version =') > 0) then packages(n_packages)%version = extract_quoted(line) end if end if end do close (unit) end subroutine load_registry_from_path