• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utool.codeblock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utool.codeblock函数的典型用法代码示例。如果您正苦于以下问题:Python codeblock函数的具体用法?Python codeblock怎么用?Python codeblock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了codeblock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: markdown_cell

def markdown_cell(markdown):
    r"""
    Args:
        markdown (str):

    Returns:
        str: json formatted ipython notebook markdown cell

    CommandLine:
        python -m ibeis.templates.generate_notebook --exec-markdown_cell

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.templates.generate_notebook import *  # NOQA
        >>> markdown = '# Title'
        >>> result = markdown_cell(markdown)
        >>> print(result)
    """
    markdown_header = ut.codeblock(
        """
          {
           "cell_type": "markdown",
           "metadata": {},
           "source": [
        """
    )
    markdown_footer = ut.codeblock(
        """
           ]
          }
        """
    )
    return (markdown_header + '\n' +
            ut.indent(repr_single(markdown), ' ' * 2) +
            '\n' + markdown_footer)
开发者ID:heroinlin,项目名称:ibeis,代码行数:35,代码来源:generate_notebook.py


示例2: make_ibeis_cell_list

def make_ibeis_cell_list(ibs):
    cell_template_list = get_default_cell_template_list(ibs)
    autogen_str = make_autogen_str()
    dbname = ibs.get_dbname()
    #if ut.get_argflag('--hacktestscore'):
    #    annotconfig_list_body = ut.codeblock(
    #        '''
    #        'timectrl',
    #        '''
    #    )
    #else:
    default_acfgstr = ut.get_argval('-a', type_=str, default='default:is_known=True')
    annotconfig_list_body = ut.codeblock(
        ut.repr2(default_acfgstr) + '\n' +
        ut.codeblock('''
        # See ibeis/expt/annotation_configs.py for names of annot configuration options
        #'default:has_any=(query,),dpername=1,exclude_reference=True',
        #'default:is_known=True',
        #'default:qsame_encounter=True,been_adjusted=True,excluderef=True'
        #'default:qsame_encounter=True,been_adjusted=True,excluderef=True,qsize=10,dsize=20',
        #'default:require_timestamp=True,min_timedelta=3600',
        #'default:species=primary',
        #'timectrl:',
        #'timectrl:been_adjusted=True,dpername=3',
        #'timectrl:qsize=10,dsize=20',
        #'unctrl:been_adjusted=True',
        ''')
    )
    #if ut.get_argflag('--hacktestscore'):
    #    pipeline_list_body = ut.codeblock(
    #        '''
    #        # See ibeis/algo/Config.py for names of pipeline config options
    #        'default:lnbnn_on=True,bar_l2_on=False,normonly_on=False,fg_on=True',
    #        'default:lnbnn_on=False,bar_l2_on=True,normonly_on=False,fg_on=True',
    #        'default:lnbnn_on=False,bar_l2_on=False,normonly_on=True,fg_on=True',
    #        'default:lnbnn_on=True,bar_l2_on=False,normonly_on=False,fg_on=False',
    #        'default:lnbnn_on=False,bar_l2_on=True,normonly_on=False,fg_on=False',
    #        'default:lnbnn_on=False,bar_l2_on=False,normonly_on=True,fg_on=False',
    #        '''
    #    )
    #elif True:
    default_pcfgstr_list = ut.get_argval(('-t', '-p'), type_=list, default='default')
    default_pcfgstr = ut.repr3(default_pcfgstr_list, nobr=True)

    pipeline_list_body = ut.codeblock(
        default_pcfgstr + '\n' +
        ut.codeblock('''
        #'default',
        #'default:K=1',
        #'default:K=1,AI=False',
        #'default:K=1,AI=False,QRH=True',
        #'default:K=1,RI=True,AI=False',
        #'default:K=1,adapteq=True',
        #'default:fg_on=[True,False]',
        ''')
    )
    locals_ = locals()
    _format = partial(format_cells, locals_=locals_)
    cell_list = ut.flatten(map(_format, cell_template_list))
    return cell_list
开发者ID:heroinlin,项目名称:ibeis,代码行数:60,代码来源:generate_notebook.py


示例3: check_jedi_can_read_googlestyle

