Skip to content

Commit 7494384

Browse files
committed
Tidying up and adding __all__s
1 parent 0f2968f commit 7494384

File tree

8 files changed

+171
-27
lines changed

8 files changed

+171
-27
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ coverage.xml
3434
.hypothesis/
3535
.pytest_cache/
3636
cover/
37-
.coverage*
3837
*.mo
3938
*.pot
4039
*.log

domdf_python_tools/doctools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# doctools.py
44
"""
5-
Utilities for documenting functions, classes and methods
5+
Utilities for documenting functions, classes and methods.
66
"""
77
#
88
# Copyright © 2020 Dominic Davis-Foster <[email protected]>
@@ -36,7 +36,7 @@
3636

3737
def deindent_string(string: str) -> str:
3838
"""
39-
Removes all indentation from the given string
39+
Removes all indentation from the given string.
4040
4141
:param string: The string to deindent
4242
:type string: str

domdf_python_tools/pagesizes/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
# !/usr/bin/env python
1+
#!/usr/bin/env python
22
#
3-
# pagesizes.py
3+
# __init__.py
44
"""
5-
List of common pagesizes and some tools for working with them
5+
List of common pagesizes and some tools for working with them.
66
77
This module defines a few common page sizes in points (1/72 inch).
88
9-
To be expanded to include things like label sizes, envelope windows
10-
etc.
9+
To be expanded to include things like label sizes, envelope windows etc.
1110
"""
1211
#
1312
# Copyright © 2020 Dominic Davis-Foster <[email protected]>

domdf_python_tools/pagesizes/classes.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,46 +310,54 @@ class PageSize(BaseSize):
310310

311311
__slots__: List[str] = []
312312

313-
def __new__(cls, width, height, unit=pt):
313+
def __new__(cls, width: AnyNumber, height: AnyNumber, unit: AnyNumber = pt):
314+
"""
315+
Create a new :class:`~domdf_python_tools.pagesizes.classes.PageSize` object.
316+
317+
:param width:
318+
:param height:
319+
:param unit:
320+
"""
321+
314322
width, height = convert_from((width, height), unit)
315323
return super().__new__(cls, width, height)
316324

317325
@property
318326
def inch(self) -> Size_inch:
319327
"""
320-
Returns the pagesize in inches
328+
Returns the pagesize in inches.
321329
"""
322330

323331
return Size_inch.from_pt(self)
324332

325333
@property
326334
def cm(self) -> Size_cm:
327335
"""
328-
Returns the pagesize in centimeters
336+
Returns the pagesize in centimeters.
329337
"""
330338

331339
return Size_cm.from_pt(self)
332340

333341
@property
334342
def mm(self) -> Size_mm:
335343
"""
336-
Returns the pagesize in millimeters
344+
Returns the pagesize in millimeters.
337345
"""
338346

339347
return Size_mm.from_pt(self)
340348

341349
@property
342350
def um(self) -> Size_um:
343351
"""
344-
Returns the pagesize in micrometers
352+
Returns the pagesize in micrometers.
345353
"""
346354

347355
return Size_um.from_pt(self)
348356

349357
@property
350358
def pc(self) -> Size_pica:
351359
"""
352-
Returns the pagesize in pica
360+
Returns the pagesize in pica.
353361
"""
354362

355363
return Size_pica.from_pt(self)
@@ -359,7 +367,7 @@ def pc(self) -> Size_pica:
359367
@property
360368
def dd(self) -> Size_didot:
361369
"""
362-
Returns the pagesize in didots
370+
Returns the pagesize in didots.
363371
"""
364372

365373
return Size_didot.from_pt(self)
@@ -369,7 +377,7 @@ def dd(self) -> Size_didot:
369377
@property
370378
def cc(self) -> Size_cicero:
371379
"""
372-
Returns the pagesize in ciceros
380+
Returns the pagesize in ciceros.
373381
"""
374382

375383
return Size_cicero.from_pt(self)
@@ -379,7 +387,7 @@ def cc(self) -> Size_cicero:
379387
@property
380388
def nd(self) -> Size_new_didot:
381389
"""
382-
Returns the pagesize in new didots
390+
Returns the pagesize in new didots.
383391
"""
384392

385393
return Size_new_didot.from_pt(self)
@@ -389,7 +397,7 @@ def nd(self) -> Size_new_didot:
389397
@property
390398
def nc(self) -> Size_new_cicero:
391399
"""
392-
Returns the pagesize in new ciceros
400+
Returns the pagesize in new ciceros.
393401
"""
394402

395403
return Size_new_cicero.from_pt(self)
@@ -399,7 +407,7 @@ def nc(self) -> Size_new_cicero:
399407
@property
400408
def sp(self) -> Size_scaled_point:
401409
"""
402-
Returns the pagesize in scaled point
410+
Returns the pagesize in scaled point.
403411
"""
404412

405413
return Size_scaled_point.from_pt(self)

domdf_python_tools/pagesizes/sizes.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,114 @@
3535
# MA 02110-1301, USA.
3636
#
3737

38+
__all__ = [
39+
"_4A0",
40+
"_2A0",
41+
"A0",
42+
"A1",
43+
"A2",
44+
"A3",
45+
"A4",
46+
"A5",
47+
"A6",
48+
"A7",
49+
"A8",
50+
"A9",
51+
"A10",
52+
"B0",
53+
"B1",
54+
"B2",
55+
"B3",
56+
"B4",
57+
"B5",
58+
"B6",
59+
"B7",
60+
"B8",
61+
"B9",
62+
"B10",
63+
"C0",
64+
"C1",
65+
"C2",
66+
"C3",
67+
"C4",
68+
"C5",
69+
"C6",
70+
"C7",
71+
"C8",
72+
"C9",
73+
"C10",
74+
"A2EXTRA",
75+
"A3EXTRA",
76+
"A3SUPER",
77+
"SUPERA3",
78+
"A4EXTRA",
79+
"A4SUPER",
80+
"SUPERA4",
81+
"A4LONG",
82+
"A5EXTRA",
83+
"SOB5EXTRA",
84+
"LETTER",
85+
"LEGAL",
86+
"TABLOID",
87+
"ELEVENSEVENTEEN",
88+
"JUNIOR_LEGAL",
89+
"HALF_LETTER",
90+
"GOV_LETTER",
91+
"GOV_LEGAL",
92+
"LEDGER",
93+
"EMPEROR",
94+
"QUAD_ROYAL",
95+
"QUAD_DEMY",
96+
"ANTIQUARIAN",
97+
"GRAND_EAGLE",
98+
"DOUBLE_ELEPHANT",
99+
"ATLAS",
100+
"DOUBLE_ROYAL",
101+
"COLOMBIER",
102+
"DOUBLE_DEMY_US",
103+
"DOUBLE_DEMY",
104+
"DOUBLE_DEMY_UK",
105+
"IMPERIAL",
106+
"DOUBLE_LARGE_POST",
107+
"ELEPHANT",
108+
"PRINCESS",
109+
"CARTRIDGE",
110+
"ROYAL",
111+
"SHEET",
112+
"HALF_POST",
113+
"DOUBLE_POST",
114+
"SUPER_ROYAL",
115+
"BROADSHEET",
116+
"MEDIUM_US",
117+
"MEDIUM_UK",
118+
"DEMY",
119+
"COPY_DRAUGHT",
120+
"LARGE_POST_US",
121+
"LARGE_POST_UK",
122+
"POST_US",
123+
"POST_UK",
124+
"CROWN",
125+
"PINCHED_POST",
126+
"FOOLSCAP_US",
127+
"FOOLSCAP_UK",
128+
"SMALL_FOOLSCAP",
129+
"BRIEF",
130+
"POTT",
131+
"QUARTO_US",
132+
"EXECUTIVE",
133+
"MONARCH",
134+
"FOLIO",
135+
"FOOLSCAP_FOLIO",
136+
"QUARTO",
137+
"QUARTO_UK",
138+
"KINGS",
139+
"DUKES",
140+
"ID_1",
141+
"ID_2",
142+
"ID_3",
143+
"ID_000",
144+
]
145+
38146
# this package
39147
from .classes import Size_inch, Size_mm
40148

domdf_python_tools/pagesizes/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# utils.py
44
"""
5-
Tools for working with pagesizes
5+
Tools for working with pagesizes.
66
"""
77
#
88
# Copyright © 2020 Dominic Davis-Foster <[email protected]>
@@ -52,13 +52,12 @@ def convert_from(
5252
from_: AnyNumber,
5353
) -> Union[float, Tuple[float, ...]]:
5454
"""
55-
Convert ``value`` to point from the unit specified in ``from_``
55+
Convert ``value`` to point from the unit specified in ``from_``.
5656
5757
:param value:
5858
:param from_: The unit to convert from, specified as a number of points
5959
6060
:return:
61-
:rtype:
6261
"""
6362

6463
if isinstance(value, Sequence):
@@ -76,7 +75,16 @@ def _sequence_convert_from(seq: Sequence[AnyNumber], from_: AnyNumber) -> Tuple[
7675
_measurement_re = re.compile(r"(\d*\.?\d+) *([A-Za-z]*)")
7776

7877

79-
def parse_measurement(measurement):
78+
def parse_measurement(measurement: str) -> Union[float, Tuple[float, ...]]:
79+
"""
80+
Parse the given measurement.
81+
82+
:param measurement:
83+
:type measurement: str
84+
85+
:return:
86+
"""
87+
8088
# TODO: docstring
8189
match = _measurement_re.findall(measurement)[0]
8290
print(match)
@@ -115,7 +123,7 @@ def parse_measurement(measurement):
115123

116124
def to_length(s):
117125
"""
118-
Convert a string to a length
126+
Convert a string to a length.
119127
120128
:param s:
121129
:type s:

