Skip to content

Commit cd8c4e3

Browse files
authored
Merge pull request #7 from pyexcel/dev
release 0.6.0
2 parents 7c46a05 + 6ee2a10 commit cd8c4e3

27 files changed

+235
-210
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
With your PR, here is a check list:
22

3-
- [ ] Has Test cases written
4-
- [ ] Has all code lines tested
3+
- [ ] Has test cases written?
4+
- [ ] Has all code lines tested?
55
- [ ] Has `make format` been run?
6-
- [ ] Has `moban` been run?
6+
- [ ] Please update CHANGELOG.yml(not CHANGELOG.rst)
77
- [ ] Passes all Travis CI builds
88
- [ ] Has fair amount of documentation if your change is complex
9-
- [ ] run 'make format' so as to confirm the pyexcel organisation's coding style
10-
- [ ] Please update CHANGELOG.rst
11-
- [ ] Please add yourself to CONTRIBUTORS.rst
129
- [ ] Agree on NEW BSD License for your contribution

.github/workflows/moban-update.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
on: [push]
2+
3+
jobs:
4+
run_moban:
5+
runs-on: ubuntu-latest
6+
name: synchronize templates via moban
7+
steps:
8+
- uses: actions/checkout@v2
9+
with:
10+
ref: ${{ github.head_ref }}
11+
- name: Set up Python
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: '3.7'
15+
- name: check changes
16+
run: |
17+
pip install moban gitfs2 pypifs moban-jinja2-github moban-ansible
18+
moban
19+
git status
20+
git diff --exit-code
21+
- name: Auto-commit
22+
if: failure()
23+
uses: docker://cdssnc/auto-commit-github-action
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
with:
27+
args: >-
28+
This is an auto-commit, updating project meta data,
29+
such as changelog.rst, contributors.rst

.isort.cfg

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[settings]
2+
line_length=79
3+
known_first_party=lxml, pyexcel_io, pyexcel
4+
known_third_party=mock,nose
5+
indent=' '
6+
multi_line_output=3
7+
length_sort=1
8+
default_section=FIRSTPARTY
9+
no_lines_before=LOCALFOLDER
10+
sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change log
22
================================================================================
33

4+
0.6.0 - 10.10.2020
5+
--------------------------------------------------------------------------------
6+
7+
**Updated**
8+
9+
#. New style xlsx plugins, promoted by pyexcel-io v0.6.2.
10+
411
0.5.3 - 23.06.2020
512
--------------------------------------------------------------------------------
613

CONTRIBUTORS.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
No contributors yet
4+
=======================
5+
6+
* Your github link will be listed here after your PR is merged

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015-2019 by Onni Software Ltd. and its contributors
1+
Copyright (c) 2015-2020 by Onni Software Ltd. and its contributors
22
All rights reserved.
33

44
Redistribution and use in source and binary forms of the software as well
@@ -13,7 +13,7 @@ that the following conditions are met:
1313
and/or other materials provided with the distribution.
1414

1515
* Neither the name of 'pyexcel-xlsxr' nor the names of the contributors
16-
may be used to endorse or promote products derived from this software
16+
may not be used to endorse or promote products derived from this software
1717
without specific prior written permission.
1818

1919
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND

Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ test: lint
66
install_test:
77
pip install -r tests/requirements.txt
88

9-
git-diff-check:
10-
git diff --exit-code
11-
129
lint:
1310
bash lint.sh
1411

README.rst

+5-16
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ pyexcel-xlsxr - Let you focus on data, instead of xlsx format
2525
.. image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg
2626
:target: https://gitter.im/pyexcel/Lobby
2727

28+
.. image:: https://img.shields.io/static/v1?label=continuous%20templating&message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0&color=blue&style=flat-square
29+
:target: https://moban.readthedocs.io/en/latest/#at-scale-continous-templating-for-open-source-projects
30+
31+
.. image:: https://img.shields.io/static/v1?label=coding%20style&message=black&color=black&style=flat-square
32+
:target: https://github.com/psf/black
2833