def check_jedi_can_read_googlestyle():
    import jedi
    import utool as ut
    source1 = ut.codeblock(
        r'''
        # STARTBLOCK
        def spam(data):
            r"""
            Args:
                data (utool.ColumnLists): a column list objct
            """
            data.
        # ENDBLOCK
        '''
    )
    source2 = ut.codeblock(
        r'''
        # STARTBLOCK
        def spam(ibs, bar):
            r"""
            Args:
                ibs (ibeis.IBEISController): an object
            """
            import jedi
            jedi.n
            x = ''
            x.l
            ibs.d
            bar.d
        # ENDBLOCK
        '''
    )

    print('\n---testing jedi with utool.ColumnLists')
    self = script = jedi.Script(source1, line=7, column=8)  # NOQA
    completions = script.completions()  # NOQA
    print('completions = %r' % (completions,))
    vartype = script.goto_definitions()
    print('vartype = %r' % (vartype,))

    print('\n---testing jedi with ibeis.IBEISController')
    script = jedi.Script(source2, line=10)
    script.completions()
    # Find the variable type of argument
    self = script = jedi.Script(source2, line=11, column=7)  # NOQA
    completions = script.completions()  # NOQA
    print('completions = %r' % (completions,))
    vartype = script.goto_definitions()
    print('vartype = %r' % (vartype,))

    print('\n---testing jedi with undefined object bar')
    self = script = jedi.Script(source2, line=12, column=7)  # NOQA
    vartype = script.goto_definitions()  # NOQA
    print('vartype = %r' % (vartype,))
    vardefs = script.goto_assignments()  # NOQA
    print('vardefs = %r' % (vardefs,))
开发者ID:Erotemic,项目名称:utool,代码行数:56,代码来源:check_jedi.py


示例4: testdata_deck

def testdata_deck():
    jeskai_black = ut.codeblock(
        """
        4 Jace, Vryn's Prodigy
        2 Dispel
        4 Mantis Rider
        4 Crackling Doom
        2 Dig Through Time
        2 Fiery Impulse
        2 Soulfire Grand Master
        3 Kolaghan's Command
        3 Ojutai's Command
        3 Tasigur, the Golden Fang
        1 Utter End
        2 Wild Slash
        1 Dragonmaster Outcast
        1 Sarkhan, the Dragonspeaker
        1 Island
        1 Plains
        2 Mountain
        1 Swamp
        1 Smoldering Marsh
        1 Sunken Hollow
        2 Prairie Stream
        1 Nomad Outpost
        4 Mystic Monastery
        4 Flooded Strand
        4 Polluted Delta
        4 Bloodstained Mire
        SB: 2 Radiant Flames
        SB: 1 Felidar Cub
        SB: 1 Negate
        SB: 2 Arashin Cleric
        SB: 2 Duress
        SB: 2 Exert Influence
        SB: 1 Dragonmaster Outcast
        SB: 1 Virulent Plague
        SB: 1 Mastery of the Unseen
        SB: 2 Roast
        """
    )

    mydiff = ut.codeblock(
        """
        +1 Plains
        +1 Sunken Hollow
        +1 Smoldering Marsh
        +1 Evolving Wilds
        +1 Battlefield Forge
        -4 Mystic Monastery
        -1 Nomad Outpost
        """
    )

    decklist_text = jeskai_black
    return decklist_text, mydiff
开发者ID:Erotemic,项目名称:mtgmonte,代码行数:56,代码来源:mtgmonte.py


示例5: assert_cache_hits

 def assert_cache_hits(ibs, ismiss_list, rowid_list, kwargs_hash, **kwargs):
     cached_rowid_list = ut.filterfalse_items(rowid_list, ismiss_list)
     cache_ = ibs.table_cache[tblname][colname][kwargs_hash]
     # Load cached values for each rowid
     cache_vals_list = ut.dict_take_list(cache_, cached_rowid_list, None)
     db_vals_list = getter_func(ibs, cached_rowid_list, **kwargs)
     # Assert everything is valid
     msg_fmt = ut.codeblock(
         """
         [assert_cache_hits] tblname = %r
         [assert_cache_hits] colname = %r
         [assert_cache_hits] cfgkeys = %r
         [assert_cache_hits] CACHE INVALID: %r != %r
         """
     )
     msg = msg_fmt % (tblname, colname, cfgkeys, cache_vals_list, db_vals_list)
     try:
         list1 = cache_vals_list
         list2 = db_vals_list
         assert ut.lists_eq(list1, list2), msg
         # if isinstance(db_vals_list, list):
         #    assert cache_vals_list == db_vals_list, msg
         # else:
         #    assert np.all(cache_vals_list == db_vals_list), msg
     except AssertionError as ex:
         raise ex
     except Exception as ex2:
         print(type(cache_vals_list))
         print(type(db_vals_list))
         ut.printex(ex2)
         ut.embed()
         raise
