-
Notifications
You must be signed in to change notification settings - Fork 4
add additional python versions to repo #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9c2da72
76cadf0
182aea6
2f82ab2
c65a9cb
5c211c6
5eb1943
735da53
dc75615
7410c4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,8 @@ SQLDIFF := $(shell command -v sqldiff 2> /dev/null) | |
| UNAME := $(shell uname) | ||
|
|
||
| ifeq ($(UNAME),Darwin) | ||
| SPATIAL := $(shell ls /usr/local/lib/*spatialite* 2> /dev/null) | ||
| # /opt/homebrew/lib on Apple Silicon, /usr/local/lib on Intel Macs | ||
| SPATIAL := $(shell ls /opt/homebrew/lib/*spatialite* 2> /dev/null || ls /usr/local/lib/*spatialite* 2> /dev/null) | ||
|
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 6 '\bSPATIAL\b|SPATIALITE_EXTENSION|mod_spatialite|spatialite' \
Makefile makerules/makerules.mkRepository: digital-land/digital-land-python Length of output: 2430 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- all references ---'
rg -n -C 4 '\bSPATIAL\b|SPATIALITE_EXTENSION|mod_spatialite|spatialite' . \
-g '!*.lock' -g '!*.json'
printf '%s\n' '--- Makefile context ---'
cat -n Makefile | sed -n '1,50p'
printf '%s\n' '--- makerules context ---'
cat -n makerules/makerules.mk | sed -n '60,90p'
printf '%s\n' '--- Makefile lexical details ---'
sed -n '13,18l' MakefileRepository: digital-land/digital-land-python Length of output: 43618 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- SPATIALITE_EXTENSION and export wiring ---'
rg -n -C 8 'SPATIALITE_EXTENSION|^[[:space:]]*export\b|export[[:space:]]' \
Makefile makerules digital_land tests
printf '%s\n' '--- makerules beginning ---'
cat -n makerules/makerules.mk | sed -n '1,65p'
printf '%s\n' '--- Python runtime lookup ---'
cat -n digital_land/package/sqlite.py | sed -n '35,62p'Repository: digital-land/digital-land-python Length of output: 6077 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- standalone GNU Make export probe ---'
make -f - --no-print-directory <<'MAKE'
SPATIAL := /opt/homebrew/lib/libspatialite.dylib
SPATIALITE_EXTENSION := /opt/homebrew/lib/mod_spatialite.dylib
all:
`@printf` 'make-SPATIAL=%s\n' '$(SPATIAL)'
`@printf` 'make-SPATIALITE_EXTENSION=%s\n' '$(SPATIALITE_EXTENSION)'
`@if` env | grep -q '^SPATIALITE_EXTENSION='; then \
printf '%s\n' 'environment-SPATIALITE_EXTENSION=present'; \
else \
printf '%s\n' 'environment-SPATIALITE_EXTENSION=absent'; \
fi
MAKE
printf '%s\n' '--- repository wiring check ---'
python3 - <<'PY'
from pathlib import Path
makefile = Path("Makefile").read_text()
makerules = Path("makerules/makerules.mk").read_text()
runtime = Path("digital_land/package/sqlite.py").read_text()
print("Makefile assigns SPATIAL:", "SPATIAL :=" in makefile)
print("Makefile maps SPATIAL to SPATIALITE_EXTENSION:",
"SPATIALITE_EXTENSION" in makefile)
print("makerules assigns Darwin SPATIALITE_EXTENSION:",
'SPATIALITE_EXTENSION="/usr/local/lib/mod_spatialite.dylib"' in makerules)
print("makerules assigns Apple Silicon path:",
"/opt/homebrew/lib/mod_spatialite.dylib" in makerules)
print("runtime reads os.environ['SPATIALITE_EXTENSION']:",
'os.environ["SPATIALITE_EXTENSION"]' in runtime)
print("runtime fallback is Intel Homebrew path:",
'"/usr/local/lib/mod_spatialite.dylib"' in runtime)
PYRepository: digital-land/digital-land-python Length of output: 253 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
makefile = Path("Makefile").read_text()
makerules = Path("makerules/makerules.mk").read_text()
runtime = Path("digital_land/package/sqlite.py").read_text()
checks = {
"Makefile assigns SPATIAL": "SPATIAL :=" in makefile,
"Makefile maps SPATIAL to SPATIALITE_EXTENSION":
"SPATIALITE_EXTENSION" in makefile,
"makerules assigns Darwin SPATIALITE_EXTENSION":
'SPATIALITE_EXTENSION="/usr/local/lib/mod_spatialite.dylib"' in makerules,
"makerules assigns Apple Silicon path":
"/opt/homebrew/lib/mod_spatialite.dylib" in makerules,
"runtime reads SPATIALITE_EXTENSION from the environment":
'os.environ["SPATIALITE_EXTENSION"]' in runtime,
"runtime fallback uses Intel Homebrew path":
'"/usr/local/lib/mod_spatialite.dylib"' in runtime,
}
for name, result in checks.items():
print(f"{name}: {result}")
assert checks["Makefile assigns SPATIAL"]
assert not checks["Makefile maps SPATIAL to SPATIALITE_EXTENSION"]
assert checks["makerules assigns Darwin SPATIALITE_EXTENSION"]
assert not checks["makerules assigns Apple Silicon path"]
assert checks["runtime reads SPATIALITE_EXTENSION from the environment"]
assert checks["runtime fallback uses Intel Homebrew path"]
PYRepository: digital-land/digital-land-python Length of output: 460 Configure 🤖 Prompt for AI Agents |
||
| else | ||
| SPATIAL := $(shell ls /usr/lib/x86_64-linux-gnu/*spatialite* 2> /dev/null) | ||
| endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import csv | ||
| from cchardet import UniversalDetector | ||
| from charset_normalizer import from_bytes, from_path | ||
| import logging | ||
| import json_stream | ||
| import os | ||
|
|
@@ -21,20 +21,26 @@ class ConversionError(Exception): | |
| pass | ||
|
|
||
|
|
||
| def _best_encoding(best): | ||
| if not best: | ||
| return None | ||
| # charset-normalizer reports the base codec even when a BOM is present | ||
| # (best.bom=True); Python needs the "-sig" variant to strip it, or the | ||
| # BOM decodes as a leading U+FEFF character in the content. | ||
| return best.encoding + "-sig" if best.bom else best.encoding | ||
|
Comment on lines
+24
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
import codecs
from charset_normalizer import from_bytes
for source_encoding in ("utf-8", "utf-16", "utf-32"):
payload = "name\ncafé\n".encode(source_encoding)
match = from_bytes(payload, enable_fallback=False).best()
detected = match.encoding if match else None
has_bom = match.bom if match else False
candidate = f"{detected}-sig" if has_bom else detected
print(source_encoding, detected, has_bom, candidate)
if candidate:
codecs.lookup(candidate)
PYRepository: digital-land/digital-land-python Length of output: 301 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
fd -t f '(^convert\.py$|requirements|pyproject|setup|poetry|Pipfile)' . | head -80
printf '%s\n' '--- convert.py symbols and relevant lines ---'
ast-grep outline digital_land/phase/convert.py --lang python 2>/dev/null || true
sed -n '1,90p' digital_land/phase/convert.py
printf '%s\n' '--- encoding uses ---'
rg -n -C 3 'encoding=|_best_encoding|from_path|from_fp|charset.?normalizer|bom' digital_land
printf '%s\n' '--- Python codec lookup ---'
python3 - <<'PY'
import codecs
for name in ("utf-8-sig", "utf_16-sig", "utf_32-sig", "utf-16", "utf-32"):
try:
info = codecs.lookup(name)
print(f"{name}: {info.name}")
except LookupError as exc:
print(f"{name}: LookupError: {exc}")
PYRepository: digital-land/digital-land-python Length of output: 10799 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- declared charset-normalizer dependency ---'
rg -n -C 3 'charset.?normalizer' pyproject.toml setup.cfg
printf '%s\n' '--- repository tests for conversion and encoding ---'
rg -n -C 3 'detect_file_encoding|detect_encoding|_best_encoding|utf.?16|utf.?32|BOM|bom' tests digital_land 2>/dev/null | head -240 || true
printf '%s\n' '--- standard-library BOM and decoding behaviour ---'
python3 - <<'PY'
import codecs
text = "name\ncafé\n"
for source_encoding in ("utf-8", "utf-16", "utf-32"):
payload = text.encode(source_encoding)
print(source_encoding, payload[:4].hex())
for candidate in ("utf-8-sig", "utf-16", "utf-32"):
try:
decoded = payload.decode(candidate)
print(f" {candidate}: {decoded!r}")
except UnicodeDecodeError as exc:
print(f" {candidate}: UnicodeDecodeError")
PYRepository: digital-land/digital-land-python Length of output: 7694 🌐 Web query:
💡 Result: In the charset-normalizer library, Byte Order Mark (BOM) handling is integrated into the detection workflow, but it is treated differently for specific encodings [1][2]. 1. BOM Stripping Behavior: The library's core detection function, from_bytes, automatically strips the BOM from the payload for most encodings [1][2]. However, it explicitly does NOT strip the BOM for UTF-16 and UTF-32 [1][2][3]. 2. UTF-16/UTF-32 Handling: Because UTF-16 and UTF-32 require a BOM to determine endianness correctly, the library avoids stripping them automatically [4][5]. If an encoding such as utf_16 or utf_32 is being tested and no BOM/SIG is present, the library may skip testing that encoding as-is and instead attempt to check specific Little Endian (LE) or Big Endian (BE) sub-encoders [4][5]. 3. Identification Utilities: The library provides internal utilities for managing these signatures, including: - charset_normalizer.utils.identify_sig_or_bom(sequence): Used to identify and extract a SIG/BOM from a byte sequence [1][6][3]. - charset_normalizer.utils.should_strip_sig_or_bom(iana_encoding): A helper function that determines whether the BOM should be stripped based on the IANA encoding name [1][2][3]. For developers, the CharsetMatch object returned by the library includes a property has_sig_or_bom (also accessible via.bom or.byte_order_mark), which indicates whether a signature was detected in the original payload [7][8]. Citations:
Map only UTF-8 BOMs to a When 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| def detect_file_encoding(path): | ||
| with open(path, "rb") as f: | ||
| return detect_encoding(f) | ||
| if not os.path.getsize(path): | ||
| return None | ||
| return _best_encoding(from_path(path).best()) | ||
|
|
||
|
|
||
| def detect_encoding(f): | ||
| detector = UniversalDetector() | ||
| detector.reset() | ||
| for line in f: | ||
| detector.feed(line) | ||
| if detector.done: | ||
| break | ||
| detector.close() | ||
| return detector.result["encoding"] | ||
| data = f.read() | ||
| if not data: | ||
| return None | ||
| return _best_encoding(from_bytes(data).best()) | ||
|
|
||
|
|
||
| def load_csv(path, encoding="UTF-8", log=None): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.