当前位置: 首页>>代码示例>>Python>>正文


Python Authentication.getst方法代码示例

本文整理汇总了Python中Authentication.getst方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.getst方法的具体用法?Python Authentication.getst怎么用?Python Authentication.getst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Authentication的用法示例。


在下文中一共展示了Authentication.getst方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Authentication

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
args = parser.parse_args()
username = args.username
password = args.password
version = args.version
string = args.string
uri = "https://uts-ws.nlm.nih.gov"
content_endpoint = "/rest/search/"+version
##get at ticket granting ticket for the session
AuthClient = Authentication(username,password)
tgt = AuthClient.gettgt()
pageNumber=0

while True:
    ##generate a new service ticket for each page if needed
    ticket = AuthClient.getst(tgt)
    pageNumber += 1
    query = {'string':string,'ticket':ticket, 'pageNumber':pageNumber}
    #query['includeObsolete'] = 'true'
    #query['includeSuppressible'] = 'true'
    #query['returnIdType'] = "sourceConcept"
    #query['sabs'] = "SNOMEDCT_US"
    r = requests.get(uri+content_endpoint,params=query)
    r.encoding = 'utf-8'
    items  = json.loads(r.text)
    jsonData = items["result"]
    #print (json.dumps(items, indent = 4))

    print("Results for page " + str(pageNumber)+"\n")
    
    for result in jsonData["results"]:
开发者ID:christinebalili,项目名称:uts-rest-api,代码行数:32,代码来源:search-terms.py

示例2:

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
tgt = AuthClient.gettgt()
uri = "https://uts-ws.nlm.nih.gov"

try:
   source
except NameError:
   source = None
   
if source is None:
    content_endpoint = "/rest/content/"+str(version)+"/CUI/"+str(identifier)

else:
    content_endpoint = "/rest/content/"+str(version)+"/source/"+str(source)+"/"+str(identifier)
    
query = {'ticket':AuthClient.getst(tgt)}
r = requests.get(uri+content_endpoint,params=query)
r.encoding = 'utf-8'
items  = json.loads(r.text)
jsonData = items["result"]

classType = jsonData["classType"]
name = jsonData["name"]
ui = jsonData["ui"]
AtomCount = jsonData["atomCount"]
Definitions = jsonData["definitions"]
Atoms = jsonData["atoms"]
DefaultPreferredAtom = jsonData["defaultPreferredAtom"]

## print out the shared data elements that are common to both the 'Concept' and 'SourceAtomCluster' class
print ("classType: " + classType)
开发者ID:nik7273,项目名称:computable-medicine,代码行数:32,代码来源:UMLS-api-wrapper.py

示例3: open

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
#C2711988 is the CUI for the SNOMED CT CORE Problem List content view
#Full list of content views is here: https://www.nlm.nih.gov/research/umls/knowledge_sources/metathesaurus/release/content_views.html,
#or over web services at https://uts-ws.nlm.nih.gov/rest/content-views/current?ticket=ST...
content_view_endpoint = "/rest/content-views/"+version+"/CUI/C2711988/members"
tgt = AuthClient.gettgt()
pageNumber=1
pageCount=1
f = open(outputfile, 'w')

#column headers - modify accordingly if you are computing a different subset
f.write("SNOMED_CID|NAME|FIRST_IN_SUBSET|IS_RETIRED_FROM_SUBSET|OCCURRENCE|USAGE|REPLACED_BY_SNOMED_CID\n")

##There are ~ 250 pages in this subset, if you're using the default of 25 objects per page.
while pageNumber<=pageCount:
    
    query = {'ticket':AuthClient.getst(tgt),'pageNumber':pageNumber}
    r = requests.get(base_uri+content_view_endpoint,params=query)
    print(r.url+"\n")
    r.encoding = 'utf-8'
    items  = json.loads(r.text)
    pageCount=items["pageCount"]
    
    print("Fetching page " + str(pageNumber)+" of results\n")
    
    for result in items["result"]:
        
        f.write(result["ui"]+"|"+str(result["name"]))
        
        #MOST CONTENT VIEW MEMBERS DO NOT HAVE ATTRIBUTES, BUT FOR MEMBERS OF THE SNOMED CT CORE PROBLEM LIST
        #THESE ARE THE CURRENT LIST OF ATTRIBUTE NAMES THAT ARE DEFINED. HOWEVER, IN THE DATA THEY ARE NOT ALWAYS PRESENT
        #FOR EXAMPLE, IF IS_RETIRED_FROM_SUBSET = True, THERE IS NO 'OCCURRENCE' OR 'USAGE' ATTRIBUTE AVAILABLE, SO WE MUST CHECK AND THEN
开发者ID:HHS,项目名称:uts-rest-api,代码行数:33,代码来源:get-content-view-members.py

示例4: str

# 需要导入模块: import Authentication [as 别名]
# 或者: from Authentication import getst [as 别名]
uri = "https://uts-ws.nlm.nih.gov"

try:
    source
except NameError:
    source = None

##if we don't specify a source vocabulary, assume we're retrieving UMLS CUIs
if source is None:
    content_endpoint = "/rest/content/" + str(version) + "/CUI/" + str(identifier)

else:
    content_endpoint = "/rest/content/" + str(version) + "/source/" + str(source) + "/" + str(identifier)

##ticket is the only parameter needed for this call - paging does not come into play because we're only asking for one Json object
query = {"ticket": AuthClient.getst(tgt)}
r = requests.get(uri + content_endpoint, params=query)
r.encoding = "utf-8"
items = json.loads(r.text)
jsonData = items["result"]

##uncomment the print statment if you want the raw json output, or you can just look at the documentation :=)
# https://documentation.uts.nlm.nih.gov/rest/concept/index.html#sample-output
# https://documentation.uts.nlm.nih.gov/rest/source-asserted-identifiers/index.html#sample-output
# print (json.dumps(items, indent = 4))

############################
### Print out fields ####

classType = jsonData["classType"]
name = jsonData["name"]
开发者ID:HHS,项目名称:uts-rest-api,代码行数:33,代码来源:retrieve-cui-or-code.py


注:本文中的Authentication.getst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。