开发者ID:Erotemic,项目名称:ibeis,代码行数:32,代码来源:accessor_decors.py


示例6: assert_eq

def assert_eq(var1, var2, msg='', var1_name=None, var2_name=None, verbose=not util_arg.QUIET):
    import utool as ut
    failed = var1 != var2
    if var1_name is None:
        var1_name = ut.get_varname_from_stack(var1, N=1, default='var1')
    if var2_name is None:
        var2_name = ut.get_varname_from_stack(var2, N=1, default='var2')
    fmtdict = dict(
        msg=msg,
        var1_name=var1_name,
        var2_name=var2_name,
        var1_repr=repr(var1),
        var2_repr=repr(var2))
    if failed:
        msg_fmtstr = ut.codeblock('''
            +=====
            ERROR {var1_name} != {var2_name}
            msg = {msg}
            ---
            {var1_name} = {var1_repr}
            ---
            {var2_name} = {var2_repr}
            L_____
            ''')
        msg = msg_fmtstr.format(**fmtdict)
        raise AssertionError(msg)
    else:
        print('ASSERT_EQ_PASSED: {var1_name} == {var2_name} == {var1_repr}'.format(**fmtdict))
开发者ID:animalus,项目名称:utool,代码行数:28,代码来源:util_assert.py


示例7: fix_pyinstaller_sip_api

def fix_pyinstaller_sip_api():
    """
    Hack to get the correct version of SIP for win32

    References:
        http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
    """
    import PyInstaller
    from os.path import dirname, join  # NOQA
    hook_fpath = join(dirname(PyInstaller.__file__), 'loader', 'rthooks', 'pyi_rth_qt4plugins.py')
    patch_code = ut.codeblock(
        '''
        try:
            import sip
            # http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string
            sip.setapi('QVariant', 2)
            sip.setapi('QString', 2)
            sip.setapi('QTextStream', 2)
            sip.setapi('QTime', 2)
            sip.setapi('QUrl', 2)
            sip.setapi('QDate', 2)
            sip.setapi('QDateTime', 2)
            if hasattr(sip, 'setdestroyonexit'):
                sip.setdestroyonexit(False)  # This prevents a crash on windows
        except ValueError as ex:
            print('Warning: Value Error: %s' % str(ex))
        pass
        ''')
    fpath = hook_fpath
    # Patch the hook file
    tag = 'SIP_API_2'
    ut.inject_python_code(fpath, patch_code, tag)
    #ut.editfile(hook_fpath)
    pass
开发者ID:Erotemic,项目名称:ibeis,代码行数:34,代码来源:installers.py


示例8: autogen_import_list

def autogen_import_list(classname, conditional_imports=None):
    import utool as ut
    #ut.embed()
    #line_list = []
    line_list = ['import sys  # NOQA']
    for modname in __CLASSNAME_CLASSKEY_REGISTER__[classname]:
        # <super hacky>
        condition = None
        for x in conditional_imports:
            if modname == x[1]:
                condition = x[0]
        # </super hacky>
        parts = modname.split('.')
        frompart = '.'.join(parts[:-1])
        imppart = parts[-1]
        #line = 'from %s import %s  # NOQA' % (frompart, imppart)
        if condition is None:
            line = 'from %s import %s' % (frompart, imppart)
        else:
            line = ut.codeblock(
                '''
                if not ut.get_argflag({condition}) or '{frompart}' in sys.modules:
                    from {frompart} import {imppart}
                ''').format(condition=condition, frompart=frompart,
                            imppart=imppart)
        line_list.append(line)
    src = '\n'.join(line_list)
    return src
开发者ID:Erotemic,项目名称:utool,代码行数:28,代码来源:util_class.py


示例9: _debug_repr_model

