Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ v0.0.3 - 2025-02-24
--------------------

Patch Release of scorecode to fix checks in scorecard data.

v0.0.4 - 2025-07-12
--------------------

Added parsing score date functionality to `PackageScoreMixin`
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# This points to aboutcode.readthedocs.io
# In case of "undefined label" ERRORS check docs on intersphinx to troubleshoot
# Link was created at commit - https://github.com/nexB/aboutcode/commit/faea9fcf3248f8f198844fe34d43833224ac4a83
# Link was created at commit - https://github.com/aboutcode-org/aboutcode/commit/faea9fcf3248f8f198844fe34d43833224ac4a83

intersphinx_mapping = {
"aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None),
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contribute/contrib_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To get started, create or identify a working directory on your local machine.

Open that directory and execute the following command in a terminal session::

git clone https://github.com/nexB/skeleton.git
git clone https://github.com/aboutcode-org/skeleton.git

That will create an ``/skeleton`` directory in your working directory.
Now you can install the dependencies in a virtualenv::
Expand Down
2 changes: 1 addition & 1 deletion docs/source/skeleton-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ corrected. You can check to see if your corrections are valid by running:
Once the wheels are collected and the ABOUT files are generated and correct,
upload them to thirdparty.aboutcode.org/pypi by placing the wheels and ABOUT
files from the thirdparty directory to the pypi directory at
https://github.com/nexB/thirdparty-packages
https://github.com/aboutcode-org/thirdparty-packages


Usage after project initialization
Expand Down
52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[build-system]
requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 6"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
# this is used populated when creating a git archive
# and when there is .git dir and/or there is no git installed
fallback_version = "9999.$Format:%h-%cs$"

[tool.pytest.ini_options]
norecursedirs = [
".git",
"bin",
"dist",
"build",
"_build",
"dist",
"etc",
"local",
"ci",
"docs",
"man",
"share",
"samples",
".cache",
".settings",
"Include",
"include",
"Lib",
"lib",
"lib64",
"Lib64",
"Scripts",
"thirdparty",
"tmp",
"venv",
"tests/data",
".eggs",
"src/*/data",
"tests/*/data"
]

python_files = "*.py"

python_classes = "Test"
python_functions = "test"

addopts = [
"-rfExXw",
"--strict-markers",
"--doctest-modules"
]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = scorecode
version = 0.0.3
version = 0.0.4
license = Apache-2.0
description = A package to fetch data from OpenSSF Scorecard API
long_description = file:README.rst
Expand Down
2 changes: 2 additions & 0 deletions src/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Put your Python source code (and installable data) in this directory.

25 changes: 24 additions & 1 deletion src/scorecode/contrib/django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
# See https://aboutcode.org for more information about nexB OSS projects.
#

from django.core.exceptions import ValidationError

from datetime import datetime

from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _


Expand Down Expand Up @@ -59,6 +62,26 @@ class ScoringTool(models.TextChoices):
help_text=_("Date when the scoring was calculated on the package"),
)

@classmethod
def parse_score_date(cls, date_str, formats=None):
"""
Parse a date string into a timezone-aware datetime object,
or return None if parsing fails.
"""

if not formats:
formats = ["%Y-%m-%d", "%Y-%m-%dT%H:%M:%SZ"]

if date_str:
for fmt in formats:
try:
naive_datetime = datetime.strptime(date_str, fmt)
return timezone.make_aware(naive_datetime, timezone.get_current_timezone())
except ValueError:
continue

return None

class Meta:
abstract = True

Expand Down
2 changes: 1 addition & 1 deletion src/scorecode/ossf_scorecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def is_available():
return response.ok


def fetch_scorecard_info(package, logger):
def fetch_scorecard_info(package, logger=None):
"""
Return scorecard info for a list of discovered packages.
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Put your Python test modules in this directory.

Loading