Example #1
0
def engine_choices():
    """Returns a dict mapping command-line options to functions that return an
    engine
    """
    choices = {'libdmtx': LibDMTXEngine,
               'zbar': ZbarEngine,
               'zxing': ZxingEngine,
               }

    choices = {k:v for k,v in choices.iteritems() if v.available()}

    if AccusoftEngine.available():
        choices.update({'accusoft-1d':  partial(AccusoftEngine, datamatrix=False),
                        'accusoft-dm': partial(AccusoftEngine, datamatrix=True),
                      })

    if DataSymbolEngine.available():
        choices.update({'datasymbol-1d': partial(DataSymbolEngine, datamatrix=False),
                        'datasymbol-dm': partial(DataSymbolEngine, datamatrix=True),
                      })

    if DTKEngine.available():
        choices.update({'dtk-1d': partial(DTKEngine, datamatrix=False),
                        'dtk-dm': partial(DTKEngine, datamatrix=True),
                      })

    if InliteEngine.available():
        choices.update({'inlite-1d': partial(InliteEngine, format='1d'),
                        'inlite-dm': partial(InliteEngine, format='datamatrix'),
                        'inlite-pdf417': partial(InliteEngine, format='pdf417'),
                        'inlite-qrcode': partial(InliteEngine, format='qrcode'),
                      })

    if StecosEngine.available():
        choices.update({'stecos-1d' : partial(StecosEngine, datamatrix=False),
                        'stecos-dm' : partial(StecosEngine, datamatrix=True),
                      })

    if SoftekEngine.available():
        choices.update({'softek-1d': partial(SoftekEngine, datamatrix=False),
                        'softek-dm': partial(SoftekEngine, datamatrix=True),
                      })

    return choices
Example #2
0
        self._test_dm(InliteEngine(format='datamatrix'))

    def test_qr(self):
        self._test_qr(InliteEngine(format='qrcode'))

    def test_pdf417(self):
        self._test_pdf417(InliteEngine(format='pdf417'))


@unittest.skipUnless(LibDMTXEngine.available(), 'LibDMTXEngine unavailable')
class TestLibDMTXEngine(TestEngine):
    def test_dm(self):
        self._test_dm(LibDMTXEngine())


@unittest.skipUnless(SoftekEngine.available(), 'SoftekEngine unavailable')
class TestSoftekEngine(TestEngine):
    # Evaluation SDK replaces the last three characters of the
    # decoded value with '???', so this test needs to do some extra work.
    
    @unittest.skipIf(sys.platform.startswith('win'),
                     "Windows SoftekEngine not able to decode self.CODE128")
    def test_1d(self):
        res = SoftekEngine(datamatrix=False)(self.CODE128)
        self.assertEqual(1, len(res))
        self.assertEqual('CODE128', res[0].type)
        self.assertIn(res[0].data, ('Stegosau???', 'Stegosaurus'))

    def test_dm(self):
        res = SoftekEngine(datamatrix=True)(self.DATAMATRIX)
        self.assertEqual(1, len(res))