def _debug_repr_model(model):
    cpd_code_list = [_debug_repr_cpd(cpd) for cpd in model.cpds]
    code_fmt = ut.codeblock(
        '''
        import numpy as np
        import pgmpy
        import pgmpy.inference
        import pgmpy.factors
        import pgmpy.models

        {cpds}

        cpd_list = {nodes}
        input_graph = {edges}
        model = pgmpy.models.BayesianModel(input_graph)
        model.add_cpds(*cpd_list)
        infr = pgmpy.inference.BeliefPropagation(model)
        ''')

    code = code_fmt.format(
        cpds='\n'.join(cpd_code_list),
        nodes=ut.repr2(sorted(model.nodes()), strvals=True),
        edges=ut.repr2(sorted(model.edges()), nl=1),
    )
    ut.print_code(code)
    ut.copy_text_to_clipboard(code)
开发者ID:heroinlin,项目名称:ibeis,代码行数:26,代码来源:pgm_viz.py


示例10: _debug_repr_cpd

def _debug_repr_cpd(cpd):
    import re
    import utool as ut
    code_fmt = ut.codeblock(
        '''
        {variable} = pgmpy.factors.TabularCPD(
            variable={variable_repr},
            variable_card={variable_card_repr},
            values={get_cpd_repr},
            evidence={evidence_repr},
            evidence_card={evidence_card_repr},
        )
        ''')
    keys = ['variable', 'variable_card', 'values', 'evidence', 'evidence_card']
    dict_ = ut.odict(zip(keys, [getattr(cpd, key) for key in keys]))
    # HACK
    dict_['values'] = cpd.get_cpd()
    r = ut.repr2(dict_, explicit=True, nobraces=True, nl=True)
    print(r)

    # Parse props that are needed for this fmtstr
    fmt_keys = [match.groups()[0] for match in re.finditer('{(.*?)}', code_fmt)]
    need_reprs = [key[:-5] for key in fmt_keys if key.endswith('_repr')]
    need_keys = [key for key in fmt_keys if not key.endswith('_repr')]
    # Get corresponding props
    # Call methods if needbe
    tmp = [(prop, getattr(cpd, prop)) for prop in need_reprs]
    tmp = [(x, y()) if ut.is_funclike(y) else (x, y) for (x, y) in tmp]
    fmtdict = dict(tmp)
    fmtdict = ut.map_dict_vals(ut.repr2, fmtdict)
    fmtdict = ut.map_dict_keys(lambda x: x + '_repr', fmtdict)
    tmp2 = [(prop, getattr(cpd, prop)) for prop in need_keys]
    fmtdict.update(dict(tmp2))
    code = code_fmt.format(**fmtdict)
    return code
开发者ID:heroinlin,项目名称:ibeis,代码行数:35,代码来源:pgm_viz.py


示例11: _get_models

def _get_models(ibs, species, modeldir="default", cfg_override=True, verbose=VERBOSE_RF):
    r"""
    Args:
        ibs (IBEISController):  ibeis controller object
        species (?):
        modeldir (str): (default = 'default')
        cfg_override (bool): (default = True)
        verbose (bool):  verbosity flag(default = False)

    Returns:
        ?: fpath_list

    CommandLine:
        python -m ibeis.algo.detect.randomforest --test-_get_models

    Example:
        >>> # ENABLE_DOCTEST
        >>> from ibeis.algo.detect.randomforest import *  # NOQA
        >>> import ibeis
        >>> ibs = ibeis.opendb(defaultdb='testdb1')
        >>> species = ibeis.const.TEST_SPECIES.ZEB_PLAIN
        >>> modeldir = 'default'
        >>> cfg_override = True
        >>> verbose = False
        >>> fpath_list = _get_models(ibs, species, modeldir, cfg_override, verbose)
        >>> result = ('fpath_list = %s' % (str(fpath_list),))
        >>> print(result)
    """
    # with ut.embed_on_exception_context:
    if cfg_override and len(ibs.cfg.detect_cfg.trees_path) > 0:
        trees_path = ibs.cfg.detect_cfg.trees_path
    else:
        # Ensure all models downloaded and accounted for
        assert species is not None, "[_get_models] Cannot detect without specifying a species"
        grabmodels.ensure_models(modeldir=modeldir, verbose=verbose)
        trees_path = grabmodels.get_species_trees_paths(species, modeldir=modeldir)
    # Load tree paths
    if ut.checkpath(trees_path, verbose=verbose):
        fpath_list = ut.ls(trees_path, "*.txt")
        # direct = Directory(trees_path, include_extensions=['txt'])
        # files = direct.files()
    else:
        # If the models do not exist, return None
        fpath_list = None
    if fpath_list is None or len(fpath_list) == 0:
        msg = (
            ut.codeblock(
                """
            [_get_models] Error loading trees, either directory or fpath_list not found
              * trees_path = %r
              * fpath_list = %r
              * species = %r
              * model_dir = %r
              * cfg_override = %r
            """
            )
            % (trees_path, fpath_list, species, modeldir, cfg_override)
        )
        raise AssertionError(msg)
    return fpath_list
