Metadata-Version: 2.1
Name: iogp
Version: 1.0.2
Summary: Python common task, general purpose library (serialization, networking, etc.).
Project-URL: Homepage, https://gitlab.com/vtopan/iogp
Author-email: Vlad Topan <vtopan@gmail.removethispart.com>
License: MIT License
        
        Copyright (c) 2018-2023 Vlad Ioan Topan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# iogp

Python common task, general purpose library (serialization, networking, etc.).
Note: this project used to be called iolib - it was renamed for PyPI.

## iogp.net

- provides the `download()` function
    - automatic caching of downloads
    - supports cookies, authentication, etc.
    - can spoof user agents (or the entire GET request) - see the `USER_AGENTS` dict in `net/net.py`
    - examples:
        - `text = iogp.net.download('https://google.com')`
        - `info = {}; iogp.net.download('https://1.1.1.1', info=info, cache=0)` => `info['code'] == 200`,
            `info['headers']['Content-Type']`, etc.


## iogp.db

- provides a persistence / caching / storage object `DataCache` that can store e.g. the results from a downloaded URL
    - use `DataStore` to also get in-memory caching of values
    - `ObjCache()` wraps `DataCache` to generate the storage filename automatically
    - usage:

        ~~~Python
        from iogp.db import DataCache

        fn = 'objects.db'

        db = DataCache(fn)
        db['key1'] = {'some':['serializable', 'object', 0]}
        db['some-other-key'] = 0
        db.close()

        db = DataCache(fn)
        print(db['key1'])
        print('key2' in db, 'some-other-key' in db)
        ~~~


## iogp.win

- ctypes wrapper over some Windows-specific functions
- example - iterating all windows and retrieving the window title for each one:

    ~~~Python
    import iogp.win as win
    
    def callback(hwnd, lparam):
        size = 512
        buf = win.unicode_buffer(size)
        win.GetWindowText(hwnd, buf, size)
        print(f'[-] Handle: {hwnd}, title: {buf.value}')
        return 1  # 0 to stop
        
    win.EnumWindows(win.WNDENUMPROC(callback), 0)
    ~~~
