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


Python os.join方法代码示例

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


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

示例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) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:27,代码来源:i18ntool.py

示例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) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:20,代码来源:settingsManager.py

示例3: savePreset

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def savePreset(_settings, _preset):
    parser = SafeConfigParser()
    
    parser.set(_preset,'gravityMultiplier',_settings['gravity'] * 100)
    parser.set(_preset,'weightMultiplier',_settings['weight'] * 100)
    parser.set(_preset,'frictionMultiplier',_settings['friction'] * 100)
    parser.set(_preset,'airControlMultiplier',_settings['airControl'] * 100)
    parser.set(_preset,'hitstunMultiplier',_settings['hitstun'] * 100)
    parser.set(_preset,'hitlagMultiplier',_settings['hitlag'] * 100)
    parser.set(_preset,'shieldStunMultiplier',_settings['shieldStun'] * 100)
    
    parser.set(_preset,'ledgeConflict',_settings['ledgeConflict'])
    sweetSpotDict = {[128,128]: 'large', [64,64]: 'medium', [32,32]: 'small'}
    parser.set(_preset,'ledgeSweetspotSize',sweetSpotDict[_settings['ledgeSweetspotSize']])
    parser.set(_preset,'ledgeSweetspotForwardOnly',_settings['ledgeSweetspotForwardOnly'])
    parser.set(_preset,'teamLedgeConflict',_settings['teamLedgeConflict'])
    parser.set(_preset,'ledgeInvincibilityTime',_settings['ledgeInvincibilityTime'])
    parser.set(_preset,'regrabInvincibility',_settings['regrabInvincibility'])
    parser.set(_preset,'slowLedgeWakeupThreshold',_settings['slowLedgeWakeupThreshold'])
    
    parser.set(_preset,'airDodgeType',_settings['airDodgeType'])
    parser.set(_preset,'freeDodgeSpecialFall',_settings['freeDodgeSpecialFall'])
    parser.set(_preset,'enableWavedash',_settings['enableWavedash'])
    
    parser.write(os.path.join(_settings.datadir.replace('main.exe',''),'settings.ini')) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:27,代码来源:settingsManager.py

示例4: run

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def run(self):
        print("run says hi: ")
        sys.stdout.flush()
        # pylint: disable=no-self-use
        while True:
            with open(DAEMON_FIFO, "r") as fifo:
                try:
                    params = fifo.read()
                    print("run says hi: " + params)
                    sys.stdout.flush()
                    tmpdirname, return_fifo, k = json.loads(params)
                    common_file, part_file, out_file = [
                        os.join(tmpdirname, name) for name in _BASENAMES
                    ]
                    print([common_file, part_file, out_file, return_fifo, k])
                    sys.stdout.flush()

                except:  # pylint: disable=bare-except

                    # SOMETHING WENT WRONG, RESPOND WITH A NON-ZERO
                    try:
                        with open(return_fifo, "w") as rf:
                            rf.write("1")
                    except:  # pylint: disable=bare-except
                        pass
                    else:
                        print("daemon something went wrong: ")
                        sys.stdout.flush()

                else:

                    # SEND THE SUCCESS RESPONSE
                    print("daemon all done: ")
                    sys.stdout.flush()
                    with open(return_fifo, "w") as rf:
                        rf.write("0") 
开发者ID:microsoft,项目名称:SparseSC,代码行数:38,代码来源:scgrad.py

示例5: add

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def add(lang):
    langs = getlangs(lang)
    puts(u"Adding %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Generating PO for %s" % loc)
        shell_call(u"django-admin.py makemessages -l %(lang)s "
                   u"-e py,html,email,txt" % {'lang': loc})
        for app in I18N_APPS:
            with indent(4):
                puts(u"Generating PO for app %s" % app)
            with chdir(os.path.join(REPO_ROOT, app)):
                shell_call(u"django-admin.py makemessages "
                           u"-d djangojs -l %(lang)s" % {'lang': loc})
        puts(colored.green("sucesssfuly generated %s" % loc)) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:17,代码来源:i18ntool.py

示例6: compile_mo

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def compile_mo(lang=None):
    langs = getlangs(lang)
    puts(u"Compiling %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Compiling %s" % loc)
        shell_call(u"django-admin.py compilemessages -l %(lang)s "
                   % {'lang': loc})
        for app in I18N_APPS:
            with indent(4):
                puts(u"Compiling app %s" % app)
            with chdir(os.path.join(REPO_ROOT, app)):
                shell_call(u"django-admin.py compilemessages -l %(lang)s"
                           % {'lang': loc})
        puts(colored.green("sucesssfuly compiled %s" % loc)) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:17,代码来源:i18ntool.py

