BELScriptWalker.g:308:1: define_namespace : ( 'DEFINE' ( (isdefault= 'DEFAULT' )? 'NAMESPACE' ) ) name= OBJECT_IDENT 'AS' 'URL' rloc= QUOTED_VALUE ;
19375
public final BELScriptWalker.define_namespace_return define_namespace() throws RecognitionException {
        BELScriptWalker.define_namespace_return retval = new BELScriptWalker.define_namespace_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        CommonTree _first_0 = null;
        CommonTree _last = null;

        CommonTree isdefault=null;
        CommonTree name=null;
        CommonTree rloc=null;
        CommonTree string_literal23=null;
        CommonTree string_literal24=null;
        CommonTree string_literal25=null;
        CommonTree string_literal26=null;

        CommonTree isdefault_tree=null;
        CommonTree name_tree=null;
        CommonTree rloc_tree=null;
        CommonTree string_literal23_tree=null;
        CommonTree string_literal24_tree=null;
        CommonTree string_literal25_tree=null;
        CommonTree string_literal26_tree=null;

        try {
            // BELScriptWalker.g:308:17: ( ( 'DEFINE' ( (isdefault= 'DEFAULT' )? 'NAMESPACE' ) ) name= OBJECT_IDENT 'AS' 'URL' rloc= QUOTED_VALUE )
            // BELScriptWalker.g:309:5: ( 'DEFINE' ( (isdefault= 'DEFAULT' )? 'NAMESPACE' ) ) name= OBJECT_IDENT 'AS' 'URL' rloc= QUOTED_VALUE
            {
            root_0 = (CommonTree)adaptor.nil();

            // BELScriptWalker.g:309:5: ( 'DEFINE' ( (isdefault= 'DEFAULT' )? 'NAMESPACE' ) )
            // BELScriptWalker.g:309:6: 'DEFINE' ( (isdefault= 'DEFAULT' )? 'NAMESPACE' )
            {
            _last = (CommonTree)input.LT(1);
            string_literal23=(CommonTree)match(input,27,FOLLOW_27_in_define_namespace312); 
            string_literal23_tree = (CommonTree)adaptor.dupNode(string_literal23);

            adaptor.addChild(root_0, string_literal23_tree);

            // BELScriptWalker.g:309:15: ( (isdefault= 'DEFAULT' )? 'NAMESPACE' )
            // BELScriptWalker.g:309:16: (isdefault= 'DEFAULT' )? 'NAMESPACE'
            {
            // BELScriptWalker.g:309:16: (isdefault= 'DEFAULT' )?
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==28) ) {
                alt7=1;
            }
            switch (alt7) {
                case 1 :
                    // BELScriptWalker.g:309:17: isdefault= 'DEFAULT'
                    {
                    _last = (CommonTree)input.LT(1);
                    isdefault=(CommonTree)match(input,28,FOLLOW_28_in_define_namespace318); 
                    isdefault_tree = (CommonTree)adaptor.dupNode(isdefault);

                    adaptor.addChild(root_0, isdefault_tree);


                    }
                    break;

            }

            _last = (CommonTree)input.LT(1);
            string_literal24=(CommonTree)match(input,29,FOLLOW_29_in_define_namespace322); 
            string_literal24_tree = (CommonTree)adaptor.dupNode(string_literal24);

            adaptor.addChild(root_0, string_literal24_tree);


            }


            }

            _last = (CommonTree)input.LT(1);
            name=(CommonTree)match(input,OBJECT_IDENT,FOLLOW_OBJECT_IDENT_in_define_namespace328); 
            name_tree = (CommonTree)adaptor.dupNode(name);

            adaptor.addChild(root_0, name_tree);

            _last = (CommonTree)input.LT(1);
            string_literal25=(CommonTree)match(input,30,FOLLOW_30_in_define_namespace330); 
            string_literal25_tree = (CommonTree)adaptor.dupNode(string_literal25);

            adaptor.addChild(root_0, string_literal25_tree);

            _last = (CommonTree)input.LT(1);
            string_literal26=(CommonTree)match(input,31,FOLLOW_31_in_define_namespace332); 
            string_literal26_tree = (CommonTree)adaptor.dupNode(string_literal26);

            adaptor.addChild(root_0, string_literal26_tree);

            _last = (CommonTree)input.LT(1);
            rloc=(CommonTree)match(input,QUOTED_VALUE,FOLLOW_QUOTED_VALUE_in_define_namespace336); 
            rloc_tree = (CommonTree)adaptor.dupNode(rloc);

            adaptor.addChild(root_0, rloc_tree);


                    final String nametext = name.getText();
                    final String rloctext = rloc.getText();

                    BELNamespaceDefinition belnsd;
                    if (isdefault != null) {
                        belnsd = new BELNamespaceDefinition(nametext, rloctext, true);
                    } else {
                        belnsd = new BELNamespaceDefinition(nametext, rloctext, false);
                    }

                    nslist.add(belnsd);
                    definedNamespaces.put(nametext, belnsd);
                

            }

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
248941
def rpc_get_names_in_namespace( self, namespace_id, offset, count, **con_info ):
        
        if not check_namespace(namespace_id):
            return {'error': 'Invalid name or namespace', 'http_status': 400}

        if not check_offset(offset):
            return {'error': 'invalid offset', 'http_status': 400}

        if not check_count(count, 100):
            return {'error': 'invalid count', 'http_status': 400}

        if not is_namespace_valid( namespace_id ):
            return {'error': 'invalid namespace ID', 'http_status': 400}

        db = get_db_state(self.working_dir)
        res = db.get_names_in_namespace( namespace_id, offset=offset, count=count )
        db.close()

        return self.success_response( {'names': res} )
