コード例 #1
0
 def get_selected_text(self):
     """
     Return text selected by current text cursor, converted in unicode
     
     Replace the unicode line separator character \u2029 by 
     the line separator characters returned by get_line_separator
     """
     return to_text_string(self.textCursor().selectedText()).replace(
         u("\u2029"), self.get_line_separator())
コード例 #2
0
 def on_enter(self, command):
     """on_enter"""
     if self.profile:
         # Simple profiling test
         t0 = time()
         for _ in range(10):
             self.execute_command(command)
         self.insert_text(u("\n<Δt>=%dms\n") % (1e2 * (time() - t0)))
         self.new_prompt(self.interpreter.p1)
     else:
         self.execute_command(command)
     self.__flush_eventqueue()
コード例 #3
0
 def get_text(self, position_from, position_to):
     """
     Return text between *position_from* and *position_to*
     Positions may be positions or 'sol', 'eol', 'sof', 'eof' or 'cursor'
     """
     cursor = self.__select_text(position_from, position_to)
     text = to_text_string(cursor.selectedText())
     all_text = position_from == 'sof' and position_to == 'eof'
     if text and not all_text:
         while text.endswith("\n"):
             text = text[:-1]
         while text.endswith(u("\u2029")):
             text = text[:-1]
     return text
コード例 #4
0
 def get_line_at(self, coordinates):
     """Return line at *coordinates* (QPoint)"""
     cursor = self.cursorForPosition(coordinates)
     cursor.select(QTextCursor.BlockUnderCursor)
     return to_text_string(cursor.selectedText()).replace(u('\u2029'), '')
コード例 #5
0
templates_path = ['templates']

# MathJax load path (doesn't have effect for sphinx 1.0-)
mathjax_path = 'MathJax/MathJax.js'

# JsMath load path (doesn't have effect for sphinx 1.1+)
jsmath_path = 'easy/load.js'

# The suffix of source filenames.
source_suffix = '.rst'

# The master toctree document.
master_doc = 'docstring'

# General information about the project.
project = u("TRex Help plugin")
copyright = u('The TRex Project Contributors')

# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['.build']

# The reST default role (used for this markup: `text`) to use for all documents.
#
# TODO: This role has to be set on a per project basis, i.e. numpy, sympy,
# mpmath, etc, use different default_role's which give different rendered
# docstrings. Setting this to None until it's solved.
default_role = 'None'

# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
コード例 #6
0
iofunctions.setup()


def save_auto(data, filename):
    """Save data into filename, depending on file extension"""
    pass


if __name__ == "__main__":
    from trex.py3compat import u
    import datetime
    testdict = {'d': 1, 'a': np.random.rand(10, 10), 'b': [1, 2]}
    testdate = datetime.date(1945, 5, 8)
    example = {
        'str': 'kjkj kj k j j kj k jkj',
        'unicode': u('éù'),
        'list': [1, 3, [4, 5, 6], 'kjkj', None],
        'tuple': ([1, testdate, testdict], 'kjkj', None),
        'dict': testdict,
        'float': 1.2233,
        'array': np.random.rand(4000, 400),
        'empty_array': np.array([]),
        'date': testdate,
        'datetime': datetime.datetime(1945, 5, 8),
    }
    import time
    t0 = time.time()
    save_dictionary(example, "test.spydata")
    print(" Data saved in %.3f seconds" %
          (time.time() - t0))  # trex: test-skip
    t0 = time.time()