text
stringlengths
0
828
:param location:
:return: a dictionary{ext : file_path}
""""""
parent_dir = dirname(location)
if parent_dir is '':
parent_dir = '.'
base_prefix = basename(location)
# trick : is sep_for_flat is a dot, we have to take into account that there is also a dot for the extension
min_sep_count = (1 if self.separator == EXT_SEPARATOR else 0)
possible_object_files = {object_file[len(base_prefix):]: join(parent_dir, object_file)
for object_file in listdir(parent_dir) if isfile(parent_dir + '/' + object_file)
and object_file.startswith(base_prefix)
# file must be named base_prefix.something
and object_file != base_prefix
and object_file[len(base_prefix)] == EXT_SEPARATOR
and (object_file[len(base_prefix):]).count(EXT_SEPARATOR) == 1
# and no other item separator should be present in the something
and (object_file[len(base_prefix):]).count(self.separator) == min_sep_count}
return possible_object_files"
1352,"def special_links_replace(text, urls):
'''
Replace simplified Regulations and Guidelines links into actual links.
'urls' dictionary is expected to provide actual links to the targeted
Regulations and Guidelines, as well as to the PDF file.
'''
match_number = r'([A-Za-z0-9]+)' + r'(\+*)'
reference_list = [(r'regulations:article:' + match_number, urls['regulations']),
(r'regulations:regulation:' + match_number, urls['regulations']),
(r'guidelines:article:' + match_number, urls['guidelines']),
(r'guidelines:guideline:' + match_number, urls['guidelines']),
]
anchor_list = [(r'regulations:contents', urls['regulations'] + r'#contents'),
(r'guidelines:contents', urls['guidelines'] + r'#contents'),
(r'regulations:top', urls['regulations'] + r'#'),
(r'guidelines:top', urls['guidelines'] + r'#'),
(r'link:pdf', urls['pdf'] + '.pdf'),
]
retval = text
for match, repl in reference_list:
retval = re.sub(match, repl + r'#\1\2', retval)
for match, repl in anchor_list:
retval = re.sub(match, repl, retval)
return retval"
1353,"def list2html(text):
'''
Very simple replacement for lists, no nesting, not even two lists in the
same 'text'... (yet sufficient for the current regulations)
Assumes list is in a paragraph.
'''
match = r'- (.+)\n'
replace = r'<li>\1</li>\n'
text = re.sub(match, replace, text)
# Set start of list
text = text.replace('<li>', '</p><ul><li>', 1)
# Set end of list
tmp = text.rsplit('</li>', 1)
return '</li></ul><p>'.join(tmp)"
1354,"def link2html(text):
''' Turns md links to html '''
match = r'\[([^\]]+)\]\(([^)]+)\)'
replace = r'<a href=""\2"">\1</a>'
return re.sub(match, replace, text)"
1355,"def simple_md2html(text, urls):
''' Convert a text from md to html '''
retval = special_links_replace(text, urls)
# Create a par break for double newlines
retval = re.sub(r'\n\n', r'</p><p>', retval)
# Create a visual br for every new line
retval = re.sub(r'\n', r'<br />\n', retval)
# Do we really need this ? Help reduce the diff to only '\n' diff.
retval = re.sub(r'""', r'&quot;', retval)
retval = list2html(retval)
return link2html(retval)"
1356,"def generate_ul(self, a_list):
''' Determines if we should generate th 'ul' around the list 'a_list' '''
return len(a_list) > 0 and (isinstance(a_list[0], Rule) or
isinstance(a_list[0], LabelDecl))"
1357,"def get_version_info():
""""""Extract version information as a dictionary from version.py.""""""
version_info = {}
with open(os.path.join(""refcycle"", ""version.py""), 'r') as f:
version_code = compile(f.read(), ""version.py"", 'exec')
exec(version_code, version_info)
return version_info"
1358,"def div_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]:
""""""Filter the JSON ``value`` for alert divs.
Arguments
---------
key
Key of the structure
value
Values in the structure
format
Output format of the processing
meta
Meta information
""""""