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
35 changes: 35 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# EditorConfig Configuration file, for more details see:
# https://EditorConfig.org
# EditorConfig is a convention description, that could be interpreted
# by multiple editors to enforce common coding conventions for specific
# file types

# top-most EditorConfig file:
# Will ignore other EditorConfig files in Home directory or upper tree level.
root = true


[*] # For All Files
# Unix-style newlines with a newline ending every file
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# Set default charset
charset = utf-8
# Indent style default
indent_style = space

[*.{py,cfg,ini}]
# 4 space indentation
indent_size = 4

[*.{html,dtml,pt,zpt,xml,zcml,js,json,ts,less,scss,css,sass,yml,yaml}]
# 2 space indentation
indent_size = 2

[{Makefile,.gitmodules}]
# Tab indentation (no size specified, but view as 4 spaces)
indent_style = tab
indent_size = unset
tab_width = unset
82 changes: 82 additions & 0 deletions .github/workflows/plone-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Plone package

# Every action is pinned to a full commit SHA of a release that has been out
# for at least two weeks (cooldown). The comment after each SHA is the tag.

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel superseded runs of the same PR only.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Install tox
run: python -m pip install tox
- name: Ruff
run: tox -e ruff-check

test:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
include:
- {python-version: '3.10', tox-env: 'py310-Plone60'}
- {python-version: '3.11', tox-env: 'py311-Plone60'}
- {python-version: '3.12', tox-env: 'py312-Plone60'}
- {python-version: '3.13', tox-env: 'py313-Plone60'}
- {python-version: '3.10', tox-env: 'py310-Plone61'}
- {python-version: '3.11', tox-env: 'py311-Plone61'}
- {python-version: '3.12', tox-env: 'py312-Plone61'}
- {python-version: '3.13', tox-env: 'py313-Plone61'}
- {python-version: '3.10', tox-env: 'py310-Plone62'}
- {python-version: '3.11', tox-env: 'py311-Plone62'}
- {python-version: '3.12', tox-env: 'py312-Plone62'}
- {python-version: '3.13', tox-env: 'py313-Plone62'}
- {python-version: '3.14', tox-env: 'py314-Plone62'}
env:
# Fail instead of skipping the tests that need java.
C2_TRANSFORM_MSOFFICE_REQUIRE_JAVA: '1'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
# The runner has several JDKs already; this pins the one on PATH.
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: '21'
- name: Install tox
run: python -m pip install tox
- name: Test with tox
run: |
set -o pipefail
tox -e ${{ matrix.tox-env }} | tee tox.log
- name: Check that no test was skipped
run: |
if grep -E '^SKIPPED|[0-9]+ skipped' tox.log; then
echo "::error::Some tests were skipped"
exit 1
fi
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# python related
*.egg-info
*.pyc
*.pyo

# tools related
__pycache__/
.coverage
.coverage.*
.mypy_cache
.pytest_cache
.ruff_cache
/build/
coverage.xml
dist/
docs/_build
node_modules/

# venv / buildout related
.eggs/
.installed.cfg
.mr.developer.cfg
.venv/
bin/
develop-eggs/
eggs/
etc/
include/
lib/
lib64
parts/
pyvenv.cfg
var/

