Exemple #1
0
    typemap = __get_typemap()
    for key in typemap.keys():
        if typemap[key] == type_bin:
            return key


def __keystr2_winreg(instr):
    """
    Takes a registry string and extracts a tuple (winreg.HIVE, root_str)
    """
    root_map = {
        'HKEY_CURRENT_USER': winreg.HKEY_CURRENT_USER,
        'HKEY_CLASSES_ROOT': winreg.HKEY_CLASSES_ROOT,
        'HKEY_LOCAL_MACHINE': winreg.HKEY_LOCAL_MACHINE,
        'HKEY_USERS': winreg.HKEY_USERS,
        'HKEY_CURRENT_CONFIG': winreg.HKEY_CURRENT_CONFIG
    }
    for root_str in root_map.keys():
        if instr.find(root_str) == 0:
            return (root_map[root_str], instr[len(root_str) + 1:])
    raise Exception('WinRegistryException', instr + ' is not a valid hive')


if __name__ == '__main__':
    r"""
    CommandLine:
        python C:/Users/erote/local/rob/internal/win_registry.py
    """
    import xdoctest
    xdoctest.doctest_module(__file__)
Exemple #2
0
                 help=('Same as if durations=0'))

    add_argument_kws = [
        # (['--style'], dict(dest='style',
        #                    type=str, help='choose your style',
        #                    choices=['auto', 'google', 'freeform'], default='auto')),
        # (['--quiet'], dict(type=int, action='store_false', dest='verbose',
        #                          help='sets verbosity=0')),
    ]

    if prefix is None:
        prefix = ['']

    for alias, kw in add_argument_kws:
        alias = [
            a.replace('--', '--' + p + '-') if p else a for a in alias
            for p in prefix
        ]
        if prefix[0]:
            kw['dest'] = prefix[0] + '_' + kw['dest']
        add_argument(*alias, **kw)


if __name__ == '__main__':
    r"""
    CommandLine:
        python -m xdoctest.runner all
    """
    import xdoctest as xdoc
    xdoc.doctest_module()
Exemple #3
0
    return module


def _pkgutil_import_modpath(modpath):  # nocover
    import six
    import xdoctest.static_analysis as static
    dpath, rel_modpath = static.split_modpath(modpath)
    modname = static.modpath_to_modname(modpath)
    if six.PY2:  # nocover
        import imp
        module = imp.load_source(modname, modpath)
    elif sys.version_info[0:2] <= (3, 4):  # nocover
        assert sys.version_info[0:2] <= (3, 2), '3.0 to 3.2 is not supported'
        from importlib.machinery import SourceFileLoader
        module = SourceFileLoader(modname, modpath).load_module()
    else:
        import importlib.util
        spec = importlib.util.spec_from_file_location(modname, modpath)
        module = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)
    return module


if __name__ == '__main__':
    """
    CommandLine:
        python -m ubelt.util_import all
    """
    import xdoctest
    xdoctest.doctest_module(__file__)
Exemple #4
0
def main():
    import xdoctest
    xdoctest.doctest_module('ubelt')