Skip to content

Commit

Permalink
Merge pull request #1970 from jmcouffin/clean-code
Browse files Browse the repository at this point in the history
fix clean code docs and regex escape characters errors
  • Loading branch information
jmcouffin authored Oct 22, 2023
2 parents 6f71503 + 18b7f34 commit 0f77399
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions pyrevitlib/pyrevit/coreutils/markdown/extensions/smarty.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@
# Constants for quote education.
punctClass = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]"""
endOfWordClass = r"[\s.,;:!?)]"
closeClass = "[^\ \t\r\n\[\{\(\-\u0002\u0003]"
closeClass = r"[^\ \t\r\n\[\{\(\-\u0002\u0003]"

openingQuotesBase = (
'(\s' # a whitespace char
'|&nbsp;' # or a non-breaking space entity
'|--' # or dashes
'|–|—' # or unicode
'|&[mn]dash;' # or named dash entities
'|&#8211;|&#8212;' # or decimal entities
')'
r'(\s' # a whitespace char
r'|&nbsp;' # or a non-breaking space entity
r'|--' # or dashes
r'|–|—' # or unicode
r'|&[mn]dash;' # or named dash entities
r'|&#8211;|&#8212;' # or decimal entities
r')'
)

substitutions = {
Expand Down
4 changes: 2 additions & 2 deletions pyrevitlib/pyrevit/coreutils/markdown/extensions/toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
def slugify(value, separator):
"""Slugify a string, to make it URL friendly."""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
value = re.sub('[^\w\s-]', '', value.decode('ascii')).strip().lower()
return re.sub('[%s\s]+' % separator, separator, value)
value = re.sub(r'[^\w\s-]', '', value.decode('ascii')).strip().lower()
return re.sub(r'[%s\s]+' % separator, separator, value)


IDCOUNT_RE = re.compile(r'^(.*)_([0-9]+)$')
Expand Down
2 changes: 1 addition & 1 deletion pyrevitlib/pyrevit/coreutils/markdown/postprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def run(self, text):
class UnescapePostprocessor(Postprocessor):
"""Restore escaped chars."""

RE = re.compile('%s(\d+)%s' % (util.STX, util.ETX))
RE = re.compile(r'%s(\d+)%s' % (util.STX, util.ETX))

def unescape(self, m):
return util.int2str(int(m.group(1)))
Expand Down
2 changes: 1 addition & 1 deletion pyrevitlib/pyrevit/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ def _prepare_context_items(self, ctx_items):

@staticmethod
def _natural_sort_key(key):
return [int(c) if c.isdigit() else c.lower() for c in re.split('(\d+)', key)]
return [int(c) if c.isdigit() else c.lower() for c in re.split(r'(\d+)', key)]

def _prepare_context(self):
if isinstance(self._context, dict) and self._context.keys():
Expand Down

0 comments on commit 0f77399

Please sign in to comment.