Skip to content

Commit d13752b

Browse files
authored
Changes to use black Python formatter (#308)
1 parent eb69bf4 commit d13752b

58 files changed

Lines changed: 13020 additions & 12106 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Check source.
2+
name: lint
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
permissions: read-all
11+
jobs:
12+
black:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
- name: Check format of Python code
17+
uses: psf/black@stable
18+
with:
19+
options: "--check"
20+
src: "."
21+
pylint:
22+
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
python-version: ['3.14']
26+
container:
27+
image: ubuntu:26.04
28+
steps:
29+
- uses: actions/checkout@v6
30+
- name: Set up container
31+
env:
32+
DEBIAN_FRONTEND: noninteractive
33+
run: |
34+
apt-get update -q
35+
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
36+
locale-gen en_US.UTF-8
37+
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
38+
- name: Install dependencies
39+
env:
40+
DEBIAN_FRONTEND: noninteractive
41+
run: |
42+
add-apt-repository -y universe
43+
add-apt-repository -y ppa:deadsnakes/ppa
44+
add-apt-repository -y ppa:gift/dev
45+
apt-get update -q
46+
apt-get install -y build-essential git pkg-config python${{ matrix.python-version }} python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python3-pip python3-setuptools tox
47+
- name: Run linter
48+
env:
49+
LANG: en_US.UTF-8
50+
run: |
51+
tox -e pylint

.github/workflows/test_tox.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,3 @@ jobs:
8585
uses: codecov/codecov-action@v6
8686
with:
8787
token: ${{ secrets.CODECOV_TOKEN }}
88-
lint:
89-
runs-on: ubuntu-latest
90-
strategy:
91-
matrix:
92-
python-version: ['3.14']
93-
container:
94-
image: ubuntu:26.04
95-
steps:
96-
- uses: actions/checkout@v6
97-
- name: Set up container
98-
env:
99-
DEBIAN_FRONTEND: noninteractive
100-
run: |
101-
apt-get update -q
102-
apt-get install -y libterm-readline-gnu-perl locales software-properties-common
103-
locale-gen en_US.UTF-8
104-
ln -f -s /usr/share/zoneinfo/UTC /etc/localtime
105-
- name: Install dependencies
106-
env:
107-
DEBIAN_FRONTEND: noninteractive
108-
run: |
109-
add-apt-repository -y universe
110-
add-apt-repository -y ppa:deadsnakes/ppa
111-
add-apt-repository -y ppa:gift/dev
112-
apt-get update -q
113-
apt-get install -y build-essential git pkg-config python${{ matrix.python-version }} python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv python3-pip python3-setuptools tox
114-
- name: Run linter
115-
env:
116-
LANG: en_US.UTF-8
117-
run: |
118-
tox -e lint

.pylintrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,11 @@ indent-after-paren=4
358358

359359
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
360360
# tab).
361-
# indent-string=' '
362-
indent-string=' '
361+
indent-string=' '
363362

364363
# Maximum number of characters on a single line.
365364
# max-line-length=100
366-
max-line-length=80
365+
max-line-length=88
367366

368367
# Maximum number of lines in a module.
369368
max-module-lines=1000
@@ -599,7 +598,7 @@ spelling-store-unknown-words=no
599598

600599
# This flag controls whether inconsistent-quotes generates a warning when the
601600
# character used as a quote delimiter is used inconsistently within a module.
602-
check-quote-consistency=no
601+
check-quote-consistency=yes
603602

604603
# This flag controls whether the implicit-str-concat should generate a warning
605604
# on implicit string concatenation in sequences defined over several lines.

dfdatetime/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@
2323
from dfdatetime import uuid_time
2424
from dfdatetime import webkit_time
2525

26-
27-
__version__ = '20260513'
26+
__version__ = "20260513"

dfdatetime/apfs_time.py

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,69 +8,79 @@
88

99

1010
class APFSTime(posix_time.PosixTimeInNanoseconds):
11-
"""Apple File System (APFS) timestamp.
11+
"""Apple File System (APFS) timestamp.
1212
13-
The APFS timestamp is a signed 64-bit integer that contains the number of
14-
nanoseconds since 1970-01-01 00:00:00.
13+
The APFS timestamp is a signed 64-bit integer that contains the number of
14+
nanoseconds since 1970-01-01 00:00:00.
1515
16-
Attributes:
17-
is_local_time (bool): True if the date and time value is in local time.
18-
"""
19-
20-
def _GetNormalizedTimestamp(self):
21-
"""Retrieves the normalized timestamp.
22-
23-
Returns:
24-
decimal.Decimal: normalized timestamp, which contains the number of
25-
seconds since January 1, 1970 00:00:00 and a fraction of second used
26-
for increased precision, or None if the normalized timestamp cannot be
27-
determined.
28-
"""
29-
if self._normalized_timestamp is None:
30-
if (self._timestamp is not None and self._timestamp >= self._INT64_MIN and
31-
self._timestamp <= self._INT64_MAX):
32-
self._normalized_timestamp = (
33-
decimal.Decimal(self._timestamp) /
34-
definitions.NANOSECONDS_PER_SECOND)
35-
36-
if self._time_zone_offset:
37-
self._normalized_timestamp -= self._time_zone_offset * 60
38-
39-
return self._normalized_timestamp
40-
41-
def CopyFromDateTimeString(self, time_string):
42-
"""Copies a APFS timestamp from a date and time string.
43-
44-
Args:
45-
time_string (str): date and time value formatted as:
46-
YYYY-MM-DD hh:mm:ss.######[+-]##:##
47-
48-
Where # are numeric digits ranging from 0 to 9 and the seconds
49-
fraction can be either 3, 6 or 9 digits. The time of day, seconds
50-
fraction and time zone offset are optional. The default time zone
51-
is UTC.
52-
53-
Raises:
54-
ValueError: if the date and time value is not supported.
55-
"""
56-
super()._CopyFromDateTimeString(time_string)
57-
58-
if (self._timestamp is None or self._timestamp < self._INT64_MIN or
59-
self._timestamp > self._INT64_MAX):
60-
raise ValueError('Date time value not supported.')
61-
62-
def CopyToDateTimeString(self):
63-
"""Copies the APFS timestamp to a date and time string.
64-
65-
Returns:
66-
str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss.#########" or
67-
None if the timestamp is missing or invalid.
16+
Attributes:
17+
is_local_time (bool): True if the date and time value is in local time.
6818
"""
69-
if (self._timestamp is None or self._timestamp < self._INT64_MIN or
70-
self._timestamp > self._INT64_MAX):
71-
return None
7219

73-
return super()._CopyToDateTimeString()
20+
def _GetNormalizedTimestamp(self):
21+
"""Retrieves the normalized timestamp.
22+
23+
Returns:
24+
decimal.Decimal: normalized timestamp, which contains the number of
25+
seconds since January 1, 1970 00:00:00 and a fraction of second used
26+
for increased precision, or None if the normalized timestamp cannot be
27+
determined.
28+
"""
29+
if self._normalized_timestamp is None:
30+
if (
31+
self._timestamp is not None
32+
and self._timestamp >= self._INT64_MIN
33+
and self._timestamp <= self._INT64_MAX
34+
):
35+
self._normalized_timestamp = (
36+
decimal.Decimal(self._timestamp)
37+
/ definitions.NANOSECONDS_PER_SECOND
38+
)
39+
40+
if self._time_zone_offset:
41+
self._normalized_timestamp -= self._time_zone_offset * 60
42+
43+
return self._normalized_timestamp
44+
45+
def CopyFromDateTimeString(self, time_string):
46+
"""Copies a APFS timestamp from a date and time string.
47+
48+
Args:
49+
time_string (str): date and time value formatted as:
50+
YYYY-MM-DD hh:mm:ss.######[+-]##:##
51+
52+
Where # are numeric digits ranging from 0 to 9 and the seconds
53+
fraction can be either 3, 6 or 9 digits. The time of day, seconds
54+
fraction and time zone offset are optional. The default time zone
55+
is UTC.
56+
57+
Raises:
58+
ValueError: if the date and time value is not supported.
59+
"""
60+
super()._CopyFromDateTimeString(time_string)
61+
62+
if (
63+
self._timestamp is None
64+
or self._timestamp < self._INT64_MIN
65+
or self._timestamp > self._INT64_MAX
66+
):
67+
raise ValueError("Date time value not supported.")
68+
69+
def CopyToDateTimeString(self):
70+
"""Copies the APFS timestamp to a date and time string.
71+
72+
Returns:
73+
str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss.#########" or
74+
None if the timestamp is missing or invalid.
75+
"""
76+
if (
77+
self._timestamp is None
78+
or self._timestamp < self._INT64_MIN
79+
or self._timestamp > self._INT64_MAX
80+
):
81+
return None
82+
83+
return super()._CopyToDateTimeString()
7484

7585

7686
factory.Factory.RegisterDateTimeValues(APFSTime)

0 commit comments

Comments
 (0)