def findTile(self, src, has_property): depth = 0 src.depth = depth found = False ls = [src] while not found: depth += 1 _ls = [] for tile in ls: children = self.neighborsOf(tile) children = __builtin__.filter(self.isFlat, children) children = __builtin__.filter(self.notVisited, children) for child in children: child.depth = depth if has_property(child): found = True return child _ls += children ls = _ls if len(ls) == 0: return None
def updateAllTileBorders(self, world): water = __builtin__.filter(world.isWater, world.tiles) grass = __builtin__.filter(world.isFlat, world.tiles) for tile in grass: self.updateTileBorders(tile) for tile in water: self.updateTileBorders(tile)
def spreadForest(self, tile, gen_chance=90.0): tile.visited = True if (random.uniform(0,100.0) < gen_chance): tile.vegetation = Vegetation.FOREST neighbors = self.neighborsOf(tile) neighbors = __builtin__.filter(self.isFlat, neighbors) neighbors = __builtin__.filter(self.notVisited, neighbors) for tile in neighbors: self.spreadForest(tile, gen_chance-20.0)
def clear_lockout(self): """Clears lockout channels and updates GUI list """ # Clear the lockout channels self.lockout_channels = [] # Process lockout file if it was provided if self.lockout_file_name != "": # Open file, split to list, remove empty strings with open(self.lockout_file_name) as lockout_file: lines = lockout_file.read().splitlines() lockout_file.close() lines = __builtin__.filter(None, lines) # Convert to baseband frequencies, round, and append for freq in lines: rf_freq = float(freq) - self.center_freq rf_freq = round(rf_freq/self.channel_spacing)*\ self.channel_spacing self.lockout_channels.append(rf_freq) else: pass # Create a lockout channel list of strings for the GUI self.gui_lockout_channels = [] for lockout_channel in self.lockout_channels: gui_lockout_channel = (lockout_channel + \ self.receiver.center_freq)/1E6 text = '{:.3f}'.format(gui_lockout_channel) self.gui_lockout_channels.append(text)
def test_pipeline_example(): from functools import reduce import operator as op data = range(100) result1 = math.sqrt( reduce( op.add, builtins.map( lambda x: x ** 2.0, builtins.filter( lambda x: x % 2 == 0, data, ) ) ) ) from toolz.curried import filter, map, reduce from flowly.tz import chained transform = chained( filter(lambda x: x % 2 == 0), map(lambda x: x ** 2.0), reduce(op.add), math.sqrt, ) result2 = transform(data) assert result1 == result2
def generateForests(self): gen_chance = 3.0 land = __builtin__.filter(self.isFlat, self.tiles) for tile in land: if (random.uniform(0, 100.0) < gen_chance) and (tile.vegetation == Vegetation.NONE): tile.vegetation = Vegetation.FOREST self.spreadForest(tile) self.resetVisited()
def filter(function, sequence): """ Return a sequence containing those items of sequence for which function(item) is True. The order of items in sequence is preserved. >>> filter(lambda x: x<3, [3, 1, 5, 0, 2, 4]) [1, 0, 2] """ return __builtin__.filter(function, sequence)
def log(self, args): """ Show the log. """ #noinspection PyTupleAssignmentBalance app_name, deployment_name = self.parse_app_deployment_name(args.name) if not deployment_name: raise InputErrorException('NoDeployment') last_time = None while True: #noinspection PyUnusedLocal logEntries = [] try: logEntries = self.api.read_log( app_name, deployment_name, args.type, last_time=last_time) except GoneError: raise InputErrorException('WrongApplication') if len(logEntries) > 0: last_time = datetime.fromtimestamp(float(logEntries[-1]["time"])) if args.type == 'worker' and args.wrk_id: logEntries = filter(lambda entry: entry['wrk_id'] == args.wrk_id, logEntries) if args.filter: if args.type in ["error", "worker"]: logEntries = filter( lambda entry: re.search( re.compile(args.filter, re.IGNORECASE), entry['message']), logEntries) if args.type == 'access': logEntries = filter(lambda entry: re.search( re.compile(args.filter, re.IGNORECASE), entry['first_request_line'] + entry['referer'] + entry['user_agent'] + entry['remote_host']), logEntries) print_log_entries(logEntries, args.type) time.sleep(2)
def get( cls, name=__name__, level=(), buffer=(), terminator=(), colored_format=(), format=() ): # # ''' Returns a new or existing instance of a logger with given \ properties. If a logger was already registered under given name \ the existing instance is given back and a new instance otherwise. **name** - logger name to get **level** - sets levels for all logger **buffer** - sets buffers for all logger **terminator** - sets an ending char for each log message in \ each logger **colored_format** - sets templates for colored logging messages \ in returned logger, if "None" is given \ normal format will be used instead. **format** - sets templates for logging messages in each \ logger Examples: >>> logger_a = Logger.get('test', buffer=(__test_buffer__,)) >>> logger_b = Logger.get('test') >>> logger_c = Logger.get('test', buffer=(__test_buffer__,)) >>> logger_a is logger_b True >>> __test_buffer__.clear() # doctest: +ELLIPSIS '...' >>> logger_a.critical('Log some information.') >>> __test_buffer__.clear() # doctest: +ELLIPSIS '... - test... - ...CRITICAL... - Log some information.\\n' ''' for logger in builtins.filter( lambda logger: logger.name == name, cls.instances ): if level or buffer or terminator or colored_format or format: cls.instances[cls.instances.index( logger )] = cls._generate_logger( name, level, buffer, terminator, colored_format, format) return logger cls.instances.append(cls._generate_logger( name, level, buffer, terminator, colored_format, format)) return cls.instances[-1]
def log(self, args): """ Show the log. """ app_name, deployment_name = self.parse_app_deployment_name(args.name) if not deployment_name: deployment_name = "default" last_time = None while True: logEntries = [] try: logEntries = self.api.read_log(app_name, deployment_name, args.type, last_time=last_time) except GoneError: raise InputErrorException("WrongApplication") if len(logEntries) > 0: last_time = datetime.fromtimestamp(float(logEntries[-1]["time"])) if args.type == "worker" and args.wrk_id: logEntries = filter(lambda entry: entry["wrk_id"] == args.wrk_id, logEntries) if args.filter: if args.type in ["error", "worker"]: logEntries = filter( lambda entry: re.search(re.compile(args.filter, re.IGNORECASE), entry["message"]), logEntries, ) if args.type == "access": logEntries = filter( lambda entry: re.search( re.compile(args.filter, re.IGNORECASE), entry["first_request_line"] + entry["referer"] + entry["user_agent"] + entry["remote_host"], ), logEntries, ) print_log_entries(logEntries, args.type) time.sleep(2)
def _check_samtools(command, threads=1, extend=None): """Return based on threads and existence of parallel samtools""" global __parallel_samtools if threads == 1: p = [executables["samtools"], command] else: if __parallel_samtools is None: (s, e) = subprocess.Popen([executables["samtools"], "view"], stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate() f = __builtin__.filter(lambda x: x.startswith("-@"), [l.strip() for l in e.split("\n")]) __parallel_samtools = len(f) > 0 if __parallel_samtools: p = [executables["samtools"], command, "-@", str(threads)] else: p = [executables["samtools"], command] if extend is not None: p.extend(extend) return p
def __init__(self, rows, cols, debug): self.db = debug self.width = cols self.height = rows self.tiles = list() num_tiles = rows*cols + rows/2 for row in range(rows): for col in range(cols): self.tiles.append(Tile(col, row)) #odd rows have an extra column if row % 2 != 0: self.tiles.append(Tile(cols, row)) #Place player #choose a random tile to place player #more likely to be towards center player_x = int( random.triangular(0,cols)) player_y = int( random.triangular(0,rows)) player_tile = self.tileAt(player_x, player_y) player_tile.has_player = True #Player location is flatland player_tile.terrain = Terrain.FLAT self.generateLandmassAround(player_tile.pos[0],player_tile.pos[1]) self.resetVisited() self.generateForests() #Place City land = __builtin__.filter(self.isClear, self.tiles) idx = random.randint(0,len(land)-1) city_tile = land[idx] city_tile.has_city = True worker = Worker(city_tile,self) city_tile.has_worker=True self.entities = [worker]
def findPath(self, src, has_property): curr = self.findTile(src, has_property) if curr == None: return list() path = [curr] f = lambda t: t.depth == (curr.depth-1) #find neighbor of dst with appropriate depth while True: neighbors = self.neighborsOf(curr) neighbors = __builtin__.filter(f, neighbors) i = random.randint(0,len(neighbors)-1) curr = neighbors[i] path.append(curr) if curr.depth == 0: path.pop() self.resetDepth() return path
def update_priority(self): """Updates priority channels """ # Clear the priority channels self.priority_channels = [] # Process priority file if it was provided if self.priority_file_name != "": # Open file, split to list, remove empty strings with open(self.priority_file_name) as priority_file: lines = priority_file.read().splitlines() priority_file.close() lines = __builtin__.filter(None, lines) # Convert to baseband frequencies, round, and append if within BW for freq in lines: bb_freq = float(freq) - self.center_freq bb_freq = round(bb_freq / self.channel_spacing) * self.channel_spacing if abs(bb_freq) <= self.samp_rate / 2.0: self.priority_channels.append(bb_freq) else: pass else: pass
def _set_properties( cls, level, buffer, terminator, colored_format, format ): # # ''' This method sets the class properties. Examples: >>> Logger._set_properties( ... level=Logger.level, buffer=Logger.buffer, ... terminator=Logger.terminator, ... colored_format=Logger.colored_format, format=Logger.format ... ) # doctest: +ELLIPSIS <class '...Logger'> ''' # TODO check branches. scope = builtins.locals() for name in builtins.filter(lambda name: scope[name], ( 'level', 'buffer', 'terminator', 'colored_format', 'format' )): builtins.setattr(cls, name, scope[name]) return cls
def update_priority(self): """Updates priority channels """ # Clear the priority channels self.priority_channels = [] # Process priority file if it was provided if self.priority_file_name != "": # Open file, split to list, remove empty strings with open(self.priority_file_name) as priority_file: lines = priority_file.read().splitlines() priority_file.close() lines = __builtin__.filter(None, lines) # Convert to baseband frequencies, round, and append if within BW for freq in lines: bb_freq = float(freq) - self.center_freq bb_freq = round(bb_freq/self.channel_spacing)*\ self.channel_spacing if abs(bb_freq) <= self.samp_rate/2.0: self.priority_channels.append(bb_freq) else: pass else: pass
def filter(fn, sequence): return __builtin__.filter(fn, sequence)
return _coconut_tail_call(rec, arr, num - 1, goal - num) else: # num > goal try: _coconut_is_recursive = rec is _coconut_recursive_func_0 except _coconut.NameError: _coconut_is_recursive = False if _coconut_is_recursive: arr, num, goal = arr, goal, goal continue else: return _coconut_tail_call(rec, arr, goal, goal) return None _coconut_recursive_func_0 = rec n = (int)(input()) summation = n * (n + 1) // 2 if summation % 2 == 1: print("NO") else: print("YES") sol = (set)(rec([], n, summation // 2)) print(len(sol)) (print)((' '.join)(map(str, sol))) sol = (list)(filter(lambda x: x not in sol, range(1, n + 1))) print(len(sol)) (print)((' '.join)(map(str, sol)))
def __init__(self): # Call the initialization method from the parent class gr.top_block.__init__(self) # Setup the parser for command line arguments parser = OptionParser(option_class=eng_option) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="print settings to stdout") parser.add_option("-a", "--args", type="string", dest="src_args", default='addr=192.168.1.13', help="USRP device address args") parser.add_option("-g", "--gain", type="eng_float", dest="src_gain", default=0, help="USRP gain in dB") parser.add_option("-q", "--squelch", type="eng_float", dest="squelch_thresh", default=-80, help="Squelch threshold in dB") parser.add_option("-s", "--soundrate", type="eng_float", dest="snd_card_rate", default=48000, help="Sound card rate in Hz (must be n*100 Hz)") parser.add_option("-c", "--channels", type="string", dest="channel_file_name", default='channels.txt', help="Text file of EOL delimited channels in Hz") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Define the user constants src_args = str(options.src_args) src_gain = float(options.src_gain) squelch_thresh = float(options.squelch_thresh) snd_card_rate = int(options.snd_card_rate) channel_file_name = str(options.channel_file_name) # Define other constants (don't mess with these) max_rf_bandwidth = 25E6 # Limited by N210 channel_sample_rate = 20000 nbfm_maxdev = 2.5E3 nbfm_tau = 75E-6 # Open file, split to list, remove empty strings, and convert to float with open(channel_file_name) as chanfile: lines = chanfile.read().splitlines() chanfile.close() lines = __builtin__.filter(None, lines) chanlist = [float(chan) for chan in lines] # Source decimation is first deternmined by the required RF bandwidth rf_bandwidth = max(chanlist) - min(chanlist) + 2*channel_sample_rate src_decimation = int(math.floor(max_rf_bandwidth/rf_bandwidth)) # Check if rf_bandwidth is too wide if rf_bandwidth > max_rf_bandwidth: print 'Error: Channels spaced beyond the \ %f MHz maximum RF bandwidth!' % (max_rf_bandwidth/1E6) sys.exit([1]) else: pass # Don't let the source decimation go above 100 (USRP N210 limit) if src_decimation > 100: src_decimation = 100 # This is a little tricky # Don't want odd values of source decimation greater than 1 # Also want the source sample rate \ # to be an integer multiple of channel sample rate src_sample_rate = max_rf_bandwidth / src_decimation while ((src_decimation%2 != 0) or \ ((max_rf_bandwidth/src_decimation) % channel_sample_rate != 0)) \ and src_decimation > 1: src_decimation = src_decimation - 1 src_sample_rate = max_rf_bandwidth / src_decimation # Calculate the channel decimation for the fxlating filter # (it will be an integer) channel_decimation = int(src_sample_rate / channel_sample_rate) # Calculate center frequency src_center_freq = (max(chanlist) + min(chanlist)) / 2 # Print some info to stdout for verbose option if options.verbose: print 'Source args string "%s" ' % src_args print 'Source center frequency = %f MHz' % (src_center_freq/1E6) print 'Source decimation = %i' % src_decimation print 'Source sample rate = %i Hz' % src_sample_rate print 'Source gain = %i dB' % src_gain print 'Squelch threshold = %i dB' % squelch_thresh print 'Channel decimation = %i' % channel_decimation print 'Channel sample rate = %i Hz' % channel_sample_rate print 'Sound card rate = %i Hz' % snd_card_rate print 'Channel list = %s' % str(chanlist) # Setup the source src = uhd.usrp_source(src_args, uhd.io_type_t.COMPLEX_FLOAT32, 1) src.set_samp_rate(src_sample_rate) src.set_center_freq(src_center_freq, 0) src.set_gain(src_gain, 0) # Get USRP true center frequency # Do nothing with it as it's only a few Hz error #print src.get_center_freq() # Create N channel flows--------------------------------------------- # Design taps for frequency translating FIR filter filter_taps = filter.firdes.low_pass(1.0, src_sample_rate, 8E3, 2E3, filter.firdes.WIN_HAMMING) # N parallel fxlating FIR filter with decimation to channel rate # Note how the tune freq is chan-src_center_freq ; reversed from GR 3.6 fxlate = [filter.freq_xlating_fir_filter_ccc(channel_decimation, filter_taps, chan - src_center_freq, src_sample_rate) for chan in chanlist] # Power squelch (complex, non blocking) prior to NBFM squelch1 = [analog.pwr_squelch_cc(squelch_thresh, 0.1, 1, False) for chan in chanlist] # NBFM receiver nbfm = [analog.nbfm_rx(channel_sample_rate, channel_sample_rate, nbfm_tau, nbfm_maxdev) for chan in chanlist] # Power squelch (float, blocking) prior to wav file resampling squelch2 = [analog.pwr_squelch_ff(squelch_thresh, 0.1, 1, True) for chan in chanlist] # Rational resampler for channel rate to 8 kHz wav file rate resampwav = [filter.rational_resampler_fff(8000, int(channel_sample_rate)) for chan in chanlist] # Wav file sink wavfile = [blocks.wavfile_sink(str(int(chan))+'.wav', 1, 8000, 8) for chan in chanlist] # Connect the blocks for chan in range(len(chanlist)): self.connect(src, fxlate[chan], squelch1[chan], nbfm[chan], squelch2[chan], resampwav[chan], wavfile[chan]) # Adder to sum the nbfm outputs for sound card adder = blocks.add_vff(1) # Rational resampler for channel rate to audio rate resampsc = filter.rational_resampler_fff(int(snd_card_rate), int(channel_sample_rate)) # Sound card sink sndcard = audio.sink(snd_card_rate, "", True) # Connect the blocks for chan in range(len(chanlist)): self.connect(nbfm[chan], (adder, chan)) # Connect the blocks self.connect(adder, resampsc, sndcard)
_coconut.operator.methodcaller("split", '\n')), [ open('./WindowsAPIhash-master/API_Hash_{_coconut_format_0}.txt'. format(_coconut_format_0=(i + 1))) for i in range(5) ])) def find_hash(h): for api in api_hashes: if h in api.lower(): return api return None funcs = filter(lambda x: x is not None, map(find_hash, hashes)) for idx, func in enumerate(funcs): print( '0x46d + {_coconut_format_0} | {_coconut_format_1}:\t{_coconut_format_2}' .format(_coconut_format_0=(hex(idx * 4)), _coconut_format_1=(hex(0x46d + idx * 4)), _coconut_format_2=(func))) # 0x349 arg_1 = b'\x15\x44\xa8\xc0' # 0xc0a84415 arg_2 = b'\x39\x05' # 0x539 socket = bytearray(0x10) socket[0] = 0 socket[1] = 2 # ax = (arg_2 << 8) | (arg_2 >> 8)
if PY2: # pragma: no cover import __builtin__ as builtins filter = builtins.filter iterkeys = dict.iterkeys itervalues = dict.itervalues iteritems = dict.iteritems listkeys = dict.keys listvalues = dict.values listitems = dict.items exec('def reraise(tp, value, tb=None):\n raise tp, value, tb') else: # pragma: no cover import builtins filter = lambda *args, **kwargs: list(builtins.filter(*args, **kwargs)) iterkeys = dict.keys itervalues = dict.values iteritems = dict.items listkeys = lambda d: list(d.keys()) listvalues = lambda d: list(d.values()) listitems = lambda d: list(d.items()) def reraise(tp, value, tb=None): if value.__traceback__ is not tb: raise value.with_traceback(tb) raise value
def __init__(self): # Call the initialization method from the parent class gr.top_block.__init__(self) # Setup the parser for command line arguments parser = OptionParser(option_class=eng_option) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="print settings to stdout") parser.add_option("-a", "--args", type="string", dest="src_args", default='addr=192.168.1.13', help="USRP device address args") parser.add_option("-g", "--gain", type="eng_float", dest="src_gain", default=0, help="USRP gain in dB") parser.add_option("-q", "--squelch", type="eng_float", dest="squelch_thresh", default=-80, help="Squelch threshold in dB") parser.add_option("-s", "--soundrate", type="eng_float", dest="snd_card_rate", default=48000, help="Sound card rate in Hz (must be n*100 Hz)") parser.add_option("-c", "--channels", type="string", dest="channel_file_name", default='channels.txt', help="Text file of EOL delimited channels in Hz") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Define the user constants src_args = str(options.src_args) src_gain = float(options.src_gain) squelch_thresh = float(options.squelch_thresh) snd_card_rate = int(options.snd_card_rate) channel_file_name = str(options.channel_file_name) # Define other constants (don't mess with these) max_rf_bandwidth = 25E6 # Limited by N210 channel_sample_rate = 20000 nbfm_maxdev = 2.5E3 nbfm_tau = 75E-6 # Open file, split to list, remove empty strings, and convert to float with open(channel_file_name) as chanfile: lines = chanfile.read().splitlines() chanfile.close() lines = __builtin__.filter(None, lines) chanlist = [float(chan) for chan in lines] # Source decimation is first deternmined by the required RF bandwidth rf_bandwidth = max(chanlist) - min(chanlist) + 2 * channel_sample_rate src_decimation = int(math.floor(max_rf_bandwidth / rf_bandwidth)) # Check if rf_bandwidth is too wide if rf_bandwidth > max_rf_bandwidth: print 'Error: Channels spaced beyond the \ %f MHz maximum RF bandwidth!' % (max_rf_bandwidth / 1E6) sys.exit([1]) else: pass # Don't let the source decimation go above 100 (USRP N210 limit) if src_decimation > 100: src_decimation = 100 # This is a little tricky # Don't want odd values of source decimation greater than 1 # Also want the source sample rate \ # to be an integer multiple of channel sample rate src_sample_rate = max_rf_bandwidth / src_decimation while ((src_decimation%2 != 0) or \ ((max_rf_bandwidth/src_decimation) % channel_sample_rate != 0)) \ and src_decimation > 1: src_decimation = src_decimation - 1 src_sample_rate = max_rf_bandwidth / src_decimation # Calculate the channel decimation for the fxlating filter # (it will be an integer) channel_decimation = int(src_sample_rate / channel_sample_rate) # Calculate center frequency src_center_freq = (max(chanlist) + min(chanlist)) / 2 # Print some info to stdout for verbose option if options.verbose: print 'Source args string "%s" ' % src_args print 'Source center frequency = %f MHz' % (src_center_freq / 1E6) print 'Source decimation = %i' % src_decimation print 'Source sample rate = %i Hz' % src_sample_rate print 'Source gain = %i dB' % src_gain print 'Squelch threshold = %i dB' % squelch_thresh print 'Channel decimation = %i' % channel_decimation print 'Channel sample rate = %i Hz' % channel_sample_rate print 'Sound card rate = %i Hz' % snd_card_rate print 'Channel list = %s' % str(chanlist) # Setup the source src = uhd.usrp_source(src_args, uhd.io_type_t.COMPLEX_FLOAT32, 1) src.set_samp_rate(src_sample_rate) src.set_center_freq(src_center_freq, 0) src.set_gain(src_gain, 0) # Get USRP true center frequency # Do nothing with it as it's only a few Hz error #print src.get_center_freq() # Create N channel flows--------------------------------------------- # Design taps for frequency translating FIR filter filter_taps = filter.firdes.low_pass(1.0, src_sample_rate, 8E3, 2E3, filter.firdes.WIN_HAMMING) # N parallel fxlating FIR filter with decimation to channel rate # Note how the tune freq is chan-src_center_freq ; reversed from GR 3.6 fxlate = [ filter.freq_xlating_fir_filter_ccc(channel_decimation, filter_taps, chan - src_center_freq, src_sample_rate) for chan in chanlist ] # Power squelch (complex, non blocking) prior to NBFM squelch1 = [ analog.pwr_squelch_cc(squelch_thresh, 0.1, 1, False) for chan in chanlist ] # NBFM receiver nbfm = [ analog.nbfm_rx(channel_sample_rate, channel_sample_rate, nbfm_tau, nbfm_maxdev) for chan in chanlist ] # Power squelch (float, blocking) prior to wav file resampling squelch2 = [ analog.pwr_squelch_ff(squelch_thresh, 0.1, 1, True) for chan in chanlist ] # Rational resampler for channel rate to 8 kHz wav file rate resampwav = [ filter.rational_resampler_fff(8000, int(channel_sample_rate)) for chan in chanlist ] # Wav file sink wavfile = [ blocks.wavfile_sink(str(int(chan)) + '.wav', 1, 8000, 8) for chan in chanlist ] # Connect the blocks for chan in range(len(chanlist)): self.connect(src, fxlate[chan], squelch1[chan], nbfm[chan], squelch2[chan], resampwav[chan], wavfile[chan]) # Adder to sum the nbfm outputs for sound card adder = blocks.add_vff(1) # Rational resampler for channel rate to audio rate resampsc = filter.rational_resampler_fff(int(snd_card_rate), int(channel_sample_rate)) # Sound card sink sndcard = audio.sink(snd_card_rate, "", True) # Connect the blocks for chan in range(len(chanlist)): self.connect(nbfm[chan], (adder, chan)) # Connect the blocks self.connect(adder, resampsc, sndcard)
def filter(pred, seq=None): return py.filter(None, pred) if seq is None else py.filter(pred, seq)
def test_mf_correct(self): """Should be identical output to map and filter without transduction.""" self.assertEqual([a for a in __builtin__.map(msq, __builtin__.filter(fodd, range(10000)))], transduce(compose(filter(fodd), map(msq)), append, [], range(10000)))
def __get_all_modules__(path=convert_to_unicode(sys.path[0])): ''' This method provides a generic way to determine all modules in \ current package or folder. It is useful for "__init__.py" files. **path** - Current working directory. Examples: >>> __get_all_modules__() # doctest: +ELLIPSIS [...] >>> from boostnode.extension.file import Handler as FileHandler >>> location = FileHandler( ... __test_folder__.path + '__get_all_modules__', ... make_directory=True) >>> a = FileHandler(location.path + 'a.py') >>> a.content = '' >>> FileHandler( ... location.path + 'b.pyc', make_directory=True ... ) # doctest: +ELLIPSIS Object of "Handler" with path "...__get_all_modu...b.pyc..." (type: ... >>> __get_all_modules__(__test_folder__.path + '__get_all_modules__') ['a'] >>> a.remove_file() True >>> __get_all_modules__(__test_folder__.path + '__get_all_modules__') [] >>> __get_all_modules__('') ['highPerformanceModification'] ''' # # python3.5 # # if not path: # # path = os.getcwd() # # return builtins.list(builtins.set(builtins.map( # # lambda name: name[:name.rfind('.')], # # builtins.filter( # # lambda name: ( # # (name.endswith('.py') or name.endswith('.pyc')) and # # not name.startswith('__init__.') and os.path.isfile( # # '%s%s%s' % (path, os.sep, name))), # # os.listdir( # # path[:-(builtins.len(os.path.basename(path)) + 1)] if # # os.path.isfile(path) else path))))) if not path: path = os.getcwd() return builtins.list(builtins.set(builtins.map( lambda name: name[:name.rfind('.')], builtins.filter( lambda name: ( (name.endswith('.py') or name.endswith('.pyc')) and not name.startswith('__init__.') and os.path.isfile( convert_to_string('%s%s%s' % (path, os.sep, name)))), builtins.map( lambda name: convert_to_unicode(name), os.listdir( path[:-(builtins.len(os.path.basename(path)) + 1)] if os.path.isfile(path) else path))))))
else: y = 0 # so next number is 0 d[x] = i i += 1 # increment index by 1 print(i, y) yield i, y x = y def diff(gen): x0 = 0 y0 = 0 for x1, y1 in gen: yield (x0, y1 - y0) x0, y0 = x1, y1 # def van_eyck(x: int, i: int, d: dict): # if x in d: def print_wait(n): print(n) input() # van_eyck() |> map$(print_wait) |> consume plot_cont(100000, (diff)( (enumerate)(map(lambda tup: tup[0], filter(lambda tup: tup[1] == 0, van_eyck())))))