emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/repology 5f496f3 2/9: Rename `repology-free-p' to `repo


From: Nicolas Goaziou
Subject: [elpa] externals/repology 5f496f3 2/9: Rename `repology-free-p' to `repology-check-freedom'
Date: Mon, 18 Jan 2021 17:27:52 -0500 (EST)

branch: externals/repology
commit 5f496f396fd45ad54508761e6805f6ec4dbd82e3
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>

    Rename `repology-free-p' to `repology-check-freedom'
    
    * repology-license.el (repology-check-freedom): Renamed from
    `repology-free-p'.  It can now return three different values.
    * repology.el (repology-search-projects): Apply renaming and change of
    return value.
    (repology--check-freedom): Apply renaming.
---
 repology-license.el | 37 +++++++++++++++++++------------------
 repology.el         | 16 +++++++---------
 2 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/repology-license.el b/repology-license.el
index 2182e1c..6705edf 100644
--- a/repology-license.el
+++ b/repology-license.el
@@ -17,17 +17,17 @@
 
 ;;; Commentary:
 
-;; This library provides the `repology-free-p' function, which returns
-;; a non-nil value when a package or a project can be considered as
-;; free.
+;; This library provides the `repology-check-freedom' function, which returns
+;; t when a package or a project can be considered as free, nil it is
+;; identified as being non-free, and `unknown' otherwise.
 
-;; The decision is made by polling a number of "Reference
-;; repositories", defined in `repology-license-reference-repositories'.
-;; If the ratio of "Free" votes is equal or above
-;; `repology-license-poll-threshold', the project is declared as free.
+;; The decision is made by polling a number of "Reference repositories",
+;; defined in `repology-license-reference-repositories'.  If the ratio of
+;; "Free" votes is above `repology-license-poll-threshold', the project is
+;; declared as free.
 
-;; In order to see the results of each vote, and possibly debug the
-;; process, you can set `repology-license-debug' to a non-nil value.
+;; In order to see the results of each vote, and possibly debug the process,
+;; you can set `repology-license-debug' to a non-nil value.
 
 ;;; Code:
 
@@ -94,10 +94,11 @@ properties:
 
 ;;; Tools
 (defun repology--license-interpret-vote (free votes)
-  "Return freedom vote result as a boolean.
+  "Return freedom vote result as nil, t or `unknown'.
 FREE is the number of \"Free\" votes.  VOTES is the total number of votes."
-  (and (> votes 0)
-       (> (/ (float free) votes) repology-license-poll-threshold)))
+  (cond ((= votes 0) 'unknown)
+        ((> (/ (float free) votes) repology-license-poll-threshold) t)
+        (t nil)))
 
 
 ;;; Reference Repository: Fedora
@@ -300,7 +301,7 @@ PACKAGE is a package object."
     (`(,_ ,_ ,boolean) boolean)
     (other (error "Wrong repository definition: %S" other))))
 
-(defun repology-free-p (datum)
+(defun repology-check-freedom (datum)
   "Return t when project or package DATUM is free.
 
 A package is free when any reference repository can attest it uses only free
@@ -309,10 +310,10 @@ repositories.  If the package does not belong to any of 
these repositories,
 or if there is not enough information to decide, return `unknown'.  Otherwise,
 return nil.
 
-A project is free if the ratio of free packages among the packages from
-reference repositories is above `repology-license-poll-threshold'.
-In any other case, return nil.  In particular, a project without any package
-from reference repositories is declared non-free.
+A project is free if the ratio of free packages among the packages in project
+from reference repositories is above `repology-license-poll-threshold'.
+If the project does not contain any package from such repositories, or if those
+repositories cannot decide, return `unknown'.  In any other case, return nil.
 
 Of course, it is not a legal statement, merely an indication."
   (pcase datum
@@ -332,10 +333,10 @@ Of course, it is not a legal statement, merely an 
indication."
            ('nil nil)
            (repository
             (unless (member repository voters)
-              (cl-incf votes)
               (push repository voters)  ;a repository votes only once
               (let ((free (repology--license-vote repository package)))
                 (when (booleanp free)   ;has repository an opinion?
+                  (cl-incf votes)
                   (when free (cl-incf yes))
                   (when repology-license-debug
                     (push (repology--license-debug-line package free)
diff --git a/repology.el b/repology.el
index ba39bfc..d2156e0 100644
--- a/repology.el
+++ b/repology.el
@@ -36,8 +36,8 @@
 ;;
 ;; By default, only projects recognized as free are included in the search
 ;; results.  You can control this behavior with the variable
-;; `repology-free-only-projects'.  The function `repology-free-p' is 
responsible
-;; for guessing if a project, or a package, is free or not.
+;; `repology-free-only-projects'.  The function `repology-check-freedom'
+;; is responsible for guessing if a project, or a package, is free.
 
 ;; You can then access data from those various objects using dedicated
 ;; accessors.  See, for example, `repology-project-name',
@@ -154,7 +154,7 @@ A value of 0 prevents any caching."
 
 Declaring a project as free the consequence of a very conservative process.
 Free projects with missing licensing information, or too confidential, may be
-ignored.  See `repology-free-p' for more information."
+ignored.  See `repology-check-freedom' for more information."
   :type 'boolean)
 
 (defcustom repology-status-faces
@@ -845,11 +845,9 @@ from output, unless `repology-free-only-projects' is nil."
                       (`(,(and (pred repology-project-p) project))
                        (concat (repology-project-name project) "-"))
                       (other (error "Invalid request result: %S" 
other))))))))))
-    ;; Possibly keep only free projects.
-    (if repology-free-only-projects
-        (with-temp-message "Repology: Filtering out non-free projects..."
-          (seq-filter #'repology-free-p result))
-      result)))
+    (if (not repology-free-only-projects) result
+      (with-temp-message "Repology: Filtering out non-free projects..."
+        (seq-filter (lambda (p) (eq t (repology-check-freedom p))) result)))))
 
 (defun repology-report-problems (repository)
   "List problems related to REPOSITORY.
@@ -888,7 +886,7 @@ REPOSITORY is a string.  Return a list of problems."
   "Check if package or project at point is free."
   (interactive)
   (message "Freedom status: %s"
-           (pcase (repology-free-p (tabulated-list-get-id))
+           (pcase (repology-check-freedom (tabulated-list-get-id))
              ('unknown (propertize "Unknown" 'face 'shadow))
              ('nil (propertize "Non-Free" 'face 'warning))
              (_ (propertize "Free" 'face 'highlight)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]