示例7: createPath

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def createPath(_path):
    if getattr(sys, 'frozen', False):
        # The application is frozen
        datadir = os.path.dirname(sys.executable)
    else:
        # The application is not frozen
        # Change this bit to match where you store your data files:
        datadir = os.path.dirname(__file__)
    return os.path.join(datadir.replace('main.exe',''),_path) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:11,代码来源:settingsManager.py

示例8: importFromURI

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def importFromURI(_filePath, _uri, _absl=False, _suffix=""):
    if not _absl:
        _uri = os.path.normpath(os.path.join(os.path.dirname(_filePath).replace('main.exe',''), _uri))
    #print(_uri)
    path, fname = os.path.split(_uri)
    mname, ext = os.path.splitext(fname)
    
    no_ext = os.path.join(path, mname)
    
    if os.path.exists(no_ext + '.py'):
        try:
            return imp.load_source((mname + _suffix), no_ext + '.py')
        except Exception as e:
            print(mname, e) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:16,代码来源:settingsManager.py

示例9: loadGameSettings

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def loadGameSettings(self,_presetSuf):
        preset_parser = SafeConfigParser()
        preset_parser.read(os.path.join(os.path.join(self.datadir.replace('main.exe','').replace('main.exe',''),'settings/rules',),_presetSuf+'.ini'))
        
        preset = 'preset_' + _presetSuf
        self.setting['current_preset'] = _presetSuf
        
        self.setting['gravity'] = float(getNumber(preset_parser, preset, 'gravityMultiplier')) / 100.0
        self.setting['weight'] = float(getNumber(preset_parser, preset, 'weightMultiplier')) / 100.0
        self.setting['friction'] = float(getNumber(preset_parser, preset, 'frictionMultiplier')) / 100.0
        self.setting['airControl'] = float(getNumber(preset_parser, preset, 'airControlMultiplier')) / 100.0
        self.setting['hitstun'] = float(getNumber(preset_parser, preset, 'hitstunMultiplier')) / 100.0
        self.setting['hitlag'] = float(getNumber(preset_parser, preset, 'hitlagMultiplier')) / 100.0
        self.setting['shieldStun'] = float(getNumber(preset_parser, preset, 'shieldStunMultiplier')) / 100.0
        
        self.setting['ledgeConflict'] = getString(preset_parser, preset, 'ledgeConflict')
        sweetSpotDict = {'large': [128,128], 'medium': [64,64], 'small': [32,32]}
        self.setting['ledgeSweetspotSize'] = sweetSpotDict[getString(preset_parser, preset, 'ledgeSweetspotSize')]
        self.setting['ledgeSweetspotForwardOnly'] = getBoolean(preset_parser, preset, 'ledgeSweetspotForwardOnly')
        self.setting['teamLedgeConflict'] = getBoolean(preset_parser, preset, 'teamLedgeConflict')
        self.setting['ledgeInvincibilityTime'] = getNumber(preset_parser, preset, 'ledgeInvincibilityTime')
        self.setting['regrabInvincibility'] = getBoolean(preset_parser, preset, 'regrabInvincibility')
        self.setting['slowLedgeWakeupThreshold'] = getNumber(preset_parser, preset, 'slowLedgeWakeupThreshold')

        self.setting['respawnDowntime'] = int(getNumber(preset_parser, preset, 'respawnDowntime'))
        self.setting['respawnLifetime'] = int(getNumber(preset_parser, preset, 'respawnLifetime'))
        self.setting['respawnInvincibility'] = int(getNumber(preset_parser, preset, 'respawnInvincibility'))
        
        self.setting['airDodgeType'] = getString(preset_parser, preset, 'airDodgeType')
        self.setting['freeDodgeSpecialFall'] = getBoolean(preset_parser, preset, 'freeDodgeSpecialFall')
        self.setting['enableWavedash'] = getBoolean(preset_parser, preset, 'enableWavedash')     
        self.setting['airDodgeLag'] = int(getNumber(preset_parser, preset, 'airDodgeLag'))
        
        self.setting['lagCancel'] = getString(preset_parser, preset, 'lagCancel')
        
        print(self.setting) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:38,代码来源:settingsManager.py

