text
stringlengths
0
828
return _MMD_LIB.markdown_to_string(src, ext, fmt).decode('utf-8')"
1743,"def convert_from(fname, ext=COMPLETE, fmt=HTML):
""""""
Reads in a file and performs MultiMarkdown conversion, with transclusion ocurring based on the
file directory. Returns the converted string.
Keyword arguments:
fname -- Filename of document to convert
ext -- extension bitfield to pass to conversion process
fmt -- flag indicating output format to use
""""""
dname = os.path.abspath(os.path.dirname(fname))
with open(fname, 'r') as fp:
src = fp.read()
return convert(src, ext, fmt, dname)"
1744,"def manifest(txt, dname):
""""""Extracts file manifest for a body of text with the given directory.""""""
_, files = _expand_source(txt, dname, HTML)
return files"
1745,"def keys(source, ext=COMPLETE):
""""""Extracts metadata keys from the provided MultiMarkdown text.
Keyword arguments:
source -- string containing MultiMarkdown text
ext -- extension bitfield for extracting MultiMarkdown
""""""
_MMD_LIB.extract_metadata_keys.restype = ctypes.c_char_p
_MMD_LIB.extract_metadata_keys.argtypes = [ctypes.c_char_p, ctypes.c_ulong]
src = source.encode('utf-8')
all_keys = _MMD_LIB.extract_metadata_keys(src, ext)
all_keys = all_keys.decode('utf-8') if all_keys else ''
key_list = [ii for ii in all_keys.split('\n') if ii]
return key_list"
1746,"def value(source, key, ext=COMPLETE):
""""""Extracts value for the specified metadata key from the given extension set.
Keyword arguments:
source -- string containing MultiMarkdown text
ext -- extension bitfield for processing text
key -- key to extract
""""""
_MMD_LIB.extract_metadata_value.restype = ctypes.c_char_p
_MMD_LIB.extract_metadata_value.argtypes = [ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p]
src = source.encode('utf-8')
dkey = key.encode('utf-8')
value = _MMD_LIB.extract_metadata_value(src, ext, dkey)
return value.decode('utf-8') if value else ''"
1747,"def tweet(self, text, in_reply_to=None, filename=None, file=None):
""""""
Post a new tweet.
:param text: the text to post
:param in_reply_to: The ID of the tweet to reply to
:param filename: If `file` param is not provided, read file from this path
:param file: A file object, which will be used instead of opening `filename`. `filename` is still required, for
MIME type detection and to use as a form field in the POST data
:return: Tweet object
""""""
if filename is None:
return Tweet(self._client.update_status(status=text, in_reply_to_status_id=in_reply_to)._json)
else:
return Tweet(self._client.update_with_media(filename=filename, file=file,
status=text, in_reply_to_status_id=in_reply_to)._json)"
1748,"def retweet(self, id):
""""""
Retweet a tweet.
:param id: ID of the tweet in question
:return: True if success, False otherwise
""""""
try:
self._client.retweet(id=id)
return True
except TweepError as e:
if e.api_code == TWITTER_PAGE_DOES_NOT_EXISTS_ERROR:
return False
raise"
1749,"def get_tweet(self, id):
""""""
Get an existing tweet.
:param id: ID of the tweet in question
:return: Tweet object. None if not found
""""""
try:
return Tweet(self._client.get_status(id=id)._json)
except TweepError as e:
if e.api_code == TWITTER_TWEET_NOT_FOUND_ERROR:
return None
raise"
1750,"def get_user(self, id):
""""""
Get a user's info.
:param id: ID of the user in question