Skip to content

Commit

Permalink
Release 1.13.2; fixing a bug preventing multiple macros from properly…
Browse files Browse the repository at this point in the history
… running on a single file.
  • Loading branch information
coddingtonbear committed Jul 18, 2015
1 parent 8ae1d0f commit 074f838
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.13.2
------

* Fixing a bug that prevented multiple macros from successfully being
applied to a file.

1.13.1
------

Expand Down
2 changes: 1 addition & 1 deletion jirafs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.13.1'
__version__ = '1.13.2'
40 changes: 16 additions & 24 deletions jirafs/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,33 +252,25 @@ def get_attributes(self, tag):
return attributes

def process_text_data(self, content):
for match_data in self.get_matches(content):
def run_replacement(match_data):
data = match_data.groupdict()
try:
replace_with = self.execute_macro(
data.get('content'),
**self.get_attributes(data.get('start', ''))
)
except Exception as e:
self.ticketfolder.log(
"Error encountered while running macro %s: %s",
args=(
self.plugin_name,
e
),
level=logging.ERROR,
)
replace_with = content
if replace_with is None:
replace_with = ''

content = (
content[0:match_data.start(0)] +
replace_with +
content[match_data.end(0):]

return self.execute_macro(
data.get('content'),
**self.get_attributes(data.get('start', ''))
)

return content
try:
return self.get_matcher().sub(run_replacement, content)
except Exception as e:
self.ticketfolder.log(
"Error encountered while running macro %s: %s",
args=(
self.plugin_name,
e
),
level=logging.ERROR,
)

def execute_macro(self, data, **attributes):
raise NotImplementedError()
Expand Down

0 comments on commit 074f838

Please sign in to comment.