示例10: getGamepadList

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def getGamepadList(self,_store=False):
        controller_parser = SafeConfigParser()
        controller_parser.read(os.path.join(os.path.join(self.datadir.replace('main.exe',''),'settings'),'gamepads.ini'))
        controller_list = []
        
        for control in controller_parser.sections():
            controls = self.loadGamepad(control)
            controller_list.append(controls)
            if _store: self.setting[control] = controls
            
        retlist = controller_parser.sections()
        retlist.extend(self.new_gamepads)
        return retlist 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:15,代码来源:settingsManager.py

示例11: initializeLibrary

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def initializeLibrary(self):
        self.sounds = {}
        directory = createPath("sfx")
        
        for f in os.listdir(directory):
            fname, ext = os.path.splitext(f)
            if self.supported_file_types.count(ext):
                self.sounds["base_" + fname] = pygame.mixer.Sound(os.path.join(directory,f)) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:10,代码来源:settingsManager.py

示例12: addSoundsFromDirectory

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def addSoundsFromDirectory(self,_path,_category):
        for f in os.listdir(_path):
            fname, ext = os.path.splitext(f)
            if self.supported_file_types.count(ext):
                self.sounds[_category + "_" + fname] = pygame.mixer.Sound(os.path.join(_path,f))
    
########################################################
#             STATIC HELPER FUNCTIONS                  #
######################################################## 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:11,代码来源:settingsManager.py

示例13: loadGamepad

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def loadGamepad(self,_controllerName):
        pygame.joystick.init()
        controller_parser = SafeConfigParser()
        controller_parser.read(os.path.join(os.path.join(self.datadir.replace('main.exe',''),'settings'),'gamepads.ini'))
        if controller_parser.has_section(_controllerName):
            joystick = None
            for pad in range(pygame.joystick.get_count()):
                joy = pygame.joystick.Joystick(pad)
                if joy.get_name() == _controllerName:
                    joystick = joy
                    joystick.init()
            
            if joystick:
                jid = joystick.get_id()
            else:
                jid = None
            
            axes = {}
            buttons = {}
            for opt in controller_parser.options(_controllerName):
                if opt[0] == 'a':
                    axes[int(opt[1:])] = tuple(controller_parser.get(_controllerName, opt)[1:-1].split(','))
                elif opt[0] == 'b':
                    buttons[int(opt[1:])] = controller_parser.get(_controllerName, opt)
        
            pad_bindings = engine.controller.PadBindings(_controllerName,jid,axes,buttons)
            
            return engine.controller.GamepadController(pad_bindings)
        else:
            joystick = None
            for pad in range(pygame.joystick.get_count()):
                joy = pygame.joystick.Joystick(pad)
                if joy.get_name() == _controllerName:
                    joystick = joy
                    joystick.init()
            
            if joystick:
                jid = joystick.get_id()
            else:
                jid = None
            
            axes = dict()
            buttons = dict()
            
            pad_bindings = engine.controller.PadBindings(_controllerName,jid,axes,buttons)
            self.setting[joystick.get_name()] = pad_bindings
            
            return engine.controller.GamepadController(pad_bindings) 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:50,代码来源:settingsManager.py

示例14: write_check_cif

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def write_check_cif(template, placed_nodes, placed_edges, g, sp, sc_unit_cell):

	sc_a,sc_b,sc_c,sc_alpha,sc_beta,sc_gamma = sp
	q = 0

	tpath = os.join('templates', template)

	with open(tpath, 'r') as tcif:

		tcif = tcif.read()
		tcif = filter(None, tcif.split('\n'))

	cpath = os.path.join('check_cifs', str(g) + '_check_scaled_placed_' + template)

	with open(cpath, 'w') as check:
		for line in tcif:
			s = line.split()
			if not isvert(s):
				if '_cell_length_a' in line:
					check.write('_cell_length_a   ' + str(sc_a))
				elif '_cell_length_b' in line:
					check.write('_cell_length_b   ' + str(sc_b))
				elif '_cell_length_c' in line:
					check.write('_cell_length_c   ' + str(sc_c))
				elif '_cell_angle_alpha' in line:
					check.write('_cell_angle_alpha   ' + str(sc_alpha))
				elif '_cell_angle_beta' in line:
					check.write('_cell_angle_beta   ' + str(sc_beta))
				elif '_cell_angle_gamma' in line:
					check.write('_cell_angle_gamma   ' + str(sc_gamma))
				else:
					check.write(line)
				check.write('\n')
			else:
				for n in placed_edges:

					q += 1
					name = re.sub('[0-9]','',n[0])
					if name == 'X':
						name = 'C'
					index = name + str(q)
					vec = np.array(list(map(float,[n[1],n[2],n[3]])))
					v = np.dot(np.linalg.inv(sc_unit_cell), vec)
					check.write('{:>5}{:>5}{:>20}{:>20}{:>20}{:>12}{:>8}{:>8}'.format(index,name,v[0],v[1],v[2],'0.00000','Uiso','1.00'))
					check.write('\n')

				for n in placed_nodes:

					q += 1
					name = re.sub('[0-9]','',n[0])
					if name == 'X':
						name = 'C'
					index = name + str(q)
					vec = np.array(list(map(float,[n[1],n[2],n[3]])))
					v = np.dot(np.linalg.inv(sc_unit_cell), vec)
					check.write('{:>5}{:>5}{:>20}{:>20}{:>20}{:>12}{:>8}{:>8}'.format(index,name,v[0],v[1],v[2],'0.00000','Uiso','1.00'))
					check.write('\n')

				break 
