當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.next方法代碼示例

本文整理匯總了Python中builtins.next方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.next方法的具體用法?Python builtins.next怎麽用?Python builtins.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在builtins的用法示例。


在下文中一共展示了builtins.next方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init_pipeline_plugins

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def init_pipeline_plugins(plugin_dir):
    """
    Initialize the pipeline plugins which triggers the auto registering of user
    defined pipeline functions.
    1. Add the plugin_dir into sys.path.
    2. Import the file under plugin_dir that starts with "cce_plugin_" and ends
    with ".py"
    """
    if not op.isdir(plugin_dir):
        logger.warning("%s is not a directory! Pipeline plugin files won't be loaded.",
                       plugin_dir)
        return

    sys.path.append(plugin_dir)
    for file_name in next(walk(plugin_dir))[2]:
        if file_name == "__init__.py" or not file_name.startswith("cce_plugin_"):
            continue
        if file_name.endswith(".py"):
            import_plugin_file(file_name) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:21,代碼來源:plugin.py

示例2: skip

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def skip(self, buffer_as, offset):
        """Skip uninteresting regions.

        Where should we go next? By default we go 1 byte ahead, but if some of
        the checkers have skippers, we may actually go much farther. Checkers
        with skippers basically tell us that there is no way they can match
        anything before the skipped result, so there is no point in trying them
        on all the data in between. This optimization is useful to really speed
        things up.
        """
        skip = 1
        for s in self.skippers:
            skip_value = s.skip(buffer_as, offset)
            skip = max(skip, skip_value)

        return skip 
開發者ID:google,項目名稱:rekall,代碼行數:18,代碼來源:scan.py

示例3: scan

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def scan(self, offset=0, maxlen=None):
        available_length = maxlen or self.session.profile.get_constant(
            "MaxPointer")

        while available_length > 0:
            to_read = min(constants.SCAN_BLOCKSIZE + self.overlap,
                          available_length)

            # Now feed all the scanners from the same address space.
            for name, scanner in list(self.scanners.items()):
                for hit in scanner.scan(offset=offset, maxlen=to_read):
                    # Yield the result as well as cache it.
                    yield name, hit

            # Move to the next scan block.
            offset += constants.SCAN_BLOCKSIZE
            available_length -= constants.SCAN_BLOCKSIZE 
開發者ID:google,項目名稱:rekall,代碼行數:19,代碼來源:scan.py

示例4: LookupIndex

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def LookupIndex(self):
        """Loookup the profile from an index."""
        try:
            index = self.session.LoadProfile(
                "%s/index" % self.plugin_args.module)
        except ValueError:
            return

        cc = self.session.plugins.cc()
        for session in self.session.plugins.sessions().session_spaces():
            # Switch the process context to this session so the address
            # resolver can find the correctly mapped driver.
            with cc:
                cc.SwitchProcessContext(next(iter(session.processes())))

                # Get the image base of the win32k module.
                image_base = self.session.address_resolver.get_address_by_name(
                    self.plugin_args.module)

                for profile, _ in index.LookupIndex(
                        image_base, minimal_match=self.plugin_args.minimal_match):
                    yield self.session.GetParameter("process_context"), profile 
開發者ID:google,項目名稱:rekall,代碼行數:24,代碼來源:index.py

示例5: extractFromVolume

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def extractFromVolume(container_urn, volume, imageURNs, destFolder):
    printVolumeInfo(container_urn.original_filename, volume)
    resolver = volume.resolver
    for imageUrn in imageURNs:
        imageUrn = utils.SmartUnicode(imageUrn)

        pathName = next(resolver.QuerySubjectPredicate(volume.urn, imageUrn, volume.lexicon.pathName))

        with resolver.AFF4FactoryOpen(imageUrn) as srcStream:
            if destFolder != "-":
                pathName = escaping.arnPathFragment_from_path(pathName.value)
                while pathName.startswith("/"):
                    pathName = pathName[1:]
                destFile = os.path.join(destFolder, pathName)
                if not os.path.exists(os.path.dirname(destFile)):
                    try:
                        os.makedirs(os.path.dirname(destFile))
                    except OSError as exc:  # Guard against race condition
                        if exc.errno != errno.EEXIST:
                            raise
                with open(destFile, "wb") as destStream:
                    shutil.copyfileobj(srcStream, destStream, length=32 * 2014)
                    print("\tExtracted %s to %s" % (pathName, destFile))
            else:
                shutil.copyfileobj(srcStream, sys.stdout) 