domdf_python_tools/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@
3030
import sys
3131
from typing import Any, Generator, Iterable, List, Sequence, Tuple, Union
3232

33+
__all__ = [
34+
"pyversion",
35+
"as_text",
36+
"check_dependencies",
37+
"chunks",
38+
"cmp",
39+
"list2str",
40+
"tuple2str",
41+
"permutations",
42+
"printr",
43+
"printt",
44+
"stderr_writer",
45+
"printe",
46+
"split_len",
47+
"splitLen",
48+
"str2tuple",
49+
"strtobool",
50+
"enquote_value",
51+
]
52+
3353
pyversion: int = int(sys.version_info.major) # Python Version
3454

3555

tox.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This file must be in the same dir as setup.py
44
[tox]
5-
envlist = py36, py37, py38, pypy3, py39-dev, docs, mypy
5+
envlist = py36, py37, py38, pypy3, py39-dev, mypy
66
skip_missing_interpreters = True
77
requires = pip >= 19.0.0
88

@@ -11,7 +11,7 @@ requires = pip >= 19.0.0
1111
python =
1212
3.6: py36, mypy
1313
3.7: py37
14-
3.8: py38, docs
14+
3.8: py38
1515
pypy3: pypy3
1616
3.9-dev: py39-dev
1717

@@ -133,7 +133,7 @@ commands = tox -e pyup,isort,yapf,mypy,lint {posargs}
133133