开发者ID:Erotemic,项目名称:ibeis,代码行数:60,代码来源:randomforest.py


示例12: ensure_inno_script

def ensure_inno_script():
    """ writes inno script to disk for win32 installer build """
    cwd = get_setup_dpath()
    iss_script_fpath = join(cwd, '_installers', 'win_installer_script.iss')
    # THE ISS USES {} AS SYNTAX. CAREFUL
    #app_publisher = 'Rensselaer Polytechnic Institute'
    #app_name = 'IBEIS'
    import ibeis
    iss_script_code = ut.codeblock(
        r'''
        ; Script generated by the Inno Setup Script Wizard.
        ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
        ; http://www.jrsoftware.org/isdl.php

        [Setup]
        ; NOTE: The value of AppId uniquely identifies this application.
        ; Do not use the same AppId value in installers for other applications.
        ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
        ; Also it seems like the off-balanced curly brace is necessary
        AppId={{47BE3DA2-261D-4672-9849-18BB2EB382FC}
        AppName=IBEIS
        AppVersion=''' + str(ibeis.__version__) + '''
        ;AppVerName=IBEIS 1
        AppPublisher=Rensselaer Polytechnic Institute
        AppPublisherURL=ibeis.org ;www.rpi.edu/~crallj/
        AppSupportURL=ibeis.org ;ww.rpi.edu/~crallj/
        AppUpdatesURL=ibeis.org ;www.rpi.edu/~crallj/
        DefaultDirName={pf}\IBEIS
        DefaultGroupName=IBEIS
        OutputBaseFilename=ibeis-win32-setup
        SetupIconFile=ibsicon.ico
        Compression=lzma
        SolidCompression=yes

        [Languages]
        Name: "english"; MessagesFile: "compiler:Default.isl"

        [Tasks]
        Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

        [Files]
        Source: "..\dist\ibeis\IBEISApp.exe"; DestDir: "{app}"; Flags: ignoreversion
        Source: "..\dist\ibeis\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
        ; NOTE: Don't use "Flags: ignoreversion" on any shared system files

        [Icons]
        Name: "{group}\ibeis"; Filename: "{app}\IBEISApp.exe"
        Name: "{commondesktop}\ibeis"; Filename: "{app}\IBEISApp.exe"; Tasks: desktopicon

        [Run]
        Filename: "{app}\IBEISApp.exe"; Description: "{cm:LaunchProgram,IBEIS}"; Flags: nowait postinstall skipifsilent
        '''
    )
    ut.write_to(iss_script_fpath, iss_script_code, onlyifdiff=True)
    assert ut.checkpath(iss_script_fpath, verbose=True, info=True), 'cannot find iss_script_fpath'
    return iss_script_fpath
开发者ID:Erotemic,项目名称:ibeis,代码行数:56,代码来源:installers.py


示例13: make_notebook

def make_notebook(cell_list):
    """
    References:
        # Change cell width
        http://stackoverflow.com/questions/21971449/how-do-i-increase-the-cell-width-of-the-ipython-notebook-in-my-browser/24207353#24207353
    """
    header = ut.codeblock(
        """
        {
         "cells": [
        """
    )

    footer = ut.codeblock(
        """
         ],
         "metadata": {
          "kernelspec": {
           "display_name": "Python 2",
           "language": "python",
           "name": "python2"
          },
          "language_info": {
           "codemirror_mode": {
            "name": "ipython",
            "version": 2
           },
           "file_extension": ".py",
           "mimetype": "text/x-python",
           "name": "python",
           "nbconvert_exporter": "python",
           "pygments_lexer": "ipython2",
           "version": "2.7.6"
          }
         },
         "nbformat": 4,
         "nbformat_minor": 0
        }
        """)

    cell_body = ut.indent(',\n'.join(cell_list), '  ')
    notebook_str = header + '\n' + cell_body +  '\n' +  footer
    return notebook_str
