|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +# |
| 3 | +# http://nexb.com and https://github.com/aboutcode-org/scancode.io |
| 4 | +# The ScanCode.io software is licensed under the Apache License version 2.0. |
| 5 | +# Data generated with ScanCode.io is provided as-is without warranties. |
| 6 | +# ScanCode is a trademark of nexB Inc. |
| 7 | +# |
| 8 | +# You may not use this software except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 |
| 10 | +# Unless required by applicable law or agreed to in writing, software distributed |
| 11 | +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 12 | +# CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 13 | +# specific language governing permissions and limitations under the License. |
| 14 | +# |
| 15 | +# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 16 | +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from |
| 17 | +# ScanCode.io should be considered or used as legal advice. Consult an Attorney |
| 18 | +# for any legal advice. |
| 19 | +# |
| 20 | +# ScanCode.io is a free software code scanning tool from nexB Inc. and others. |
| 21 | +# Visit https://github.com/aboutcode-org/scancode.io for support and download. |
| 22 | + |
| 23 | +import os |
| 24 | +from scanpipe.pipelines import Pipeline |
| 25 | +from scanpipe.pipes import federatedcode |
| 26 | + |
| 27 | +from minecode_pipelines.miners.cran import get_cran_db |
| 28 | +from minecode_pipelines.pipes import cran |
| 29 | + |
| 30 | +FEDERATEDCODE_CRAN_GIT_URL = os.environ.get( |
| 31 | + "FEDERATEDCODE_CRAN_GIT_URL", "" |
| 32 | +) |
| 33 | + |
| 34 | + |
| 35 | +class MineandPublishCRANPURLs(Pipeline): |
| 36 | + """ |
| 37 | + Mine all packageURLs from a CRAN R index and publish them to a FederatedCode repo. |
| 38 | + """ |
| 39 | + |
| 40 | + @classmethod |
| 41 | + def steps(cls): |
| 42 | + return ( |
| 43 | + cls.check_federatedcode_eligibility, |
| 44 | + cls.setup_federatedcode_cran, |
| 45 | + cls.mine_and_publish_cran_packageurls, |
| 46 | + ) |
| 47 | + |
| 48 | + def check_federatedcode_eligibility(self): |
| 49 | + """ |
| 50 | + Check if the project fulfills the following criteria for |
| 51 | + pushing the project result to FederatedCode. |
| 52 | + """ |
| 53 | + federatedcode.check_federatedcode_configured_and_available() |
| 54 | + |
| 55 | + def setup_federatedcode_cran(self): |
| 56 | + """ |
| 57 | + Clone the FederatedCode CRAN repository and download the CRAN DB JSON file. |
| 58 | + """ |
| 59 | + self.fed_repo = federatedcode.clone_repository(repo_url=FEDERATEDCODE_CRAN_GIT_URL) |
| 60 | + self.db_path = get_cran_db() |
| 61 | + |
| 62 | + def mine_and_publish_cran_packageurls(self): |
| 63 | + """Get cran packageURLs for all mined cran package names.""" |
| 64 | + cran.mine_and_publish_cran_packageurls(fed_repo=self.fed_repo, db_path=self.db_path) |
0 commit comments