Ejemplo n.º 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
Ejemplo n.º 2
0
        expected = [Barcode(type=type, data=u'Metasequoia')]
        res = engine(self.PDF417)
        self.assertEqual(expected, res)
        self.assertEqual([], engine(self.NOBARCODE))


@unittest.skipUnless(AccusoftEngine.available(), 'AccusoftEngine unavailable')
class TestAccusoftEngine(TestEngine):
    def test_1d(self):
        self._test_1d(AccusoftEngine(datamatrix=False), type='Code 128')

    def test_dm(self):
        self._test_dm(AccusoftEngine(datamatrix=True), type='DataMatrix')


@unittest.skipUnless(DataSymbolEngine.available(), 'DataSymbolEngine unavailable')
class TestDataSymbolEngine(TestEngine):
    # Evaluation SDK replaces the last three characters of the
    # decoded value with 'DEMO', so this test needs to do some extra work.
    def test_1d(self):
        res = DataSymbolEngine(datamatrix=False)(self.CODE128)
        self.assertEqual(1, len(res))
        self.assertEqual('Code 128', res[0].type)
        self.assertIn(res[0].data, ('StegosauDEMO', 'Stegosaurus'))


@unittest.skipUnless(DTKEngine.available(), 'DTKEngine unavailable')
class TestDTKEngine(TestEngine):
    def test_1d(self):
        self._test_1d(DTKEngine(datamatrix=False), type='Code 128')