开发者ID:heroinlin,项目名称:ibeis,代码行数:43,代码来源:generate_notebook.py


示例14: make_bayes_notebook

def make_bayes_notebook():
    r"""
    CommandLine:
        python -m ibeis.algo.hots.demobayes --exec-make_bayes_notebook

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.algo.hots.demobayes import *  # NOQA
        >>> result = make_bayes_notebook()
        >>> print(result)
    """
    from ibeis.templates import generate_notebook
    initialize = ut.codeblock(
        r'''
        # STARTBLOCK
        import os
        os.environ['UTOOL_NO_CNN'] = 'True'
        from ibeis.algo.hots.demobayes import *  # NOQA
        # Matplotlib stuff
        import matplotlib as mpl
        %matplotlib inline
        %load_ext autoreload
        %autoreload
        from IPython.core.display import HTML
        HTML("<style>body .container { width:99% !important; }</style>")
        # ENDBLOCK
        '''
    )
    cell_list_def = [
        initialize,
        show_model_templates,
        demo_modes,
        demo_name_annot_complexity,
        ###demo_model_idependencies,
        demo_single_add,
        demo_ambiguity,
        demo_conflicting_evidence,
        demo_annot_idependence_overlap,
    ]
    def format_cell(cell):
        if ut.is_funclike(cell):
            header = '# ' + ut.to_title_caps(ut.get_funcname(cell))
            code = (header, ut.get_func_sourcecode(cell, stripdef=True, stripret=True))
        else:
            code = (None, cell)
        return generate_notebook.format_cells(code)

    cell_list = ut.flatten([format_cell(cell) for cell in cell_list_def])
    nbstr = generate_notebook.make_notebook(cell_list)
    print('nbstr = %s' % (nbstr,))
    fpath = 'demobayes.ipynb'
    ut.writeto(fpath, nbstr)
    ut.startfile(fpath)
开发者ID:heroinlin,项目名称:ibeis,代码行数:53,代码来源:demobayes.py


示例15: kwiver

def kwiver():
    import utool as ut
    ut.codeblock(
        r'''
        # STARTBLOCK bash

        git checkout master

        cd ~/code/kwiver
        rm -rf ~/code/kwiver/build-py2-nocuda
        mkdir -p build-py2-nocuda

        cd ~/code/kwiver/build-py2-nocuda
        cmake -G "Unix Makefiles" \
            -D KWIVER_ENABLE_ARROWS:BOOL=True \
            -D KWIVER_ENABLE_C_BINDINGS:BOOL=True \
            -D KWIVER_ENABLE_PYTHON:BOOL=True \
            -D KWIVER_ENABLE_TESTS:BOOL=True \
            -D PYTHON_VERSION=$(python -c "import sys; print(sys.version[0:3])") \
            -D fletch_DIR:PATH=~/code/fletch/build-py2-nocuda/ \
            ~/code/kwiver

        ''')
开发者ID:Erotemic,项目名称:local,代码行数:23,代码来源:custom_fletch.py


示例16: make_autogen_str

def make_autogen_str():
    import sys
    autogenkw = dict(
        stamp=ut.timestamp('printable'),
        regen_cmd=' '.join(sys.argv)
    )
    return ut.codeblock(
        '''
        # Autogenerated on {stamp}
        # Regen Command:
        #    {regen_cmd}
        #
        '''
    ).format(**autogenkw)
开发者ID:heroinlin,项目名称:ibeis,代码行数:14,代码来源:generate_notebook.py


