# mcedit2.util package — mceditlib 0.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- mceditlib 0.1 documentation »
- mcedit2 package »

# mcedit2.util package

## Submodules

## mcedit2.util.bresenham module

`mcedit2.util.bresenham.``bresenham`(p1, p2)

  Bresenham line algorithm adapted for 3d. slooooow. Now in generator style.

## mcedit2.util.bugfixes module

`mcedit2.util.bugfixes.``QObject_tr_unicode_literals_fix`()

  Because of a bug in PySide, QObject.tr will return an empty string if a unicode object is passed. Additionally, if a utf-8 encoded byte string is passed to tr (maybe this is only when no translations are loaded) then the returned string will be an incorrectly decoded unicode object (each character’s code point is a single byte of the utf-8 encoded byte string that was passed. Thus, encode using ‘ascii’ and avoid using non-ascii characters in string literals.

## mcedit2.util.custom_traceback module

custom_traceback

`mcedit2.util.custom_traceback.``extract_tb`(tb, limit=None)

  Return list of up to limit pre-processed entries from traceback.

  This is useful for alternate formatting of stack traces. If ‘limit’ is omitted or None, all entries are extracted. A pre-processed stack trace entry is a 5-tuple (filename, line number, function name, text, selfstr) representing the information that is usually printed for a stack trace. The text is a string with leading and trailing whitespace stripped; if the source is not available it is None.

  This function is modified to return the name of the ‘self’ parameter’s class as the 5th element of the tuple.

`mcedit2.util.custom_traceback.``format_list`(extracted_list)

  Format a list of traceback entry tuples for printing.

  Given a list of tuples as returned by extract_tb() or extract_stack(), return a list of strings ready for printing. Each string in the resulting list corresponds to the item with the same index in the argument list. Each string ends in a newline; the strings may contain internal newlines as well, for those items whose source text line is not None.

  This function is modified to include the 5th item of the tuple as the name of the class of the ‘self’ parameter

`mcedit2.util.custom_traceback.``print_list`(extracted_list, file=None)

  Print the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file.

  This function is modified to print the 5th element of the tuple
    returned by the modified functions above.

`mcedit2.util.custom_traceback.``print_tb`(tb, limit=None, file=None)

  Print up to ‘limit’ stack trace entries from the traceback ‘tb’.

  If ‘limit’ is omitted or None, all entries are printed. If ‘file’ is omitted or None, the output goes to sys.stderr; otherwise ‘file’ should be an open file or file-like object with a write() method.

  This function is modified to also print the name of the ‘self’ parameter’s class.

`mcedit2.util.custom_traceback.``install`()

## mcedit2.util.dialogs module

dialogs

`mcedit2.util.dialogs.``NotImplementedYet`()

## mcedit2.util.directories module

`mcedit2.util.directories.``getUserFilesDirectory`()

## mcedit2.util.geometry module

${NAME}

## mcedit2.util.glutils module

Copyright (c) 2010-2012 David Rio Vierra

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

glutils.py

Pythonesque wrappers around certain OpenGL functions.

class `mcedit2.util.glutils.``gl`

  Bases: `object`

  classmethod `ResetGL`()
  classmethod `glPushMatrix`(*args, **kwds)
  classmethod `glPushAttrib`(*args, **kwds)
  classmethod `glPushClientAttrib`(*args, **kwds)
  classmethod `glBegin`(*args, **kwds)
  classmethod `glEnable`(*args, **kwds)
  classmethod `glEnableClientState`(*args, **kwds)
  `listCount` = 0
  classmethod `glGenLists`(n)
  classmethod `glDeleteLists`(base, n)

class `mcedit2.util.glutils.``DisplayList`(drawFunc=None)

  Bases: `object`

  classmethod `destroyAllLists`()
  `invalidate`()
  `destroy`()
  `compile`(drawFunc)
  `getList`(drawFunc=None)
  `call`(drawFunc=None)

class `mcedit2.util.glutils.``Texture`(textureFunc=None, minFilter=None, magFilter=None, maxLOD=4)

  Bases: `object`

  `allTextures` = []
  `defaultFilter` = GL_NEAREST
  `load`()
  `dispose`()
  `bind`()
  `invalidate`()

class `mcedit2.util.glutils.``FramebufferTexture`(width, height, drawFunc)

  Bases: `mcedit2.util.glutils.Texture`

`mcedit2.util.glutils.``debugDrawPoint`(point)

## mcedit2.util.ipython_widget module

ipython_widget

`mcedit2.util.ipython_widget.``print_process_id`()

`mcedit2.util.ipython_widget.``terminal_widget`(**kwargs)

`mcedit2.util.ipython_widget.``main`()

## mcedit2.util.lazyprop module

${NAME}

`mcedit2.util.lazyprop.``lazyprop`(fn)

  Lazily computed property wrapper.

      >>> class Foo(object):
      ...     @lazyprop
      ...     def func(self):
      ...         print("Big computation here!")
      ...         return 42
      >>> f = Foo()
      >>> f.func
      Big computation here!
      42
      >>> f.func
      42
      >>> del f.func
      >>> f.func
      Big computation here!
      42

  Returns: |
  Return type: |

## mcedit2.util.load_png module

`mcedit2.util.load_png.``loadPNGTexture`(filename, *a, **kw)

`mcedit2.util.load_png.``loadTextureFunc`(w, h, ndata)

`mcedit2.util.load_png.``loadPNGImage`(img)

`mcedit2.util.load_png.``loadPNGData`(data)

`mcedit2.util.load_png.``loadPNGFile`(filename)

## mcedit2.util.load_ui module

${NAME}

class `mcedit2.util.load_ui.``MCEUILoader`(baseinstance=None, *a, **kw)

  Bases: `PySide.QtUiTools.QUiLoader`

  `createWidget`(className, parent=None, name=u'')

    QWidget * QUiLoader::createWidget ( const QString & className, QWidget * parent = 0, const QString & name = QString() ) [virtual]

    Parameters:

    - className – str
    - parent – QWidget
    - name – str

    Returns: |
    Return type: |

  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x0000000006102548>

`mcedit2.util.load_ui.``registerCustomWidget`(cls)

`mcedit2.util.load_ui.``load_ui`(name, parent=None, baseinstance=None)

## mcedit2.util.mceaction module

${NAME}

`mcedit2.util.mceaction.``ChangeBinding`(shortcutName, shortcutString)

class `mcedit2.util.mceaction.``MCEAction`(name, parent, shortcutName=None, *args, **kwargs)

  Bases: `PySide.QtGui.QAction`

  `shortcutChanged`(shortcutString)
  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x000000000ADC1F08>

## mcedit2.util.minecraftinstall module

minecraftinstall

class `mcedit2.util.minecraftinstall.``MCInstall`(path, name='Unnamed')

  Bases: `object`

  `checkUsable`()

    Raises MCInstallError explaining why this install is unusable, or else does nothing :return: :rtype:

  `versionsDir`
  `versions`
  `getVersionJarPath`(version)
  `resourcePacks`
  `getSaveFileDir`()
  `getResourcePackPath`(filename)
  `getJsonSettingValue`()
  `getResourceLoader`(version, resourcePack)
  `findVersion1_8`()

`mcedit2.util.minecraftinstall.``splitVersion`(version)

  Split a Minecraft version ID into major, minor, and revision. If the version could not be parsed, return (0, 0, “”) The revision is returned with the leading period. For example, if “1.8.1-pre3” is passed, (1, 8, ”.1-pre3”) will be returned.

  Parameters: | version (unicode) –
  Returns: | major, minor, revision
  Return type: | int, int, unicode

`mcedit2.util.minecraftinstall.``usableVersion`(version)

  Return True if the version has unstitched texture data in assets/minecraft/textures/blocks (v1.6+) (earlier versions have unstitched textures elsewhere, so don’t bother with them) :param version: :type version: :return: :rtype:

exception `mcedit2.util.minecraftinstall.``MCInstallError`

  Bases: `exceptions.ValueError`

  Raised for invalid or unusable Minecraft installs.

`mcedit2.util.minecraftinstall.``getDefaultInstall`()

  Returns: |
  Return type: | MCInstall

`mcedit2.util.minecraftinstall.``listInstalls`()

`mcedit2.util.minecraftinstall.``selectedInstallIndex`()

`mcedit2.util.minecraftinstall.``getInstall`(index)

`mcedit2.util.minecraftinstall.``ensureInstallation`()

  Called on app startup. Auto-detect install, display config dialog if no installs were found :return: :rtype:

class `mcedit2.util.minecraftinstall.``NameItem`

  Bases: `PySide.QtGui.QTableWidgetItem`

  `setData`(data, role)

class `mcedit2.util.minecraftinstall.``PathItem`

  Bases: `PySide.QtGui.QTableWidgetItem`

  `setData`(data, role)

class `mcedit2.util.minecraftinstall.``MinecraftInstallsDialog`(*args, **kwargs)

  Bases: `PySide.QtGui.QDialog`

  `itemChanged`(row, column)
  `add`()
  `remove`()
  `select`()
  `ok`()
  `close`()
  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x000000000854E788>

## mcedit2.util.objgraphwidget module

objgraphwidget

class `mcedit2.util.objgraphwidget.``ObjGraphWidget`(*a, **kw)

  Bases: `PySide.QtGui.QWidget`

  `itemChanged`()
  `showTempImage`(*args, **kwds)
  `showGarbage`()
  `showRefs`()
  `showBackrefs`()
  `showGraph`()
  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x000000000854EB88>

## mcedit2.util.profiler module

profiler

class `mcedit2.util.profiler.``Profiler`

  Bases: `object`

  `sampleLimit` = 100000
  `dumpSamples`()
  `enter`(name, entry=True)

    Record the entry into a named profiling area. Call profiler.exit() to return to the previous area.

    Parameters: | name –
    Returns: |
    Return type: |

  `exit`()
  `context`(*args, **kwds)
  `function`(name)
  `iterate`(it, name)
  `iterator`(name)
  `recordSample`(entry=False)
  `analyze`()

class `mcedit2.util.profiler.``DummyProfiler`

  Bases: `mcedit2.util.profiler.Profiler`

  `enter`(name, entry=False)
  `exit`()
  `function`(name)
  `iterate`(it, name)

class `mcedit2.util.profiler.``AnalysisNode`(**kwargs)

  Bases: `collections.defaultdict`

  `totalTime`

class `mcedit2.util.profiler.``ProfileAnalysis`(times, counts, **kwargs)

  Bases: `mcedit2.util.profiler.AnalysisNode`

`mcedit2.util.profiler.``getProfiler`()

`mcedit2.util.profiler.``function`(name)

  Decorate a function with profiler calls. If name is not given, uses the function’s name.

  Usage:

  @profiler.function def foo():

  > print “Work work.”

  @profiler.function(“Subroutine ‘bar’ #2”) def bar():

  > print “Work work work.”

  Parameters: | name –

  Returns:

  rtype: | function

`mcedit2.util.profiler.``context`(*a, **kw)

`mcedit2.util.profiler.``iterate`(it, name)

  Wraps an iterator with profiler calls. Each call to it.next() is wrapped in a Profiler.context() call.

  Usage:

  someIterator = xrange(1000) for i in profiler.iterate(someIterator, “Costly foo iteration.”):

  > print i

`mcedit2.util.profiler.``iterator`(name=None)

  Decorates a function which returns an iterator by wrapping the iterator with profile calls. If name is not given, uses the function’s name.

  Usage:

  @profiler.iterator def foo_iter():

  > for i in range(100):
  >   yield i

  @profiler.iterator(“Iterator ‘bar’ #2”) def bar_iter():

  > for i in range(100):
  >   yield i

  Returns:

  rtype: | function

## mcedit2.util.profilerui module

profilerui

class `mcedit2.util.profilerui.``ProfilerWidget`(*args, **kwargs)

  Bases: `PySide.QtGui.QWidget`

  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x000000000875FFC8>
  `updateTable`(*a, **kw)

## mcedit2.util.raycast module

raycast

exception `mcedit2.util.raycast.``RayCastError`

  Bases: `exceptions.ValueError`

exception `mcedit2.util.raycast.``MaxDistanceError`

  Bases: `mcedit2.util.raycast.RayCastError`

  Raised when a ray cast exceeds its max distance.

exception `mcedit2.util.raycast.``RayBoundsError`

  Bases: `mcedit2.util.raycast.RayCastError`

  Raised when a ray exits or does not enter the level boundaries.

`mcedit2.util.raycast.``rayCastInBounds`(ray, dimension, maxDistance=100, hitAir=False)

`mcedit2.util.raycast.``rayCast`(*a, **kw)

  Borrowed from https://gamedev.stackexchange.com/questions/47362/cast-ray-to-select-block-in-voxel-game

  Updates a factor t along each axis to compute the distance from the vector origin (in units of the vector magnitude) to the next integer value (i.e. block edge) along that axis.

  Return the block position and face of the block touched.

  Raises MaxDistanceError if the ray exceeded the max distance without hitting any blocks, or if the ray exits or doesn’t enter the dimension’s bounds.

  Parameters:

  - ray (Ray) –
  - maxDistance (int) –
  - dimension (mceditlib.worldeditor.WorldEditorDimension) –

  Returns: | (point, face)
  Return type: |

`mcedit2.util.raycast.``intbound`(o, v, step)

`mcedit2.util.raycast.``advanceToChunk`(ray, dimension, maxDistance)

## mcedit2.util.resources module

${NAME}

`mcedit2.util.resources.``resourcePath`(filename)

## mcedit2.util.scanmodules module

${NAME}

`mcedit2.util.scanmodules.``ScanModules`(modulename, path)

## mcedit2.util.screen module

screen

`mcedit2.util.screen.``centerWidgetInScreen`(widget, resize=None)

  Parameters:

  - widget –
  - resize – Fraction of screen width/height to resize widget to

  Returns: |
  Return type: |

## mcedit2.util.settings module

settings

`mcedit2.util.settings.``Settings`()

class `mcedit2.util.settings.``MCESettingsOption`(settings, key, type, *args, **kwargs)

  Bases: `PySide.QtCore.QObject`

  `value`(default=None)
  `setValue`(value)
  `valueChanged` = <PySide.QtCore.Signal object at 0x00000000083B1F80>
  `jsonValue`(default=None)
  `setJsonValue`(value)
  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x00000000083B6948>

class `mcedit2.util.settings.``MCESettings`(*args, **kwargs)

  Bases: `PySide.QtCore.QSettings`

  `getSignal`(key)

    Returns a signal to be triggered when the setting `key` is changed. The signal handler receives one argument: the setting’s new value.

    Parameters: | key (str) – Settings key
    Return type: | None

  `emitSignal`(key, val)
  `setValue`(key, val)
  `jsonValue`(key, default=None)
  `setJsonValue`(key, value)
  `getOption`(key, type=None)

    Return an object that represents the setting at ‘key’. The object may be used to get and set the value and get the value’s valueChanged signal. Among other uses, the object’s setValue attribute may be connected to the valueChanged signal of an input field.

    Parameters: | key –
    Returns: |
    Return type: |

  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x00000000083B6988>

## mcedit2.util.showprogress module

${NAME}

`mcedit2.util.showprogress.``showProgress`(text, iter, cancel=False)

  Show a progress dialog for the given task. The task should be an iterable, yielding progress info as (current, max) or (current, max, statusString) tuples. Return the last value yielded by the task. :param text: :type text: :param iter: :type iter: :param cancel: :type cancel: :return: :rtype:

## mcedit2.util.undostack module

undostack

class `mcedit2.util.undostack.``MCEUndoStack`

  Bases: `PySide.QtGui.QUndoStack`

  `undoBlock` = None
  `undo`()
  `redo`()
  `push`(*args, **kwargs)
  `setUndoBlock`(callback)

    Set a function to be called before the next time undo, redo, or beginUndo is called. Some tools may need to call beginUndo, then interact with the user for a time before calling commitUndo, or they may need to use multiple undo revisions for a single operation with freedom given to the user between revisions. This ensures that the interactive operation will be completed or aborted before the next command begins its undo revision.

    User actions that only change the editor state will not call beginUndo, and their QUndoCommand may end up before the interrupted command in the history.

    Parameters: | callback (callable) – Function to call

  `removeUndoBlock`(callback)
  `clearUndoBlock`()

    If an undo block is set, calls its callback and removes it.

    Returns: |
    Return type: |

  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x0000000003D95C08>

## mcedit2.util.worldloader module

${NAME}

class `mcedit2.util.worldloader.``LoaderTimer`(*args, **kwargs)

  Bases: `PySide.QtCore.QTimer`

  classmethod `stopCtx`(*args, **kwds)
  static `stopAll`()
  static `startAll`()
  `staticMetaObject` = <PySide.QtCore.QMetaObject object at 0x0000000008471348>

class `mcedit2.util.worldloader.``WorldLoader`(scene)

  Bases: `object`

  `loadChunk`()
  `work`(*a, **kw)

## Module contents

### Navigation

- index
- modules |
- next |
- previous |
- mceditlib 0.1 documentation »
- mcedit2 package »