# mxdev
.installed.txt
.lock
/.mxdev_cache/
/.make-sentinels/
/*-mxdev.txt
/instance/
/reports/
/sources/
/venv/
# mxdev generated
constraints.txt
constraints-mxdev.txt
requirements.txt
requirements-mxdev.txt

.tox/
18 changes: 0 additions & 18 deletions .hgignore

This file was deleted.

60 changes: 60 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Notes for contributors and coding agents

## Rules

- This is a public package. Write code, comments, documentation, commit
messages and pull requests in English.
- Do not add design documents, specs or plans to the repository.
- Record user-facing changes as towncrier fragments in `news/`
(`news/+<name>.<type>` or `news/<issue>.<type>`, types as in
`pyproject.toml`), not in `CHANGELOG.md`.

## Layout

- `src/c2/transform/msoffice/`: the package. `c2` and `c2.transform` are
PEP 420 namespace packages, so they have no `__init__.py`.
- `transform.py`: the `msoffice_to_text` transform that runs the jar.
- `config.py`: MIME types; importing it adds them to `mimetypes`.
- `setuphandlers.py`: install and uninstall (`post_handler`s).
- `msdoc2txt.jar`: the bundled Java program (Apache POI 3.17).
- `tests/`: pytest tests (not shipped in the wheel).
- `test_transform.py`, `test_config.py`: unit tests; `java` is replaced.
- `test_setup.py`: install and uninstall in a Plone site.
- `test_java.py`: runs the real jar on the files in `tests/samples/`.

## Development

Run the tests and the linters with tox:

```shell
tox -e py314-Plone62 # one Python and Plone version
tox -e ruff-check # lint and format check
tox -e ruff-fix # fix and format
tox # the whole matrix
```

Extra arguments go to pytest, for example
`tox -e py314-Plone62 -- tests/test_transform.py`.

`tests/test_java.py` needs `java` on `PATH`. Without it the tests are
skipped; set `C2_TRANSFORM_MSOFFICE_REQUIRE_JAVA=1` to make them fail
instead, as CI does. Write expected values in tests as literals.

## Test samples

All files in `tests/samples/` were made for this package; do not add
documents of unknown origin. The `.docx`, `.doc`, `.xlsx`, `.xls` and `.pptx`
files were converted with LibreOffice in headless mode from short text and
CSV files (`soffice --headless --convert-to docx document.txt`, the CSV
with `--infilter="CSV:44,34,76,1"`, and the presentation by converting a PDF
of the text with `--infilter=impress_pdf_import`); `<cp:revision>` was then
removed from `docProps/core.xml` of the OOXML files, because the jar prints
it as text. `empty.docx` is a converted empty text file.

The `.ppt` file was written with the Apache POI classes in the bundled jar
(`HSLFSlideShow` with one text box), because it is much smaller than the one
LibreOffice writes; the jar cannot read either of them (see the known issues
in `README.md`). POI's empty template names a person as the last editor in
the Current User stream, so the name was cleared with
`getSlideShowImpl().getCurrentUserAtom().setLastEditUsername("")`. Check new
samples for names in their metadata before adding them.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Changelog

<!--
You should *NOT* be adding new change log entries to this file.
You should create a file in the news directory instead.
For helpful instructions, please see:
https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst
-->

<!-- towncrier release notes start -->

## 1.0b6 (2018-04-02)

- change from POI 3.6 to POI 3.17 with Java 8 [Tetsuya Morimoto]

## 1.0b5 (2018-02-28)

- modify setup.py for target Plone [terapyon]
- tested Plone 5.1

## 1.0b4 (2013-03-16)

- modify kill process for Popen [Takayuki Nagai]

## 1.0b3 (2010-10-06)

- adding terminated suspicious zombie process [terapyon]

## 1.0b2 (2010-02-19)

- remove the copyright in the files [terapyon]

## 1.0b1 (2010-02-01)

- modify getting from metadata and note in the msoffice file [terapyon]
- no support for Windows [terapyon]

## 0.3.2 (2010-01-19)

- setting some mimetypes [terapyon]

## 0.3.1 (2009-12-22)

- bug fix for Windows [terapyon]

## 0.3 (2009-12-22)

- support Windows OS

## 0.2 (2009-12-21)

- support Plone 4.x [terapyon]

## 0.1.2 (2009-12-17)

- modify typo

## 0.1.1 (2009-12-16)

- modify exception code
- adding java args for big size file

## 0.1 (2009-12-16)

- Initial release
File renamed without changes.
File renamed without changes.
11 changes: 8 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
recursive-include c2 *
recursive-include docs *
global-exclude *pyc *pyo
graft src/c2
include *.md
include pyproject.toml
exclude tox.ini
exclude *.txt
global-exclude *.pyc
include LICENSE.GPL
include LICENSE.txt
Loading
Loading