text
stringlengths 0
828
|
|---|
Implements the high level loop of the algorithm for learning a
|
Mealy machine.
|
Args:
|
None
|
Returns:
|
MealyMachine: The learned mealy machine
|
""""""
|
logging.info('Initializing learning procedure.')
|
self._init_table()
|
logging.info('Generating a closed and consistent observation table.')
|
while True:
|
closed = False
|
# Make sure that the table is closed and consistent
|
while not closed:
|
logging.debug('Checking if table is closed.')
|
closed, string = self.observation_table.is_closed()
|
if not closed:
|
logging.debug('Closing table.')
|
self._ot_make_closed(string)
|
else:
|
logging.debug('Table closed.')
|
# Create conjecture
|
mma = self.get_mealy_conjecture()
|
logging.info('Generated conjecture machine with %d states.',
|
len(list(mma.states)))
|
# _check correctness
|
logging.debug('Running equivalence query.')
|
found, counter_example = self._equivalence_query(mma)
|
# Are we done?
|
if found:
|
logging.info('No counterexample found. Hypothesis is correct!')
|
break
|
# Add the new experiments into the table to reiterate the
|
# learning loop
|
logging.info(
|
'Processing counterexample %input_string with length %d.',
|
counter_example,
|
len(counter_example))
|
self._process_counter_example(mma, counter_example)
|
logging.info('Learning complete.')
|
return mma"
|
1100,"def get_headers(environ):
|
""""""
|
Returns only proper HTTP headers.
|
""""""
|
for key, value in environ.iteritems():
|
key = str(key)
|
if key.startswith('HTTP_') and key not in \
|
('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'):
|
yield key[5:].replace('_', '-').title(), value
|
elif key in ('CONTENT_TYPE', 'CONTENT_LENGTH'):
|
yield key.replace('_', '-').title(), value"
|
1101,"def get_host(environ):
|
""""""Return the real host for the given WSGI environment. This takes care
|
of the `X-Forwarded-Host` header.
|
:param environ: the WSGI environment to get the host of.
|
""""""
|
scheme = environ.get('wsgi.url_scheme')
|
if 'HTTP_X_FORWARDED_HOST' in environ:
|
result = environ['HTTP_X_FORWARDED_HOST']
|
elif 'HTTP_HOST' in environ:
|
result = environ['HTTP_HOST']
|
else:
|
result = environ['SERVER_NAME']
|
if (scheme, str(environ['SERVER_PORT'])) not \
|
in (('https', '443'), ('http', '80')):
|
result += ':' + environ['SERVER_PORT']
|
if result.endswith(':80') and scheme == 'http':
|
result = result[:-3]
|
elif result.endswith(':443') and scheme == 'https':
|
result = result[:-4]
|
return result"
|
1102,"def parse_library(lib_files):
|
""""""
|
Analizuje pliki podane w liście lib_files
|
Zwraca instancję MusicLibrary
|
""""""
|
tracks, playlists = lib_files
|
lib = MusicLibrary()
|
lib_length = len(tracks)
|
i = 0
|
writer = lib.ix.writer()
|
previous_procent_done_str = """"
|
for f in tracks:
|
track_info = TrackInfo(f)
|
lib.add_track_internal(track_info, writer)
|
current_percent_done_str = ""%d%%"" % (i / lib_length * 100)
|
if current_percent_done_str != previous_procent_done_str:
|
logs.print_info(""Analizowanie biblioteki muzycznej... "" + current_percent_done_str)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.