PrEditor 0.0.0.dev1__py2.py3-none-any.whl → 0.1.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of PrEditor might be problematic. Click here for more details.
- PrEditor-0.1.0.dist-info/LICENSE +165 -0
- PrEditor-0.1.0.dist-info/METADATA +212 -0
- PrEditor-0.1.0.dist-info/RECORD +149 -0
- {PrEditor-0.0.0.dev1.dist-info → PrEditor-0.1.0.dist-info}/WHEEL +1 -1
- PrEditor-0.1.0.dist-info/entry_points.txt +18 -0
- PrEditor-0.1.0.dist-info/top_level.txt +1 -0
- preditor/__init__.py +301 -0
- {blurdev → preditor}/__main__.py +13 -13
- preditor/about_module.py +166 -0
- preditor/cli.py +192 -0
- {blurdev → preditor}/contexts.py +119 -119
- preditor/cores/core.py +65 -0
- preditor/dccs/maya/PrEditor_maya.mod +2 -0
- preditor/dccs/maya/plug-ins/PrEditor_maya.py +108 -0
- preditor/debug.py +294 -0
- blurdev/scintilla/delayable_engine.py → preditor/delayable_engine/__init__.py +310 -299
- blurdev/scintilla/delayables/base.py → preditor/delayable_engine/delayables.py +85 -85
- {blurdev → preditor}/enum.py +728 -1003
- {blurdev → preditor}/gui/__init__.py +84 -125
- preditor/gui/app.py +159 -0
- {blurdev → preditor}/gui/codehighlighter.py +209 -219
- {blurdev → preditor}/gui/completer.py +226 -236
- {blurdev → preditor}/gui/console.py +801 -858
- {blurdev → preditor}/gui/dialog.py +200 -216
- preditor/gui/drag_tab_bar.py +190 -0
- preditor/gui/editor_chooser.py +57 -0
- {blurdev → preditor}/gui/errordialog.py +100 -97
- preditor/gui/fuzzy_search/fuzzy_search.py +93 -0
- preditor/gui/group_tab_widget/__init__.py +319 -0
- preditor/gui/group_tab_widget/grouped_tab_menu.py +35 -0
- preditor/gui/group_tab_widget/grouped_tab_models.py +108 -0
- preditor/gui/group_tab_widget/grouped_tab_widget.py +75 -0
- preditor/gui/group_tab_widget/one_tab_widget.py +54 -0
- preditor/gui/level_buttons.py +349 -0
- {blurdev → preditor}/gui/logger_window_handler.py +46 -45
- {blurdev → preditor}/gui/loggerwindow.py +1205 -1417
- {blurdev → preditor}/gui/newtabwidget.py +69 -68
- {blurdev → preditor}/gui/redmine_login_dialog.py +63 -61
- {blurdev → preditor}/gui/set_text_editor_path_dialog.py +59 -57
- preditor/gui/ui/editor_chooser.ui +93 -0
- {blurdev → preditor}/gui/ui/errordialog.ui +81 -81
- {blurdev → preditor}/gui/ui/loggerwindow.ui +1030 -864
- {blurdev → preditor}/gui/ui/redmine_login_dialog.ui +124 -124
- {blurdev → preditor}/gui/ui/set_text_editor_path_dialog.ui +149 -149
- {blurdev → preditor}/gui/window.py +183 -199
- preditor/gui/workbox_mixin.py +357 -0
- preditor/gui/workbox_text_edit.py +117 -0
- preditor/gui/workboxwidget.py +276 -0
- preditor/logging_config.py +52 -0
- preditor/osystem.py +401 -0
- preditor/plugins.py +65 -0
- preditor/prefs.py +74 -0
- {blurdev → preditor}/resource/environment_variables.html +26 -38
- {blurdev → preditor}/resource/error_mail.html +85 -85
- {blurdev → preditor}/resource/error_mail_inline.html +41 -41
- preditor/resource/img/README.md +7 -0
- preditor/resource/img/arrow_forward.png +0 -0
- preditor/resource/img/check-bold.png +0 -0
- preditor/resource/img/chevron-down.png +0 -0
- preditor/resource/img/chevron-up.png +0 -0
- preditor/resource/img/close-thick.png +0 -0
- preditor/resource/img/comment-edit.png +0 -0
- preditor/resource/img/content-copy.png +0 -0
- preditor/resource/img/content-cut.png +0 -0
- preditor/resource/img/content-duplicate.png +0 -0
- preditor/resource/img/content-paste.png +0 -0
- preditor/resource/img/content-save.png +0 -0
- preditor/resource/img/debug_disabled.png +0 -0
- preditor/resource/img/eye-check.png +0 -0
- preditor/resource/img/file-plus.png +0 -0
- preditor/resource/img/file-remove.png +0 -0
- preditor/resource/img/format-align-left.png +0 -0
- preditor/resource/img/format-letter-case-lower.png +0 -0
- preditor/resource/img/format-letter-case-upper.png +0 -0
- preditor/resource/img/information.png +0 -0
- preditor/resource/img/logging_critical.png +0 -0
- preditor/resource/img/logging_custom.png +0 -0
- preditor/resource/img/logging_debug.png +0 -0
- preditor/resource/img/logging_error.png +0 -0
- preditor/resource/img/logging_info.png +0 -0
- preditor/resource/img/logging_not_set.png +0 -0
- preditor/resource/img/logging_warning.png +0 -0
- preditor/resource/img/marker.png +0 -0
- preditor/resource/img/play.png +0 -0
- preditor/resource/img/playlist-play.png +0 -0
- preditor/resource/img/plus-minus-variant.png +0 -0
- preditor/resource/img/preditor.ico +0 -0
- preditor/resource/img/preditor.png +0 -0
- preditor/resource/img/preditor.psd +0 -0
- preditor/resource/img/preditor.svg +44 -0
- preditor/resource/img/restart.svg +1 -0
- preditor/resource/img/skip-forward-outline.png +0 -0
- preditor/resource/img/skip-next-outline.png +0 -0
- preditor/resource/img/skip-next.png +0 -0
- preditor/resource/img/skip-previous.png +0 -0
- preditor/resource/img/subdirectory-arrow-right.png +0 -0
- preditor/resource/img/text-search-variant.png +0 -0
- {blurdev → preditor}/resource/lang/python.json +30 -30
- preditor/resource/settings.ini +25 -0
- {blurdev/resource/stylesheet/logger → preditor/resource/stylesheet}/Bright.css +56 -61
- {blurdev → preditor}/resource/stylesheet/Dark.css +190 -132
- {blurdev → preditor}/scintilla/__init__.py +22 -28
- preditor/scintilla/delayables/__init__.py +11 -0
- {blurdev → preditor}/scintilla/delayables/smart_highlight.py +94 -93
- {blurdev → preditor}/scintilla/delayables/spell_check.py +173 -172
- {blurdev → preditor}/scintilla/documenteditor.py +2039 -2115
- {blurdev → preditor}/scintilla/finddialog.py +68 -81
- {blurdev → preditor}/scintilla/lang/__init__.py +80 -93
- {blurdev → preditor}/scintilla/lang/config/bash.ini +15 -15
- {blurdev → preditor}/scintilla/lang/config/batch.ini +14 -14
- {blurdev → preditor}/scintilla/lang/config/cpp.ini +19 -19
- {blurdev → preditor}/scintilla/lang/config/css.ini +19 -19
- {blurdev → preditor}/scintilla/lang/config/eyeonscript.ini +17 -17
- {blurdev → preditor}/scintilla/lang/config/html.ini +21 -21
- {blurdev → preditor}/scintilla/lang/config/javascript.ini +24 -24
- {blurdev → preditor}/scintilla/lang/config/lua.ini +16 -16
- {blurdev → preditor}/scintilla/lang/config/maxscript.ini +20 -20
- {blurdev → preditor}/scintilla/lang/config/mel.ini +18 -18
- {blurdev → preditor}/scintilla/lang/config/mu.ini +22 -22
- {blurdev → preditor}/scintilla/lang/config/nsi.ini +5 -5
- {blurdev → preditor}/scintilla/lang/config/perl.ini +19 -19
- {blurdev → preditor}/scintilla/lang/config/puppet.ini +19 -19
- {blurdev → preditor}/scintilla/lang/config/python.ini +28 -28
- {blurdev → preditor}/scintilla/lang/config/ruby.ini +19 -19
- {blurdev → preditor}/scintilla/lang/config/sql.ini +7 -7
- {blurdev → preditor}/scintilla/lang/config/xml.ini +21 -21
- {blurdev → preditor}/scintilla/lang/config/yaml.ini +18 -18
- {blurdev → preditor}/scintilla/lang/language.py +240 -250
- preditor/scintilla/lexers/__init__.py +0 -0
- {blurdev → preditor}/scintilla/lexers/cpplexer.py +21 -30
- {blurdev → preditor}/scintilla/lexers/javascriptlexer.py +25 -34
- {blurdev → preditor}/scintilla/lexers/maxscriptlexer.py +234 -253
- {blurdev → preditor}/scintilla/lexers/mellexer.py +368 -376
- {blurdev → preditor}/scintilla/lexers/mulexer.py +32 -41
- {blurdev → preditor}/scintilla/lexers/pythonlexer.py +41 -50
- {blurdev → preditor}/scintilla/ui/finddialog.ui +160 -160
- preditor/settings.py +71 -0
- preditor/stream/__init__.py +80 -0
- preditor/stream/director.py +56 -0
- preditor/stream/manager.py +74 -0
- preditor/streamhandler_helper.py +46 -0
- preditor/utils/__init__.py +0 -0
- preditor/utils/cute.py +30 -0
- preditor/utils/stylesheets.py +54 -0
- {blurdev → preditor}/version.py +5 -5
- preditor/weakref.py +363 -0
- PrEditor-0.0.0.dev1.dist-info/METADATA +0 -51
- PrEditor-0.0.0.dev1.dist-info/RECORD +0 -279
- PrEditor-0.0.0.dev1.dist-info/top_level.txt +0 -1
- blurdev/__init__.py +0 -356
- blurdev/cores/__init__.py +0 -98
- blurdev/cores/application.py +0 -26
- blurdev/cores/core.py +0 -634
- blurdev/debug.py +0 -593
- blurdev/external.py +0 -391
- blurdev/gui/level_buttons.py +0 -585
- blurdev/gui/workboxwidget.py +0 -205
- blurdev/logger.py +0 -238
- blurdev/osystem.py +0 -813
- blurdev/prefs.py +0 -33
- blurdev/protocols/__init__.py +0 -71
- blurdev/protocols/write_std_output_handler.py +0 -83
- blurdev/resource/designer_plugins.xml +0 -9
- blurdev/resource/error_email_old.html +0 -41
- blurdev/resource/img/add.png +0 -0
- blurdev/resource/img/ajax-loader.gif +0 -0
- blurdev/resource/img/application.png +0 -0
- blurdev/resource/img/applications.png +0 -0
- blurdev/resource/img/assburner.png +0 -0
- blurdev/resource/img/assfreezer.png +0 -0
- blurdev/resource/img/bar.gif +0 -0
- blurdev/resource/img/blank.png +0 -0
- blurdev/resource/img/blurdev.png +0 -0
- blurdev/resource/img/calendar_disabled.png +0 -0
- blurdev/resource/img/calendar_enabled.png +0 -0
- blurdev/resource/img/cancel.png +0 -0
- blurdev/resource/img/custom.png +0 -0
- blurdev/resource/img/debug_high.png +0 -0
- blurdev/resource/img/debug_low.png +0 -0
- blurdev/resource/img/debug_mid.png +0 -0
- blurdev/resource/img/debug_off.png +0 -0
- blurdev/resource/img/django.png +0 -0
- blurdev/resource/img/doc.png +0 -0
- blurdev/resource/img/edit.png +0 -0
- blurdev/resource/img/elemental.png +0 -0
- blurdev/resource/img/explore.png +0 -0
- blurdev/resource/img/favorite.png +0 -0
- blurdev/resource/img/file.png +0 -0
- blurdev/resource/img/folder.png +0 -0
- blurdev/resource/img/ide/add.png +0 -0
- blurdev/resource/img/ide/add_note.png +0 -0
- blurdev/resource/img/ide/arrow_down.png +0 -0
- blurdev/resource/img/ide/arrow_up.png +0 -0
- blurdev/resource/img/ide/check.png +0 -0
- blurdev/resource/img/ide/class.png +0 -0
- blurdev/resource/img/ide/clean.png +0 -0
- blurdev/resource/img/ide/clearlog.png +0 -0
- blurdev/resource/img/ide/close.png +0 -0
- blurdev/resource/img/ide/comment_add.png +0 -0
- blurdev/resource/img/ide/comment_remove.png +0 -0
- blurdev/resource/img/ide/comment_toggle.png +0 -0
- blurdev/resource/img/ide/console.png +0 -0
- blurdev/resource/img/ide/copy.png +0 -0
- blurdev/resource/img/ide/copylstrip.png +0 -0
- blurdev/resource/img/ide/cut.png +0 -0
- blurdev/resource/img/ide/edit.png +0 -0
- blurdev/resource/img/ide/find.png +0 -0
- blurdev/resource/img/ide/find_replace.png +0 -0
- blurdev/resource/img/ide/findnext.png +0 -0
- blurdev/resource/img/ide/findprev.png +0 -0
- blurdev/resource/img/ide/folder_find.png +0 -0
- blurdev/resource/img/ide/function.png +0 -0
- blurdev/resource/img/ide/git-bash.png +0 -0
- blurdev/resource/img/ide/git-gui.png +0 -0
- blurdev/resource/img/ide/gitk.png +0 -0
- blurdev/resource/img/ide/goto.png +0 -0
- blurdev/resource/img/ide/goto_def.png +0 -0
- blurdev/resource/img/ide/help.png +0 -0
- blurdev/resource/img/ide/highlighter.png +0 -0
- blurdev/resource/img/ide/lowercase.png +0 -0
- blurdev/resource/img/ide/newfile.png +0 -0
- blurdev/resource/img/ide/newfolder.png +0 -0
- blurdev/resource/img/ide/newproject.png +0 -0
- blurdev/resource/img/ide/newwizard.png +0 -0
- blurdev/resource/img/ide/open.png +0 -0
- blurdev/resource/img/ide/paste.png +0 -0
- blurdev/resource/img/ide/pdb_continue.png +0 -0
- blurdev/resource/img/ide/pdb_down.png +0 -0
- blurdev/resource/img/ide/pdb_next.png +0 -0
- blurdev/resource/img/ide/pdb_step.png +0 -0
- blurdev/resource/img/ide/pdb_up.png +0 -0
- blurdev/resource/img/ide/plus_minus.png +0 -0
- blurdev/resource/img/ide/preferences.png +0 -0
- blurdev/resource/img/ide/project_find.png +0 -0
- blurdev/resource/img/ide/python.png +0 -0
- blurdev/resource/img/ide/pyular.png +0 -0
- blurdev/resource/img/ide/qt.png +0 -0
- blurdev/resource/img/ide/quit.png +0 -0
- blurdev/resource/img/ide/redo.png +0 -0
- blurdev/resource/img/ide/refresh.png +0 -0
- blurdev/resource/img/ide/remove.png +0 -0
- blurdev/resource/img/ide/ruler.png +0 -0
- blurdev/resource/img/ide/run.png +0 -0
- blurdev/resource/img/ide/runall.png +0 -0
- blurdev/resource/img/ide/runallclear.png +0 -0
- blurdev/resource/img/ide/runselected.png +0 -0
- blurdev/resource/img/ide/runselectedclear.png +0 -0
- blurdev/resource/img/ide/save.png +0 -0
- blurdev/resource/img/ide/saveas.png +0 -0
- blurdev/resource/img/ide/sdk.png +0 -0
- blurdev/resource/img/ide/separator.png +0 -0
- blurdev/resource/img/ide/tabbed.png +0 -0
- blurdev/resource/img/ide/tile.png +0 -0
- blurdev/resource/img/ide/toolbar.png +0 -0
- blurdev/resource/img/ide/undo.png +0 -0
- blurdev/resource/img/ide/uppercase.png +0 -0
- blurdev/resource/img/ide/view_as.png +0 -0
- blurdev/resource/img/ide/windowed.png +0 -0
- blurdev/resource/img/ide.ico +0 -0
- blurdev/resource/img/ide.png +0 -0
- blurdev/resource/img/ide48.png +0 -0
- blurdev/resource/img/info.png +0 -0
- blurdev/resource/img/legacy tool.png +0 -0
- blurdev/resource/img/library.png +0 -0
- blurdev/resource/img/logger/about.png +0 -0
- blurdev/resource/img/logger/arrow_forward.png +0 -0
- blurdev/resource/img/logger/clear.png +0 -0
- blurdev/resource/img/logger/close.png +0 -0
- blurdev/resource/img/logger/debug_disabled.png +0 -0
- blurdev/resource/img/logger/debug_high.png +0 -0
- blurdev/resource/img/logger/debug_low.png +0 -0
- blurdev/resource/img/logger/debug_mid.png +0 -0
- blurdev/resource/img/logger/down.png +0 -0
- blurdev/resource/img/logger/find.png +0 -0
- blurdev/resource/img/logger/logging_critical.png +0 -0
- blurdev/resource/img/logger/logging_debug.png +0 -0
- blurdev/resource/img/logger/logging_error.png +0 -0
- blurdev/resource/img/logger/logging_info.png +0 -0
- blurdev/resource/img/logger/logging_not_set.png +0 -0
- blurdev/resource/img/logger/logging_warning.png +0 -0
- blurdev/resource/img/logger/next.png +0 -0
- blurdev/resource/img/logger/play.png +0 -0
- blurdev/resource/img/logger/playlist_play.png +0 -0
- blurdev/resource/img/logger/previous.png +0 -0
- blurdev/resource/img/logger/return.png +0 -0
- blurdev/resource/img/logger/save.png +0 -0
- blurdev/resource/img/logger/subdirectory_arrow_right.png +0 -0
- blurdev/resource/img/logger/up.png +0 -0
- blurdev/resource/img/lovebar.png +0 -0
- blurdev/resource/img/new.png +0 -0
- blurdev/resource/img/new_selected.png +0 -0
- blurdev/resource/img/node.png +0 -0
- blurdev/resource/img/ok.png +0 -0
- blurdev/resource/img/options.png +0 -0
- blurdev/resource/img/packages.png +0 -0
- blurdev/resource/img/preview/add.png +0 -0
- blurdev/resource/img/preview/brush.png +0 -0
- blurdev/resource/img/preview/delete.png +0 -0
- blurdev/resource/img/preview/delte.png +0 -0
- blurdev/resource/img/preview/fill.png +0 -0
- blurdev/resource/img/preview/layers.png +0 -0
- blurdev/resource/img/preview/media.png +0 -0
- blurdev/resource/img/preview/navigate.png +0 -0
- blurdev/resource/img/preview/pencil.png +0 -0
- blurdev/resource/img/preview/select.png +0 -0
- blurdev/resource/img/preview/type.png +0 -0
- blurdev/resource/img/preview/visible.png +0 -0
- blurdev/resource/img/project.png +0 -0
- blurdev/resource/img/python_logger.ico +0 -0
- blurdev/resource/img/python_logger.png +0 -0
- blurdev/resource/img/refresh.png +0 -0
- blurdev/resource/img/remove.png +0 -0
- blurdev/resource/img/reset.png +0 -0
- blurdev/resource/img/richtext/font_bold.png +0 -0
- blurdev/resource/img/richtext/font_italic.png +0 -0
- blurdev/resource/img/richtext/link_image.png +0 -0
- blurdev/resource/img/richtext/spell_check.png +0 -0
- blurdev/resource/img/richtext/unordered_list.png +0 -0
- blurdev/resource/img/save.png +0 -0
- blurdev/resource/img/savesettings.png +0 -0
- blurdev/resource/img/settings.png +0 -0
- blurdev/resource/img/tool.png +0 -0
- blurdev/resource/img/toolbarHandleHorizontal.png +0 -0
- blurdev/resource/img/toolbarHandleVertical.png +0 -0
- blurdev/resource/img/trash.png +0 -0
- blurdev/resource/img/trax.png +0 -0
- blurdev/resource/img/tree.png +0 -0
- blurdev/resource/img/treegrunt.ico +0 -0
- blurdev/resource/img/treegrunt.png +0 -0
- blurdev/resource/img/treegruntedit.png +0 -0
- blurdev/resource/img/user interface.png +0 -0
- blurdev/resource/img/warning.png +0 -0
- blurdev/resource/img/watermark.png +0 -0
- blurdev/resource/sdk/blurdev.sdk +0 -3
- blurdev/resource/settings.ini +0 -82
- blurdev/resource/softimage/BlurApplication.dll +0 -0
- blurdev/resource/softimage/BlurApplication64.dll +0 -0
- blurdev/resource/stylesheet/Carbon.css +0 -35
- blurdev/resource/stylesheet/logger/Dark.css +0 -62
- blurdev/resource/templ/py_comment.templ +0 -1
- blurdev/resource/templ/py_debug_raise_error.templ +0 -7
- blurdev/resource/templ/py_doc_string.templ +0 -10
- blurdev/resource/templ/py_header.templ +0 -9
- blurdev/resource/templ/py_line_comment.templ +0 -1
- blurdev/resource/templ/py_log_to_file.templ +0 -22
- blurdev/resource/templ/py_module_path.templ +0 -1
- blurdev/resource/templ/py_pyqt_core.templ +0 -1
- blurdev/resource/templ/py_pyqt_gui.templ +0 -1
- blurdev/resource/templ/py_splashscreen.templ +0 -6
- blurdev/resource/templ/py_testing_note.templ +0 -1
- blurdev/resource/templ/py_testing_note_end.templ +0 -1
- blurdev/resource/tools_environments.json +0 -72
- blurdev/resource/tools_environments.xml +0 -11
- blurdev/resource/tools_environments_linux.xml +0 -11
- blurdev/resource/tools_environments_offline.xml +0 -7
- blurdev/runtimes/__init__.py +0 -2
- blurdev/runtimes/logger.py +0 -44
- blurdev/scintilla/delayables/__init__.py +0 -9
- blurdev/settings.py +0 -312
- blurdev/utils/error.py +0 -389
- {blurdev/scintilla/lexers → preditor/cores}/__init__.py +0 -0
- {blurdev/utils → preditor/gui/fuzzy_search}/__init__.py +0 -0
- {blurdev → preditor}/resource/img/warning-big.png +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import absolute_import, print_function
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from . import STDERR, STDOUT
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Director(io.TextIOBase):
|
|
10
|
+
"""A file like object that stores the text written to it in a manager.
|
|
11
|
+
This manager can be shared between multiple Directors to build a single
|
|
12
|
+
continuous history of all writes.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
manager (Manager): The manager that writes are stored in.
|
|
16
|
+
state: The state passed to the manager. This is often ``preditor.stream.STDOUT``
|
|
17
|
+
or ``preditor.stream.STDERR``.
|
|
18
|
+
old_stream: A second stream that will be written to every time this stream
|
|
19
|
+
is written to. This allows this object to replace sys.stdout and still
|
|
20
|
+
send that output to the original stdout, which is useful for not breaking
|
|
21
|
+
DCC's script editors. Pass False to disable this feature. If you pass None
|
|
22
|
+
and state is set to ``preditor.stream.STDOUT`` or ``preditor.stream.STDERR``
|
|
23
|
+
this will automatically be set to the current sys.stdout or sys.stderr.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, manager, state, old_stream=None, *args, **kwargs):
|
|
27
|
+
super(Director, self).__init__(*args, **kwargs)
|
|
28
|
+
self.manager = manager
|
|
29
|
+
self.state = state
|
|
30
|
+
|
|
31
|
+
if old_stream is False:
|
|
32
|
+
old_stream = None
|
|
33
|
+
elif old_stream is None:
|
|
34
|
+
if state == STDOUT:
|
|
35
|
+
old_stream = sys.stdout
|
|
36
|
+
elif state == STDERR:
|
|
37
|
+
old_stream = sys.stderr
|
|
38
|
+
self.old_stream = old_stream
|
|
39
|
+
|
|
40
|
+
def close(self):
|
|
41
|
+
if self.old_stream:
|
|
42
|
+
self.old_stream.close()
|
|
43
|
+
|
|
44
|
+
super(Director, self).close()
|
|
45
|
+
|
|
46
|
+
def flush(self):
|
|
47
|
+
if self.old_stream:
|
|
48
|
+
self.old_stream.flush()
|
|
49
|
+
|
|
50
|
+
super(Director, self).flush()
|
|
51
|
+
|
|
52
|
+
def write(self, msg):
|
|
53
|
+
self.manager.write(msg, self.state)
|
|
54
|
+
|
|
55
|
+
if self.old_stream:
|
|
56
|
+
self.old_stream.write(msg)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from __future__ import absolute_import, print_function
|
|
2
|
+
|
|
3
|
+
import collections
|
|
4
|
+
|
|
5
|
+
from ..weakref import WeakList
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Manager(collections.deque):
|
|
9
|
+
"""Stores all of the data from the stdout/stderr writes. You can iterate over this
|
|
10
|
+
object to see all of the (msg, state) calls that have been written to it up to the
|
|
11
|
+
maxlen specified when constructing it.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
maxlen (int, optional): The maximum number of raw writes to store. If this is
|
|
15
|
+
exceeded, the oldest writes are discarded.
|
|
16
|
+
|
|
17
|
+
Properties:
|
|
18
|
+
store_writes (bool): Set this to False if you no longer want write calls to
|
|
19
|
+
store on the manager.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, maxlen=10000):
|
|
23
|
+
super(Manager, self).__init__(maxlen=maxlen)
|
|
24
|
+
self.callbacks = WeakList()
|
|
25
|
+
self.store_writes = True
|
|
26
|
+
|
|
27
|
+
def add_callback(self, callback, replay=False, disable_writes=False, clear=False):
|
|
28
|
+
"""Add a callable that will be called every time write is called.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
callback (callable): A callable object that takes two arguments. It must
|
|
32
|
+
take two arguments (msg, state). See write for more details.
|
|
33
|
+
replay (bool, optional): If True, then iterate over all the stored writes
|
|
34
|
+
and pass them to callback. This is useful for when you are initializing
|
|
35
|
+
a gui and want to include all previous prints.
|
|
36
|
+
disable_writes (bool, optional): Set store_writes to False if this is True.
|
|
37
|
+
clear (bool, optional): Clear the stored history on this object.
|
|
38
|
+
"""
|
|
39
|
+
self.callbacks.append(callback)
|
|
40
|
+
|
|
41
|
+
if replay:
|
|
42
|
+
# Replay the existing prints into the console.
|
|
43
|
+
for msg, state in self:
|
|
44
|
+
callback(msg, state)
|
|
45
|
+
|
|
46
|
+
if disable_writes:
|
|
47
|
+
# Disable storing data in the buffer. buffer.write calls will now
|
|
48
|
+
# directly write to console so there is no reason to duplicate the
|
|
49
|
+
# data to the buffer.
|
|
50
|
+
self.store_writes = False
|
|
51
|
+
|
|
52
|
+
if clear:
|
|
53
|
+
self.clear()
|
|
54
|
+
|
|
55
|
+
def remove_callback(self, callback):
|
|
56
|
+
self.callbacks.remove(callback)
|
|
57
|
+
|
|
58
|
+
def get_value(self, fmt="[{state}:{msg}]"):
|
|
59
|
+
return ''.join([fmt.format(msg=d[0], state=d[1]) for d in self])
|
|
60
|
+
|
|
61
|
+
def write(self, msg, state):
|
|
62
|
+
"""Adds the written text to the manager and passes it to any attached callbacks.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
msg (str): The text to be written.
|
|
66
|
+
state: A identifier for how the text is to be written. For example if this
|
|
67
|
+
write is coming from sys.stderr this will likely be set to
|
|
68
|
+
``preditor.stream.STDERR``.
|
|
69
|
+
"""
|
|
70
|
+
if self.store_writes:
|
|
71
|
+
self.append((msg, state))
|
|
72
|
+
|
|
73
|
+
for callback in self.callbacks:
|
|
74
|
+
callback(msg, state)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class StreamHandlerHelper(object):
|
|
8
|
+
"""A collection of functions for manipulating ``logging.StreamHandler`` objects."""
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def set_stream(cls, handler, stream):
|
|
12
|
+
"""For the given StreamHandler, set its stream. This works around
|
|
13
|
+
python 2's lack of StreamHandler.setStream by replicating python 3.
|
|
14
|
+
"""
|
|
15
|
+
# TODO: once python 2 is no longer supported, replace any uses of this
|
|
16
|
+
# function with `handler.setStream(stream)`
|
|
17
|
+
if sys.version_info[0] > 2:
|
|
18
|
+
handler.setStream(stream)
|
|
19
|
+
else:
|
|
20
|
+
# Copied from python 3's logging's setStream to work in python 2
|
|
21
|
+
handler.acquire()
|
|
22
|
+
try:
|
|
23
|
+
handler.flush()
|
|
24
|
+
handler.stream = stream
|
|
25
|
+
finally:
|
|
26
|
+
handler.release()
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def replace_stream(cls, old, new, logger=None):
|
|
30
|
+
"""Replaces the stream of StreamHandlers by checking all
|
|
31
|
+
`logging.StreamHandler`'s attached to the provided logger. If any of them are
|
|
32
|
+
using old for their stream, update that stream to new.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
old (stream): Only StreamHandlers using this stream will be updated to new.
|
|
36
|
+
new (stream): A file stream object like `sys.stderr` that will replace old.
|
|
37
|
+
logger (logging.Logger, optional): The logger to update streams for. If
|
|
38
|
+
None, the root logger(`logging.getLogger()`) will be used.
|
|
39
|
+
"""
|
|
40
|
+
if logger is None:
|
|
41
|
+
logger = logging.getLogger()
|
|
42
|
+
|
|
43
|
+
for handler in logger.handlers:
|
|
44
|
+
if isinstance(handler, logging.StreamHandler):
|
|
45
|
+
if handler.stream == old:
|
|
46
|
+
cls.set_stream(handler, new)
|
|
File without changes
|
preditor/utils/cute.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
|
|
3
|
+
__all__ = ["ensureWindowIsVisible"]
|
|
4
|
+
from Qt.QtWidgets import QApplication
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def ensureWindowIsVisible(widget):
|
|
8
|
+
"""
|
|
9
|
+
Checks the widget's geometry against all of the system's screens. If it does
|
|
10
|
+
not intersect it will reposition it to the top left corner of the highest
|
|
11
|
+
numbered desktop. Returns a boolean indicating if it had to move the
|
|
12
|
+
widget.
|
|
13
|
+
"""
|
|
14
|
+
desktop = QApplication.desktop()
|
|
15
|
+
geo = widget.geometry()
|
|
16
|
+
for screen in range(desktop.screenCount()):
|
|
17
|
+
monGeo = desktop.screenGeometry(screen)
|
|
18
|
+
if monGeo.intersects(geo):
|
|
19
|
+
break
|
|
20
|
+
else:
|
|
21
|
+
geo.moveTo(monGeo.x() + 7, monGeo.y() + 30)
|
|
22
|
+
# setting the geometry may trigger a second check if setGeometry is overridden
|
|
23
|
+
disable = hasattr(widget, 'checkScreenGeo') and widget.checkScreenGeo
|
|
24
|
+
if disable:
|
|
25
|
+
widget.checkScreenGeo = False
|
|
26
|
+
widget.setGeometry(geo)
|
|
27
|
+
if disable:
|
|
28
|
+
widget.checkScreenGeo = True
|
|
29
|
+
return True
|
|
30
|
+
return False
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from __future__ import absolute_import
|
|
2
|
+
|
|
3
|
+
import glob
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def read_stylesheet(stylesheet='', path=None):
|
|
8
|
+
"""Returns the contents of the requested stylesheet.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
|
|
12
|
+
stylesheet (str): the name of the stylesheet. Attempt to load stylesheet.css
|
|
13
|
+
shipped with preditor. Ignored if path is provided.
|
|
14
|
+
|
|
15
|
+
path (str): Return the contents of this file path.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
str: The contents of stylesheet or blank if stylesheet was not found.
|
|
19
|
+
valid: A stylesheet was found and loaded.
|
|
20
|
+
"""
|
|
21
|
+
if path is None:
|
|
22
|
+
path = os.path.join(
|
|
23
|
+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
|
24
|
+
'resource',
|
|
25
|
+
'stylesheet',
|
|
26
|
+
'{}.css'.format(stylesheet),
|
|
27
|
+
)
|
|
28
|
+
if os.path.isfile(path):
|
|
29
|
+
with open(path) as f:
|
|
30
|
+
return f.read(), True
|
|
31
|
+
return '', False
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def stylesheets(subFolder=None):
|
|
35
|
+
"""Returns a list of installed stylesheet names.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
subFolder (str or None, optional): Use this to access sub-folders of
|
|
39
|
+
the stylesheet resource directory.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
list: A list .css file paths in the target directory.
|
|
43
|
+
"""
|
|
44
|
+
components = [
|
|
45
|
+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
|
46
|
+
'resource',
|
|
47
|
+
'stylesheet',
|
|
48
|
+
]
|
|
49
|
+
if subFolder is not None:
|
|
50
|
+
components.append(subFolder)
|
|
51
|
+
cssdir = os.path.join(*components)
|
|
52
|
+
cssfiles = sorted(glob.glob(os.path.join(cssdir, '*.css')))
|
|
53
|
+
# Only return the filename without the .css extension
|
|
54
|
+
return [os.path.splitext(os.path.basename(fp))[0] for fp in cssfiles]
|
{blurdev → preditor}/version.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
# file generated by setuptools_scm
|
|
3
|
-
# don't change, don't track in version control
|
|
4
|
-
version = '0.
|
|
5
|
-
version_tuple = (0,
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# file generated by setuptools_scm
|
|
3
|
+
# don't change, don't track in version control
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
version_tuple = (0, 1, 0)
|
preditor/weakref.py
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
# /*##########################################################################
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2016-2018 European Synchrotron Radiation Facility
|
|
5
|
+
#
|
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
# furnished to do so, subject to the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
|
14
|
+
# all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
# THE SOFTWARE.
|
|
23
|
+
#
|
|
24
|
+
# ###########################################################################*/
|
|
25
|
+
# Code pulled from the silx codebase
|
|
26
|
+
# https://github.com/silx-kit/silx/blob/master/src/silx/utils/weakref.py
|
|
27
|
+
"""Weakref utils for compatibility between Python 2 and Python 3 or for
|
|
28
|
+
extended features.
|
|
29
|
+
"""
|
|
30
|
+
from __future__ import absolute_import
|
|
31
|
+
|
|
32
|
+
__authors__ = ["V. Valls"]
|
|
33
|
+
__license__ = "MIT"
|
|
34
|
+
__date__ = "15/09/2016"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
import inspect
|
|
38
|
+
import types
|
|
39
|
+
import weakref
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def ref(object, callback=None):
|
|
43
|
+
"""Returns a weak reference to object. The original object can be retrieved
|
|
44
|
+
by calling the reference object if the referent is still alive. If the
|
|
45
|
+
referent is no longer alive, calling the reference object will cause None
|
|
46
|
+
to be returned.
|
|
47
|
+
|
|
48
|
+
The signature is the same as the standard `weakref` library, but it returns
|
|
49
|
+
`WeakMethod` if the object is a bound method.
|
|
50
|
+
|
|
51
|
+
:param object: An object
|
|
52
|
+
:param func callback: If provided, and the returned weakref object is
|
|
53
|
+
still alive, the callback will be called when the object is about to
|
|
54
|
+
be finalized. The weak reference object will be passed as the only
|
|
55
|
+
parameter to the callback. Then the referent will no longer be
|
|
56
|
+
available.
|
|
57
|
+
:return: A weak reference to the object
|
|
58
|
+
"""
|
|
59
|
+
if inspect.ismethod(object):
|
|
60
|
+
return WeakMethod(object, callback)
|
|
61
|
+
else:
|
|
62
|
+
return weakref.ref(object, callback)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def proxy(object, callback=None):
|
|
66
|
+
"""Return a proxy to object which uses a weak reference. This supports use
|
|
67
|
+
of the proxy in most contexts instead of requiring the explicit
|
|
68
|
+
dereferencing used with weak reference objects.
|
|
69
|
+
|
|
70
|
+
The signature is the same as the standard `weakref` library, but it returns
|
|
71
|
+
`WeakMethodProxy` if the object is a bound method.
|
|
72
|
+
|
|
73
|
+
:param object: An object
|
|
74
|
+
:param func callback: If provided, and the returned weakref object is
|
|
75
|
+
still alive, the callback will be called when the object is about to
|
|
76
|
+
be finalized. The weak reference object will be passed as the only
|
|
77
|
+
parameter to the callback. Then the referent will no longer be
|
|
78
|
+
available.
|
|
79
|
+
:return: A proxy to a weak reference of the object
|
|
80
|
+
"""
|
|
81
|
+
if inspect.ismethod(object):
|
|
82
|
+
return WeakMethodProxy(object, callback)
|
|
83
|
+
else:
|
|
84
|
+
return weakref.proxy(object, callback)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class WeakMethod(object):
|
|
88
|
+
"""Wraps a callable object like a function or a bound method.
|
|
89
|
+
Feature callback when the object is about to be finalized.
|
|
90
|
+
Provids the same interface as a normal weak reference.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
def __init__(self, function, callback=None):
|
|
94
|
+
"""
|
|
95
|
+
Constructor
|
|
96
|
+
:param function: Function/method to be called
|
|
97
|
+
:param callback: If callback is provided and not None,
|
|
98
|
+
and the returned weakref object is still alive, the
|
|
99
|
+
callback will be called when the object is about to
|
|
100
|
+
be finalized; the weak reference object will be passed
|
|
101
|
+
as the only parameter to the callback; the referent will
|
|
102
|
+
no longer be available
|
|
103
|
+
"""
|
|
104
|
+
self.__callback = callback
|
|
105
|
+
|
|
106
|
+
if inspect.ismethod(function):
|
|
107
|
+
# it is a bound method
|
|
108
|
+
self.__obj = weakref.ref(function.__self__, self.__call_callback)
|
|
109
|
+
self.__method = weakref.ref(function.__func__, self.__call_callback)
|
|
110
|
+
else:
|
|
111
|
+
self.__obj = None
|
|
112
|
+
self.__method = weakref.ref(function, self.__call_callback)
|
|
113
|
+
|
|
114
|
+
def __call_callback(self, ref):
|
|
115
|
+
"""Called when the object is about to be finalized"""
|
|
116
|
+
if not self.is_alive():
|
|
117
|
+
return
|
|
118
|
+
self.__obj = None
|
|
119
|
+
self.__method = None
|
|
120
|
+
if self.__callback is not None:
|
|
121
|
+
self.__callback(self)
|
|
122
|
+
|
|
123
|
+
def __call__(self):
|
|
124
|
+
"""Return a callable function or None if the WeakMethod is dead."""
|
|
125
|
+
if self.__obj is not None:
|
|
126
|
+
method = self.__method()
|
|
127
|
+
obj = self.__obj()
|
|
128
|
+
if method is None or obj is None:
|
|
129
|
+
return None
|
|
130
|
+
return types.MethodType(method, obj)
|
|
131
|
+
elif self.__method is not None:
|
|
132
|
+
return self.__method()
|
|
133
|
+
else:
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
def is_alive(self):
|
|
137
|
+
"""True if the WeakMethod is still alive"""
|
|
138
|
+
return self.__method is not None
|
|
139
|
+
|
|
140
|
+
def __eq__(self, other):
|
|
141
|
+
"""Check it another obect is equal to this.
|
|
142
|
+
|
|
143
|
+
:param object other: Object to compare with
|
|
144
|
+
"""
|
|
145
|
+
if isinstance(other, WeakMethod):
|
|
146
|
+
if not self.is_alive():
|
|
147
|
+
return False
|
|
148
|
+
return self.__obj == other.__obj and self.__method == other.__method
|
|
149
|
+
return False
|
|
150
|
+
|
|
151
|
+
def __ne__(self, other):
|
|
152
|
+
"""Check it another obect is not equal to this.
|
|
153
|
+
|
|
154
|
+
:param object other: Object to compare with
|
|
155
|
+
"""
|
|
156
|
+
if isinstance(other, WeakMethod):
|
|
157
|
+
if not self.is_alive():
|
|
158
|
+
return False
|
|
159
|
+
return self.__obj != other.__obj or self.__method != other.__method
|
|
160
|
+
return True
|
|
161
|
+
|
|
162
|
+
def __hash__(self):
|
|
163
|
+
"""Returns the hash for the object."""
|
|
164
|
+
return self.__obj.__hash__() ^ self.__method.__hash__()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class WeakMethodProxy(WeakMethod):
|
|
168
|
+
"""Wraps a callable object like a function or a bound method
|
|
169
|
+
with a weakref proxy.
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
def __call__(self, *args, **kwargs):
|
|
173
|
+
"""Dereference the method and call it if the method is still alive.
|
|
174
|
+
Else raises an ReferenceError.
|
|
175
|
+
|
|
176
|
+
:raises: ReferenceError, if the method is not alive
|
|
177
|
+
"""
|
|
178
|
+
fn = super(WeakMethodProxy, self).__call__()
|
|
179
|
+
if fn is None:
|
|
180
|
+
raise ReferenceError("weakly-referenced object no longer exists")
|
|
181
|
+
return fn(*args, **kwargs)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class WeakList(list):
|
|
185
|
+
"""Manage a list of weaked references.
|
|
186
|
+
When an object is dead, the list is flaged as invalid.
|
|
187
|
+
If expected the list is cleaned up to remove dead objects.
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
def __init__(self, enumerator=()):
|
|
191
|
+
"""Create a WeakList
|
|
192
|
+
|
|
193
|
+
:param iterator enumerator: A list of object to initialize the
|
|
194
|
+
list
|
|
195
|
+
"""
|
|
196
|
+
list.__init__(self)
|
|
197
|
+
self.__list = []
|
|
198
|
+
self.__is_valid = True
|
|
199
|
+
for obj in enumerator:
|
|
200
|
+
self.append(obj)
|
|
201
|
+
|
|
202
|
+
def __invalidate(self, ref):
|
|
203
|
+
"""Flag the list as invalidated. The list contains dead references."""
|
|
204
|
+
self.__is_valid = False
|
|
205
|
+
|
|
206
|
+
def __create_ref(self, obj):
|
|
207
|
+
"""Create a weakref from an object. It uses the `ref` module function."""
|
|
208
|
+
return ref(obj, self.__invalidate)
|
|
209
|
+
|
|
210
|
+
def __clean(self):
|
|
211
|
+
"""Clean the list from dead references"""
|
|
212
|
+
if self.__is_valid:
|
|
213
|
+
return
|
|
214
|
+
self.__list = [ref for ref in self.__list if ref() is not None]
|
|
215
|
+
self.__is_valid = True
|
|
216
|
+
|
|
217
|
+
def __iter__(self):
|
|
218
|
+
"""Iterate over objects of the list"""
|
|
219
|
+
for ref in self.__list:
|
|
220
|
+
obj = ref()
|
|
221
|
+
if obj is not None:
|
|
222
|
+
yield obj
|
|
223
|
+
|
|
224
|
+
def __len__(self):
|
|
225
|
+
"""Count item on the list"""
|
|
226
|
+
self.__clean()
|
|
227
|
+
return len(self.__list)
|
|
228
|
+
|
|
229
|
+
def __getitem__(self, key):
|
|
230
|
+
"""Returns the object at the requested index
|
|
231
|
+
|
|
232
|
+
:param key: Indexes to get
|
|
233
|
+
:type key: int or slice
|
|
234
|
+
"""
|
|
235
|
+
self.__clean()
|
|
236
|
+
data = self.__list[key]
|
|
237
|
+
if isinstance(data, list):
|
|
238
|
+
result = [ref() for ref in data]
|
|
239
|
+
else:
|
|
240
|
+
result = data()
|
|
241
|
+
return result
|
|
242
|
+
|
|
243
|
+
def __setitem__(self, key, obj):
|
|
244
|
+
"""Set an item at an index
|
|
245
|
+
|
|
246
|
+
:param key: Indexes to set
|
|
247
|
+
:type key: int or slice
|
|
248
|
+
"""
|
|
249
|
+
self.__clean()
|
|
250
|
+
if isinstance(key, slice):
|
|
251
|
+
objs = [self.__create_ref(o) for o in obj]
|
|
252
|
+
self.__list[key] = objs
|
|
253
|
+
else:
|
|
254
|
+
obj_ref = self.__create_ref(obj)
|
|
255
|
+
self.__list[key] = obj_ref
|
|
256
|
+
|
|
257
|
+
def __delitem__(self, key):
|
|
258
|
+
"""Delete an Indexes item of this list
|
|
259
|
+
|
|
260
|
+
:param key: Index to delete
|
|
261
|
+
:type key: int or slice
|
|
262
|
+
"""
|
|
263
|
+
self.__clean()
|
|
264
|
+
del self.__list[key]
|
|
265
|
+
|
|
266
|
+
def __delslice__(self, i, j):
|
|
267
|
+
"""Looks to be used in Python 2.7"""
|
|
268
|
+
self.__delitem__(slice(i, j, None))
|
|
269
|
+
|
|
270
|
+
def __setslice__(self, i, j, sequence):
|
|
271
|
+
"""Looks to be used in Python 2.7"""
|
|
272
|
+
self.__setitem__(slice(i, j, None), sequence)
|
|
273
|
+
|
|
274
|
+
def __getslice__(self, i, j):
|
|
275
|
+
"""Looks to be used in Python 2.7"""
|
|
276
|
+
return self.__getitem__(slice(i, j, None))
|
|
277
|
+
|
|
278
|
+
def __reversed__(self):
|
|
279
|
+
"""Returns a copy of the reverted list"""
|
|
280
|
+
reversed_list = reversed(list(self))
|
|
281
|
+
return WeakList(reversed_list)
|
|
282
|
+
|
|
283
|
+
def __contains__(self, obj):
|
|
284
|
+
"""Returns true if the object is in the list"""
|
|
285
|
+
ref = self.__create_ref(obj)
|
|
286
|
+
return ref in self.__list
|
|
287
|
+
|
|
288
|
+
def __add__(self, other):
|
|
289
|
+
"""Returns a WeakList containing this list an the other"""
|
|
290
|
+
l = WeakList(self) # noqa: E741
|
|
291
|
+
l.extend(other)
|
|
292
|
+
return l
|
|
293
|
+
|
|
294
|
+
def __iadd__(self, other):
|
|
295
|
+
"""Add objects to this list inplace"""
|
|
296
|
+
self.extend(other)
|
|
297
|
+
return self
|
|
298
|
+
|
|
299
|
+
def __mul__(self, n):
|
|
300
|
+
"""Returns a WeakList containing n-duplication object of this list"""
|
|
301
|
+
return WeakList(list(self) * n)
|
|
302
|
+
|
|
303
|
+
def __imul__(self, n):
|
|
304
|
+
"""N-duplication of the objects to this list inplace"""
|
|
305
|
+
self.__list *= n
|
|
306
|
+
return self
|
|
307
|
+
|
|
308
|
+
def append(self, obj):
|
|
309
|
+
"""Add an object at the end of the list"""
|
|
310
|
+
ref = self.__create_ref(obj)
|
|
311
|
+
self.__list.append(ref)
|
|
312
|
+
|
|
313
|
+
def count(self, obj):
|
|
314
|
+
"""Returns the number of occurencies of an object"""
|
|
315
|
+
ref = self.__create_ref(obj)
|
|
316
|
+
return self.__list.count(ref)
|
|
317
|
+
|
|
318
|
+
def extend(self, other):
|
|
319
|
+
"""Append the list with all objects from another list"""
|
|
320
|
+
for obj in other:
|
|
321
|
+
self.append(obj)
|
|
322
|
+
|
|
323
|
+
def index(self, obj):
|
|
324
|
+
"""Returns the index of an object"""
|
|
325
|
+
ref = self.__create_ref(obj)
|
|
326
|
+
return self.__list.index(ref)
|
|
327
|
+
|
|
328
|
+
def insert(self, index, obj):
|
|
329
|
+
"""Insert an object at the requested index"""
|
|
330
|
+
ref = self.__create_ref(obj)
|
|
331
|
+
self.__list.insert(index, ref)
|
|
332
|
+
|
|
333
|
+
def pop(self, index=-1):
|
|
334
|
+
"""Remove and return an object at the requested index"""
|
|
335
|
+
self.__clean()
|
|
336
|
+
obj = self.__list.pop(index)()
|
|
337
|
+
return obj
|
|
338
|
+
|
|
339
|
+
def remove(self, obj):
|
|
340
|
+
"""Remove an object from the list"""
|
|
341
|
+
ref = self.__create_ref(obj)
|
|
342
|
+
self.__list.remove(ref)
|
|
343
|
+
|
|
344
|
+
def reverse(self):
|
|
345
|
+
"""Reverse the list inplace"""
|
|
346
|
+
self.__list.reverse()
|
|
347
|
+
|
|
348
|
+
def sort(self, key=None, reverse=False):
|
|
349
|
+
"""Sort the list inplace.
|
|
350
|
+
Not very efficient.
|
|
351
|
+
"""
|
|
352
|
+
sorted_list = list(self)
|
|
353
|
+
sorted_list.sort(key=key, reverse=reverse)
|
|
354
|
+
self.__list = []
|
|
355
|
+
self.extend(sorted_list)
|
|
356
|
+
|
|
357
|
+
def __str__(self):
|
|
358
|
+
unref_list = list(self)
|
|
359
|
+
return "WeakList(%s)" % str(unref_list)
|
|
360
|
+
|
|
361
|
+
def __repr__(self):
|
|
362
|
+
unref_list = list(self)
|
|
363
|
+
return "WeakList(%s)" % repr(unref_list)
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: PrEditor
|
|
3
|
-
Version: 0.0.0.dev1
|
|
4
|
-
Summary: PrEditor
|
|
5
|
-
Home-page: https://gitlab.blur.com/pipeline/blurdev.git
|
|
6
|
-
Author: Blur Studio
|
|
7
|
-
Author-email: opensource@blur.com
|
|
8
|
-
License: GNU LGPLv3
|
|
9
|
-
Platform: any
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Programming Language :: Python
|
|
13
|
-
Classifier: Programming Language :: Python :: 2
|
|
14
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
19
|
-
Classifier: Operating System :: OS Independent
|
|
20
|
-
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
21
|
-
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
Requires-Dist: blur-cute (>=0.25.0)
|
|
24
|
-
Requires-Dist: blur-pillar (>=0.40.0)
|
|
25
|
-
Requires-Dist: blur-sentry-bootstrap (>=1.1.0)
|
|
26
|
-
Requires-Dist: certifi (>=2019.9.11)
|
|
27
|
-
Requires-Dist: click (>=7.1.2)
|
|
28
|
-
Requires-Dist: configparser (>=4.0.2)
|
|
29
|
-
Requires-Dist: Deprecated (>=1.2.7)
|
|
30
|
-
Requires-Dist: future (>=0.18.2)
|
|
31
|
-
Requires-Dist: Jinja2 (>=2.10.3)
|
|
32
|
-
Requires-Dist: MarkupSafe (>=1.1.1)
|
|
33
|
-
Requires-Dist: Pygments (>=2.4.2)
|
|
34
|
-
Requires-Dist: python-redmine (>=2.1.1)
|
|
35
|
-
Requires-Dist: signalslot (>=0.1.2)
|
|
36
|
-
Requires-Dist: tabulate (>=0.8.7)
|
|
37
|
-
Requires-Dist: urllib3 (>=1.25.7)
|
|
38
|
-
Requires-Dist: winshell (>=0.6) ; platform_system == "Windows"
|
|
39
|
-
Requires-Dist: QScintilla (>=2.11.4) ; python_version >= "3.5" and platform_system == "Windows"
|
|
40
|
-
Provides-Extra: dev
|
|
41
|
-
Requires-Dist: black ; extra == 'dev'
|
|
42
|
-
Requires-Dist: covdefaults ; extra == 'dev'
|
|
43
|
-
Requires-Dist: coverage ; extra == 'dev'
|
|
44
|
-
Requires-Dist: flake8 ; extra == 'dev'
|
|
45
|
-
Requires-Dist: flake8-bugbear ; extra == 'dev'
|
|
46
|
-
Requires-Dist: pep8-naming ; extra == 'dev'
|
|
47
|
-
Requires-Dist: pytest ; extra == 'dev'
|
|
48
|
-
Requires-Dist: tox ; extra == 'dev'
|
|
49
|
-
|
|
50
|
-
UNKNOWN
|
|
51
|
-
|