Skip to content

Commit

Permalink
- some cleaning (deleted commented stuff, etc.)
Browse files Browse the repository at this point in the history
- setup.py
	- up to version 1.5
  • Loading branch information
manuvazquez committed May 30, 2020
1 parent f6a74e6 commit d78e6a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
49 changes: 21 additions & 28 deletions gift_wrapper/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,32 @@
from . import remote
from . import colors

# # a string ended in ".svg" that does *not* begin with "http"
# pattern_svg_file = '(?<!\S)(?!http)(\S+\.svg)(?!\S)'
# # pattern_svg_file = '(?:^|\s)(?!http)\S+\.svg(?!\S)'
# # pattern_svg_file = '(?:^| )(?!http)\S+\.svg(?!\S)'
# # pattern_svg_file = '(?:^| )(?!http)\S+\.svg(?!\.\S{3})'
# # pattern_svg_file = '(?:^| |>)(?!http)(\S+\.svg)(?!\.\S{3})'
# # pattern_svg_file = '(?:^| |>)(?!http)([a-zA-Z0-9_/]+\.svg)(?!\.\S{3})'
# # pattern_svg_file = r'(?<!\S)(?!http)(\S+\.svg)(?:<br>)?(?!\S)'

# regular expression to extract a percentage
re_percentage = re.compile('(\d*\.\d+|\d+)\s*%')
re_percentage = re.compile(r'(\d*\.\d+|\d+)\s*%')


# a string template to be used in markdown generation
markdown_header_template = string.Template('<span style="font-family:Papyrus; font-size:2em;">$text</span>')
def markdown_header(
text: str,
template: string.Template = string.Template('<span style="font-family:Papyrus; font-size:2em;">$text</span>')
) -> str:
"""
Returns a markdown header for a given text.
Parameters
----------
text : str
Text for the header.
template : string template
The template that defines the appearance of the header, and in which `text` will be embedded.
def markdown_header(text: str) -> str:
Returns
-------
str:
Markdown-compatible text.
"""

return f'\n{markdown_header_template.substitute(text=text)}\n\n'
return f'\n{template.substitute(text=text)}\n\n'


class HtmlQuestion(metaclass=abc.ABCMeta):
Expand Down Expand Up @@ -269,7 +276,6 @@ def answer(self):
if 'perfect' in self.answers:

# ...it is added in a special way
# processed_answers.append('=' + self.process_text(self.answers['perfect']))
processed_answers.insert(0, '=' + self.process_text(self.answers['perfect']))

else:
Expand Down Expand Up @@ -408,7 +414,6 @@ def process_match(f):
# NOTE: an extra space is added in the replacement for `SvgToInline` --- not anymore
self.pre_processing_functions.append(functools.partial(
self.transform_files, pattern='(\S+)\.tex', process_match=process_match, replacement=r'\1.svg'))
# self.transform_files, pattern='(\S+)\.tex', process_match=process_match, replacement=r' \1.svg'))


class SvgToHttp(QuestionDecorator):
Expand Down Expand Up @@ -448,14 +453,9 @@ def process_match(f):
# ...and a note is made of it
self.history['already transferred'].add(f)

# else:
#
# print(f'{f} already transferred...')

# a new pre-processing function is attached to the corresponding list
self.pre_processing_functions.append(functools.partial(
self.transform_files, pattern=self.pattern_svg_file,
# self.transform_files, pattern='(?<!\S)(?!http)(\S+\.svg)\??(?!\S)',
process_match=process_match, replacement=replacement_function))


Expand Down Expand Up @@ -483,8 +483,6 @@ class SvgToInline(QuestionDecorator):
Decorator to reformat svg files for including them in markdown strings.
"""

# pattern_svg_file = r'<br>\s*(?!<br>)(\S+\.svg)\s*<br>'

# notice the order is important: each pattern will result in a different post-processing function and they are
# applied *sequentially*, each one on the result of the previous one
patterns = [r'<br>\s*(?!<br>)(\S+\.svg)\s*<br>', r'(\S+\.svg)']
Expand All @@ -509,8 +507,3 @@ def replacement_function(m) -> str:
# a new pre-processing function is attached to the corresponding list
self.post_processing_functions.append(functools.partial(
self.transform_files, pattern=p, process_match=process_match, replacement=replacement_function))

# # a new pre-processing function is attached to the corresponding list
# self.post_processing_functions.append(functools.partial(
# self.transform_files, pattern=self.pattern_svg_file,
# process_match=process_match, replacement=replacement_function))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="gift-wrapper", # Replace with your own username
version="1.3.5",
version="1.5",
author="Manuel A. Vázquez",
author_email="[email protected]",
description="Build GIFT (Moodle compatible) files easily",
Expand Down

0 comments on commit d78e6a8

Please sign in to comment.