diff --git a/.gitignore b/.gitignore index aeaec0f716b3d4a8dd1006ab0e467182584f932f..246ff9db42110bf0fd9550cfa8251e9505e8de9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -/*~ +*~ +/build +/dist +__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index b67377d801be47313b6d3465386344670a8b03ae..7eb5887f08adcddc7b46645f5e0a6f30e86b8112 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,29 @@ izodparse: tool for exploring file formats and testbed for Hammer ideas ======================================================================= -This is a prototype PEG parsing engine intended as a testbed for +This is a prototype PEG parsing engine in Python 3 intended as a testbed for low-cost experimentation, initially with CMap and PDF files and later -for Hammer features. Basically I wanted a more interactive way to +for features for the Hammer parsing engine. +Basically I wanted a more interactive way to explore PDF files than recompiling batch-mode C programs and looking at the results in a text editor. +Quick start +----------- + + $ python ./setup.py install + ... + $ python + Python 3.8.10 (default, Jun 2 2021, 10:49:15) + [GCC 9.4.0] on linux + Type "help", "copyright", "credits" or "license" for more information. + >>> from izodparse import pdftour + >>> p = pdftour.read_pdf('../Descargas/1.2754649.pdf') + >>> p.catalog + << /Type /Catalog /Pages 13 0 R >> + >>> _['Pages'] + << /Count 4 /Type /Pages /ITXT b'5.1.2' /Kids [11 0 R 38 0 R 74 0 R 86 0 R] >> + History ------- diff --git a/izodparse/__init__.py b/izodparse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b8023d8bc0ca413584a729e5106f86ba8fe65400 --- /dev/null +++ b/izodparse/__init__.py @@ -0,0 +1 @@ +__version__ = '0.0.1' diff --git a/pdftour.py b/izodparse/pdftour.py similarity index 99% rename from pdftour.py rename to izodparse/pdftour.py index b7b3e19d6bdb887c175fb479806dcda03d610987..3a48cbc93d0de76b9a3d5c8f43a1c587fde18976 100755 --- a/pdftour.py +++ b/izodparse/pdftour.py @@ -1,9 +1,9 @@ #!/usr/bin/python3 -"""Explore PDF file structure, at least enough to parse a CMap file, hopefully. +r"""Explore PDF file structure, at least enough to parse a CMap file, hopefully. For example, we can navigate the PDF structure. - >>> import pdftour + >>> from izodparse import pdftour >>> p = pdftour.read_pdf('../Descargas/1.2754649.pdf') >>> p.catalog << /Type /Catalog /Pages 13 0 R >> diff --git a/plans.org b/plans.org index 1fa5b1cd9b905e8c2352c512ff6711419024fdf2..996d0b4e8129a3ef865dba3b7f908319a872e771 100644 --- a/plans.org +++ b/plans.org @@ -6,7 +6,8 @@ popular) martel? (could be, but common surname) maillet? (could be, but common surname) otsuchi? (would be fine) totokia? (would be fine) mere? (too common) patu? (too common) -For now it's 1zodparse. +For now it's 1zodparse. No, izodparse, so it's a valid Python module +name. How do I git filter-branch? I want pdftour.py and parsecmaps.py. or maybe git-filter-repo? no, don't have it. --prune-empty? --all? @@ -66,6 +67,8 @@ we find this suggestion: This apparently changes GIT_COMMITTER_DATE but I don't care. +* DONE make izodparse an installable Python package +Man, I forgot all about the distutils/setuptools mess. * TODO examine example PDF file with compressed object streams and no fonts in page resource dictionaries * TODO fix nested parentheses parsing * TODO make xrefs, etc., lazy properties diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..ffed5fe03f1d6a110c7b0e16be1d2498fb8c4423 --- /dev/null +++ b/setup.py @@ -0,0 +1,31 @@ +from distutils.core import setup # setuptools may be nicer but it's not in the stdlib + +with open("README.md", "r", encoding="utf-8") as f: + long_description = f.read() + +setup( + name='izodparse', + version='0.0.1', + author='Kragen Javier Sitaker', + license='GPL3+', + description='tool for exploring file formats and testbed for Hammer ideas', + long_description=long_description, + long_description_content_type="text/markdown", + platforms='any', + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Topic :: Software Development :: Libraries :: Python Modules", + ], + python_requires=">=3.7", + packages=["izodparse"], +)