2934
**pyexcel-xlsxr** is a specialized xlsx reader using lxml. It does partial reading, meaning
3035
it wont load all content into memory.
@@ -343,22 +348,6 @@ Please run::
343348
so as to beautify your code otherwise travis-ci may fail your unit test.
344349

345350

346-
And make sure you would have run moban command
347-
---------------------------------------------------------
348-
349-
Additional steps are required:
350-
351-
#. pip install moban
352-
#. make your changes in `.moban.d` directory, then issue command `moban`
353-
#. moban
354-
355-
otherwise travis-ci may also fail your unit test.
356-
357-
What is .moban.d
358-
---------------------------------
359-
360-
`.moban.d` stores the specific meta data for the library.
361-
362351

363352
.. testcode::
364353
:hide:

changelog.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: pyexcel-xlsxr
22
organisation: pyexcel
33
releases:
4+
- changes:
5+
- action: Updated
6+
details:
7+
- 'New style xlsx plugins, promoted by pyexcel-io v0.6.2.'
8+
date: 10.10.2020
9+
version: 0.6.0
410
- changes:
511
- action: Fixed
612
details:

format.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
isort -y $(find pyexcel_xlsxr -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
1+
isort $(find pyexcel_xlsxr -name "*.py"|xargs echo) $(find tests -name "*.py"|xargs echo)
22
black -l 79 pyexcel_xlsxr
33
black -l 79 tests

lint.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pip install flake8
2-
flake8 . --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long
3-
python setup.py checkdocs
2+
flake8 --exclude=.moban.d,docs,setup.py --builtins=unicode,xrange,long . && python setup.py checkdocs

pyexcel-xlsxr.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
overrides: "pyexcel.yaml"
22
name: "pyexcel-xlsxr"
33
nick_name: "xlsxr"
4-
version: "0.5.3"
5-
current_version: "0.5.3"
6-
release: "0.5.3"
4+
version: "0.6.0"
5+
current_version: "0.6.0"
6+
release: "0.6.0"
77
file_type: xlsx
88
nodocs: true
99
dependencies:
10-
- lxml >= 3.4.4
11-
- pyexcel-io >= 0.5.4
10+
- lxml>=3.4.4
11+
- pyexcel-io>=0.6.2
1212
description: "Read xlsx file using partial xml"
1313
test_dependencies:
14-
- pyexcel<=0.6.0
14+
- pyexcel
1515
- pyexcel-xlsxw
16+
python_requires: ">=3.6"
17+
min_python_version: "3.6"

pyexcel_xlsxr/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
pyexcel_xlsxr
33
~~~~~~~~~~~~~~~~~~~
44
The lower level xlsx file format handler using lxml
5-
:copyright: (c) 2015-2017 by Onni Software Ltd & its contributors
5+
:copyright: (c) 2015-2020 by Onni Software Ltd & its contributors
66
:license: New BSD License
77
"""
88
from pyexcel_io.io import get_data as read_data
99
from pyexcel_io.io import isstream
10-
from pyexcel_io.plugins import IOPluginInfoChain
11-
12-
from pyexcel_xlsxr._version import __author__, __version__ # flake8: noqa
10+
from pyexcel_io.plugins import IOPluginInfoChainV2
11+
from pyexcel_xlsxr._version import __author__, __version__ # noqa
1312

1413
__FILE_TYPE__ = "xlsx"
1514

16-
IOPluginInfoChain(__name__).add_a_reader(
15+
IOPluginInfoChainV2(__name__).add_a_reader(
1716
relative_plugin_class_path="xlsxr.XLSXBook",
17+
locations=["file", "memory"],
18+
file_types=[__FILE_TYPE__],
19+
stream_type="binary",
20+
).add_a_reader(
21+
relative_plugin_class_path="xlsxr.XLSXBookInContent",
22+
locations=["content"],
1823
file_types=[__FILE_TYPE__],
1924
stream_type="binary",
2025
)

pyexcel_xlsxr/_version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.5.3"
2-
__author__ = "C.W."
1+
__version__ = '0.6.0'
2+
__author__ = 'chfw'

pyexcel_xlsxr/messy_xlsx.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io
22
import re
33
import zipfile
4-
from datetime import datetime, time, timedelta
4+
from datetime import time, datetime, timedelta
55

66
from lxml import etree
77
from pyexcel_io._compact import OrderedDict
@@ -11,15 +11,15 @@
1111
WORK_BOOK = "xl/workbook.xml"
1212
SHEET_MATCHER = "xl/worksheets/(work)?sheet([0-9]+)?.xml"
1313
SHEET_INDEX_MATCHER = "xl/worksheets/(work)?sheet(([0-9]+)?).xml"
14-
XLSX_ROW_MATCH = re.compile(b".*?(<row.*?<\/.*?row>).*?", re.MULTILINE)
14+
XLSX_ROW_MATCH = re.compile(rb".*?(<row.*?<\/.*?row>).*?", re.MULTILINE)
1515
NUMBER_FMT_MATCHER = re.compile(
16-
b".*?(<numFmts.*?<\/.*?numFmts>).*?", re.MULTILINE
16+
rb".*?(<numFmts.*?<\/.*?numFmts>).*?", re.MULTILINE
1717
)
1818
XFS_FMT_MATCHER = re.compile(
19-
b".*?(<cellXfs.*?<\/.*?cellXfs>).*?", re.MULTILINE
19+
rb".*?(<cellXfs.*?<\/.*?cellXfs>).*?", re.MULTILINE
2020
)
21-
SHEET_FMT_MATCHER = re.compile(b".*?(<sheet .*?\/>).*?", re.MULTILINE)
22-
DATE_1904_MATCHER = re.compile(b".*?(<workbookPr.*?\/>).*?", re.MULTILINE)
21+
SHEET_FMT_MATCHER = re.compile(rb".*?(<sheet .*?\/>).*?", re.MULTILINE)
22+
DATE_1904_MATCHER = re.compile(rb".*?(<workbookPr.*?\/>).*?", re.MULTILINE)
2323
# "xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
2424
# But it not used for now
2525
X14AC_NAMESPACE = b'xmlns:x14ac="http://not.used.com/"'
@@ -140,8 +140,9 @@ def __extract_book_properties(self):
140140
book_content = self.zip_file.open(WORK_BOOK).read()
141141
return parse_book_properties(book_content)
142142

143-
def __del__(self):
144-
self.zip_file.close()
143+
def close(self):
144+
if self.zip_file:
145+
self.zip_file.close()
145146

146147
def make_tables(self):
147148
sheet_files = find_sheets(self.zip_file.namelist())
@@ -216,9 +217,9 @@ def parse_cell_type(cell):
216217
cell_type = None
217218
if cell.style_string:
218219
date_time_flag = (
219-
re.match("^\d+(\.\d+)?$", cell.value)
220+
re.match(r"^\d+(\.\d+)?$", cell.value)
220221
and re.match(".*[hsmdyY]", cell.style_string)
221-
and not re.match(".*\[.*[dmhys].*\]", cell.style_string)
222+
and not re.match(r".*\[.*[dmhys].*\]", cell.style_string)
222223
)
223224
if cell.style_string in FORMATS:
224225
cell_type = FORMATS[cell.style_string]
@@ -227,7 +228,7 @@ def parse_cell_type(cell):
227228
cell_type = "time"
228229
else:
229230
cell_type = "date"
230-
elif re.match("^-?\d+(.\d+)?$", cell.value):
231+
elif re.match(r"^-?\d+(.\d+)?$", cell.value):
231232
cell_type = "float"
232233
return cell_type
233234

@@ -313,9 +314,12 @@ def parse_book_properties(book_content):
313314
properties["date1904"] = value.lower().strip() == "true"
314315
else:
315316
properties["date1904"] = False
316-
namespaces = {
317-
"r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" # flake8: noqa
318-
}
317+
318+
ns = (
319+
"http://schemas.openxmlformats.org/"
320+
+ "officeDocument/2006/relationships"
321+
)
322+
namespaces = {"r": ns}
319323

320324
xlsx_header = u"<wrapper {0}>".format(
321325
" ".join('xmlns:{0}="{1}"'.format(k, v) for k, v in namespaces.items())

0 commit comments

Comments
 (0)