Merge lp:~fgallaire/aafigure/textual-strict into lp:aafigure

Proposed by Florent Gallaire on 2011-07-11
Status: Merged
Merged at revision: 120
Proposed branch: lp:~fgallaire/aafigure/textual-strict
Merge into: lp:aafigure
Diff against target: 91 lines (+26/-17)
1 file modified
aafigure/aafigure.py (+26/-17)
To merge this branch: bzr merge lp:~fgallaire/aafigure/textual-strict
Reviewer Review Type Date Requested Status
aafigure-team 2011-07-11 Pending
Review via email: mp+67492@code.launchpad.net

Description of the change

Hello, this commit adds a --textual-strict option wich disables horizontal AND vertical fill detection. As it's a very common need, it would be great if you could merge.

To post a comment you must log in.
zsquareplusc (zsquareplusc) wrote :

Merged, but it also required updates to the documentation and docutils plugin.

Florent Gallaire (fgallaire) wrote :

Thanks !

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'aafigure/aafigure.py'
2--- aafigure/aafigure.py 2010-03-24 18:26:48 +0000
3+++ aafigure/aafigure.py 2011-07-11 05:42:31 +0000
4@@ -27,17 +27,18 @@
5 CLASS_FIXED = 'fixed'
6
7 DEFAULT_OPTIONS = dict(
8- background = '#ffffff',
9- foreground = '#000000',
10- line_width = 2.0,
11- scale = 1.0,
12- aspect = 1.0,
13- format = 'svg',
14- debug = False,
15- textual = False,
16- proportional = False,
17- encoding = 'utf-8',
18- widechars = 'F,W',
19+ background = '#ffffff',
20+ foreground = '#000000',
21+ line_width = 2.0,
22+ scale = 1.0,
23+ aspect = 1.0,
24+ format = 'svg',
25+ debug = False,
26+ textual = False,
27+ textual_strict = False,
28+ proportional = False,
29+ encoding = 'utf-8',
30+ widechars = 'F,W',
31 )
32
33 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34@@ -59,10 +60,11 @@
35
36 QUOTATION_CHARACTERS = list('"\'`')
37
38- def __init__(self, text, aspect_ratio=1, textual=False, widechars='F,W'):
39+ def __init__(self, text, aspect_ratio=1, textual=False, textual_strict=False, widechars='F,W'):
40 """Take a ASCII art figure and store it, prepare for ``recognize``"""
41 self.aspect_ratio = float(aspect_ratio)
42 self.textual = textual
43+ self.textual_strict = textual_strict
44 # XXX TODO tab expansion
45 # detect size of input image, store as list of lines
46 self.image = []
47@@ -186,7 +188,7 @@
48 elif character in self.FIXED_CHARACTERS:
49 self.shapes.extend(self.get_fixed_character(character)(x, y))
50 self.tag([(x, y)], CLASS_FIXED)
51- elif character in self.FILL_CHARACTERS:
52+ elif not self.textual_strict and character in self.FILL_CHARACTERS:
53 if self.textual:
54 if self.get(x, y+1) == character:
55 self.shapes.extend(self._follow_fill(character, x, y))
56@@ -958,7 +960,7 @@
57 if options['debug']:
58 sys.stderr.write('%r\n' % (input,))
59
60- aaimg = AsciiArtImage(input, options['aspect'], options['textual'], options['widechars'])
61+ aaimg = AsciiArtImage(input, options['aspect'], options['textual'], options['textual_strict'], options['widechars'])
62
63 if options['debug']:
64 sys.stderr.write('%s\n' % (aaimg,))
65@@ -1104,6 +1106,13 @@
66 default = DEFAULT_OPTIONS['textual'],
67 )
68
69+ parser.add_option("-S", "--textual-strict",
70+ dest = "textual_strict",
71+ action = "store_true",
72+ help = "disable horizontal and vertical fill detection",
73+ default = DEFAULT_OPTIONS['textual_strict'],
74+ )
75+
76 parser.add_option("-s", "--scale",
77 dest = "scale",
78 action = "store",
79@@ -1186,9 +1195,9 @@
80
81 # explicit copying of parameters to the options dictionary
82 options_dict = {}
83- for key in ('widechars', 'textual', 'proportional',
84- 'line_width', 'aspect', 'scale',
85- 'format', 'debug'):
86+ for key in ('widechars', 'textual', 'textual_strict',
87+ 'proportional', 'line_width', 'aspect',
88+ 'scale', 'format', 'debug'):
89 options_dict[key] = getattr(options, key)
90 # ensure all color parameters start with a '#'
91 # this is for the convenience of the user as typing the shell comment

Subscribers

People subscribed via source and target branches