text
stringlengths
0
828
newnode = self.B[orderedstates[n].stateid]
if self.B[orderedstates[i].stateid] != self.empty:
if newnode is not None:
self.B[orderedstates[i].stateid] += newnode
else:
self.B[orderedstates[i].stateid] = newnode
for j in range(0, n):
# A[i,j] += A[i,n] . A[n,j]
newnode = None
if self.A[
orderedstates[i].stateid,
orderedstates[n].stateid] != self.empty \
and self.A[orderedstates[n].stateid, orderedstates[j].stateid] \
!= self.empty:
newnode = self.A[orderedstates[i].stateid, orderedstates[
n].stateid] + self.A[orderedstates[n].stateid, orderedstates[j].stateid]
elif self.A[orderedstates[i].stateid, orderedstates[n].stateid] != self.empty:
newnode = self.A[
orderedstates[i].stateid,
orderedstates[n].stateid]
elif self.A[orderedstates[n].stateid, orderedstates[j].stateid] != self.empty:
newnode = self.A[
orderedstates[n].stateid,
orderedstates[j].stateid]
if self.A[
orderedstates[i].stateid,
orderedstates[j].stateid] != self.empty:
if newnode is not None:
self.A[
orderedstates[i].stateid,
orderedstates[j].stateid] += newnode
else:
self.A[
orderedstates[i].stateid,
orderedstates[j].stateid] = newnode"
1739,"def load_mmd():
""""""Loads libMultiMarkdown for usage""""""
global _MMD_LIB
global _LIB_LOCATION
try:
lib_file = 'libMultiMarkdown' + SHLIB_EXT[platform.system()]
_LIB_LOCATION = os.path.abspath(os.path.join(DEFAULT_LIBRARY_DIR, lib_file))
if not os.path.isfile(_LIB_LOCATION):
_LIB_LOCATION = ctypes.util.find_library('MultiMarkdown')
_MMD_LIB = ctypes.cdll.LoadLibrary(_LIB_LOCATION)
except:
_MMD_LIB = None"
1740,"def _expand_source(source, dname, fmt):
""""""Expands source text to include headers, footers, and expands Multimarkdown transclusion
directives.
Keyword arguments:
source -- string containing the Multimarkdown text to expand
dname -- directory name to use as the base directory for transclusion references
fmt -- format flag indicating which format to use to convert transclusion statements
""""""
_MMD_LIB.g_string_new.restype = ctypes.POINTER(GString)
_MMD_LIB.g_string_new.argtypes = [ctypes.c_char_p]
src = source.encode('utf-8')
gstr = _MMD_LIB.g_string_new(src)
_MMD_LIB.prepend_mmd_header(gstr)
_MMD_LIB.append_mmd_footer(gstr)
manif = _MMD_LIB.g_string_new(b"""")
_MMD_LIB.transclude_source.argtypes = [ctypes.POINTER(GString), ctypes.c_char_p,
ctypes.c_char_p, ctypes.c_int, ctypes.POINTER(GString)]
_MMD_LIB.transclude_source(gstr, dname.encode('utf-8'), None, fmt, manif)
manifest_txt = manif.contents.str
full_txt = gstr.contents.str
_MMD_LIB.g_string_free(manif, True)
_MMD_LIB.g_string_free(gstr, True)
manifest_txt = [ii for ii in manifest_txt.decode('utf-8').split('\n') if ii]
return full_txt.decode('utf-8'), manifest_txt"
1741,"def has_metadata(source, ext):
""""""Returns a flag indicating if a given block of MultiMarkdown text contains metadata.""""""
_MMD_LIB.has_metadata.argtypes = [ctypes.c_char_p, ctypes.c_int]
_MMD_LIB.has_metadata.restype = ctypes.c_bool
return _MMD_LIB.has_metadata(source.encode('utf-8'), ext)"
1742,"def convert(source, ext=COMPLETE, fmt=HTML, dname=None):
""""""Converts a string of MultiMarkdown text to the requested format.
Transclusion is performed if the COMPATIBILITY extension is not set, and dname is set to a
valid directory
Keyword arguments:
source -- string containing MultiMarkdown text
ext -- extension bitfield to pass to conversion process
fmt -- flag indicating output format to use
dname -- Path to use for transclusion - if None, transclusion functionality is bypassed
""""""
if dname and not ext & COMPATIBILITY:
if os.path.isfile(dname):
dname = os.path.abspath(os.path.dirname(dname))
source, _ = _expand_source(source, dname, fmt)
_MMD_LIB.markdown_to_string.argtypes = [ctypes.c_char_p, ctypes.c_ulong, ctypes.c_int]
_MMD_LIB.markdown_to_string.restype = ctypes.c_char_p
src = source.encode('utf-8')