semvec/pypi-packages huggingface dataset:
leangaurav 0.0.1
Iterator utility classes and functions
Requires Python: >=3.6
Keywords: ITERATOR,TIMEOUT,SYNC

Provides a wrapper class TimeoutIterator to add timeout feature to normal iterators

### Installation:

    pip intall iterator


See help of TimeoutIterator for all the features. Check tests for examples on how to use TimeoutIterator.
See example tests below for basic  usage

### Example:

1. TimeoutIterator works like normal iterator:

    ```
    def iter_simple():
        yield 1
        yield 2

    def test_normal_iteration(self):
        i = iter_simple()
        it = TimeoutIterator(i)

        self.assertEqual(next(it), 1)
        self.assertEqual(next(it), 2)

        self.assertRaises(StopIteration, next, it)
        self.assertRaises(StopIteration, next, it)
    ```

1. When timeout is needed, use like this
    ```    
    def iter_with_sleep():
        yield 1
        time.sleep(0.6)
        yield 2
        time.sleep(0.4)
        yield 3

    def test_fixed_timeout(self):
        i = iter_with_sleep()
        it = TimeoutIterator(i, timeout=0.5)
        self.assertEqual(next(it), 1)
        self.assertEqual(next(it), it.get_sentinel())
        
        self.assertEqual(next(it), 2)
        self.assertEqual(next(it), 3)
        self.assertRaises(StopIteration, next, it)
    ```

1. Dynamic timeout adjustment
    ```
    def iter_with_sleep():
        yield 1
        time.sleep(0.6)
        yield 2
        time.sleep(0.4)
        yield 3

    def test_timeout_update(self):
        i = iter_with_sleep()
        it = TimeoutIterator(i, timeout=0.5)
        self.assertEqual(next(it), 1)
        self.assertEqual(next(it), it.get_sentinel())
        
        it.set_timeout(0.3)
        self.assertEqual(next(it), 2)
        self.assertEqual(next(it), it.get_sentinel())

        self.assertEqual(next(it), 3)
        self.assertRaises(StopIteration, next, it)
    ```

### Run unit tests locally:
    python -m unittest discover tests
usb-barcode-scanner-julz 0.2
Handheld USB Scanner package
Requires Python: >=3.6

# usb_barcode_scanner

Support input from a hand-held USB scanner in python - such as this one: 

https://www.amazon.co.uk/gp/product/B0736NNZNV/


Usage:
--

The library is very simple to use: just import it and in case, wait for input.

```
from usb_scanner.scanner import barcode_reader
if __name__ == '__main__':
    try:
        while True:
            upcnumber = barcode_reader()
            print(upcnumber)
    except KeyboardInterrupt:
        logging.debug('Keyboard interrupt')
    except Exception as err:
        logging.error(err)
```

Installation
--
pypi homepage : https://pypi.org/project/usb-barcode-scanner/
github : https://github.com/julzhk/usb_barcode_scanner

install with:
```
pip install usb-barcode-scanner
```

Compatibility
--

Tested and working in Linux and Raspberry Pi, using Python 3.6, but should work with Python 2.7 too.

License
--
The software is provided "As is", without warranty of any kind, express or implied. 
Please see the MIT license attached. 

Support & Contribution
--
Questions? Drop me a line : usb_barcode_scanner_support.20.learningfuture@spamgourmet.com

Suggestions and improvements welcome.