开发者ID:tobacco-mofs,项目名称:tobacco_3.0,代码行数:61,代码来源:write_cifs.py

示例15: write_cif

# 需要导入模块: import os [as 别名]
# 或者: from os import join [as 别名]
def write_cif(placed_all, fixed_bonds, scaled_params, sc_unit_cell, cifname, charges):

	sc_a,sc_b,sc_c,sc_alpha,sc_beta,sc_gamma = scaled_params

	opath = os.path.join('output_cifs', cifname)
	
	with open(opath, 'w') as out:
		out.write('data_' + cifname[0:-4] + '\n')
		out.write('_audit_creation_date              ' + datetime.datetime.today().strftime('%Y-%m-%d') + '\n')
		out.write("_audit_creation_method            'tobacco_3.0'" + '\n')
		out.write("_symmetry_space_group_name_H-M    'P1'" + '\n')
		out.write('_symmetry_Int_Tables_number       1' + '\n')
		out.write('_symmetry_cell_setting            triclinic' + '\n')
		out.write('loop_' + '\n')
		out.write('_symmetry_equiv_pos_as_xyz' + '\n')
		out.write('  x,y,z' + '\n')
		out.write('_cell_length_a                    ' + str(sc_a) + '\n')
		out.write('_cell_length_b                    ' + str(sc_b) + '\n')
		out.write('_cell_length_c                    ' + str(sc_c) + '\n')
		out.write('_cell_angle_alpha                 ' + str(sc_alpha) + '\n')
		out.write('_cell_angle_beta                  ' + str(sc_beta) + '\n')
		out.write('_cell_angle_gamma                 ' + str(sc_gamma) + '\n')
		out.write('loop_' + '\n')
		out.write('_atom_site_label' + '\n')
		out.write('_atom_site_type_symbol' + '\n')
		out.write('_atom_site_fract_x' + '\n')
		out.write('_atom_site_fract_y' + '\n')
		out.write('_atom_site_fract_z' + '\n')
		if charges:
			out.write('_atom_site_charge' + '\n')

		for l in placed_all:
			vec = list(map(float, l[1:4]))
			cvec = np.dot(np.linalg.inv(sc_unit_cell), vec)
			if charges:
				out.write('{:7} {:>4} {:>15} {:>15} {:>15} {:>15}'.format(l[0], re.sub('[0-9]','',l[0]), "%.10f" % np.round(cvec[0],10), "%.10f" % np.round(cvec[1],10), "%.10f" % np.round(cvec[2],10), l[4]))
				out.write('\n')
			else:
				out.write('{:7} {:>4} {:>15} {:>15} {:>15}'.format(l[0], re.sub('[0-9]','',l[0]), "%.10f" % np.round(cvec[0],10), "%.10f" % np.round(cvec[1],10), "%.10f" % np.round(cvec[2],10)))
				out.write('\n')

		out.write('loop_' + '\n')
		out.write('_geom_bond_atom_site_label_1' + '\n')
		out.write('_geom_bond_atom_site_label_2' + '\n')
		out.write('_geom_bond_distance' + '\n')
		out.write('_geom_bond_site_symmetry_2' + '\n')
		out.write('_ccdc_geom_bond_type' + '\n')

		for e in fixed_bonds:
			out.write('{:7} {:>7} {:>5} {:>7} {:>3}'.format(e[0], e[1], "%.3f" % float(e[2]), e[3], e[4]))
			out.write('\n') 
开发者ID:tobacco-mofs,项目名称:tobacco_3.0,代码行数:53,代码来源:write_cifs.py


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