開發者ID:aff4,項目名稱:pyaff4,代碼行數:27,代碼來源:aff4.py

示例6: _get_or_insert_iam_binding

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def _get_or_insert_iam_binding(policy, role):
  """Return the binding corresponding to the given role. Creates the binding if
  needed."""
  existing_binding = next(
      (binding for binding in policy['bindings'] if binding['role'] == role),
      None)
  if existing_binding:
    return existing_binding

  new_binding = {
      'role': role,
      'members': [],
  }

  policy['bindings'].append(new_binding)
  return new_binding 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:18,代碼來源:service_accounts.py

示例7: get_filetype_by_name

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def get_filetype_by_name(self, name, tree):
        fileTypeRows = tree.findall('FileTypes/FileType')

        fileTypeRow = next((element for element in fileTypeRows if element.attrib.get('name') == name), None)
        if fileTypeRow is None:
            Logutil.log('Configuration error. FileType %s does not exist in config.xml' % name, util.LOG_LEVEL_ERROR)
            return None, util.localize(32005)

        fileType = FileType()
        fileType.name = name

        try:
            fileType.id = fileTypeRow.attrib.get('id')
            fileType.type = fileTypeRow.find('type').text
            fileType.parent = fileTypeRow.find('parent').text
        except KeyError:
            Logutil.log('Configuration error. FileType %s must have an id' % name, util.LOG_LEVEL_ERROR)
            return None, util.localize(32005)
        except AttributeError:
            pass

        return fileType, '' 
開發者ID:maloep,項目名稱:romcollectionbrowser,代碼行數:24,代碼來源:config.py

示例8: is_abstract

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def is_abstract(self, pass_is_abstract=True):
        """return true if the method is abstract
        It's considered as abstract if the only statement is a raise of
        NotImplementError, or, if pass_is_abstract, a pass statement
        """
        for child_node in self.code.getChildNodes():
            if isinstance(child_node, Raise) and child_node.expr1:
                try:
                    name = next(child_node.expr1.nodes_of_class(Name))
                    if name.name == 'NotImplementedError':
                        return True
                except StopIteration:
                    pass
            if pass_is_abstract and isinstance(child_node, Pass):
                return True
            return False
        # empty function is the same as function with a single "pass" statement
        if pass_is_abstract:
            return True 
開發者ID:jlachowski,項目名稱:clonedigger,代碼行數:21,代碼來源:scoped_nodes.py

示例9: infer_subscript

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def infer_subscript(self, context=None):
    """infer simple subscription such as [1,2,3][0] or (1,2,3)[-1]
    """
    if len(self.subs) == 1:
        index = next(self.subs[0].infer(context))
        if index is YES:
            yield YES
            return
        try:
            # suppose it's a Tuple/List node (attribute error else)
            assigned = self.expr.getitem(index.value)
        except AttributeError:
            raise InferenceError()
        except IndexError:
            yield YES
            return
        for infered in assigned.infer(context):
            yield infered
    else:
        raise InferenceError() 
開發者ID:jlachowski,項目名稱:clonedigger,代碼行數:22,代碼來源:inference.py

示例10: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def __init__(self, methanalysis):
        method = methanalysis.get_method()
        self.method = method
        self.irmethod = None
        self.start_block = next(methanalysis.get_basic_blocks().get(), None)
        self.cls_name = method.get_class_name()
        self.name = method.get_name()
        self.lparams = []
        self.var_to_name = defaultdict()
        self.offset_to_node = {}
        self.graph = None

        self.access = util.get_access_method(method.get_access_flags())

        desc = method.get_descriptor()
        self.type = desc.split(')')[-1]
        self.params_type = util.get_params_type(desc)
        self.triple = method.get_triple()

        self.exceptions = methanalysis.exceptions.exceptions
        self.curret_block = None

        self.var_versions = defaultdict(int)

        code = self.method.get_code()
        if code:
            start = code.registers_size - code.ins_size
            if 'static' not in self.access:
                self.lparams.append(start)
                start += 1
            num_param = 0
            for ptype in self.params_type:
                param = start + num_param
                self.lparams.append(param)
                num_param += util.get_type_size(ptype)

        if DEBUG:
            from androguard.core import bytecode
            bytecode.method2png('graphs/%s#%s.png' % \
                                (self.cls_name.split('/')[-1][:-1], self.name),
                                methanalysis) 
開發者ID:amimo,項目名稱:dcc,代碼行數:43,代碼來源:compiler.py

