Skip to content

Commit

Permalink
Merge pull request #48 from kchason/python-3.13
Browse files Browse the repository at this point in the history
Python 3.13 Support
  • Loading branch information
dc3-tsd authored Oct 30, 2024
2 parents 4d43401 + ca120d8 commit 76d3c32
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
# The Python version for the build jobs as well as the primary one for the test and artifact generation. This MUST be
# in the python-version matrix in the `test` job.
PYTHON_VERSION: "3.12"
PYTHON_VERSION: "3.13"
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -16,7 +16,7 @@ jobs:
# This allows the pipeline to be run against multiple Python versions. eg. [3.6, 3.7, 3.8, 3.9, 3.10]. This results
# in linting and unit tests running for all listed versions as well as the creation of packages and wheels on
# creation of a tag in Git.
python-version: [ "3.8", "3.10", "3.12" ]
python-version: [ "3.8", "3.10", "3.12", "3.13" ]

steps:
# Get the code from the repository to be packaged
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ default:
tags:
- docker
- devnet
image: python:3.11
image: python:3.13

stages:
- Lint
Expand All @@ -30,9 +30,9 @@ FlakeLint:
- pip install .
- pip install -q flake8
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- flake8 ./sqlite_dissect/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- flake8 ./sqlite_dissect/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

PyTest:
stage: Test
Expand Down
20 changes: 10 additions & 10 deletions sqlite_dissect/file/schema/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, index, column_text, comments=None):
logger = getLogger(LOGGER_NAME)

self.index = index
self.column_text = sub("\s\s+", " ", column_text.strip())
self.column_text = sub(r"\s\s+", " ", column_text.strip())

"""
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(self, index, column_text, comments=None):
raise MasterSchemaRowParsingError(log_message)

# Update the parsed column text replacing any whitespace with a single " " character and stripping it
parsed_column_text = sub("\s\s+", " ", parsed_column_text.strip())
parsed_column_text = sub(r"\s\s+", " ", parsed_column_text.strip())

# Check the comments sent in for validity
if comments:
Expand Down Expand Up @@ -188,7 +188,7 @@ def __init__(self, index, column_text, comments=None):
# Get the next segment
segment = remaining_column_text[:segment_index + 1]

if (len(segment) == len(remaining_column_text) or match("\w", remaining_column_text[segment_index + 1])) \
if (len(segment) == len(remaining_column_text) or match(r"\w", remaining_column_text[segment_index + 1])) \
and ColumnDefinition._is_column_constraint_preface(segment):

"""
Expand Down Expand Up @@ -222,8 +222,8 @@ def __init__(self, index, column_text, comments=None):
"""

segment = sub("\s*\(\s*", "(", segment)
segment = sub("\s*\)\s*", ")", segment)
segment = sub(r"\s*\(\s*", "(", segment)
segment = sub(r"\s*\)\s*", ")", segment)
segment = segment.strip()

# Convert it to all uppercase for the derived data type name
Expand Down Expand Up @@ -325,7 +325,7 @@ def _get_column_name_and_remaining_sql(index, column_text):
elif column_text[0] == "[":

# The column name is surrounded by brackets
match_object = match("^\[(.*?)\]", column_text)
match_object = match(r"^\[(.*?)\]", column_text)

if not match_object:
log_message = "No bracket match found for sql column definition: {} with text: {}."
Expand Down Expand Up @@ -427,15 +427,15 @@ def _get_data_type(derived_data_type):
derived_data_type = derived_data_type.upper()

# Remove any parenthesis along with numerical values
derived_data_type = sub("\(.*\)$", "", derived_data_type)
derived_data_type = sub(r"\(.*\)$", "", derived_data_type)

# Replace spaces with underscores
derived_data_type = derived_data_type.replace(" ", "_")

for data_type in DATA_TYPE:

# We remove any numerical values from the end since sqlite does not recognize them in the data types
if sub("_\d+.*$", "", data_type) == derived_data_type:
if sub(r"_\d+.*$", "", data_type) == derived_data_type:
return data_type

# If no data type was found we return an invalid data type
Expand Down Expand Up @@ -544,15 +544,15 @@ def _is_column_constraint_preface(segment):
Note: When the check is done on the segment, we check the next character is not one of the allowed
characters in a column name, data type, etc. to make sure the constraint preface is not the
beginning of a longer name where it is not actually a constraint preface (example: primaryEmail).
The "\w" regular expression when no LOCALE and UNICODE flags are set will be equivalent to the set:
The regular expression when no LOCALE and UNICODE flags are set will be equivalent to the set:
[a-zA-Z0-9_].
"""

# Check to see if the segment starts with the column constraint preface
if segment.upper().startswith(column_constraint_preface):
if not (len(column_constraint_preface) + 1 <= len(segment)
and match("\w", segment[len(column_constraint_preface)])):
and match(r"\w", segment[len(column_constraint_preface)])):
return True

return False
Expand Down
2 changes: 1 addition & 1 deletion sqlite_dissect/file/schema/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ class for parsing. This was decided to be the best way to associate comments ba
Note: When the check is done on the definition, we check the next character is not one of the
allowed characters in a column name to make sure the constraint preface is not the
beginning of a longer column name where it is not actually a constraint preface
(example: primaryEmail). The r'\w' regular expression when no LOCALE and UNICODE flags
(example: primaryEmail). The regular expression when no LOCALE and UNICODE flags
are set will be equivalent to the set: [a-zA-Z0-9_].
"""
Expand Down

0 comments on commit 76d3c32

Please sign in to comment.