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

Proposed by Florent Gallaire
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 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.
Revision history for this message
zsquareplusc (zsquareplusc) wrote :

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

Revision history for this message
Florent Gallaire (fgallaire) wrote :

Thanks !

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'aafigure/aafigure.py'
--- aafigure/aafigure.py 2010-03-24 18:26:48 +0000
+++ aafigure/aafigure.py 2011-07-11 05:42:31 +0000
@@ -27,17 +27,18 @@
27CLASS_FIXED = 'fixed'27CLASS_FIXED = 'fixed'
2828
29DEFAULT_OPTIONS = dict(29DEFAULT_OPTIONS = dict(
30 background = '#ffffff',30 background = '#ffffff',
31 foreground = '#000000',31 foreground = '#000000',
32 line_width = 2.0,32 line_width = 2.0,
33 scale = 1.0,33 scale = 1.0,
34 aspect = 1.0,34 aspect = 1.0,
35 format = 'svg',35 format = 'svg',
36 debug = False,36 debug = False,
37 textual = False,37 textual = False,
38 proportional = False,38 textual_strict = False,
39 encoding = 'utf-8',39 proportional = False,
40 widechars = 'F,W',40 encoding = 'utf-8',
41 widechars = 'F,W',
41)42)
4243
43# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -44# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -59,10 +60,11 @@
5960
60 QUOTATION_CHARACTERS = list('"\'`')61 QUOTATION_CHARACTERS = list('"\'`')
6162
62 def __init__(self, text, aspect_ratio=1, textual=False, widechars='F,W'):63 def __init__(self, text, aspect_ratio=1, textual=False, textual_strict=False, widechars='F,W'):
63 """Take a ASCII art figure and store it, prepare for ``recognize``"""64 """Take a ASCII art figure and store it, prepare for ``recognize``"""
64 self.aspect_ratio = float(aspect_ratio)65 self.aspect_ratio = float(aspect_ratio)
65 self.textual = textual66 self.textual = textual
67 self.textual_strict = textual_strict
66 # XXX TODO tab expansion68 # XXX TODO tab expansion
67 # detect size of input image, store as list of lines69 # detect size of input image, store as list of lines
68 self.image = []70 self.image = []
@@ -186,7 +188,7 @@
186 elif character in self.FIXED_CHARACTERS:188 elif character in self.FIXED_CHARACTERS:
187 self.shapes.extend(self.get_fixed_character(character)(x, y))189 self.shapes.extend(self.get_fixed_character(character)(x, y))
188 self.tag([(x, y)], CLASS_FIXED)190 self.tag([(x, y)], CLASS_FIXED)
189 elif character in self.FILL_CHARACTERS:191 elif not self.textual_strict and character in self.FILL_CHARACTERS:
190 if self.textual:192 if self.textual:
191 if self.get(x, y+1) == character:193 if self.get(x, y+1) == character:
192 self.shapes.extend(self._follow_fill(character, x, y))194 self.shapes.extend(self._follow_fill(character, x, y))
@@ -958,7 +960,7 @@
958 if options['debug']:960 if options['debug']:
959 sys.stderr.write('%r\n' % (input,))961 sys.stderr.write('%r\n' % (input,))
960962
961 aaimg = AsciiArtImage(input, options['aspect'], options['textual'], options['widechars'])963 aaimg = AsciiArtImage(input, options['aspect'], options['textual'], options['textual_strict'], options['widechars'])
962964
963 if options['debug']:965 if options['debug']:
964 sys.stderr.write('%s\n' % (aaimg,))966 sys.stderr.write('%s\n' % (aaimg,))
@@ -1104,6 +1106,13 @@
1104 default = DEFAULT_OPTIONS['textual'],1106 default = DEFAULT_OPTIONS['textual'],
1105 )1107 )
11061108
1109 parser.add_option("-S", "--textual-strict",
1110 dest = "textual_strict",
1111 action = "store_true",
1112 help = "disable horizontal and vertical fill detection",
1113 default = DEFAULT_OPTIONS['textual_strict'],
1114 )
1115
1107 parser.add_option("-s", "--scale",1116 parser.add_option("-s", "--scale",
1108 dest = "scale",1117 dest = "scale",
1109 action = "store",1118 action = "store",
@@ -1186,9 +1195,9 @@
11861195
1187 # explicit copying of parameters to the options dictionary1196 # explicit copying of parameters to the options dictionary
1188 options_dict = {}1197 options_dict = {}
1189 for key in ('widechars', 'textual', 'proportional',1198 for key in ('widechars', 'textual', 'textual_strict',
1190 'line_width', 'aspect', 'scale',1199 'proportional', 'line_width', 'aspect',
1191 'format', 'debug'):1200 'scale', 'format', 'debug'):
1192 options_dict[key] = getattr(options, key)1201 options_dict[key] = getattr(options, key)
1193 # ensure all color parameters start with a '#'1202 # ensure all color parameters start with a '#'
1194 # this is for the convenience of the user as typing the shell comment1203 # this is for the convenience of the user as typing the shell comment

Subscribers

People subscribed via source and target branches