134134
[flake8]
135135
max-line-length = 120
136-
select = E301 E303 E304 E305 E306 E502 W291 W293 W391 E226 E225 E241 E231 E101 E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E227 E228 E242 E251 E261 E262 E271 E272 E402 E703 E711 E712 E713 E714 E721 W504 E302 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 PT001 PT002 PT003 PT004 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q000 Q001 Q002 Q003 W292 E265
136+
select = E301 E303 E304 E305 E306 E502 W291 W293 W391 E226 E225 E241 E231 E101 E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E227 E228 E242 E251 E261 E262 E271 E272 E402 E703 E711 E712 E713 E714 E721 W504 E302 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 PT001 PT002 PT003 PT004 PT005 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q000 Q001 Q002 Q003 W292 E265 D100 D101 D102 D103 D104 D105 D106 D107 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417
137137
exclude = .git,__pycache__,doc-source,old,build,dist,make_conda_recipe.py,__pkginfo__.py,setup.py
138138
rst-roles =
139139
class,
@@ -149,6 +149,8 @@ rst-directives =
149149
envvar,
150150
exception,
151151
seealso
152+
per-file-ignores =
153+
tests/*: D100 D101 D102 D103 D104 D105 D106 D107 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417
152154
pytest-parametrize-names-type = csv
153155
inline-quotes = "
154156
multiline-quotes = """

0 commit comments

Comments
 (0)