Skip to content

Commit 6f6bc91

Browse files
authored
Merge pull request #9 from aboutcode-org/patch-release@v0.0.4
Update PackageScoreMixin with score date parsing
2 parents d80aa38 + cacea52 commit 6f6bc91

File tree

10 files changed

+90
-6
lines changed

10 files changed

+90
-6
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ v0.0.3 - 2025-02-24
2424
--------------------
2525

2626
Patch Release of scorecode to fix checks in scorecard data.
27+
28+
v0.0.4 - 2025-07-12
29+
--------------------
30+
31+
Added parsing score date functionality to `PackageScoreMixin`

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

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

4848
intersphinx_mapping = {
4949
"aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None),

docs/source/contribute/contrib_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To get started, create or identify a working directory on your local machine.
1212

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

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

1717
That will create an ``/skeleton`` directory in your working directory.
1818
Now you can install the dependencies in a virtualenv::

docs/source/skeleton-usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ corrected. You can check to see if your corrections are valid by running:
118118
Once the wheels are collected and the ABOUT files are generated and correct,
119119
upload them to thirdparty.aboutcode.org/pypi by placing the wheels and ABOUT
120120
files from the thirdparty directory to the pypi directory at
121-
https://github.com/nexB/thirdparty-packages
121+
https://github.com/aboutcode-org/thirdparty-packages
122122

123123

124124
Usage after project initialization

pyproject.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[build-system]
2+
requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 6"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
# this is used populated when creating a git archive
7+
# and when there is .git dir and/or there is no git installed
8+
fallback_version = "9999.$Format:%h-%cs$"
9+
10+
[tool.pytest.ini_options]
11+
norecursedirs = [
12+
".git",
13+
"bin",
14+
"dist",
15+
"build",
16+
"_build",
17+
"dist",
18+
"etc",
19+
"local",
20+
"ci",
21+
"docs",
22+
"man",
23+
"share",
24+
"samples",
25+
".cache",
26+
".settings",
27+
"Include",
28+
"include",
29+
"Lib",
30+
"lib",
31+
"lib64",
32+
"Lib64",
33+
"Scripts",
34+
"thirdparty",
35+
"tmp",
36+
"venv",
37+
"tests/data",
38+
".eggs",
39+
"src/*/data",
40+
"tests/*/data"
41+
]
42+
43+
python_files = "*.py"
44+
45+
python_classes = "Test"
46+
python_functions = "test"
47+
48+
addopts = [
49+
"-rfExXw",
50+
"--strict-markers",
51+
"--doctest-modules"
52+
]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = scorecode
3-
version = 0.0.3
3+
version = 0.0.4
44
license = Apache-2.0
55
description = A package to fetch data from OpenSSF Scorecard API
66
long_description = file:README.rst

src/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Put your Python source code (and installable data) in this directory.
2+

src/scorecode/contrib/django/models.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
# See https://aboutcode.org for more information about nexB OSS projects.
77
#
88

9-
from django.core.exceptions import ValidationError
9+
10+
from datetime import datetime
11+
1012
from django.db import models
13+
from django.utils import timezone
1114
from django.utils.translation import gettext_lazy as _
1215

1316

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

65+
@classmethod
66+
def parse_score_date(cls, date_str, formats=None):
67+
"""
68+
Parse a date string into a timezone-aware datetime object,
69+
or return None if parsing fails.
70+
"""
71+
72+
if not formats:
73+
formats = ["%Y-%m-%d", "%Y-%m-%dT%H:%M:%SZ"]
74+
75+
if date_str:
76+
for fmt in formats:
77+
try:
78+
naive_datetime = datetime.strptime(date_str, fmt)
79+
return timezone.make_aware(naive_datetime, timezone.get_current_timezone())
80+
except ValueError:
81+
continue
82+
83+
return None
84+
6285
class Meta:
6386
abstract = True
6487

src/scorecode/ossf_scorecard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def is_available():
4747
return response.ok
4848

4949

50-
def fetch_scorecard_info(package, logger):
50+
def fetch_scorecard_info(package, logger=None):
5151
"""
5252
Return scorecard info for a list of discovered packages.
5353
"""

tests/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Put your Python test modules in this directory.
2+

0 commit comments

Comments
 (0)