本文整理匯總了后端語言Python中os.join方法的典型用法及代碼示例,這里的代碼示例可能為您提供幫助。也可以進一步了解該方法所在模塊os的用法示例。
如果想了解web前端內容,包括html,css,Javascript可以點擊相關鏈接查看
示例1: update
# 需要導入模塊: import os [as 別名]
# 或者: from os import join [as 別名]
def update(user, password, lang=None):
langs = getlangs(lang)
puts(u"Updating %s" % ', '.join(langs))
for loc in langs:
with indent(2):
puts(u"Downloading PO for %s" % loc)
url = (u'https://www.transifex.com/projects/p/formhub/'
u'resource/django/l/%(lang)s/download/for_use/' % {'lang': loc})
try:
tmp_po_file = download_with_login(url, TX_LOGIN_URL,
login=user, password=password,
ext='po',
username_field='identification',
password_field='password',
form_id=1)
po_file = os.path.join(REPO_ROOT, 'locale', loc,
'LC_MESSAGES', 'django.po')
with indent(2):
puts(u"Copying downloaded file to %s" % po_file)
shutil.move(tmp_po_file, po_file)
except Exception as e:
puts(colored.red(u"Unable to update %s "
u"from Transifex: %r" % (loc, e)))
puts(colored.green("sucesssfuly retrieved %s" % loc))
compile_mo(langs)
示例2: saveGamepad
# 需要導入模塊: import os [as 別名]
# 或者: from os import join [as 別名]
def saveGamepad(_settings):
parser = SafeConfigParser()
for controller_name in getSetting().getGamepadList():
gamepad = getSetting(controller_name)
if not parser.has_section(controller_name):
parser.add_section(controller_name)
for key,value in gamepad.key_bindings.axis_bindings.iteritems():
neg,pos = value
if not neg: neg = 'none'
if not pos: pos = 'none'
parser.set(controller_name,'a'+str(key),'('+str(neg)+','+str(pos)+')' )
for key,value in gamepad.key_bindings.button_bindings.iteritems():
parser.set(controller_name,'b'+str(key),str(value))
with open(os.path.join(getSetting().datadir.replace('main.exe',''),'settings','gamepads.ini'), 'w') as configfile:
parser.write(configfile)
