本文整理汇总了Python中util.user_dir函数的典型用法代码示例。如果您正苦于以下问题:Python user_dir函数的具体用法?Python user_dir怎么用?Python user_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handle_anim_sequence
def handle_anim_sequence( screen, view, anims, record_anim=False ):
tick = 0
if record_anim:
view.anims.clear()
view( screen, show_quick_stats=False )
pygame.display.flip()
pygame.image.save( screen, util.user_dir( "anim_{:0>3}.png".format(tick) ) )
tick += 1
while anims:
view.anims.clear()
for a in anims[:]:
if a.needs_deletion:
anims.remove( a )
anims += a.children
else:
view.anims[a.pos].append( a )
a.update()
view( screen, show_quick_stats=False )
pygame.display.flip()
if record_anim:
pygame.image.save( screen, util.user_dir( "anim_{:0>3}.png".format(tick) ) )
pygwrap.anim_delay()
tick += 1
view.anims.clear()
开发者ID:carriercomm,项目名称:dmeternal,代码行数:26,代码来源:animobs.py
示例2: load_characters
def load_characters(party, screen, predraw=None, delete_file=True, max_party_size=4):
file_list = glob.glob(util.user_dir("c_*.sav"))
pc_list = []
charsheets = dict()
for fname in file_list:
with open(fname, "rb") as f:
pc = cPickle.load(f)
if pc:
pc_list.append(pc)
charsheets[pc] = charsheet.CharacterSheet(pc, screen=screen)
psr = charsheet.PartySelectRedrawer(
charsheets=charsheets, predraw=predraw, screen=screen, caption="Select Party Members"
)
while len(party) < max_party_size:
rpm = charsheet.RightMenu(screen, predraw=psr, add_desc=False)
psr.menu = rpm
for pc in pc_list:
rpm.add_item(str(pc), pc)
rpm.sort()
rpm.add_alpha_keys()
pc = rpm.query()
if pc:
pc_list.remove(pc)
party.append(pc)
if delete_file:
pc.backup()
os.remove(util.user_dir("c_{}.sav".format(pc.name)))
else:
break
return party
开发者ID:jwvhewitt,项目名称:dmeternal,代码行数:31,代码来源:charloader.py
示例3: fix_characters
def fix_characters():
file_list = glob.glob( util.user_dir( "c_*.sav" ) )
for fname in file_list:
f = open( fname, "rb" )
pc = cPickle.load( f )
f.close()
pc.stat_damage = collections.defaultdict(int)
f = open( util.user_dir( "c_" + pc.name + ".sav" ) , "wb" )
cPickle.dump( pc , f, -1 )
f.close()
开发者ID:carriercomm,项目名称:dmeternal,代码行数:12,代码来源:campaign.py
示例4: load_party
def load_party( screen ):
# Select up to four characters to form the new party.
# Start by loading all characters from disk.
file_list = glob.glob( util.user_dir( "c_*.sav" ) )
pc_list = []
charsheets = dict()
party = []
for fname in file_list:
f = open( fname, "rb" )
pc = cPickle.load( f )
f.close()
if pc:
pc_list.append( pc )
charsheets[ pc ] = charsheet.CharacterSheet( pc , screen=screen )
psr = charsheet.PartySelectRedrawer( charsheets=charsheets, screen=screen, caption="Select Party Members" )
for t in range( 4 ):
rpm = charsheet.RightMenu( screen, predraw=psr, add_desc=False )
psr.menu = rpm
for pc in pc_list:
rpm.add_item( str( pc ), pc )
rpm.sort()
rpm.add_alpha_keys()
pc = rpm.query()
if pc:
pc_list.remove( pc )
party.append( pc )
else:
break
return party
开发者ID:BrendanPotts,项目名称:dmeternal,代码行数:32,代码来源:campaign.py
示例5: wait_event
def wait_event():
# Wait for input, then return it when it comes.
ev = pygame.event.wait()
# Android-specific:
if android:
if android.check_pause():
android.wait_for_resume()
# Record if a quit event took place
if ev.type == pygame.QUIT:
my_state.got_quit = True
elif ev.type == TIMEREVENT:
pygame.event.clear( TIMEREVENT )
elif ev.type == pygame.KEYDOWN:
if ev.key == pygame.K_PRINT:
pygame.image.save( my_state.screen, util.user_dir( "out.png" ) )
elif ev.key in my_state.get_keys_for("next_widget"):
my_state.active_widget_hilight = True
my_state.activate_next_widget()
elif ev.type == pygame.VIDEORESIZE:
my_state.screen = pygame.display.set_mode( (max(ev.w,800),max(ev.h,600)), pygame.RESIZABLE )
# Inform any interested widgets of the event.
my_state.widget_clicked = False
if my_state.widgets_active:
for w in my_state.widgets:
w.respond_event(ev)
return ev
开发者ID:jwvhewitt,项目名称:gearhead-caramel,代码行数:30,代码来源:__init__.py
示例6: init_path
def init_path(self, options):
"""Set the path of the wallet."""
path = None
if options:
# this will call read_wallet_config only if there is a wallet_path value in options
try:
path = options.wallet_path
except:
pass
if not path:
path = self.get('default_wallet_path')
if path is not None:
self.path = path
return
# Look for wallet file in the default data directory.
# Keeps backwards compatibility.
wallet_dir = user_dir()
# Make wallet directory if it does not yet exist.
if not os.path.exists(wallet_dir):
os.mkdir(wallet_dir)
self.path = os.path.join(wallet_dir, "electrum.dat")
开发者ID:arsenische,项目名称:electrum,代码行数:26,代码来源:simple_config.py
示例7: make_and_save_character
def make_and_save_character(screen):
pc = make_character(screen)
if pc:
f = open(util.user_dir("c_" + pc.name + ".sav"), "wb")
cPickle.dump(pc, f, -1)
f.close()
return pc
开发者ID:BrendanPotts,项目名称:dmeternal,代码行数:7,代码来源:chargen.py
示例8: __init__
def __init__(self, options={}):
# system conf, readonly
self.system_config = {}
if options.get('portable') == False:
self.read_system_config()
# user conf, writeable
self.user_dir = user_dir()
self.user_config = {}
if options.get('portable') == False:
self.read_user_config()
# command-line options
self.options_config = options
self.wallet_config = {}
self.wallet_file_exists = False
self.init_path(self.options_config.get('wallet_path'))
print_error( "path", self.path )
if self.path:
self.read_wallet_config(self.path)
# portable wallet: use the same directory for wallet and headers file
if options.get('portable'):
self.wallet_config['blockchain_headers_path'] = os.path.dirname(self.path)
开发者ID:AdvancedStyle,项目名称:electrum,代码行数:26,代码来源:simple_config.py
示例9: __init__
def __init__(self):
# Find electrum data folder
self.config_folder = user_dir()
self.config = self.default_options
# Read the file
if os.path.exists(self.config_file_path()):
self.load_config()
self.save_config()
开发者ID:mhanne,项目名称:electrum,代码行数:8,代码来源:simple_config.py
示例10: backup_wallet
def backup_wallet(self):
try:
folderName = QFileDialog.getExistingDirectory(QWidget(), 'Select folder to save a copy of your wallet to', os.path.expanduser('~/'))
if folderName:
sourceFile = util.user_dir() + '/electrum.dat'
shutil.copy2(sourceFile, str(folderName))
QMessageBox.information(None,"Wallet backup created", "A copy of your wallet file was created in '%s'" % str(folderName))
except (IOError, os.error), reason:
QMessageBox.critical(None,"Unable to create backup", "Electrum was unable copy your wallet file to the specified location.\n" + str(reason))
开发者ID:crazyrabbitLTC,项目名称:electrum,代码行数:9,代码来源:gui_lite.py
示例11: save_user_config
def save_user_config(self):
import ConfigParser
config = ConfigParser.RawConfigParser()
config.add_section('client')
for k,v in self.user_config.items():
config.set('client', k, v)
with open( os.path.join( user_dir(), 'electrum.conf'), 'wb') as configfile:
config.write(configfile)
开发者ID:arsenische,项目名称:electrum,代码行数:9,代码来源:simple_config.py
示例12: save_user_config
def save_user_config(self):
import ConfigParser
config = ConfigParser.RawConfigParser()
config.add_section("client")
for k, v in self.user_config.items():
config.set("client", k, v)
with open(os.path.join(user_dir(), "electrum.conf"), "wb") as configfile:
config.write(configfile)
开发者ID:flatfly,项目名称:electrum,代码行数:10,代码来源:simple_config.py
示例13: set_path
def set_path(self, wallet_path):
"""Set the path of the wallet."""
if wallet_path is not None:
self.path = wallet_path
return
# Look for wallet file in the default data directory.
# Keeps backwards compatibility.
wallet_dir = user_dir()
# Make wallet directory if it does not yet exist.
if not os.path.exists(wallet_dir):
os.mkdir(wallet_dir)
self.path = os.path.join(wallet_dir, "electrum.dat")
开发者ID:mhanne,项目名称:electrum,代码行数:13,代码来源:wallet.py
示例14: load_campaign
def load_campaign( screen ):
rpm = rpgmenu.Menu( screen,screen.get_width()//2-250,screen.get_height()//2-50,500,100,predraw=PosterRedraw(screen) )
rpm.add_files( util.user_dir("rpg_*.sav") )
rpm.sort()
rpm.add_alpha_keys()
rpm.add_item( "Cancel Load Campaign", None )
cmd = rpm.query()
if cmd:
pygwrap.please_stand_by( screen, "Loading..." )
with open( cmd, "rb" ) as f:
camp = cPickle.load( f )
if camp:
camp.play( screen )
开发者ID:jwvhewitt,项目名称:dmeternal,代码行数:13,代码来源:__init__.py
示例15: init_path
def init_path(self):
# Read electrum path in the system configuration
self.path = self.system_config.get('electrum_path')
# If not set, use the user's default data directory.
if self.path is None:
self.path = user_dir()
# Make directory if it does not yet exist.
if not os.path.exists(self.path):
os.mkdir(self.path)
print_error( "electrum directory", self.path)
开发者ID:AdamISZ,项目名称:electrum,代码行数:14,代码来源:simple_config.py
示例16: read_user_config
def read_user_config(self):
name = os.path.join(user_dir(), "electrum.conf")
if os.path.exists(name):
try:
import ConfigParser
except:
print "cannot parse electrum.conf. please install ConfigParser"
return
p = ConfigParser.ConfigParser()
p.read(name)
try:
for k, v in p.items("client"):
self.user_config[k] = v
except ConfigParser.NoSectionError:
pass
开发者ID:flatfly,项目名称:electrum,代码行数:16,代码来源:simple_config.py
示例17: init_path
def init_path(self):
# Read shuttle path in the command line configuration
self.path = self.options_config.get('shuttle_path')
# Read shuttle path in the system configuration
if self.path is None:
self.path = self.system_config.get('shuttle_path')
# If not set, use the user's default data directory.
if self.path is None:
self.path = user_dir()
# Make directory if it does not yet exist.
if not os.path.exists(self.path):
os.mkdir(self.path)
print_error( "shuttle directory", self.path)
开发者ID:moolah-io,项目名称:electrum,代码行数:18,代码来源:simple_config.py
示例18: __init__
def __init__(self, options={}):
# system conf, readonly
self.system_config = {}
self.read_system_config()
# user conf, writeable
self.user_dir = user_dir()
self.user_config = {}
self.read_user_config()
# command-line options
self.options_config = options
self.wallet_config = {}
self.wallet_file_exists = False
self.init_path(self.options_config.get('wallet_path'))
print_error( "path", self.path )
if self.path:
self.read_wallet_config(self.path)
开发者ID:Azelphur,项目名称:electrum,代码行数:20,代码来源:simple_config.py
示例19: browse_pcs
def browse_pcs( screen ):
# Look at the previously created characters.
# Start by loading all characters from disk.
file_list = glob.glob( util.user_dir( "c_*.sav" ) )
pc_list = []
charsheets = dict()
for fname in file_list:
f = open( fname, "rb" )
pc = cPickle.load( f )
f.close()
if pc:
pc_list.append( pc )
charsheets[ pc ] = charsheet.CharacterSheet( pc , screen=screen )
if pc_list:
psr = charsheet.PartySelectRedrawer( charsheets=charsheets, screen=screen, caption="Browse Characters" )
rpm = charsheet.RightMenu( screen, predraw=psr, add_desc=False )
psr.menu = rpm
for pc in pc_list:
rpm.add_item( str( pc ), pc )
rpm.sort()
pc = rpm.query()
开发者ID:carriercomm,项目名称:dmeternal,代码行数:21,代码来源:campaign.py
示例20: wait_event
def wait_event():
# Wait for input, then return it when it comes.
ev = pygame.event.wait()
# Android-specific:
if android:
if android.check_pause():
android.wait_for_resume()
# Record if a quit event took place
if ev.type == pygame.QUIT:
global GOT_QUIT
GOT_QUIT = True
elif ev.type == TIMEREVENT:
pygame.event.clear( TIMEREVENT )
elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_PRINT:
screen = pygame.display.get_surface()
pygame.image.save( screen, util.user_dir( "out.png" ) )
return ev
开发者ID:BrendanPotts,项目名称:dmeternal,代码行数:21,代码来源:pygwrap.py
注:本文中的util.user_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论