utool._internal package¶
Submodules¶
utool._internal.meta_util_arg module¶
-
utool._internal.meta_util_arg.
get_argval
(argstr, type_=None, default=None)[source]¶ Returns a value of an argument specified on the command line after some flag
- CommandLine:
- python -c “import utool; print([(type(x), x) for x in [utool.get_argval(’–quest’)]])” –quest=”holy grail” python -c “import utool; print([(type(x), x) for x in [utool.get_argval(’–quest’)]])” –quest=”42” python -c “import utool; print([(type(x), x) for x in [utool.get_argval(’–quest’)]])” –quest=42 python -c “import utool; print([(type(x), x) for x in [utool.get_argval(’–quest’)]])” –quest 42 python -c “import utool; print([(type(x), x) for x in [utool.get_argval(’–quest’, float)]])” –quest 42
Example
>>> # DISABLE_DOCTEST >>> from utool.util_arg import * # NOQA >>> import sys >>> sys.argv.extend(['--spam', 'eggs', '--quest=holy grail', '--ans=42']) >>> get_argval('--spam', type_=str, default=None) eggs >>> get_argval('--quest', type_=str, default=None) holy grail >>> get_argval('--ans', type_=int, default=None) 42
utool._internal.meta_util_cache module¶
utool._internal.meta_util_constants module¶
utool._internal.meta_util_cplat module¶
utool._internal.meta_util_dbg module¶
utool._internal.meta_util_git module¶
utool._internal.meta_util_iter module¶
-
utool._internal.meta_util_iter.
ensure_iterable
(obj)[source]¶ Parameters: obj (scalar or iterable) – Returns: obj if it was iterable otherwise [obj] Return type: it3erable - CommandLine:
- python -m utool._internal.meta_util_iter –test-ensure_iterable
- Timeit:
- %timeit ut.ensure_iterable([1]) %timeit ut.ensure_iterable(1) %timeit ut.ensure_iterable(np.array(1)) %timeit ut.ensure_iterable([1]) %timeit [1]
Example
>>> # DISABLE_DOCTEST >>> from utool._internal.meta_util_iter import * # NOQA >>> # build test data >>> obj_list = [3, [3], '3', (3,), [3,4,5]] >>> # execute function >>> result = [ensure_iterable(obj) for obj in obj_list] >>> # verify results >>> result = str(result) >>> print(result) [[3], [3], ['3'], (3,), [3, 4, 5]]
-
utool._internal.meta_util_iter.
isiterable
(obj)[source]¶ Returns if the object can be iterated over and is NOT a string # TODO: implement isscalar similar to numpy
Parameters: obj (scalar or iterable) – Returns: Return type: bool - CommandLine:
- python -m utool._internal.meta_util_iter –test-isiterable
Example
>>> # DISABLE_DOCTEST >>> from utool._internal.meta_util_iter import * # NOQA >>> # build test data >>> obj_list = [3, [3], '3', (3,), [3,4,5]] >>> # execute function >>> result = [isiterable(obj) for obj in obj_list] >>> # verify results >>> print(result) [False, True, False, True, True]
utool._internal.meta_util_path module¶
-
utool._internal.meta_util_path.
truepath
(path)[source]¶ Normalizes and returns absolute path with so specs
utool._internal.meta_util_six module¶
utool._internal.py2_syntax_funcs module¶
-
utool._internal.py2_syntax_funcs.
ignores_exc_tb
(*args, **kwargs)[source]¶ PYTHON 2 ONLY VERSION – needs to be in its own file for syntactic reasons
ignore_exc_tb decorates a function and remove both itself and the function from any exception traceback that occurs.
This is useful to decorate other trivial decorators which are polluting your stacktrace.
utool._internal.randomwrap module¶
This is a minimal Python client for Mads Haahr’s random number generator at www.random.org
# This tiny set of functions only implements a subset of the HTTP interface available. In particular it only uses the ‘live’ # random number generator, and doesn’t offer the option of using the alternative ‘stored’ random # number sets. However, it should be obvious how to extend it by sending requests with different parameters. # The web service code is modelled on Mark Pilgrim’s “Dive into Python” tutorial at http://www.diveintopython.org/http_web_services # This client by George Dunbar, University of Warwick (Copyright George Dunbar, 2008) # It is distributed under the Gnu General Public License.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
See <http://www.gnu.org/licenses/> for a copy of the GNU General Public License. For use that falls outside this license, please contact me.
To use in a python script or at the interactive prompt (randomwrapy.py has to be in the Python search path, of course):
from randomwrapy import *
- rnumlistwithoutreplacement(0, 12)
- # returns a list of the integers 0 - 12 inclusive, in a random order
- rnumlistwithreplacement(12, 5)
- # returns 12 integers from the range [0, 5]
- rnumlistwithreplacement(12, 5, 2)
- # returns 12 integers from the range [2, 5]
- rrandom()
- # returns a random float in the range [0, 1]
- reportquota()
- # tells you how many bits you have available; visit www.random.org/quota for more information
Arguments where given are (must be) numbers, of course. There is almost no error checking in these scripts! For example, if the web site is down, Python will simply raise an exception and report the http error code. See worldrandom.py for an alternative implementation that goes a little further with error checking.
-
utool._internal.randomwrap.
rnumlistwithoutreplacement
(min, max)[source]¶ Returns a randomly ordered list of the integers between min and max
utool._internal.util_importer module¶
NEEDS CLEANUP SO IT EITHER DOES THE IMPORTS OR GENERATES THE FILE
python -c “import utool”
-
utool._internal.util_importer.
dynamic_import
(modname, import_tuples, developing=True, ignore_froms=[], dump=False, ignore_startswith=[], ignore_endswith=[], ignore_list=[], check_not_imported=True, return_initstr=False, verbose=False)[source]¶ MAIN ENTRY POINT
Dynamically import listed util libraries and their attributes. Create reload_subs function.
Using __import__ like this is typically not considered good style However, it is better than import * and this will generate the good file text that can be used when the module is ‘frozen”
Returns: - init_inject_str - by default all imports are executed in this
- function and only the remainig code needed to be executed is returned to define the reload logic.
- str, str: init_inject_str, init_str - if return_initstr is True then
- also returns init_str defining the from imports.
Return type: str - Ignore:
- ignore_startswith = [] ignore_endswith = [] check_not_imported = True verbose = True
utool._internal.win32_send_keys module¶
Check that SendInput can work the way we want it to
The tips and tricks at http://www.pinvoke.net/default.aspx/user32.sendinput is useful!
Module contents¶
Need to hack to make work for internal modules and reload subs properly
- Regen Command:
- cd /home/joncrall/code/utool/utool/_internal makeinit.py -x win32_send_keys