From 2b1374681f53287ea8ddd60442a0abe011e230c3 Mon Sep 17 00:00:00 2001 From: Fabian Wicker Date: Mon, 17 Apr 2023 12:21:48 +0200 Subject: [PATCH] init capabilities --- .github/ISSUE_TEMPLATE.md | 26 - .github/PULL_REQUEST_TEMPLATE.md | 10 - .github/dependabot.yml | 23 - .github/workflows/black.yml | 10 - .github/workflows/codeql-analysis.yml | 71 -- .github/workflows/documentation.yml | 31 - .github/workflows/pythonpackage.yml | 43 -- capabilities-data/.gitignore | 3 + capabilities-data/.travis.yml | 13 + capabilities-data/LICENSE.md | 395 +++++++++++ capabilities-data/README.md | 37 + capabilities-data/data/encoding.yml | 668 ++++++++++++++++++ capabilities-data/data/profile/AF-240.yml | 29 + capabilities-data/data/profile/CT-S651.yml | 70 ++ capabilities-data/data/profile/NT-5890K.yml | 8 + capabilities-data/data/profile/OCD-100.yml | 50 ++ capabilities-data/data/profile/OCD-300.yml | 51 ++ capabilities-data/data/profile/P822D.yml | 96 +++ capabilities-data/data/profile/POS-5890.yml | 100 +++ capabilities-data/data/profile/RP326.yml | 63 ++ capabilities-data/data/profile/SP2000.yml | 67 ++ capabilities-data/data/profile/Sunmi-V2.yml | 51 ++ capabilities-data/data/profile/TEP-200M.yml | 9 + .../data/profile/TM-P80-42col.yml | 21 + capabilities-data/data/profile/TM-P80.yml | 21 + capabilities-data/data/profile/TM-T88II.yml | 109 +++ capabilities-data/data/profile/TM-T88III.yml | 22 + .../data/profile/TM-T88IV-SA.yml | 25 + capabilities-data/data/profile/TM-T88IV.yml | 31 + capabilities-data/data/profile/TM-T88V.yml | 57 ++ capabilities-data/data/profile/TM-U220.yml | 18 + capabilities-data/data/profile/TSP600.yml | 7 + capabilities-data/data/profile/TUP500.yml | 7 + capabilities-data/data/profile/ZJ-5870.yml | 47 ++ capabilities-data/data/profile/default.yml | 120 ++++ capabilities-data/data/profile/simple.yml | 21 + capabilities-data/doc/add-your-printer.md | 103 +++ capabilities-data/scripts/collate.py | 148 ++++ 38 files changed, 2467 insertions(+), 214 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/black.yml delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/documentation.yml delete mode 100644 .github/workflows/pythonpackage.yml create mode 100644 capabilities-data/.gitignore create mode 100644 capabilities-data/.travis.yml create mode 100644 capabilities-data/LICENSE.md create mode 100644 capabilities-data/README.md create mode 100644 capabilities-data/data/encoding.yml create mode 100644 capabilities-data/data/profile/AF-240.yml create mode 100644 capabilities-data/data/profile/CT-S651.yml create mode 100644 capabilities-data/data/profile/NT-5890K.yml create mode 100644 capabilities-data/data/profile/OCD-100.yml create mode 100644 capabilities-data/data/profile/OCD-300.yml create mode 100644 capabilities-data/data/profile/P822D.yml create mode 100644 capabilities-data/data/profile/POS-5890.yml create mode 100644 capabilities-data/data/profile/RP326.yml create mode 100644 capabilities-data/data/profile/SP2000.yml create mode 100644 capabilities-data/data/profile/Sunmi-V2.yml create mode 100644 capabilities-data/data/profile/TEP-200M.yml create mode 100644 capabilities-data/data/profile/TM-P80-42col.yml create mode 100644 capabilities-data/data/profile/TM-P80.yml create mode 100644 capabilities-data/data/profile/TM-T88II.yml create mode 100644 capabilities-data/data/profile/TM-T88III.yml create mode 100644 capabilities-data/data/profile/TM-T88IV-SA.yml create mode 100644 capabilities-data/data/profile/TM-T88IV.yml create mode 100644 capabilities-data/data/profile/TM-T88V.yml create mode 100644 capabilities-data/data/profile/TM-U220.yml create mode 100644 capabilities-data/data/profile/TSP600.yml create mode 100644 capabilities-data/data/profile/TUP500.yml create mode 100644 capabilities-data/data/profile/ZJ-5870.yml create mode 100644 capabilities-data/data/profile/default.yml create mode 100644 capabilities-data/data/profile/simple.yml create mode 100644 capabilities-data/doc/add-your-printer.md create mode 100755 capabilities-data/scripts/collate.py diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 36ed5e6..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,26 +0,0 @@ - - - -I have: -- [ ] searched open and closed issues for duplicates - -### Bug description - -### Steps to reproduce -- add your steps here -- as a list -- using hyphens - -### Device info - - **Printer:** Manufacturer Model XVI - - - **python-escpos version:** 0.0.0 - - **python version:** 0.0 - - **operating system:** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 32544d2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,10 +0,0 @@ -### Contributor checklist - -- [ ] I have read the CONTRIBUTING.rst -- [ ] I have tested my contribution on these devices: - * e.g. Epson TM-T88II -- [ ] My contribution is ready to be merged as is - ----------- - -### Description diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 932d224..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,23 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "daily" - - package-ecosystem: "pip" - directory: "/doc" - schedule: - interval: "daily" - - package-ecosystem: "gitsubmodule" - directory: "/" - schedule: - interval: "daily" - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 9065b5e..0000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Lint - -on: [push, pull_request] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: psf/black@stable diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 1d0085c..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -name: "CodeQL" - -on: - push: - branches: [master] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] - schedule: - - cron: '0 1 * * 5' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['python'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index 3b44bb6..0000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Documentation build - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "docs" - docs: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - name: Install packages - run: - sudo apt-get update -y && - sudo apt-get install -y git python3-sphinx graphviz libenchant1c2a && - sudo pip install tox - - name: Test doc build - run: tox -e docs diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml deleted file mode 100644 index de64106..0000000 --- a/.github/workflows/pythonpackage.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4.5.0 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest tox tox-gh-actions - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with tox - run: | - tox - env: - ESCPOS_CAPABILITIES_FILE: /home/runner/work/python-escpos/python-escpos/capabilities-data/dist/capabilities.json diff --git a/capabilities-data/.gitignore b/capabilities-data/.gitignore new file mode 100644 index 0000000..af6e4fe --- /dev/null +++ b/capabilities-data/.gitignore @@ -0,0 +1,3 @@ +*.swp +*.swo +*.swn diff --git a/capabilities-data/.travis.yml b/capabilities-data/.travis.yml new file mode 100644 index 0000000..74245c8 --- /dev/null +++ b/capabilities-data/.travis.yml @@ -0,0 +1,13 @@ +--- +dist: trusty + +language: python + +install: + - sudo pip install yamllint + - pip install pyyaml pyaml + +script: + - find data/ -name '*.yml' | xargs yamllint + - python scripts/collate.py +... diff --git a/capabilities-data/LICENSE.md b/capabilities-data/LICENSE.md new file mode 100644 index 0000000..06c608d --- /dev/null +++ b/capabilities-data/LICENSE.md @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More_considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/capabilities-data/README.md b/capabilities-data/README.md new file mode 100644 index 0000000..9dfd8b1 --- /dev/null +++ b/capabilities-data/README.md @@ -0,0 +1,37 @@ +# ESC/POS printer database [![Build Status](https://travis-ci.org/receipt-print-hq/escpos-printer-db.svg?branch=master)](https://travis-ci.org/receipt-print-hq/escpos-printer-db) + +This is a community-maintained database of thermal receipt printer capabilities. + +The capability data is shared by multiple open source receipt printing projects, +to allow improvements in hardware support, compatibility and localization. + +Only features of ESC/POS printers are tracked at this stage. If you have a ZPL, +DPL, or ESC/P printer, it is not in-scope for being listed in this database. + +## Browse + +A browsable version of the printer database is hosted [here](https://mike42.me/escpos-printer-db). The single-page app that hosts this data is [also open to contributions](https://github.com/receipt-print-hq/escpos-printer-db-browser). + +The [data/](https://github.com/receipt-print-hq/escpos-printer-db/tree/master/data) directory in this repository contains the actual printer data, and is where you should send corrections. + +## Contribute + +This project is open to any kind of contribution, eg. + +- Submitting information about your printer +- Writing new profiles +- Typing up legacy code pages + +### Add your printer + +See: [How to get your printer included in the database](https://github.com/receipt-print-hq/escpos-printer-db/blob/master/doc/add-your-printer.md) + +## License + +This data and documentation is provided under [Creative Commons Attribution 4.0](https://creativecommons.org/licenses/by/4.0/). See LICENSE.md for details. + +## Participating projects + +- [python-escpos](https://github.com/python-escpos/python-escpos) +- [escpos-php](https://github.com/mike42/escpos-php) + diff --git a/capabilities-data/data/encoding.yml b/capabilities-data/data/encoding.yml new file mode 100644 index 0000000..4eb2ef4 --- /dev/null +++ b/capabilities-data/data/encoding.yml @@ -0,0 +1,668 @@ +# encoding.yml: This file maps known code pages and other character encodings +# to a method of encoding. +# +# Its purpose is to account for the use of different code page names and +# implementations, so that drivers have a common data set to use for converting +# UTF-8 text into something that a printer is likely to understand. +# +# Where multiple encoders are listed, any of them can be used to give identical +# results. + +--- +CP037: + iconv: CP037 + python_encode: cp037 + +CP038: + iconv: CP038 + +CP273: + iconv: CP273 + python_encode: cp273 + +CP274: + iconv: CP274 + +CP275: + iconv: CP275 + +CP278: + iconv: CP278 + +CP280: + iconv: CP280 + +CP281: + iconv: CP281 + +CP282: + iconv: CP282 + +CP284: + iconv: CP284 + +CP285: + iconv: CP285 + +CP290: + iconv: CP290 + +CP297: + iconv: CP297 + +CP367: + iconv: CP367 + +CP420: + iconv: CP420 + +CP423: + iconv: CP423 + +CP424: + iconv: CP424 + python_encode: cp424 + +CP437: + iconv: CP437 + python_encode: cp437 + +CP500: + iconv: CP500 + python_encode: cp500 + +CP720: + python_encode: cp720 + +CP737: + iconv: CP737 + python_encode: cp737 + +CP747: {} + +CP770: + iconv: CP770 + +CP771: + iconv: CP771 + +CP772: + iconv: CP772 + +CP773: + iconv: CP773 + +CP774: + iconv: CP774 + +CP775: + iconv: CP775 + python_encode: cp775 + +CP803: + iconv: CP803 + +CP813: + iconv: CP813 + +CP819: + iconv: CP819 + +CP850: + iconv: CP850 + python_encode: cp850 + +CP851: + name: "Greek CP851" + notes: "Not used, due to inconsistencies between implementations." + +CP852: + iconv: CP852 + python_encode: cp852 + +CP853: {} + +CP855: + iconv: CP855 + python_encode: cp855 + +CP856: + iconv: CP856 + python_encode: cp856 + +CP857: + iconv: CP857 + python_encode: cp857 + +CP858: + python_encode: cp858 + +CP860: + iconv: CP860 + python_encode: cp860 + +CP861: + iconv: CP861 + python_encode: cp861 + +CP862: + iconv: CP862 + python_encode: cp862 + +CP863: + iconv: CP863 + python_encode: cp863 + +CP864: + iconv: CP864 + python_encode: cp864 + +CP865: + iconv: CP865 + python_encode: cp865 + +CP866: + iconv: CP866 + python_encode: cp866 + +CP866NAV: + iconv: CP866NAV + +CP868: + iconv: CP868 + +CP869: + iconv: CP869 + python_encode: cp869 + +CP870: + iconv: CP870 + +CP871: + iconv: CP871 + +CP874: + iconv: CP874 + python_encode: cp874 + +CP875: + iconv: CP875 + python_encode: cp875 + +CP880: + iconv: CP880 + +CP891: + iconv: CP891 + +CP901: + iconv: CP901 + +CP902: + iconv: CP902 + +CP903: + iconv: CP903 + +CP904: + iconv: CP904 + +CP905: + iconv: CP905 + +CP912: + iconv: CP912 + +CP915: + iconv: CP915 + +CP916: + iconv: CP916 + +CP918: + iconv: CP918 + +CP920: + iconv: CP920 + +CP921: + iconv: CP921 + +CP922: + iconv: CP922 + +CP928: {} + +CP930: + iconv: CP930 + +CP932: + iconv: CP932 + python_encode: cp932 + +CP933: + iconv: CP933 + +CP935: + iconv: CP935 + +CP936: + iconv: CP936 + +CP937: + iconv: CP937 + +CP939: + iconv: CP939 + +CP949: + iconv: CP949 + python_encode: cp949 + +CP950: + iconv: CP950 + python_encode: cp950 + +CP1001: + name: Unimplemented Star-specific CP1001 + +CP1004: + iconv: CP1004 + +CP1006: + python_encode: cp1006 + +CP1008: + iconv: CP1008 + +CP1025: + iconv: CP1025 + +CP1026: + iconv: CP1026 + python_encode: cp1026 + +CP1046: + iconv: CP1046 + +CP1047: + iconv: CP1047 + +CP1070: + iconv: CP1070 + +CP1079: + iconv: CP1079 + +CP1081: + iconv: CP1081 + +CP1084: + iconv: CP1084 + +CP1089: + iconv: CP1089 + +CP1097: + iconv: CP1097 + +CP1098: {} + +CP1112: + iconv: CP1112 + +CP1122: + iconv: CP1122 + +CP1123: + iconv: CP1123 + +CP1124: + iconv: CP1124 + +CP1125: + iconv: CP1125 + python_encode: cp1125 + +CP1129: + iconv: CP1129 + +CP1130: + iconv: CP1130 + +CP1132: + iconv: CP1132 + +CP1133: + iconv: CP1133 + +CP1137: + iconv: CP1137 + +CP1140: + iconv: CP1140 + python_encode: cp1140 + +CP1141: + iconv: CP1141 + +CP1142: + iconv: CP1142 + +CP1143: + iconv: CP1143 + +CP1144: + iconv: CP1144 + +CP1145: + iconv: CP1145 + +CP1146: + iconv: CP1146 + +CP1147: + iconv: CP1147 + +CP1148: + iconv: CP1148 + +CP1149: + iconv: CP1149 + +CP1153: + iconv: CP1153 + +CP1154: + iconv: CP1154 + +CP1155: + iconv: CP1155 + +CP1156: + iconv: CP1156 + +CP1157: + iconv: CP1157 + +CP1158: + iconv: CP1158 + +CP1160: + iconv: CP1160 + +CP1161: + iconv: CP1161 + +CP1162: + iconv: CP1162 + +CP1163: + iconv: CP1163 + +CP1164: + iconv: CP1164 + +CP1166: + iconv: CP1166 + +CP1167: + iconv: CP1167 + +CP1250: + iconv: CP1250 + python_encode: cp1250 + +CP1251: + iconv: CP1251 + python_encode: cp1251 + +CP1252: + iconv: CP1252 + python_encode: cp1252 + +CP1253: + iconv: CP1253 + python_encode: cp1253 + +CP1254: + iconv: CP1254 + python_encode: cp1254 + +CP1255: + iconv: CP1255 + python_encode: cp1255 + +CP1256: + iconv: CP1256 + python_encode: cp1256 + +CP1257: + iconv: CP1257 + python_encode: cp1257 + +CP1258: + iconv: CP1258 + python_encode: cp1258 + +CP1282: + iconv: CP1282 + +CP1361: + iconv: CP1361 + +CP1364: + iconv: CP1364 + +CP1371: + iconv: CP1371 + +CP1388: + iconv: CP1388 + +CP1390: + iconv: CP1390 + +CP1399: + iconv: CP1399 + +CP2001: + name: Unimplemented Star-specific CP2001 + +CP3001: + name: Unimplemented Star-specific CP3001 + +CP3002: + name: Unimplemented Star-specific CP3002 + +CP3011: + name: "CP3011 Latvian" + data: + - "ÇüéâäàåçêëèïîìÄÅ" + - "ÉæÆôöòûùÿÖÜ¢£¥₧ƒ" + - "áíóúñѪº¿⌐¬½¼¡«»" + - "░▒▓│┤Ā╢ņ╕╣║╗╝╜╛┐" + - "└┴┬├─┼ā╟╚╔╩╦╠═╬╧" + - "Š╤čČ╘╒ģĪī┘┌█▄ūŪ▀" + - "αßΓπΣσµτΦΘΩδ∞φε∩" + - "ĒēĢķĶļĻžŽ∙·√Ņš■ " + +CP3012: + name: "CP3012 Cyrillic" + data: + - "АБВГДЕЖЗИЙКЛМНОП" + - "РСТУФХЦЧШЩЪЫЬЭЮЯ" + - "абвгдежзийклмноп" + - "░▒▓│┤Ā╢ņ╕╣║╗╝Ō╛┐" + - "└┴┬├─┼ā╟╚╔╩╦╠═╬╧" + - "Š╤čČ╘╒ģĪī┘┌█▄ūŪ▀" + - "рстуфхцчшщъыьэюя" + - "ĒēĢķĶļĻžŽ∙·√Ņš■ " + +CP3021: + name: Unimplemented Star-specific CP3021 + +CP3041: + name: Unimplemented Star-specific CP3041 + +CP3840: + name: Unimplemented Star-specific CP3840 + +CP3841: + name: Unimplemented Star-specific CP3841 + +CP3843: + name: Unimplemented Star-specific CP3843 + +CP3844: + name: Unimplemented Star-specific CP3844 + +CP3845: + name: Unimplemented Star-specific CP3845 + +CP3847: + name: Unimplemented Star-specific CP3847 + +CP3846: + name: Unimplemented Star-specific CP3846 + +CP3848: + name: Unimplemented Star-specific CP3848 + +CP4517: + iconv: CP4517 + +CP4899: + iconv: CP4899 + +CP4909: + iconv: CP4909 + +CP4971: + iconv: CP4971 + +CP5347: + iconv: CP5347 + +CP9030: + iconv: CP9030 + +CP9066: + iconv: CP9066 + +CP9448: + iconv: CP9448 + +CP10007: + iconv: CP10007 + +CP12712: + iconv: CP12712 + +CP16804: + iconv: CP16804 + +ISO_8859-1: + iconv: "ISO_8859-1" + python_encode: "latin_1" + +ISO_8859-2: + iconv: "ISO_8859-2" + python_encode: "iso8859_2" + +ISO_8859-3: + iconv: "ISO_8859-3" + python_encode: "iso8859_3" + +ISO_8859-4: + iconv: "ISO_8859-4" + python_encode: "iso8859_4" + +ISO_8859-5: + iconv: "ISO_8859-5" + python_encode: "iso8859_5" + +ISO_8859-6: + iconv: "ISO_8859-6" + python_encode: "iso8859_6" + +ISO_8859-7: + iconv: "ISO_8859-7" + python_encode: "iso8859_7" + +ISO_8859-8: + iconv: "ISO_8859-8" + python_encode: "iso8859_8" + +ISO_8859-9: + iconv: "ISO_8859-9" + python_encode: "iso8859_9" + +ISO_8859-10: + iconv: "ISO_8859-10" + python_encode: "iso8859-10" + +ISO_8859-11: + iconv: "ISO_8859-11" + python_encode: "iso8859-11" + +ISO_8859-13: + iconv: "ISO_8859-13" + python_encode: "iso8859-13" + +ISO_8859-14: + iconv: "ISO_8859-14" + python_encode: "iso8859-14" + +ISO_8859-15: + iconv: "ISO_8859-15" + python_encode: "iso8859-15" + +ISO_8859-16: + iconv: "ISO_8859-16" + python_encode: "iso8859_16" + +RK1048: + iconv: RK1048 + +TCVN-3-1: + name: "Vietnamese TCVN-3 1" + data: + - " " + - " " + - " ăâêôơưđ " + - " àảãáạ ằẳẵắ " + - " ặầẩẫấậè ẻẽ" + - "éẹềểễếệìỉ ĩíịò" + - " ỏõóọồổỗốộờởỡớợù" + - " ủũúụừửữứựỳỷỹýỵ " + +TCVN-3-2: + name: "Vietnamese TCVN-3 1" + data: + - " " + - " " + - " Ă РÊÔƠƯ " + - " ÀẢÃÁẠ ẰẲẴẮ " + - " ẶẦẨẪẤẬÈ ẺẼ" + - "ÉẸỀỂỄẾỆÌỈ ĨÍỊÒ" + - " ỎÕÓỌỒỔỖỐỘỜỞỠỚỢÙ" + - " ỦŨÚỤỪỬỮỨỰỲỶỸÝỴ " + +OXHOO-EUROPEAN: + name: Oxhoo-specific European + data: + - "ÇüéâäàåçêëèïîìÄÅ" + - "ÉæÆôöòûùÿÖÜñѪº¿" + - "áíóú¢£¥₧ƒ¡ÃãÕõØø" + - "·¨°`´½¼×÷≤≥«»≠√¯" + - "⌠⌡∞◤↵↑↓→←┌┐└┘•®©" + # Some unidentified chars + - "™†§¶Γ◢Θ " + - "ß ε " + - "τ " + +Unknown: + name: Unknown + notes: Code page that has not yet been identified. +... diff --git a/capabilities-data/data/profile/AF-240.yml b/capabilities-data/data/profile/AF-240.yml new file mode 100644 index 0000000..456ac91 --- /dev/null +++ b/capabilities-data/data/profile/AF-240.yml @@ -0,0 +1,29 @@ +--- +AF-240: + name: AF-240 Customer Display + vendor: Oxhoo + inherits: simple + features: + bitImageRaster: false + bitImageColumn: false + graphics: false + highDensity: false + pulseStandard: false + fonts: + 0: + name: Font A + columns: 20 + media: + width: + # Approximate measurement + mm: 120 + # 5x7 pixels per char, by 20 columns. + pixels: 100 + notes: > + This is a two-line, ESC/POS-aware customer display from Oxhoo. The ESC/POS + command mode can be activated persistently by sending: + + echo -ne "\n\x02\x05\x43\x31\x03" > /dev/ttyUSB0 + codePages: + 0: OXHOO-EUROPEAN +... diff --git a/capabilities-data/data/profile/CT-S651.yml b/capabilities-data/data/profile/CT-S651.yml new file mode 100644 index 0000000..7d59e53 --- /dev/null +++ b/capabilities-data/data/profile/CT-S651.yml @@ -0,0 +1,70 @@ +--- +CT-S651: + name: CT-S651 + vendor: "Citizen" + inherits: default + notes: > + Citizen CT-S651 profile. This is a two-color thermal printer, + supporting paper sizes from 58mm up to 83mm + features: + barcodeA: true + barcodeB: true + bitImageRaster: true + bitImageColumn: true + graphics: true + starCommands: false + qrCode: true + pdf417Code: true + highDensity: true + pulseStandard: true + pulseBel: true + paperFullCut: true + paperPartCut: true + colors: + 0: black + 1: red + fonts: + 0: + name: Font A + columns: 48 + 1: + name: Font B + columns: 64 + 2: + name: Font C + columns: 72 + media: + width: + mm: 80 + pixels: 640 + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 6: CP852 + 7: CP866 + 8: CP857 + 9: CP1252 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + # Thai code11 1 Pass + 20: Unknown + # Thai code11 3 Pass + 21: Unknown + # Thai code18 1 Pass + 25: Unknown + # Thai code18 3 Pass + 26: Unknown + # TCVN3 + 30: TCVN-3-1 + # TCVN3 Caps + 31: TCVN-3-2 + 40: CP864 + # Space page (For user setting) + 255: Unknown +... diff --git a/capabilities-data/data/profile/NT-5890K.yml b/capabilities-data/data/profile/NT-5890K.yml new file mode 100644 index 0000000..e095094 --- /dev/null +++ b/capabilities-data/data/profile/NT-5890K.yml @@ -0,0 +1,8 @@ +--- +NT-5890K: + name: NT-5890K + vendor: Netum + inherits: POS-5890 + notes: "" + features: + bitImageColumn: true diff --git a/capabilities-data/data/profile/OCD-100.yml b/capabilities-data/data/profile/OCD-100.yml new file mode 100644 index 0000000..d879680 --- /dev/null +++ b/capabilities-data/data/profile/OCD-100.yml @@ -0,0 +1,50 @@ +--- +OCD-100: + name: OCD-100 Customer Display + vendor: Aures + inherits: simple + features: + bitImageRaster: false + bitImageColumn: false + graphics: false + highDensity: false + pulseStandard: false + fonts: + 0: + name: Font A + columns: 20 + media: + width: + # 9x5.25mm per char, by 20 columns. + mm: 180 + # 5x7 pixels per char, by 20 columns. + pixels: 100 + notes: > + This is a two-line, ESC/POS-aware customer display from Aures. It has some + graphics support via custom fonts, but is otherwise text-only. + This profile is also suitable for the OCD-150 pole-mounted display. + codePages: + 0: CP437 + # Katakana (for Japan) + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # Slawie + 6: Unknown + # Russia + 7: Unknown + # Greek + 8: Unknown + 9: CP852 + 10: CP862 + 11: CP866 + 12: CP1251 + 13: CP1254 + 14: CP1255 + 15: CP1257 + 16: CP1252 + 17: CP1253 + 19: CP858 +... diff --git a/capabilities-data/data/profile/OCD-300.yml b/capabilities-data/data/profile/OCD-300.yml new file mode 100644 index 0000000..e9bd65b --- /dev/null +++ b/capabilities-data/data/profile/OCD-300.yml @@ -0,0 +1,51 @@ +--- +OCD-300: + name: OCD-300 Customer Display + vendor: Aures + inherits: simple + features: + bitImageRaster: false + bitImageColumn: false + graphics: false + highDensity: false + pulseStandard: false + fonts: + 0: + name: Font A + columns: 20 + media: + width: + mm: 130.2 + # 12x32 pixels per char + pixels: 240 + notes: > + This is a two-line, ESC/POS-aware customer display from Aures. It has some + graphics support via vendor-provided tools, but is otherwise text-only. + codePages: + 0: CP437 + # Katakana (for Japan) + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # Slawie + 6: Unknown + # Russia + 7: Unknown + # Greek + 8: Unknown + 9: CP852 + 10: CP862 + 11: CP866 + 12: CP1251 + 13: CP1254 + 14: CP1255 + 15: CP1257 + 16: CP1252 + 17: CP1253 + 18: CP1250 + 19: CP858 + # Arabic + 20: Unknown +... diff --git a/capabilities-data/data/profile/P822D.yml b/capabilities-data/data/profile/P822D.yml new file mode 100644 index 0000000..a11cefc --- /dev/null +++ b/capabilities-data/data/profile/P822D.yml @@ -0,0 +1,96 @@ +--- +P822D: + name: P822D + vendor: PBM + inherits: default + notes: "" + features: + graphics: false + codePages: + 0: CP437 + # Katakana + 1: Unknown + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # Western Europe + 6: Unknown + # Greek + 7: Unknown + # Hebrew + 8: Unknown + # Eastern europe + 9: Unknown + # Iran + 10: Unknown + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + # Iran II + 20: Unknown + # latvian + 21: Unknown + # Arabic + 22: Unknown + # PT151, 1251 + 23: Unknown + 24: CP747 + 25: CP1257 + # Vietnam + 27: Unknown + 28: CP864 + 29: CP1001 + # Uigur + 30: Unknown + # Hebrew + 31: Unknown + 32: CP1255 + 33: CP720 + 34: CP1256 + 35: CP1257 + # Thai + 255: Unknown + 50: CP437 + # Jatakana + 51: Unknown + 52: CP437 + 53: CP858 + 54: CP852 + 55: CP860 + 56: CP861 + 57: CP863 + 58: CP865 + 59: CP866 + 60: CP855 + 61: CP857 + 62: CP862 + 63: CP864 + 64: CP737 + 65: CP851 + 66: CP869 + 67: CP928 + 68: CP772 + 69: CP774 + 70: CP874 + 71: CP1252 + 72: CP1250 + 73: CP1251 + 74: CP3840 + 75: CP3841 + 76: CP3843 + 77: CP3844 + 78: CP3845 + 79: CP3846 + 80: CP3847 + 81: CP3848 + 82: CP1001 + 83: CP2001 + 84: CP3001 + 85: CP3002 + 86: CP3011 + 87: CP3012 + 88: CP3021 + 89: CP3041 +... diff --git a/capabilities-data/data/profile/POS-5890.yml b/capabilities-data/data/profile/POS-5890.yml new file mode 100644 index 0000000..ed14868 --- /dev/null +++ b/capabilities-data/data/profile/POS-5890.yml @@ -0,0 +1,100 @@ +--- +POS-5890: + name: POS5890 Series + vendor: Zjiang + inherits: simple + fonts: + 0: + name: Font A + columns: 32 + 1: + name: Font B + columns: 42 + media: + width: + mm: 57.5 + pixels: 384 + notes: > + POS-5890 thermal printer series, also marketed under various other names. + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # West Europe + 6: Unknown + # Greek + 7: Unknown + # Hebrew + 8: Unknown + # East Europe + 9: Unknown + # Iran + 10: Unknown + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + # Iran II + 20: Unknown + # Latvian + 21: Unknown + # Arabic + 22: Unknown + # PT151, 1251 + 23: Unknown + 24: CP747 + 25: CP1257 + 27: CP1258 + 28: CP864 + # Hebrew + 31: Unknown + 32: CP1255 + 50: CP437 + 52: CP437 + 53: CP858 + 54: CP852 + 55: CP860 + 56: CP861 + 57: CP863 + 58: CP865 + 59: CP866 + 60: CP855 + 61: CP857 + 62: CP862 + 63: CP864 + 64: CP737 + 65: CP851 + 66: CP869 + 68: CP772 + 69: CP774 + 71: CP1252 + 72: CP1250 + 73: CP1251 + 74: CP3840 + 76: CP3843 + 77: CP3844 + 78: CP3845 + 79: CP3846 + 80: CP3847 + 81: CP3848 + 83: CP2001 + 84: CP3001 + 85: CP3002 + 86: CP3011 + 87: CP3012 + 88: CP3021 + 89: CP3041 + 90: CP1253 + 91: CP1254 + 92: CP1256 + 93: CP720 + 94: CP1258 + 95: CP775 + # Thai 2 + 96: Unknown + # Thai + 255: Unknown +... diff --git a/capabilities-data/data/profile/RP326.yml b/capabilities-data/data/profile/RP326.yml new file mode 100644 index 0000000..3e7b656 --- /dev/null +++ b/capabilities-data/data/profile/RP326.yml @@ -0,0 +1,63 @@ +--- +RP326: + name: RP326 + vendor: Rongta + inherits: default + notes: "" + features: + graphics: false + codePages: + 0: CP437 + # Katakana + 1: Unknown + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 6: CP1251 + 7: CP866 + # MIK[Cyrillic /Bulgarian] + 8: Unknown + # CP755 + 9: Unknown + # Iran + 10: Unknown + 15: CP862 + 16: CP1252 + 17: CP1253 + 18: CP852 + 19: CP858 + # Iran II + 20: Unknown + # Latvian + 21: Unknown + # Arabic + 22: Unknown + 23: ISO_8859-1 + 24: CP737 + 25: CP1257 + # Thai + 26: Unknown + 27: CP720 + 28: CP855 + 29: CP857 + 30: CP1250 + 31: CP775 + 32: CP1254 + 33: CP1255 + 34: CP1256 + 35: CP1258 + 36: ISO_8859-2 + 37: ISO_8859-3 + 38: ISO_8859-4 + 39: ISO_8859-5 + 40: ISO_8859-6 + 41: ISO_8859-7 + 42: ISO_8859-8 + 43: ISO_8859-9 + 44: ISO_8859-15 + # Thai + 45: Unknown + 46: CP856 + 47: CP874 +... diff --git a/capabilities-data/data/profile/SP2000.yml b/capabilities-data/data/profile/SP2000.yml new file mode 100644 index 0000000..11d005a --- /dev/null +++ b/capabilities-data/data/profile/SP2000.yml @@ -0,0 +1,67 @@ +--- +SP2000: + name: SP2000 Series + vendor: Star Micronics + inherits: default + notes: Star SP2000 impact printer series with ESC/POS emulation enabled + features: + starCommands: true + codePages: + # "Normal" + 0: CP437 + 1: CP437 + 2: CP932 + 3: CP437 + 4: CP858 + 5: CP852 + 6: CP860 + 7: CP861 + 8: CP863 + 9: CP865 + 10: CP866 + 11: CP855 + 12: CP857 + 13: CP862 + 14: CP864 + 15: CP737 + 16: CP851 + 17: CP869 + 18: CP928 + 19: CP772 + 20: CP774 + 21: CP874 + 32: CP1252 + 33: CP1250 + 34: CP1251 + 64: CP3840 + 65: CP3841 + 66: CP3843 + 67: CP3844 + 68: CP3845 + 69: CP3846 + 70: CP3847 + 71: CP3848 + 72: CP1001 + 73: CP2001 + 74: CP3001 + 75: CP3002 + 76: CP3011 + 77: CP3012 + 78: CP3021 + 79: CP3041 + # Thai Character Code 42 + 96: Unknown + # Thai Character Code 11 + 97: Unknown + # Thai Character Code 13 + 98: Unknown + # Thai Character Code 14 + 99: Unknown + # Thai Character Code 16 + 100: Unknown + # Thai Character Code 17 + 101: Unknown + # Thai Character Code 18 + 102: Unknown + 255: Unknown +... diff --git a/capabilities-data/data/profile/Sunmi-V2.yml b/capabilities-data/data/profile/Sunmi-V2.yml new file mode 100644 index 0000000..3a705d8 --- /dev/null +++ b/capabilities-data/data/profile/Sunmi-V2.yml @@ -0,0 +1,51 @@ +--- +Sunmi-V2: + name: Sunmi V2 + vendor: Sunmi + notes: > + Sunmi mini-POS Android device with a built-in Virtual Bluetooth + thermal printer. + inherits: default + features: + # column mode doesn't work reliably on this device + bitImageColumn: false + bitImageRaster: true + # not tested, status unknown + graphics: false + # has no paper cutter + paperFullCut: false + paperPartCut: false + colors: + 0: black + fonts: + 0: + name: Font A + columns: 32 + 1: + name: Font B + columns: 42 + media: + width: + mm: 57.5 + pixels: 384 + codePages: + 0: CP437 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 13: CP857 + 14: CP737 + 15: ISO_8859-7 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + # Thai Character Code 11 + 21: CP874 + 33: CP775 + 34: CP855 + 36: CP862 + 37: CP864 + 254: CP855 +... diff --git a/capabilities-data/data/profile/TEP-200M.yml b/capabilities-data/data/profile/TEP-200M.yml new file mode 100644 index 0000000..c22bd13 --- /dev/null +++ b/capabilities-data/data/profile/TEP-200M.yml @@ -0,0 +1,9 @@ +--- +# More info on this printer is posted at +# https://github.com/mike42/escpos-php/issues/6 +TEP-200M: + name: TEP200M Series + vendor: EPOS + notes: "" + inherits: default +... diff --git a/capabilities-data/data/profile/TM-P80-42col.yml b/capabilities-data/data/profile/TM-P80-42col.yml new file mode 100644 index 0000000..107b0d8 --- /dev/null +++ b/capabilities-data/data/profile/TM-P80-42col.yml @@ -0,0 +1,21 @@ +--- +TM-P80-42col: + name: TM-P80 (42 column mode) + vendor: Epson + inherits: TM-P80 + notes: Portable printer (42-column mode) + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 60 + 2: + name: Kanji + columns: 21 + media: + width: + mm: 63.6 + pixels: 546 +... diff --git a/capabilities-data/data/profile/TM-P80.yml b/capabilities-data/data/profile/TM-P80.yml new file mode 100644 index 0000000..a3a72ee --- /dev/null +++ b/capabilities-data/data/profile/TM-P80.yml @@ -0,0 +1,21 @@ +--- +TM-P80: + name: TM-P80 + vendor: Epson + inherits: default + notes: Portable printer (48-column mode) + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + 2: + name: Kanji + columns: 24 + media: + width: + mm: 72 + pixels: 576 +... diff --git a/capabilities-data/data/profile/TM-T88II.yml b/capabilities-data/data/profile/TM-T88II.yml new file mode 100644 index 0000000..977492c --- /dev/null +++ b/capabilities-data/data/profile/TM-T88II.yml @@ -0,0 +1,109 @@ +--- +TM-T88II: + name: TM-T88II + vendor: "Epson" + inherits: default + notes: > + Epson TM-T88II profile. The specs where taken from a TM-T88IIP machine + (I assume the P just stands for parallel port). The standart 80mm paper + width version was used here. There is also a custom 58mm factory option. + If you are using the custom version change media width to 50.8mm and + 360px accordingly. This printer is discontinued by the Vendor and has + similar feature support to the TM-T88III. The code page mapping is + documented in the "TM-T88II/T88III Technical Reference Guide". + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + media: + width: + mm: 72 + pixels: 512 + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # Hiragana + 6: Unknown + # One-pass printing Kanji characters + 7: Unknown + # One-pass printing Kanji characters + 8: Unknown + 11: Unknown + 12: Unknown + 13: CP857 + 14: CP737 + 15: ISO_8859-7 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: Unknown + # Thai Character Code 42 + 20: Unknown + # Thai Character Code 11 + 21: CP874 + # Thai Character Code 13 + 22: Unknown + # Thai Character Code 14 + 23: Unknown + # Thai Character Code 16 + 24: Unknown + # Thai Character Code 17 + 25: Unknown + # Thai Character Code 18 + 26: Unknown + 30: TCVN-3-1 + 31: TCVN-3-2 + 32: Unknown + 33: CP775 + 34: CP855 + 35: CP861 + 36: CP862 + 37: CP864 + 38: CP869 + 39: ISO_8859-2 + 40: ISO_8859-15 + 41: Unknown + 42: CP774 + 43: CP772 + 44: CP1125 + 45: CP1250 + 46: CP1251 + 47: CP1253 + 48: CP1254 + 49: CP1255 + 50: CP1256 + 51: CP1257 + 52: CP1258 + 53: RK1048 + # Devanagari + 66: Unknown + # Bengali + 67: Unknown + # Tamil + 68: Unknown + # Telugu + 69: Unknown + # Assamese + 70: Unknown + # Oriya + 71: Unknown + # Kannada + 72: Unknown + # Malayalam + 73: Unknown + # Gujarati + 74: Unknown + # Punjabi + 75: Unknown + # Marathi + 82: Unknown + 254: Unknown + 255: Unknown +... diff --git a/capabilities-data/data/profile/TM-T88III.yml b/capabilities-data/data/profile/TM-T88III.yml new file mode 100644 index 0000000..23a4d36 --- /dev/null +++ b/capabilities-data/data/profile/TM-T88III.yml @@ -0,0 +1,22 @@ +--- +TM-T88III: + name: TM-T88III + vendor: "Epson" + inherits: default + notes: > + Epson TM-T88III profile. This printer has similar feature support to the + TM-T88II. The code page mapping is documented in the + "TM-T88II/T88III Technical Reference Guide". + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 16: CP1252 + 17: CP866 + 18: CP862 + 19: CP858 + 255: Unknown +... diff --git a/capabilities-data/data/profile/TM-T88IV-SA.yml b/capabilities-data/data/profile/TM-T88IV-SA.yml new file mode 100644 index 0000000..81e9ef2 --- /dev/null +++ b/capabilities-data/data/profile/TM-T88IV-SA.yml @@ -0,0 +1,25 @@ +--- +TM-T88IV-SA: + name: TM-T88IV South Asia + vendor: "Epson" + inherits: TM-T88IV + notes: > + Epson TM-T88IV profile (South Asia models) + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + codePages: + 0: CP437 + # Thai Character Code 42 + 20: Unknown + # Thai Character Code 11 + 21: CP874 + # Thai Character Code 18 + 26: Unknown + 30: TCVN-3-1 + 31: TCVN-3-2 +... diff --git a/capabilities-data/data/profile/TM-T88IV.yml b/capabilities-data/data/profile/TM-T88IV.yml new file mode 100644 index 0000000..ae01cdd --- /dev/null +++ b/capabilities-data/data/profile/TM-T88IV.yml @@ -0,0 +1,31 @@ +--- +TM-T88IV: + name: TM-T88IV + vendor: "Epson" + inherits: default + notes: > + Epson TM-T88IV profile + media: + width: + mm: 80 + pixels: 512 + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + 255: Unknown +... diff --git a/capabilities-data/data/profile/TM-T88V.yml b/capabilities-data/data/profile/TM-T88V.yml new file mode 100644 index 0000000..d63186b --- /dev/null +++ b/capabilities-data/data/profile/TM-T88V.yml @@ -0,0 +1,57 @@ +--- +TM-T88V: + name: TM-T88V + vendor: "Epson" + inherits: default + notes: > + Epson TM-T88V profile + media: + width: + mm: 80 + pixels: 512 + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 11: CP851 + 12: CP853 + 13: CP857 + 14: CP737 + 15: ISO_8859-7 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + 30: TCVN-3-1 + 31: TCVN-3-2 + 32: CP720 + 33: CP775 + 34: CP855 + 35: CP861 + 36: CP862 + 37: CP864 + 38: CP869 + 39: ISO_8859-2 + 40: ISO_8859-15 + 41: CP1098 + 45: CP1250 + 46: CP1251 + 47: CP1253 + 48: CP1254 + 49: CP1255 + 50: CP1256 + 51: CP1257 + 52: CP1258 + 53: RK1048 + 255: Unknown +... diff --git a/capabilities-data/data/profile/TM-U220.yml b/capabilities-data/data/profile/TM-U220.yml new file mode 100644 index 0000000..15dc97b --- /dev/null +++ b/capabilities-data/data/profile/TM-U220.yml @@ -0,0 +1,18 @@ +--- +TM-U220: + name: TM-U220 + vendor: Epson + inherits: simple + notes: Two-color impact printer with 80mm output + features: + bitImageRaster: false + bitImageColumn: true + highDensity: false + colors: + 0: black + 1: alternate + media: + width: + mm: 80 + pixels: Unknown +... diff --git a/capabilities-data/data/profile/TSP600.yml b/capabilities-data/data/profile/TSP600.yml new file mode 100644 index 0000000..7aa5c4d --- /dev/null +++ b/capabilities-data/data/profile/TSP600.yml @@ -0,0 +1,7 @@ +--- +TSP600: + name: TSP600 Series + vendor: Star Micronics + inherits: SP2000 + notes: Star TSP600 thermal printer series with ESC/POS emulation enabled +... diff --git a/capabilities-data/data/profile/TUP500.yml b/capabilities-data/data/profile/TUP500.yml new file mode 100644 index 0000000..c0bea5d --- /dev/null +++ b/capabilities-data/data/profile/TUP500.yml @@ -0,0 +1,7 @@ +--- +TUP500: + name: TUP500 Series + vendor: Star Micronics + inherits: SP2000 + notes: Star TUP500 thermal printer series with ESC/POS emulation enabled +... diff --git a/capabilities-data/data/profile/ZJ-5870.yml b/capabilities-data/data/profile/ZJ-5870.yml new file mode 100644 index 0000000..3f7c7ca --- /dev/null +++ b/capabilities-data/data/profile/ZJ-5870.yml @@ -0,0 +1,47 @@ +--- +ZJ-5870: + name: ZJ-5870 Thermal Receipt Printer + vendor: ZiJiang + notes: > + ESC/POS Profile for ZiJiang ZJ-5870 Thermal Receipt Printer, + which may be branded AGPtEK or Esky, + and identifies itself as a POS-58 Thermal Printer on selftest. + This profile is suitable for alphanumberic character mode, + but is untested on Chinese character mode. + (Change modes by holding down feed button during power-on + until the mode LED turns off, then release immediately.) + features: + barcodeA: false + barcodeB: false + bitImageRaster: true + bitImageColumn: true + graphics: false + starCommands: false + qrCode: false + pdf417Code: false + highDensity: false + pulseStandard: true + pulseBel: false + paperFullCut: false + paperPartCut: false + colors: + 0: black + fonts: + 0: + name: Font A + columns: 32 + media: + width: + mm: 48 + pixels: 384 + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + 16: CP1252 + 17: CP866 + 18: CP852 +... diff --git a/capabilities-data/data/profile/default.yml b/capabilities-data/data/profile/default.yml new file mode 100644 index 0000000..5ade6ba --- /dev/null +++ b/capabilities-data/data/profile/default.yml @@ -0,0 +1,120 @@ +--- +default: + name: Default + vendor: Generic + notes: > + Default ESC/POS profile, suitable for standards-compliant or + Epson-branded printers. This profile allows the use of standard + ESC/POS features, and can encode a variety of code pages. + features: + barcodeA: true + barcodeB: true + bitImageRaster: true + bitImageColumn: true + graphics: true + starCommands: false + qrCode: true + pdf417Code: true + highDensity: true + pulseStandard: true + pulseBel: false + paperFullCut: true + paperPartCut: true + colors: + 0: black + fonts: + 0: + name: Font A + columns: 42 + 1: + name: Font B + columns: 56 + media: + width: + mm: Unknown + pixels: Unknown + codePages: + 0: CP437 + 1: CP932 + 2: CP850 + 3: CP860 + 4: CP863 + 5: CP865 + # Hiragana + 6: Unknown + # One-pass printing Kanji characters + 7: Unknown + # One-pass printing Kanji characters + 8: Unknown + 11: CP851 + 12: CP853 + 13: CP857 + 14: CP737 + 15: ISO_8859-7 + 16: CP1252 + 17: CP866 + 18: CP852 + 19: CP858 + # Thai Character Code 42 + 20: Unknown + # Thai Character Code 11 + 21: CP874 + # Thai Character Code 13 + 22: Unknown + # Thai Character Code 14 + 23: Unknown + # Thai Character Code 16 + 24: Unknown + # Thai Character Code 17 + 25: Unknown + # Thai Character Code 18 + 26: Unknown + 30: TCVN-3-1 + 31: TCVN-3-2 + 32: CP720 + 33: CP775 + 34: CP855 + 35: CP861 + 36: CP862 + 37: CP864 + 38: CP869 + 39: ISO_8859-2 + 40: ISO_8859-15 + 41: CP1098 + 42: CP774 + 43: CP772 + 44: CP1125 + 45: CP1250 + 46: CP1251 + 47: CP1253 + 48: CP1254 + 49: CP1255 + 50: CP1256 + 51: CP1257 + 52: CP1258 + 53: RK1048 + # Devanagari + 66: Unknown + # Bengali + 67: Unknown + # Tamil + 68: Unknown + # Telugu + 69: Unknown + # Assamese + 70: Unknown + # Oriya + 71: Unknown + # Kannada + 72: Unknown + # Malayalam + 73: Unknown + # Gujarati + 74: Unknown + # Punjabi + 75: Unknown + # Marathi + 82: Unknown + 254: Unknown + 255: Unknown +... diff --git a/capabilities-data/data/profile/simple.yml b/capabilities-data/data/profile/simple.yml new file mode 100644 index 0000000..074dc24 --- /dev/null +++ b/capabilities-data/data/profile/simple.yml @@ -0,0 +1,21 @@ +--- +simple: + name: Simple + vendor: Generic + inherits: default + notes: > + A profile for use in printers with unknown or poor compatibility. This + profile indicates that a small number of features are supported, so that + commands are not sent a printer that is unlikely to understand them. + features: + barcodeA: false + barcodeB: false + bitImageColumn: false + graphics: false + qrCode: false + pdf417Code: false + paperFullCut: false + paperPartCut: false + codePages: + 0: CP437 +... diff --git a/capabilities-data/doc/add-your-printer.md b/capabilities-data/doc/add-your-printer.md new file mode 100644 index 0000000..d633b75 --- /dev/null +++ b/capabilities-data/doc/add-your-printer.md @@ -0,0 +1,103 @@ +# How to get your printer included in the database + +We aim to list every ESC/POS printer in this database, and we need your help! + +## Why is it good to have my printer listed? + +Data from this project is used by multiple open source projects to improve +printer compatibility. + +If your printer is listed with accurate information, then drivers which use +this data will know how to safely use features like images, QR codes, +barcodes, and non-ASCII text encoding. + +## Is my printer in the database already? + +Check [the browsable version of this database](https://mike42.me/escpos-printer-db/). + +Some printers are sold under several names, so look out for similar model numbers as well. + +## Is my printer eligible to be listed? + +Any ESC/POS devices can be listed, including: + +- ESC/POS thermal and impact printers +- Printers with ESC/POS emulation mode +- Non-printing ESC/POS devices like customer displays + +If your printer does not understand ESC/POS, then we wont list it. + +## Information to gather + +The minimum info that you need to make a printer profile is: + +- Vendor name and model number. +- Link to a vendor programming guide that lists supported features if it is available online. +- Paper width (58mm and 80mm are common). + +If you don't have documentation, then you need to print some things to try to find out what your printer supports: + +- Test page output listing supported character encodings. +- Output of some ESC/POS commands to see what works. + +For testing out features, you can send [escpos-php test files](https://github.com/mike42/escpos-php/tree/master/test/integration/resources/output) +to your printer and note the output for each file. + +Once you have this, file a [new issue](https://github.com/receipt-print-hq/escpos-printer-db/issues/new) with the information. + +## How to write a printer profile + +Profiles are written in `yml` syntax. Start by selecting a base profile, then override a +small number of options. + +- The `default` profile is a good base for printers with a lot of features +- The `simple` profile is a good base for printers which have very few features + +This example is the `TM-U220` profile, which is based on the `simple` profile but notes +that the printer supports two colors, and does not support high-density images. + +```yaml +--- +TM-U220: + name: TM-U220 + vendor: Epson + inherits: simple + notes: Two-color impact printer with 80mm output + features: + bitImageRaster: false + bitImageColumn: true + highDensity: false + colors: + 0: black + 1: alternate + media: + width: + mm: 80 + pixels: Unknown +... +``` + +As another example, the `SP2000` profile is based on the `default` profile, +but lists the different code pages used by Star printers. + +```yaml +--- +SP2000: + name: SP2000 Series + vendor: Star Micronics + inherits: default + notes: Star SP2000 impact printer series with ESC/POS emulation enabled + features: + starCommands: true + codePages: + # "Normal" + 0: CP437 + 1: CP437 + 2: CP932 + 3: CP437 + # .. code page list continues ... +``` + +Once you have written a profile for your own printer, send us a pull request with the +new file. The profile will need to pass `yamllint`, an automated build, and be reviewed +by a project contributor. diff --git a/capabilities-data/scripts/collate.py b/capabilities-data/scripts/collate.py new file mode 100755 index 0000000..05450ec --- /dev/null +++ b/capabilities-data/scripts/collate.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python + +""" +Quick build script to assemble profiles. + +Lots of room to improve validation or documentation at this step, threw in +some assertions to avoid passing malformed profiles to a driver. +""" + +import json +import collections +import os + +import pyaml +import yaml + +def load_encodings(): + """ + Load in all the encodings from the encoding definition file + """ + encoding_fn = os.path.dirname(__file__) + "/../data/encoding.yml" + encodings_raw = yaml.safe_load(open(encoding_fn).read()) + return encodings_raw + +def load_profiles(): + """ + Load in all the profiles from the profile folder (file-per-profile) + """ + profiles_raw = {} + profiles_dir = os.path.dirname(__file__) + "/../data/profile/" + for profile_fn in os.listdir(profiles_dir): + if not profile_fn[-3:] == 'yml': + continue + + profile_dict = yaml.safe_load(open(profiles_dir + profile_fn).read()) + # One item per file + assert len(profile_dict) == 1, "{}: expected one entry, got {}" \ + .format(profile_fn, len(profile_dict)) + # Item must match filename + profile_name, profile_val = profile_dict.popitem() + assert profile_name + ".yml" == profile_fn, \ + "{}: Expected to find profile named the same as file, got {}" \ + .format(profile_fn, profile_name) + profiles_raw[profile_name] = profile_val + return profiles_raw + +def substitute_profile(profile_name, profiles_raw, encodings_raw): + """ + Substitute in the values for 'inherited' profiles so that values are simply + repeated in the output. + """ + # Build stack of inheritance + current_key = profile_name + keys = [current_key] + values = [profiles_raw[current_key]] + while 'inherits' in profiles_raw[current_key]: + assert not profiles_raw[current_key]['inherits'] in keys, \ + "Profile {}: Circular reference calculating inheritance" \ + .format(profile_name) + current_key = profiles_raw[current_key]['inherits'] + keys.append(current_key) + values.append(profiles_raw[current_key]) + + # Check for some required keys in this profile which should not be left to + # inheritance to set + required_keys = ['vendor', 'notes', 'name'] + for i in required_keys: + assert i in profiles_raw[profile_name].keys(), \ + "{}: Profile key '{}' must be defined in every profile" \ + .format(profile_name, i) + + # Merge base profiles and sub-profiles by overriding entire keys, except for + # 'features' list, which are merged item-by-item. + profile = dict((k, v) for d in values[::-1] for k, v in d.items()) + profile['features'] = dict((k, v) for d in values[::-1] for k, v in \ + (d['features'].items() if 'features' in d else [])) + if 'inherits' in profile: + del profile['inherits'] + + # Sanity check for required keys exist + required_keys = ['vendor', 'features', 'media', 'notes', 'fonts', 'colors', \ + 'codePages', 'name'] + for i in required_keys: + assert i in profile.keys(), \ + "{}: Profile key '{}' must be defined or inherited" \ + .format(profile_name, i) + + # Sanity check for required features exist + required_features = ['starCommands', 'highDensity', 'barcodeB', \ + 'bitImageColumn', 'graphics', 'qrCode', 'bitImageRaster'] + for i in required_features: + assert i in profile['features'].keys(), \ + "{}: Profile feature '{}' must be defined or inherited" \ + .format(profile_name, i) + + # Reference check over encodings + for i in profile['codePages'].values(): + assert i in encodings_raw.keys(), \ + "{}: Profile claims to support fictional encoding '{}'" \ + .format(profile_name, i) + + return profile + +def filter_encodings(encodings_raw, profiles_subsituted): + """ + Filter down encodings list, adding unset names and excluding unused + encodings. + """ + # Give everything a name if not set + for name, encoding in encodings_raw.items(): + if not 'name' in encoding: + encoding['name'] = name + + # Strip out un-used code pages + unused = encodings_raw.keys() + for profile in profiles_subsituted.values(): + used = profile['codePages'].values() + unused = [x for x in unused if x not in used] + return {k: v for k, v in encodings_raw.items() if k not in unused} + +def run_collation(): + """ + Execute collation of all YAML files into single-file databases, in two + formats. + """ + encodings_raw = load_encodings() + profiles_raw = load_profiles() + profiles_substituted = {} + for profile_name in profiles_raw.keys(): + profiles_substituted[profile_name] = \ + substitute_profile(profile_name, profiles_raw, encodings_raw) + encodings_filtered = filter_encodings(encodings_raw, profiles_substituted) + + capabilities = {'profiles': profiles_substituted, 'encodings': encodings_filtered} + + # Dump output in format that is safe for human consumption in reasonable quantities + json_capabilities = json.dumps(capabilities, sort_keys=True, indent=4, separators=(',', ': ')) + with open(os.path.dirname(__file__) + "/../dist/capabilities.json", "wb+") as json_f: + json_f.write(json_capabilities.encode('utf-8')) + + # Convert it to YAML, preserving the same order + ordered_dict = json.loads(json_capabilities, object_pairs_hook=collections.OrderedDict) + yml_capabilities = pyaml.dumps(ordered_dict, string_val_style='"', explicit_start=True) + with open(os.path.dirname(__file__) + "/../dist/capabilities.yml", "wb+") as yml_f: + yml_f.write(yml_capabilities) + +if __name__ == "__main__": + run_collation()