brand namespace instance to keep track of subspace root
490505
function Namespace(path, hex) {
  this.hex = !!hex
  this.keyEncoding = hex ? 'utf8' : 'binary'

  this.path = path
  this.buffer = bytewise.encode(path)
  this.prehooks = []
  this.posthooks = []
}
938071
def __normalize_name(self, name):
        

        if not name.startswith(self.__root_namespace):
            name = foundations.namespace.set_namespace(self.__root_namespace,
                                                       foundations.namespace.set_namespace(self.__default_namespace,
                                                                                           name))
            LOGGER.debug("> Normalized name: '{0}'.".format(name))
            return name
        else:
            LOGGER.debug("> Name '{0}' is already normalized!".format(name))
            return name
936541
def main(client, adgroup_id):
  """"""
  adgroup_criterion_service = client.GetService(
      'AdGroupCriterionService', version='v201809')

  helper = ProductPartitionHelper(adgroup_id)

  # The most trivial partition tree has only a unit node as the root, e.g.:
  # helper.CreateUnit(bid_amount=100000)

  root = helper.CreateSubdivision()

  new_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
      'condition': 'NEW'
  }

  used_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
      'condition': 'USED'
  }

  other_product_canonical_condition = {
      'xsi_type': 'ProductCanonicalCondition',
  }

  helper.CreateUnit(root, new_product_canonical_condition, 200000)
  helper.CreateUnit(root, used_product_canonical_condition, 100000)
  other_condition = helper.CreateSubdivision(
      root, other_product_canonical_condition)

  cool_product_brand = {
      'xsi_type': 'ProductBrand',
      'value': 'CoolBrand'
  }

  cheap_product_brand = {
      'xsi_type': 'ProductBrand',
      'value': 'CheapBrand'
  }

  other_product_brand = {
      'xsi_type': 'ProductBrand',
  }

  helper.CreateUnit(other_condition, cool_product_brand, 900000)
  helper.CreateUnit(other_condition, cheap_product_brand, 10000)
  other_brand = helper.CreateSubdivision(other_condition, other_product_brand)

  # The value for the bidding category is a fixed ID for the 'Luggage & Bags'
  # category. You can retrieve IDs for categories from the ConstantDataService.
  # See the 'GetProductTaxonomy' example for more details.
  luggage_category = {
      'xsi_type': 'ProductBiddingCategory',
      'type': 'BIDDING_CATEGORY_L1',
      'value': '-5914235892932915235'
  }

  generic_category = {
      'xsi_type': 'ProductBiddingCategory',
      'type': 'BIDDING_CATEGORY_L1',
  }

  helper.CreateUnit(other_brand, luggage_category, 750000)
  helper.CreateUnit(other_brand, generic_category, 110000)

  # Make the mutate request
  result = adgroup_criterion_service.mutate(helper.GetOperations())

  children = {}

  root_node = None

  # For each criterion, make an array containing each of its children.
  # We always create the parent before the child, so we can rely on that here.
  for adgroup_criterion in result['value']:
    children[adgroup_criterion['criterion']['id']] = []

    if 'parentCriterionId' in adgroup_criterion['criterion']:
      children[adgroup_criterion['criterion']['parentCriterionId']].append(
          adgroup_criterion['criterion'])
    else:
      root_node = adgroup_criterion['criterion']

  # Show the tree
  DisplayTree(root_node, children)
685495
def namedb_get_namespace_by_preorder_hash( cur, preorder_hash, include_history=True ):
    

    select_query = "SELECT * FROM namespaces WHERE preorder_hash = ?;"
    namespace_rows = namedb_query_execute( cur, select_query, (preorder_hash,))

    namespace_row = namespace_rows.fetchone()
    if namespace_row is None:
        # no such namespace 
        return None 

    namespace = {}
    namespace.update( namespace_row )

    if include_history:
        hist = namedb_get_history( cur, namespace['namespace_id'] )
        namespace['history'] = hist

    namespace = op_decanonicalize(op_get_opcode_name(namespace['op']), namespace)
    return namespace
711918
def name_match(self, elt):
        '''
        '''
        return self.pname == elt.localName and \
                    self.nspname in [None, '', elt.namespaceURI]
46870
def namespace(self, name=None, function=None, recursive=None):
        

        return (
            self._find_single(
                scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
                name=name,
                function=function,
                recursive=recursive)
        )
1086358
def gridfs_namespace(self, plain_src_ns):
        
        namespace = self.lookup(plain_src_ns)
        if namespace and namespace.gridfs:
            return namespace.dest_name
        return None