1146847
def _create_namespace(namespace, apiserver_url):
    '''  '''
    # Prepare URL
    url = "{0}/api/v1/namespaces".format(apiserver_url)
    # Prepare data
    data = {
        "kind": "Namespace",
        "apiVersion": "v1",
        "metadata": {
            "name": namespace,
        }
    }
    log.trace("namespace creation requests: %s", data)
    # Make request
    ret = _kpost(url, data)
    log.trace("result is: %s", ret)
    # Check requests status
    return ret
334956
public final void mOBJECT_IDENT() throws RecognitionException {
        try {
            int _type = OBJECT_IDENT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:277:13: ( ( '_' | LETTER | DIGIT )+ )
            // BELScript.g:278:5: ( '_' | LETTER | DIGIT )+
            {
            // BELScript.g:278:5: ( '_' | LETTER | DIGIT )+
            int cnt7=0;
            loop7:
            do {
                int alt7=2;
                int LA7_0 = input.LA(1);

                if ( ((LA7_0>='0' && LA7_0<='9')||(LA7_0>='A' && LA7_0<='Z')||LA7_0=='_'||(LA7_0>='a' && LA7_0<='z')) ) {
                    alt7=1;
                }


                switch (alt7) {
            	case 1 :
            	    // BELScript.g:
            	    {
            	    if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) {
            	        input.consume();

            	    }
            	    else {
            	        MismatchedSetException mse = new MismatchedSetException(null,input);
            	        recover(mse);
            	        throw mse;}


            	    }
            	    break;

            	default :
            	    if ( cnt7 >= 1 ) break loop7;
                        EarlyExitException eee =
                            new EarlyExitException(7, input);
                        throw eee;
                }
                cnt7++;
            } while (true);


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
406064
def process_parsed_args(opts: Namespace, error_fun: Optional[Callable], connect: bool=True) -> Namespace:
    
    def setdefault(vn: str, default: object) -> None:
        assert vn in opts, "Unknown option"
        if not getattr(opts, vn):
            setattr(opts, vn, default)

    if error_fun and \
            (getattr(opts, 'dburl') is None or getattr(opts, 'user') is None or getattr(opts, 'password') is None):
        error_fun("db url, user id and password must be supplied")
    setdefault('crcdb', opts.dburl)
    setdefault('crcuser', opts.user)
    setdefault('crcpassword', opts.password)
    setdefault('ontodb', opts.dburl)
    setdefault('ontouser', opts.user)
    setdefault('ontopassword', opts.password)
    if connect:
        opts.tables = I2B2Tables(opts)

    # TODO: This approach needs to be re-thought.  As i2b2tablenames is a singleton, any changes here
    # impact the entire testing harness
    if opts.onttable:
        i2b2tablenames.ontology_table = opts.onttable
    return opts
934548
def __parse_namespace(self):
        
        if self.manifest.has_option('config', 'namespace'):
            return self.manifest.get('config', 'namespace')
        elif self.manifest.has_option('config', 'source'):
            return NAMESPACE_REGEX.search(self.manifest.get('config', 'source')).groups()[0]
        else:
            logger.warn('Could not parse namespace implicitely')
            return None
779338
QName constructQName(XMLLibImpl lib, Context cx, Object namespace, Object name) {
        String nameString = null;
        if (name instanceof QName) {
            if (namespace == Undefined.instance) {
                return (QName)name;
            } else {
                nameString = ((QName)name).localName();
            }
        }
        if (name == Undefined.instance) {
            nameString = "";
        } else {
            nameString = ScriptRuntime.toString(name);
        }

        if (namespace == Undefined.instance) {
            if ("*".equals(nameString)) {
                namespace = null;
            } else {
                namespace = lib.getDefaultNamespace(cx);
            }
        }
        Namespace namespaceNamespace = null;
        if (namespace == null) {
            //    leave as null
        } else if (namespace instanceof Namespace) {
            namespaceNamespace = (Namespace)namespace;
        } else {
            namespaceNamespace = lib.newNamespace(ScriptRuntime.toString(namespace));
        }
        String q_localName = nameString;
        String q_uri;
        String q_prefix;
        if (namespace == null) {
            q_uri = null;
            q_prefix = null;    //    corresponds to undefined; see QName class
        } else {
            q_uri = namespaceNamespace.uri();
            q_prefix = namespaceNamespace.prefix();
        }
        return newQName(lib, q_uri, q_localName, q_prefix);
    }
1321451
def capture_url_missing_namespace(self, node):
        
        for arg in node.args:
            if not(isinstance(arg, ast.Call) and isinstance(arg.func, ast.Name)):
                continue
            if arg.func.id != 'include':
                continue
            for keyword in arg.keywords:
                if keyword.arg == 'namespace':
                    return

            return DJ05(
                lineno=node.lineno,
                col=node.col_offset,
            )
86249
def literal_to_ObjectLiteral(self, literal: ShExDocParser.LiteralContext) -> ShExJ.ObjectLiteral:
        
        rval = ShExJ.ObjectLiteral()
        if literal.rdfLiteral():
            rdflit = literal.rdfLiteral()
            txt = rdflit.string().getText()
            quote_char = ''
            if len(txt) > 5 and (txt.startswith("'''") and txt.endswith("'''") or
                                 txt.startswith('"""') and txt.endswith('"""')):
                txt = txt[3:-3]
            else:
                quote_char = txt[0]
                txt = txt[1:-1]

            txt = self.fix_text_escapes(txt, quote_char)
            rval.value = jsg.String(txt)
            if rdflit.LANGTAG():
                rval.language = ShExJ.LANGTAG(rdflit.LANGTAG().getText()[1:].lower())
            if rdflit.datatype():
                rval.type = self.iri_to_str(rdflit.datatype().iri())
        elif literal.numericLiteral():
            numlit = literal.numericLiteral()
            if numlit.INTEGER():
                rval.value = jsg.String(numlit.INTEGER().getText())
                rval.type = RDF_INTEGER_TYPE
            elif numlit.DECIMAL():
                rval.value = jsg.String(numlit.DECIMAL().getText())
                rval.type = RDF_DECIMAL_TYPE
            elif numlit.DOUBLE():
                rval.value = jsg.String(numlit.DOUBLE().getText())
                rval.type = RDF_DOUBLE_TYPE
        elif literal.booleanLiteral():
            rval.value = jsg.String(literal.booleanLiteral().getText().lower())
            rval.type = RDF_BOOL_TYPE
        return rval
571425
def p_namespace(self, p):
        ''''''
        p[0] = ast.Namespace(scope=p[2], name=p[3], lineno=p.lineno(1))
804223
function (body, value, constant) {

            // we want to match "define('CONST', 'blah');" with any whitespace and any quote type
            // note that heredoc and now doc are NOT covered

            // Quote matching possiblities
            // JS doesn't support look backs, not sure if there is a more elegant solution (maybe with capture groups?)
            var envRegexSLSR = new RegExp("(define\\s*\\(\\s*[']" + constant + "[']\\s*,\\s*['])[^']*([']\\s*\\)\\s*;)"),
                envRegexSLDR = new RegExp("(define\\s*\\(\\s*[']" + constant + "[']\\s*,\\s*[\"])[^\"]*([\"]\\s*\\)\\s*;)"),
                envRegexDLDR = new RegExp("(define\\s*\\(\\s*[\"]" + constant + "[\"]\\s*,\\s*[\"])[^\"]*([\"]\\s*\\)\\s*;)"),
                envRegexDLSR = new RegExp("(define\\s*\\(\\s*[\"]" + constant + "[\"]\\s*,\\s*['])[^']*([']\\s*\\)\\s*;)"),
                envRegexSLNR = new RegExp("(define\\s*\\(\\s*[']" + constant + "[']\\s*,\\s*)[^\\s]+(\\s*\\)\\s*;)"),
                envRegexDLNR = new RegExp("(define\\s*\\(\\s*[\"]" + constant + "[\"]\\s*,\\s*)[^\\s]+(\\s*\\)\\s*;)"),
                lines = body.replace(/\r\n/g, '\n').split(/\n/),
                output = [];

            lines.forEach(function (oneLine) {
                // If a regex matches, that's it, we stop

                var theEnv =    envRegexSLSR.exec(oneLine) ||
                                envRegexSLDR.exec(oneLine) ||
                                envRegexDLDR.exec(oneLine) ||
                                envRegexDLSR.exec(oneLine) ||
                                envRegexSLNR.exec(oneLine) ||
                                envRegexDLNR.exec(oneLine);


                if (theEnv) {
                    oneLine = updateLine(oneLine, theEnv, value);
                }

                output.push(oneLine);

            });

            return output.join('\n');
        }
546712
def get_or_create_annotation(self, url: str) -> Namespace:
        
        result = self.get_namespace_by_url(url)

        if result is not None:
            return result

        t = time.time()

        bel_resource = get_bel_resource(url)

        result = Namespace(
            url=url,
            is_annotation=True,
            **_get_annotation_insert_values(bel_resource)
        )
        result.entries = [
            NamespaceEntry(name=name, identifier=label)
            for name, label in bel_resource['Values'].items()
            if name
        ]

        self.session.add(result)
        self.session.commit()

        log.info('inserted annotation: %s (%d terms in %.2f seconds)', url, len(bel_resource['Values']),
                 time.time() - t)

        return result
1295984
public void eInit(SarlScript script, String name, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlSpace == null) {
			this.sarlSpace = SarlFactory.eINSTANCE.createSarlSpace();
			script.getXtendTypes().add(this.sarlSpace);
			this.sarlSpace.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendTypeDeclaration());
			if (!Strings.isEmpty(name)) {
				this.sarlSpace.setName(name);
			}
		}
	}