示例17: add_label

 def add_label(co_wgt):
     # Very simply adds the text
     _LABEL = partial(guitool.newLabel, parent=co_wgt)
     if not co_wgt.hack:
         text = ut.codeblock(
             '''
             * Find the image of the clock
             * Set the sliders to correspond with the clock
             * Click Set
             * Skip if time synchonization is not relevant to you
             '''
         )
         main_label = _LABEL(text=text, align='left')
         co_wgt.text_layout.addWidget(main_label)
     else:
         text = ut.codeblock(
             '''
             * Set the time for image %r
             ''' % (co_wgt.gid_list,)
         )
         gpath = co_wgt.ibs.get_image_paths(co_wgt.gid_list[co_wgt.current_gindex])
         image_label = _LABEL(text='', gpath=gpath)  # align='left')
         co_wgt.image_label = image_label
         co_wgt.text_layout.addWidget(image_label)
开发者ID:Erotemic,项目名称:ibeis,代码行数:24,代码来源:clock_offset_gui.py


示例18: make_default_module_maintest

def make_default_module_maintest(modname):
    """
    make_default_module_maintest

    TODO: use path relative to home dir if the file is a script

    Args:
        modname (str):  module name

    Returns:
        str: text

    References:
        http://legacy.python.org/dev/peps/pep-0338/

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_autogen import *  # NOQA
        >>> modname = 'utool.util_autogen'
        >>> text = make_default_module_maintest(modname)
        >>> result = str(text)
        >>> print(result)
    """
    import utool as ut
    # Need to use python -m to run a module
    # otherwise their could be odd platform specific errors.
    #python -c "import utool, {modname};
    # utool.doctest_funcs({modname}, allexamples=True)"
    text = ut.codeblock(
        '''
        if __name__ == '__main__':
            """
            CommandLine:
                python -m {modname}
                python -m {modname} --allexamples
                python -m {modname} --allexamples --noface --nosrc
            """
            import multiprocessing
            multiprocessing.freeze_support()  # for win32
            import utool as ut  # NOQA
            ut.doctest_funcs()
        '''
    ).format(modname=modname)
    return text
开发者ID:animalus,项目名称:utool,代码行数:44,代码来源:util_autogen.py


示例19: main

    def main(self):
        """
        python -m utool SetupRepo.main --modname=sklearn --repo=scikit-learn --codedir=~/code -w
        python -m utool SetupRepo.main --repo=ubelt --codedir=~/code --modname=ubelt -w

        Example:
            >>> # SCRIPT
            >>> from utool.util_project import *  # NOQA
            >>> SetupRepo().main()
        """
        self.regencmd = self.regenfmt.format(cmd='main', **self.__dict__)
        import utool as ut
        self.ensure_text(
            fname=join(self.modname, '__main__.py'),
            chmod='+x',
            text=ut.codeblock(
                r'''
                # STARTBLOCK
                #!/usr/bin/env python
                # -*- coding: utf-8 -*-
                """
                Initially Generated By:
                    {regencmd}
                """
                from __future__ import absolute_import, division, print_function, unicode_literals


                def {modname}_main():
                    ignore_prefix = []
                    ignore_suffix = []
                    import utool as ut
                    ut.main_function_tester('{modname}', ignore_prefix, ignore_suffix)

                if __name__ == '__main__':
                    """
                    Usage:
                        python -m {modname} <funcname>
                    """
                    print('Running {modname} main')
                    {modname}_main()
                # ENDBLOCK
                '''
            )
        )
开发者ID:Erotemic,项目名称:utool,代码行数:44,代码来源:util_project.py


示例20: makeinit

def makeinit(module_path, exclude_modnames=[]):
    #module_name = basename(module_path)
    module_name = ut.get_modname_from_modpath(module_path)
    IMPORT_TUPLES = util_importer.make_import_tuples(module_path, exclude_modnames=exclude_modnames)
    initstr = util_importer.make_initstr(module_name, IMPORT_TUPLES)
    regen_command = 'cd %s\n' % (module_path)
    regen_command += '    makeinit.py'
    if len(exclude_modnames ) > 0:
        regen_command += ' -x ' + ' '.join(exclude_modnames)
    regen_block = (ut.codeblock('''
    """
    Regen Command:
        {regen_command}
    """
    ''').format(regen_command=regen_command))

    print('### __init__.py ###')
    print(initstr)
    print('\nIMPORT_TUPLES = ' + ut.list_str(IMPORT_TUPLES))
    print(regen_block)
开发者ID:animalus,项目名称:utool,代码行数:20,代码来源:makeinit.py



注:本文中的utool.codeblock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utool.compress函数代码示例发布时间:2022-05-26
下一篇:
Python utm.to_latlon函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap