~ubuntu-branches/ubuntu/vivid/kate/vivid-updates

« back to all changes in this revision

Viewing changes to addons/kate/pate/src/plugins/expand/all.expand

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Expand-functions in this modude mostly for demonstration
3
 
# than for daily use...
4
 
#
5
 
 
6
 
try:
7
 
  import builtins as interpreter
8
 
except ImportError:
9
 
  import __builtin__ as interpreter
10
 
 
11
 
try:
12
 
    from io import StringIO
13
 
except:
14
 
    from cStringIO import StringIO
15
 
 
16
 
import sys
17
 
 
18
 
def eval(s):
19
 
    # get automatic conversion to unicode or (that failing)
20
 
    # a string representation
21
 
    return interpreter.eval(s)
22
 
 
23
 
def python(s):
24
 
    # execute a block. sys.stdout is written to the document
25
 
    old = sys.stdout
26
 
    io = StringIO()
27
 
    sys.stdout = io
28
 
    try:
29
 
        exec(s)
30
 
    finally:
31
 
        sys.stdout = old
32
 
    return io.getvalue().strip() # should we always strip?
33
 
 
34
 
def test(s):
35
 
    raise ValueError(s)
36
 
 
37
 
# kate: hl python; indent-width 4;