示例11: client_adatper

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def client_adatper(job_func):
    class TaDataClientAdapter(TaDataClient):
        def __init__(self, all_conf_contents, meta_config, task_config,
                     chp_mgr):
            super(TaDataClientAdapter, self).__init__(meta_config, task_config,
                                                      chp_mgr)
            self._execute_times = 0
            self._gen = job_func(self._task_config, chp_mgr)

        def stop(self):
            """
            overwrite to handle stop control command
            """

            # normaly base class just set self._stop as True
            super(TaDataClientAdapter, self).stop()

        def get(self):
            """
            overwrite to get events
            """
            self._execute_times += 1
            if self.is_stopped():
                # send stop signal
                self._gen.send(self.is_stopped())
                raise StopIteration
            if self._execute_times == 1:
                return next(self._gen)
            return self._gen.send(self.is_stopped())

    return TaDataClientAdapter 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:33,代碼來源:ta_data_client.py

示例12: addinfo

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def addinfo(self):
        """ The purpose of this method is to populate the
        modular action info variable with the contents of info.csv.

        @raise Exception: raises Exception if self.info_file could not be opened
                          or if there were problems parsing the info.csv data
        """
        if self.info_file:
            try:
                with open(self.info_file, 'rU') as fh:
                    self.info = next(csv.DictReader(fh))
            except Exception as e:
                self.message('Could not retrieve info.csv', level=logging.WARN) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:15,代碼來源:cim_actions.py

示例13: nextOrNone

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def nextOrNone(iterable):
    try:
        return next(iterable)
    except:
        return None 
開發者ID:aff4,項目名稱:pyaff4,代碼行數:7,代碼來源:aff4.py

示例14: extractAllFromVolume

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def extractAllFromVolume(container_urn, volume, destFolder):
    printVolumeInfo(container_urn.original_filename, volume)
    resolver = volume.resolver
    for imageUrn in resolver.QueryPredicateObject(volume.urn, lexicon.AFF4_TYPE, lexicon.standard11.FileImage):
        imageUrn = utils.SmartUnicode(imageUrn)

        pathName = next(resolver.QuerySubjectPredicate(volume.urn, imageUrn, lexicon.standard11.pathName)).value
        if pathName.startswith("/"):
            pathName = "." + pathName
        with resolver.AFF4FactoryOpen(imageUrn) as srcStream:
            if destFolder != "-":
                destFile = os.path.join(destFolder, pathName)
                if not os.path.exists(os.path.dirname(destFile)):
                    try:
                        os.makedirs(os.path.dirname(destFile))
                    except OSError as exc:  # Guard against race condition
                        if exc.errno != errno.EEXIST:
                            raise
                with open(destFile, "wb") as destStream:
                    shutil.copyfileobj(srcStream, destStream)
                    print("\tExtracted %s to %s" % (pathName, destFile))

                lastWritten = nextOrNone(
                    resolver.QuerySubjectPredicate(volume.urn, imageUrn, lexicon.standard11.lastWritten))
                lastAccessed = nextOrNone(
                    resolver.QuerySubjectPredicate(volume.urn, imageUrn, lexicon.standard11.lastAccessed))
                recordChanged = nextOrNone(
                    resolver.QuerySubjectPredicate(volume.urn, imageUrn, lexicon.standard11.recordChanged))
                birthTime = nextOrNone(
                    resolver.QuerySubjectPredicate(volume.urn, imageUrn, lexicon.standard11.birthTime))
                logical.resetTimestamps(destFile, lastWritten, lastAccessed, recordChanged, birthTime)

            else:
                shutil.copyfileobj(srcStream, sys.stdout) 
開發者ID:aff4,項目名稱:pyaff4,代碼行數:36,代碼來源:aff4.py

示例15: getDTB

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import next [as 別名]
def getDTB(self):
        # UGLY: At the moment, the CR3 returned by MacPMEM doesnt seem to work, so we need to rely on scanning
        # that being the case, we dont return the dtb if it is OSX

        kaslrSlide = list(self.resolver.QuerySubjectPredicate(self.urn, lexicon.standard.OSXKALSRSlide))
        if len(kaslrSlide) == 1 and int(kaslrSlide[0]) != 0:
            # it is Mac OS
            return 0
        else:
            try:
                dtb = next(self.resolver.QuerySubjectPredicate(self.urn, lexicon.standard.memoryPageTableEntryOffset))
                return int(dtb)
            except:
                # some early images generated by Rekall don't contain a CR3
                return 0 
開發者ID:aff4,項目名稱:pyaff4,代碼行數:17,代碼來源:aff4.py


注:本文中的builtins.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。