text
stringlengths
0
828
""""""
assert isinstance(entity, Entity), ""Error: entity must have an instance of Entity""
return self.__collection.update({'_id': entity._id}, {'$set': entity.as_dict()})"
1729,"async def get_poll(poll_id):
"""""" Get a strawpoll.
Example:
poll = strawpy.get_poll('11682852')
:param poll_id:
:return: strawpy.Strawpoll object
""""""
async with aiohttp.get('{api_url}/{poll_id}'.format(api_url=api_url, poll_id=poll_id)) as r:
return await StrawPoll(r)"
1730,"async def create_poll(title, options, multi=True, permissive=True, captcha=False, dupcheck='normal'):
"""""" Create a strawpoll.
Example:
new_poll = strawpy.create_poll('Is Python the best?', ['Yes', 'No'])
:param title:
:param options:
:param multi:
:param permissive:
:param captcha:
:param dupcheck:
:return: strawpy.Strawpoll object
""""""
query = {
'title': title,
'options': options,
'multi': multi,
'permissive': permissive,
'captcha': captcha,
'dupcheck': dupcheck
}
async with aiohttp.post(api_url, data=json.dumps(query)) as r:
return await StrawPoll(r)"
1731,"def raise_status(response):
""""""Raise an exception if the request did not return a status code of 200.
:param response: Request response body
""""""
if response.status != 200:
if response.status == 401:
raise StrawPollException('Unauthorized', response)
elif response.status == 403:
raise StrawPollException('Forbidden', response)
elif response.status == 404:
raise StrawPollException('Not Found', response)
else:
response.raise_for_status()"
1732,"def results_with_percent(self):
"""""" Zip options, votes and percents (as integers) together.
:return: List of tuples (option, votes, percent)
""""""
percents = [int(float(v) / sum(self.votes) * 100) if sum(self.votes) > 0 else 0 for v in self.votes]
return zip(self.options, self.votes, percents)"
1733,"def open(self, results=False):
"""""" Open the strawpoll in a browser. Can specify to open the main or results page.
:param results: True/False
""""""
webbrowser.open(self.results_url if results else self.url)"
1734,"def main():
""""""
Testing function for DFA brzozowski algebraic method Operation
""""""
argv = sys.argv
if len(argv) < 2:
targetfile = 'target.y'
else:
targetfile = argv[1]
print 'Parsing ruleset: ' + targetfile,
flex_a = Flexparser()
mma = flex_a.yyparse(targetfile)
print 'OK'
print 'Perform minimization on initial automaton:',
mma.minimize()
print 'OK'
print 'Perform Brzozowski on minimal automaton:',
brzozowski_a = Brzozowski(mma)
mma_regex = brzozowski_a.get_regex()
print mma_regex"
1735,"def _bfs_sort(self, start):
""""""
maintain a map of states distance using BFS
Args:
start (fst state): The initial DFA state
Returns:
list: An ordered list of DFA states
using path distance
""""""