580079
def __applytns(self, root):
        """"""
        TNS = "targetNamespace"
        tns = root.get(TNS)
        if tns is None:
            tns = self.schema.tns[1]
            root.set(TNS, tns)
        else:
            if self.schema.tns[1] != tns:
                raise Exception, "%s mismatch" % TNS
391804
def match(self, root, ns):
        
        tns = root.get('targetNamespace')
        if len(self.tns):
            matched = ( tns in self.tns )
        else:
            matched = 1
        itself = ( ns == tns )
        return ( matched and not itself )
982924
private void checkNamespaces() {
    for (Name name : nameMap.values()) {
      if (name.isNamespaceObjectLit()
          && (name.getAliasingGets() > 0
              || name.getLocalSets() + name.getGlobalSets() > 1
              || name.getDeleteProps() > 0)) {
        boolean initialized = name.getDeclaration() != null;
        for (Ref ref : name.getRefs()) {
          if (ref == name.getDeclaration()) {
            continue;
          }

          if (ref.type == Ref.Type.DELETE_PROP) {
            if (initialized) {
              warnAboutNamespaceRedefinition(name, ref);
            }
          } else if (
              ref.type == Ref.Type.SET_FROM_GLOBAL
              || ref.type == Ref.Type.SET_FROM_LOCAL) {
            if (initialized && !isSafeNamespaceReinit(ref)) {
              warnAboutNamespaceRedefinition(name, ref);
            }

            initialized = true;
          } else if (ref.type == Ref.Type.ALIASING_GET) {
            warnAboutNamespaceAliasing(name, ref);
          }
        }
      }
    }
  }
346142
def namespace(self, prefix=None):
        
        ns = self.schema.tns
        if ns[0] is None:
            ns = (prefix, ns[1])
        return ns
72073
def _run_namespace(self, doc):
        """"""
        for receiver in self.receivers[doc['ns']]:
            params = self.receivers[doc['ns']][receiver]
            if params[doc['op']]:
                if params[doc['op']] is True or str(doc['o']['_id']) in params[doc['op']]:
                    notification_id = self._notify_receiver(receiver, params, doc)
                    if params['reliable'] and self._max_attempts > 1:
                        self.notifications[notification_id] = {
                            'receiver': receiver,
                            'params': dict(params),
                            'doc': dict(doc),
                            'ts': datetime.datetime.utcnow(),
                            'attempts': 1}
43194
def add_namespace(self, name, a_namespace):
        """"""
        # save a local copy of the namespace
        self.namespaces[name] = a_namespace
        # iterate through the namespace branding each of the options with the
        # name of the subparser to which they belong
        for k in a_namespace.keys_breadth_first():
            an_option = a_namespace[k]
            if not an_option.foreign_data:
                an_option.foreign_data = DotDict()
            an_option.foreign_data['argparse.owning_subparser_name'] = name
1120478
def namespace_present(name, **kwargs):
    '''
    

    '''
    ret = {'name': name,
           'changes': {},
           'result': False,
           'comment': ''}

    namespace = __salt__['kubernetes.show_namespace'](name, **kwargs)

    if namespace is None:
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = 'The namespace is going to be created'
            return ret

        res = __salt__['kubernetes.create_namespace'](name, **kwargs)
        ret['result'] = True
        ret['changes']['namespace'] = {
            'old': {},
            'new': res}
    else:
        ret['result'] = True if not __opts__['test'] else None
        ret['comment'] = 'The namespace already exists'

    return ret
1248455
protected String lookupNamespaceURIImpl(String name) {
        String prefix = getPrefixFromQualifiedName(name);
        String namespaceURI = this.xmlNode.lookupNamespaceURI(prefix);
        return namespaceURI;
    }
223232
def ensure_default_namespace(self) -> Namespace:
        """"""
        namespace = self.get_namespace_by_keyword_version(BEL_DEFAULT_NAMESPACE, BEL_DEFAULT_NAMESPACE_VERSION)

        if namespace is None:
            namespace = Namespace(
                name='BEL Default Namespace',
                contact='charles.hoyt@scai.fraunhofer.de',
                keyword=BEL_DEFAULT_NAMESPACE,
                version=BEL_DEFAULT_NAMESPACE_VERSION,
                url=BEL_DEFAULT_NAMESPACE_URL,
            )

            for name in set(chain(pmod_mappings, gmod_mappings, activity_mapping, compartment_mapping)):
                entry = NamespaceEntry(name=name, namespace=namespace)
                self.session.add(entry)

            self.session.add(namespace)
            self.session.commit()

        return namespace
1322973
def history(namespace_module):
    """"""
    for path in get_namespace_history(namespace_module):
        h = get_bel_resource_hash(path.as_posix())
        click.echo('{}\t{}'.format(path, h))