Use CiscoConfParse to find parent lines that contain a specific child line.

    :param parent: The parent line to search for
    :param child:  The child line required under the given parent
    :param config: The device running/startup config
765085
def cisco_conf_parse_parents(parent, child, config):
    
    if type(config) == str:
        config = config.splitlines()
    parse = CiscoConfParse(config)
    cfg_obj = parse.find_parents_w_child(parent, child)
    return cfg_obj
1325944
def check_node_parent(
        self, resource_id, new_parent_id, db_session=None, *args, **kwargs
    ):
        
        return self.service.check_node_parent(
            resource_id=resource_id,
            new_parent_id=new_parent_id,
            db_session=db_session,
            *args,
            **kwargs
        )
567540
def do_get_config(self, line):
        

        def f(p, args):
            try:
                source = args[0]
            except:
                print("argument error")
                return
            print(p.get_config(source))

        self._request(line, f)
1020482
def _gather_config_parms(self, is_provider_vlan, vlan_id):
        """"""
        if is_provider_vlan:
            auto_create = cfg.CONF.ml2_cisco.provider_vlan_auto_create
            auto_trunk = cfg.CONF.ml2_cisco.provider_vlan_auto_trunk
        else:
            auto_create = True
            auto_trunk = True
        return auto_create, auto_trunk
410731
def parent(self):
        
        if len(self.nodes) > 0:
            parent = self.nodes[-1].proxy
        else:
            parent = None
        return parent
1233142
public static function queryByParent( $parentId, $parentType, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'parentId=:pid AND parentType=:ptype AND siteId=:siteId', [ ':pid' => $parentId, ':ptype' => $parentType, ':siteId' => $siteId ] );
		}
		else {

			return static::find()->where( 'parentId=:pid AND parentType=:ptype', [ ':pid' => $parentId, ':ptype' => $parentType ] );
		}
	}
237489
def parent(version=None, include=None):
    '''
    
    '''
    parser = argparse.ArgumentParser(add_help=False)
    add_default_args(parser, version=version, include=include)
    return parser
702285
def parents(self, as_resources=False):

		'''
		
		'''

		parents = [o for s,p,o in self.rdf.graph.triples((None, self.rdf.prefixes.fedora.hasParent, None))]

		# if as_resources, issue GET requests for children and return
		if as_resources:
			logger.debug('retrieving parent as resource')
			parents = [ self.repo.get_resource(parent) for parent in parents ]

		return parents
1166956
def parent_for_matching_rest_name(self, rest_names):
        

        parent = self

        while parent:
            if parent.rest_name in rest_names:
                return parent

            parent = parent.parent_object

        return None
338958
public function getByParent( $parentId, $parentType, $config = [] ) {

		$modelClass	= static::$modelClass;

		return $modelClass::findByParent( $parentId, $parentType, $config );
	}
643646
def parent_chain(self):
        
        chain = [self]
        while True:
            try:
                parent = chain[-1].parent
            except Exception:
                break
            if parent is None:
                break
            chain.append(parent)
        return chain
672096
def parent_child_paths(path, some_path):
        
        return PathFilterUtil.is_child(path, some_path) or PathFilterUtil.is_child(some_path, path)
592226
def addparent(args):
    
    p = OptionParser(addparent.__doc__)
    p.add_option("--childfeat", default="CDS", help="Type of children feature")
    p.add_option("--parentfeat", default="mRNA", help="Type of merged feature")
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    gff_file, = args
    gff = Gff(gff_file)
    data = defaultdict(list)
    for g in gff:
        if g.type != opts.childfeat:
            continue
        data[g.parent].append(g)

    logging.debug("A total of {0} {1} features clustered".\
                    format(len(data), opts.childfeat))

    parents = []
    for parent, dd in data.items():
        d = dd[0]
        start, end = min(x.start for x in dd), max(x.end for x in dd)
        gffline = "\t".join(str(x) for x in \
                        (d.seqid, d.source, opts.parentfeat, start, end,
                         ".", d.strand, ".", "ID={0};Name={0}".format(parent)))
        parents.append(GffLine(gffline))
    parents.sort(key=lambda x: (x.seqid, x.start))
    logging.debug("Merged feature sorted")

    fw = must_open(opts.outfile, "w")
    for parent in parents:
        print(parent, file=fw)
        parent_id = parent.id
        for d in data[parent_id]:
            if d.accn == parent_id:
                new_id = "{0}.{1}1".format(parent_id, opts.childfeat)
                d.set_attr("ID", new_id)
                d.set_attr("Name", new_id, update=True)
            print(d, file=fw)
    fw.close()
58512
protected T getParentFromConfig() {
      //TODO: Move this to a converter
      String parentName = Config.get(canonicalName(), "parent").asString(null);
      if (parentName != null && DynamicEnum.isDefined(Cast.as(getClass()), parentName)) {
         return DynamicEnum.valueOf(Cast.as(getClass()), parentName);
      } else if (parentName != null) {
         try {
            parentName = parentName.replaceFirst(Pattern.quote(getClass().getCanonicalName()), "");
            DynamicEnum.register(Cast.as(Reflect.onClass(getClass()).invoke("create", parentName).get()));
         } catch (ReflectionException e) {
            return null;
         }
      }
      return null;
   }
942497
def search(self, keyword, children=None, arg=None):
        
        if children is None:
            children = self.substmts
        return [ ch for ch in children
                 if (ch.keyword == keyword and
                     (arg is None or ch.arg == arg))]
657964
def has_child(self, child):
        
        if u'children' not in self:
            return False

        if not isinstance(child, basestring):
            child = child.get_id()

        return child in self.children
1272648
def _merge_configuration(self, parent_config, child_options):
        
        # Copy the parent error codes so we won't override them
        error_codes = copy.deepcopy(parent_config.checked_codes)
        if self._has_exclusive_option(child_options):
            error_codes = self._get_exclusive_error_codes(child_options)

        self._set_add_options(error_codes, child_options)

        kwargs = dict(checked_codes=error_codes)
        for key in ('match', 'match_dir', 'ignore_decorators'):
            kwargs[key] = \
                getattr(child_options, key) or getattr(parent_config, key)
        return CheckConfiguration(**kwargs)