本文整理汇总了Python中MyUtil.get_yn方法的典型用法代码示例。如果您正苦于以下问题:Python MyUtil.get_yn方法的具体用法?Python MyUtil.get_yn怎么用?Python MyUtil.get_yn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyUtil
的用法示例。
在下文中一共展示了MyUtil.get_yn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_cid
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def make_cid(dirpath, CID_coll, htmlfile, outroot):
# Get list of DCC documents from a Word file saved as html
GetUrlWord.get_url_word(dirpath + outroot, dirpath + htmlfile)
# Login to DCC
s = DCC.login(CF.dcc_url + CF.dcc_login)
json_handlelist = dirpath + outroot + 'bothlist.txt'
json_ssdata = dirpath + outroot + 'CID.txt'
get_cid_ssdata(s, json_handlelist, json_ssdata)
xlfile = dirpath + outroot + 'CID_Analysis.xls'
write_spreadsheet(json_ssdata, xlfile)
json_verlist = dirpath + outroot + 'ver_list.txt'
json_doclist = dirpath + outroot + 'doc_list.txt'
make_handle_lists(json_ssdata, json_doclist, json_verlist)
## Remove the files that are currently located in the collection for the CID
if MyUtil.get_yn('Remove location (not delete) of files from ' + CID_coll[0] +'(Y/N)?: '):
doclist = DCC.list_obj_in_coll(s, CID_coll[0],Print=True,Jwrite=False,Depth='infinity',Type='Doc')
for doc in doclist:
DCC.dcc_remove_doc_from_coll(s, doc, CID_coll[0])
## Add CID files to the collection
fh = open(json_doclist, 'r')
dl = json.load(fh)
fh.close()
if MyUtil.get_yn('Add CID files to ' + CID_coll[0] +' (Y/N)?: '):
DCC.add_docs_2_collections(s, dl, CID_coll)
# Check that the expected docs are in the collection
DCC.check_docs_in_coll(s, dl, CID_coll)
示例2: make_cid
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def make_cid(dirpath, CID_coll, htmlfile, outroot):
# Get list of DCC documents from a Word file saved as html
GetUrlWord.get_url_word(dirpath + outroot, dirpath + htmlfile)
# Login to DCC
prod = ['prod', 'production', 'p', ' ']
tes = ['test', 'tes', 't']
checker = False
print("Would you like to log into the production site or the test site?")
print("Valid Inputs are as follows: Production, prod, p, test, t :", end="")
choice = input().lower()
#while loop to continue asking the user for input until a correct input has been entered
while (checker == False):
#Production site login choice
if(choice in prod):
print("You are now logging into the Production version of DocuShare")
s = DCC.login(Site ='Production')
checker = True
#test site login choice
elif(choice in tes):
print("You are now logging into the test VM DocuShare")
s = DCC.login(Site ='Test')
checker = True
#cf.dcc_url + cf.dcc_login
#error message alerting user to enter a valid choice
else:
print("Please enter a valid choice, (P)roduction or (T)est")
choice = input().lower()
json_handlelist = dirpath + outroot + 'bothlist.txt'
json_ssdata = dirpath + outroot + 'CID.txt'
get_cid_ssdata(s, json_handlelist, json_ssdata)
xlfile = dirpath + outroot + 'CID_Analysis.xls'
write_spreadsheet(json_ssdata, xlfile)
json_verlist = dirpath + outroot + 'ver_list.txt'
json_doclist = dirpath + outroot + 'doc_list.txt'
make_handle_lists(json_ssdata, json_doclist, json_verlist)
## Remove the files that are currently located in the collection for the CID
if MyUtil.get_yn('Remove location (not delete) of files from ' + CID_coll[0] +'(Y/N)?: '):
doclist = DCC.list_obj_in_coll(s, CID_coll[0],Print=True,Jwrite=False,Depth='infinity',Type='Doc')
for doc in doclist:
DCC.dcc_remove_doc_from_coll(s, doc, CID_coll[0])
## Add CID files to the collection
fh = open(json_doclist, 'r')
dl = json.load(fh)
fh.close()
if MyUtil.get_yn('Add CID files to ' + CID_coll[0] +' (Y/N)?: '):
DCC.add_docs_2_collections(s, dl, CID_coll)
# Check that the expected docs are in the collection
DCC.check_docs_in_coll(s, dl, CID_coll)
示例3: make_perm_changes
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def make_perm_changes(s, handle, permdata, removelist, changelist, addlist, **kwargs):
ask_flag = kwargs.get('Ask',True)
mod_flag = False
if ask_flag == True:
ans = MyUtil.get_all_none_indiv('Make Changes? All/None/Individual (A/N/I)?')
if ans == 'All':
ask_flag = False
elif ans == 'None':
return
for perm in removelist:
print('Remove?: ',end='')
DCC.print_perm(perm)
if ask_flag == False or MyUtil.get_yn(': (Y/N)?'):
if ask_flag == False: print()
mod_flag = True
MyUtil.remove_dict_from_list(permdata['perms'],'handle',perm['handle'])
for chperm in changelist:
print('Change?:', end='')
DCC.print_perm(chperm)
if ask_flag == False or MyUtil.get_yn(': (Y/N)?'):
if ask_flag == False: print()
mod_flag = True
for perm in permdata['perms']:
if perm['handle'] == chperm['handle']:
if 'Read' in perm: del(perm['Read'])
if 'Write'in perm: del(perm['Write'])
if 'Manage' in perm: del(perm['Manage'])
for key,val in chperm.items():
perm[key] = val
for addperm in addlist:
print('Add?:', end='')
DCC.print_perm(addperm)
if ask_flag == False or MyUtil.get_yn(': (Y/N)?'):
if ask_flag == False: print()
mod_flag = True
permdata['perms'].append(addperm)
if debug: DCC.print_perms(permdata)
if mod_flag:
# check ask_flag since it may have been modified from kwargs value
if ask_flag == False:
modify_dcc_perms(s, handle, permdata, Ask=False)
else:
modify_dcc_perms(s,handle,permdata, **kwargs)
示例4: modify_dcc_perms
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def modify_dcc_perms(s, handle, permdata, **kwargs):
ask_flag = kwargs.get('Ask',True)
print('\n Modifying Permissions to:',handle)
DCC.print_perms(permdata)
if ask_flag == False or MyUtil.get_yn('Change Permissions (Y/N)?'):
print('Changing permissions...')
DCC.set_permissions(s, handle, permdata)
示例5: check_perms
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def check_perms(s, set, handles, **kwargs):
ask_flag = kwargs.get('Ask', True)
if not ask_flag:
if not MyUtil.get_yn('!!! Warning !!! ask = False: Will not ask to make changes, okay? Enter N to Exit, Y to Continue:'):
print('exiting...')
sys.exit(0)
for handle in handles:
if 'Document-' in handle:
fd = DCC.prop_get(s, handle, InfoSet = 'DocBasic')
elif 'Collection-' in handle:
fd = DCC.prop_get(s, handle, InfoSet = 'CollData')
else:
fd = DCC.prop_get(s, handle, InfoSet = 'Title')
fd['permissions'] = DCC.prop_get(s, handle, InfoSet = 'Perms')
# print(fd['handle'], ':', fd['title'])
print('\n>>>>>>>>>>>>>> DCC Information <<<<<<<<<<<<<<')
if 'Document-' in handle:
DCC.print_doc_basic(fd)
elif 'Collection-' in handle:
DCC.print_coll_data(fd)
else:
print('Not Document or Collection:', handle, ':', fd['title'])
print('\n\tDoc Properties URL: ',Tree.url_view(handle))
print('\tPermissions URL: ',Tree.url_perm(handle))
print('\tGet Document URL: ',Tree.url_access(handle))
print()
fix_objact(s, fd, handle, set, **kwargs)
fix_permact(s, fd, handle, set, **kwargs)
示例6: fix_objact
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def fix_objact(s, fd, handle, set, **kwargs):
ask_flag = kwargs.get('Ask',True)
if not check_fd_sel(fd, set):
return
for obj_act in set['ObjAct']:
if not obj_act['Action']:
pass
if Match.parse(obj_act['Criteria'], fd):
if obj_act['Action']['Action'] == 'SetOwner':
nu = DCC.prop_get(s, obj_act['Action']['Owner'], InfoSet = 'User')
print('??? Change Owner from [', fd['owner-userid'], ',', fd['owner-username'], '] to [',
nu['owner-userid'], ',', nu['owner-username'], ']', sep = '', end = '')
if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
DCC.change_owner(s, handle, obj_act['Action']['Owner'])
elif obj_act['Action']['Action'] == 'AddKeyword':
print('??? Add Keyword "', obj_act['Action']['Keyword'], '" to "', fd['keywords'].strip(), '"', sep = '', end = '')
if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
kw = obj_act['Action']['Keyword'] + fd['keywords'].strip(' ')
DCC.set_metadata(s, handle, Keywords = kw)
elif obj_act['Action']['Action'] == 'DelKeyword':
print('??? Remove Keyword "', obj_act['Action']['Keyword'], '" from "', fd['keywords'], '"', sep = '', end = '')
if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
kw = fd['keywords'].strip(' ').replace(obj_act['Action']['Keyword'], '')
DCC.set_metadata(s, handle, Keywords = kw)
elif obj_act['Action']['Action'] == 'RepTitle':
print('??? Change Title to "', obj_act['Action']['Title'], '" from "', fd['title'], '"', sep = '', end = '')
if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
DCC.set_metadata(s, handle, Title = obj_act['Action']['Title'])
elif obj_act['Action']['Action'] == 'RepTmtNum':
print('??? Change TmtNum to "', obj_act['Action']['TmtNum'], '" from "', fd['tmtnum'], '"', sep = '', end = '')
if ask_flag == False or MyUtil.get_yn(': (Y/N)? '):
DCC.set_metadata(s, handle, Summary = obj_act['Action']['TmtNum'])
pass
elif obj_act['Action']['Action'] == 'Message':
print(obj_act['Action']['Message'])
else:
print('Error in PERM.fix_objact: ObjAct Action not recognized:', obj_act['Action']['Action'])
示例7: check_perms
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def check_perms(s, set, handle, treename, **kwargs):
ask_flag = kwargs.get('Ask', True)
if not ask_flag:
if not MyUtil.get_yn('!!! Warning !!! ask = False: Will not ask to make changes, okay? Enter N to Exit, Y to Continue:'):
print('exiting...')
sys.exit(0)
tr = Tree.return_tree(s, handle, treename)
handles = Tree.get_flat_tree(tr)
for handle in handles:
fix_set(s, handle, set, **kwargs)
示例8: return_tree
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def return_tree(s, target, rootfilename, **kwargs):
load_flag = kwargs.get("Load")
if load_flag != False and FileSys.file_check_json(s, rootfilename):
if load_flag == None:
load_flag = MyUtil.get_yn("File already exists. [Load from disk = Y, re-create = N] (Y/N)?")
tr = FileSys.file_read_json(rootfilename)
return tr
tr = get_tree(s, target)
# print_tree(s, tr)
FileSys.file_write_json(tr, rootfilename, path=CF.dccfilepath)
return tr
示例9: return_tree
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def return_tree(s, target, rootfilename, **kwargs):
load_flag = kwargs.get('Load')
if FileSys.file_check_json(s, rootfilename) == True:
if load_flag == None:
print('File [',rootfilename,'] already exists - use existing file? ', sep = '', end = '')
load_flag = MyUtil.get_yn('[Load from disk = Y, re-create = N] (Y/N)? ')
if load_flag == True:
tr = FileSys.file_read_json(rootfilename)
FileSys.file_write_json(tr, rootfilename, path = CF.dccfilepath)
return(tr)
tr = get_tree(s,target, **kwargs)
FileSys.file_write_json(tr, rootfilename, path = CF.dccfilepath)
# print_tree(s, tr)
return(tr)
示例10: main
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
def main():
# Login to DCC
s = DCC.login(CF.dcc_url + CF.dcc_login)
#****** SET Flag for asking about changes ******
ask_flag = MyUtil.get_yn('Ask about changes to files *** BE CAREFUL !!! *** (Y/N)? ')
print()
#****** Choose SET ******
### Safe to run without checking ###
# set = PD.SET_REMOVE_RO_IF_SE_READERSHIP
# set = PD.SET_REMOVE_STR_MANAGERS
# set = PD.SET_REMOVE_INACTIVE
set = PD.SET_PUBLISHED
### Don't Run without checking ###
# set = PD.SET_PERM_NRTCPDR
# set = PD.SET_M1CS_PDR
# set = PD.SET_REMOVE_STR_MANAGERS
# set = PD.SET_SE_READERSHIP
# set = PD.SET_IRIS_REMOVE_MATTHIAS_MANAGE_FALSE
# set = PD.SET_IRIS_REMOVE_ISBRUCKER
# set = PD.SET_REPLACE_IRIS_EAR_WITH_ALL
# set = PD.SET_REMOVE_STR_MANAGERS
# set = PD.SET_REMOVE_UNNEEDED
### IRIS Manager Set with removal of group membership
# set = PD.SET_IRIS_TEAM
# ghs = PERM.get_group_handles(s,PD.grp_IRIS_MANAGE)
# for gh in ghs:
# PD.SET_ADD_IRIS_MANAGER['PermAct'].append(PD.remove_user(gh))
# print(PD.SET_ADD_IRIS_MANAGER['PermAct'])
### IRIS Team Set with removal of group members
# set = PD.SET_IRIS_TEAM
# ghs = PERM.get_group_handles(s,PD.grp_IRIS_team)
# for gh in ghs:
# PD.SET_IRIS_TEAM['PermAct'].append(PD.remove_user_ifperms(gh, PD.manage_false))
# print(PD.SET_IRIS_TEAM['PermAct'])
### M1S Team Set with removal of optics group members
# set = PD.SET_M1S_Suijian
#
# PD.remove_user_if_group(s, set, PD.grp_optics, PD.manage_false)
# PD.remove_user_if_group(s, set, PD.grp_niaotEAR, PD.WM_false)
#
# print(PD.SET_M1S_Suijian['PermAct'])
### CRYO Team Set with removal of optics group members
# set = PD.SET_EMPTY
#
# PD.remove_user_if_group(s, set, PD.grp_CryoTeam, PD.manage_false)
# PD.remove_user_if_group(s, set, PD.grp_CryoManager,PD.read_true)
#
# print(PD.SET_EMPTY['PermAct'])
#****** Choose Collection ******
# m1cs_pdr_root = 'Collection-10725'
# m1cs_pdr_presentation = 'Collection-10821'
# handle = m1cs_pdr_presentation
# config_control = 'Collection-8277'
# handle = config_control
IRIS_science = 'Collection-7542'
IRIS = 'Collection-2463'
Change_control = 'Collection-399'
SE_access_handling = 'Collection-2949'
SE_interface_control = 'Collection-195'
SE_budgets = 'Collection-309'
Published = 'Collection-8277'
IRIS_LPDR = 'Collection-11161'
NRTC_PDR = 'Collection-10045'
M1S_suijian_coll = 'Collection-5678'
CRYO_coll = 'Collection-9141'
LGSF_IOE = 'Collection-4956'
ENC_Construction_Phase = 'Collection-10598'
Test = 'Document-27819'
# set = PD.SET_ENC_CONSTRUCTION
# set = PD.SET_REMOVE_RO_IF_SE_READERSHIP
# handle = ENC_Construction_Phase
# handle = Test
handle = Published
#******!!! Run !!! ******
# print(set)
tr = Tree.return_tree(s, handle, 'Tree_' + handle)
handles = Tree.get_flat_tree(tr)
PERM.check_perms(s, set, handles, Ask = ask_flag)
示例11: module
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
import MyUtil
# This code takes a search criteria, defined in "docinfo", and searches
# the DOORS document module (as stored in TraceTree) to find matches.
# It prints a report on all files found based on the list of attributes
# in "docmodreport".
# In setting search criteria it is possible to look for undefined
# attributes by using '_UNASSIGNED' as the matching criteria.
found_flag = False
if os.path.isfile(CF.tracetreefilepath + CF.docmod_dict_file):
print('Found existing DocMod file: ', CF.docmod_dict_file)
found_flag = True
if found_flag == False or MyUtil.get_yn('Create New DocMod File (Y/N)? : '):
print('Creating DocMod file: ', CF.docmod_dict_file)
DocMod.create_docmod_file(CF.docmod_dict_file)
flag_update = MyUtil.get_yn('Do to want to be offered to make changes (Y/N)? ')
# Open the document module
fh = open(CF.tracetreefilepath + CF.docmod_dict_file,'r')
dm = json.load(fh)
fh.close()
# construct reflist to determine the search criteria
reflist = {}
docinfo = {}
docinfo['TMTPublished'] = 'True'
示例12: module
# 需要导入模块: import MyUtil [as 别名]
# 或者: from MyUtil import get_yn [as 别名]
import MyUtil
# This code takes a search criteria, defined in "docinfo", and searches
# the DOORS document module (as stored in TraceTree) to find matches.
# It prints a report on all files found based on the list of attributes
# in "docmodreport".
# In setting search criteria it is possible to look for undefined
# attributes by using '_UNASSIGNED' as the matching criteria.
found_flag = False
if os.path.isfile(CF.tracetreefilepath + CF.docmod_dict_file):
print('Found existing DocMod file: ', CF.docmod_dict_file)
found_flag = True
if found_flag == False or MyUtil.get_yn('Create New DocMod File (Y/N)? : '):
print('Creating DocMod file: ', CF.docmod_dict_file)
DocMod.create_docmod_file(CF.docmod_dict_file)
# Open the document module
fh = open(CF.tracetreefilepath + CF.docmod_dict_file,'r')
dm = json.load(fh)
fh.close()
# construct reflist to determine the search criteria
reflist = {}
docinfo = {}
docinfo['TMTPublished'] = 'True'
reflist['ICD'] = docinfo