941441
def root_namespace(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "root_namespace", value)
        self.__root_namespace = value
1337640
def DEFINE_string(  # pylint: disable=invalid-name,redefined-builtin
    name, default, help, flag_values=_flagvalues.FLAGS, **args):
  """"""
  parser = _argument_parser.ArgumentParser()
  serializer = _argument_parser.ArgumentSerializer()
  DEFINE(parser, name, default, help, flag_values, serializer, **args)
593183
def namespace(self, namespace):
        """"""
        # pylint: disable=attribute-defined-outside-init
        self._namespace = _ensure_unicode(namespace)
        if self._namespace is not None:
            # In Python 3, a byte string cannot be stripped by a unicode char
            # Therefore, the stripping needs to be done after the unicode
            # conversion.
            self._namespace = self._namespace.strip('/')
907634
def namedb_namespace_insert( cur, input_namespace_rec ):
    

    namespace_rec = copy.deepcopy( input_namespace_rec )

    namedb_namespace_fields_check( namespace_rec )

    try:
        query, values = namedb_insert_prepare( cur, namespace_rec, "namespaces" )
    except Exception, e:
        log.exception(e)
        log.error("FATAL: Failed to insert revealed namespace '%s'" % namespace_rec['namespace_id']) 
        os.abort()

    namedb_query_execute( cur, query, values )
    return True