本文整理汇总了Python中config.config.get方法的典型用法代码示例。如果您正苦于以下问题:Python config.get方法的具体用法?Python config.get怎么用?Python config.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.config
的用法示例。
在下文中一共展示了config.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_ship
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export_ship(self, filename=None):
string = json.dumps(self.ship(False), ensure_ascii=False, indent=2, separators=(',', ': ')).encode('utf-8') # pretty print
if filename:
with open(filename, 'wt') as h:
h.write(string)
return
ship = ship_file_name(self.state['ShipName'], self.state['ShipType'])
regexp = re.compile(re.escape(ship) + '\.\d\d\d\d\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt')
oldfiles = sorted([x for x in listdir(config.get('outdir')) if regexp.match(x)])
if oldfiles:
with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h:
if h.read() == string:
return # same as last time - don't write
# Write
filename = join(config.get('outdir'), '%s.%s.txt' % (ship, strftime('%Y-%m-%dT%H.%M.%S', localtime(time()))))
with open(filename, 'wt') as h:
h.write(string)
# singleton
示例2: export
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export(data, filename=None):
string = json.dumps(companion.ship(data), ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')).encode('utf-8') # pretty print
if filename:
with open(filename, 'wt') as h:
h.write(string)
return
# Look for last ship of this type
ship = companion.ship_file_name(data['ship'].get('shipName'), data['ship']['name'])
regexp = re.compile(re.escape(ship) + '\.\d\d\d\d\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt')
oldfiles = sorted([x for x in os.listdir(config.get('outdir')) if regexp.match(x)])
if oldfiles:
with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h:
if h.read() == string:
return # same as last time - don't write
querytime = config.getint('querytime') or int(time.time())
# Write
filename = join(config.get('outdir'), '%s.%s.txt' % (ship, time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime(querytime))))
with open(filename, 'wt') as h:
h.write(string)
示例3: station
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def station(self):
data = self.query(URL_QUERY)
if data['commander'].get('docked'):
services = data['lastStarport'].get('services', {})
if services.get('commodities'):
marketdata = self.query(URL_MARKET)
if (data['lastStarport']['name'] != marketdata['name'] or
int(data['lastStarport']['id']) != int(marketdata['id'])):
raise ServerLagging()
else:
data['lastStarport'].update(marketdata)
if services.get('outfitting') or services.get('shipyard'):
shipdata = self.query(URL_SHIPYARD)
if (data['lastStarport']['name'] != shipdata['name'] or
int(data['lastStarport']['id']) != int(shipdata['id'])):
raise ServerLagging()
else:
data['lastStarport'].update(shipdata)
return data
示例4: export_outfitting
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export_outfitting(self, data, is_beta):
economies = data['lastStarport'].get('economies') or {}
modules = data['lastStarport'].get('modules') or {}
ships = data['lastStarport'].get('ships') or { 'shipyard_list': {}, 'unavailable_list': [] }
# Horizons flag - will hit at least Int_PlanetApproachSuite other than at engineer bases ("Colony"), prison or rescue Megaships, or under Pirate Attack etc
horizons = (any(economy['name'] == 'Colony' for economy in economies.itervalues()) or
any(module.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for module in modules.itervalues()) or
any(ship.get('sku') == 'ELITE_HORIZONS_V_PLANETARY_LANDINGS' for ship in (ships['shipyard_list'] or {}).values()))
outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['name'].lower()) for module in modules.itervalues() if self.MODULE_RE.search(module['name']) and module.get('sku') in [None, 'ELITE_HORIZONS_V_PLANETARY_LANDINGS'] and module['name'] != 'Int_PlanetApproachSuite'])
if outfitting and this.outfitting != (horizons, outfitting): # Don't send empty modules list - schema won't allow it
self.send(data['commander']['name'], {
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
'message' : OrderedDict([
('timestamp', data['timestamp']),
('systemName', data['lastSystem']['name']),
('stationName', data['lastStarport']['name']),
('marketId', data['lastStarport']['id']),
('horizons', horizons),
('modules', outfitting),
]),
})
this.outfitting = (horizons, outfitting)
示例5: export_journal_commodities
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export_journal_commodities(self, cmdr, is_beta, entry):
items = entry.get('Items') or []
commodities = sorted([OrderedDict([
('name', self.canonicalise(commodity['Name'])),
('meanPrice', commodity['MeanPrice']),
('buyPrice', commodity['BuyPrice']),
('stock', commodity['Stock']),
('stockBracket', commodity['StockBracket']),
('sellPrice', commodity['SellPrice']),
('demand', commodity['Demand']),
('demandBracket', commodity['DemandBracket']),
]) for commodity in items], key = lambda c: c['name'])
if commodities and this.commodities != commodities: # Don't send empty commodities list - schema won't allow it
self.send(cmdr, {
'$schemaRef' : 'https://eddn.edcd.io/schemas/commodity/3' + (is_beta and '/test' or ''),
'message' : OrderedDict([
('timestamp', entry['timestamp']),
('systemName', entry['StarSystem']),
('stationName', entry['StationName']),
('marketId', entry['MarketID']),
('commodities', commodities),
]),
})
this.commodities = commodities
示例6: export_journal_outfitting
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export_journal_outfitting(self, cmdr, is_beta, entry):
modules = entry.get('Items') or []
horizons = entry.get('Horizons', False)
outfitting = sorted([self.MODULE_RE.sub(lambda m: m.group(0).capitalize(), module['Name']) for module in modules if module['Name'] != 'int_planetapproachsuite'])
if outfitting and this.outfitting != (horizons, outfitting): # Don't send empty modules list - schema won't allow it
self.send(cmdr, {
'$schemaRef' : 'https://eddn.edcd.io/schemas/outfitting/2' + (is_beta and '/test' or ''),
'message' : OrderedDict([
('timestamp', entry['timestamp']),
('systemName', entry['StarSystem']),
('stationName', entry['StationName']),
('marketId', entry['MarketID']),
('horizons', horizons),
('modules', outfitting),
]),
})
this.outfitting = (horizons, outfitting)
示例7: export_journal_shipyard
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def export_journal_shipyard(self, cmdr, is_beta, entry):
ships = entry.get('PriceList') or []
horizons = entry.get('Horizons', False)
shipyard = sorted([ship['ShipType'] for ship in ships])
if shipyard and this.shipyard != (horizons, shipyard): # Don't send empty ships list - shipyard data is only guaranteed present if user has visited the shipyard.
self.send(cmdr, {
'$schemaRef' : 'https://eddn.edcd.io/schemas/shipyard/2' + (is_beta and '/test' or ''),
'message' : OrderedDict([
('timestamp', entry['timestamp']),
('systemName', entry['StarSystem']),
('stationName', entry['StationName']),
('marketId', entry['MarketID']),
('horizons', horizons),
('ships', shipyard),
]),
})
this.shipyard = (horizons, shipyard)
示例8: prefs_changed
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def prefs_changed(cmdr, is_beta):
config.set('edsm_out', this.log.get())
if cmdr and not is_beta:
cmdrs = config.get('edsm_cmdrs')
usernames = config.get('edsm_usernames') or []
apikeys = config.get('edsm_apikeys') or []
if cmdr in cmdrs:
idx = cmdrs.index(cmdr)
usernames.extend([''] * (1 + idx - len(usernames)))
usernames[idx] = this.user.get().strip()
apikeys.extend([''] * (1 + idx - len(apikeys)))
apikeys[idx] = this.apikey.get().strip()
else:
config.set('edsm_cmdrs', cmdrs + [cmdr])
usernames.append(this.user.get().strip())
apikeys.append(this.apikey.get().strip())
config.set('edsm_usernames', usernames)
config.set('edsm_apikeys', apikeys)
示例9: credentials
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def credentials(cmdr):
# Credentials for cmdr
if not cmdr:
return None
cmdrs = config.get('edsm_cmdrs')
if not cmdrs:
# Migrate from <= 2.25
cmdrs = [cmdr]
config.set('edsm_cmdrs', cmdrs)
if cmdr in cmdrs and config.get('edsm_usernames') and config.get('edsm_apikeys'):
idx = cmdrs.index(cmdr)
return (config.get('edsm_usernames')[idx], config.get('edsm_apikeys')[idx])
else:
return None
示例10: main
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def main(args):
tmpdir = tempfile.mkdtemp()
zipfile = ZipFile(args.apk_file)
zipfile.extractall(tmpdir)
import_plugins()
processing_modules = Obfuscator.__subclasses__()
try:
for module in processing_modules:
module(tmpdir, config.get(module.__name__, {})).run()
except Exception as ex:
logging.error('Exception encountered: %s' % str(ex))
shutil.rmtree(tmpdir)
return
if args.force_overwrite or not os.path.isfile(args.outfile):
zipdir(tmpdir, args.outfile, args.keep_meta)
else:
logging.error('Output file already exists (use -f to overwrite)!')
shutil.rmtree(tmpdir)
示例11: check_version
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def check_version(self):
version_range = self.server.server_version()
self.motd = _edr(version_range["l10n_motd"])
if version_range is None:
# Translators: this is shown on EDMC's status bar when the version check fails
self.status = _(u"check for version update has failed.")
return
if self.is_obsolete(version_range["min"]):
EDRLOG.log(u"Mandatory update! {version} vs. {min}"
.format(version=self.edr_version, min=version_range["min"]), "ERROR")
self.mandatory_update = True
self.autoupdate_pending = version_range.get("autoupdatable", False)
self.__status_update_pending()
elif self.is_obsolete(version_range["latest"]):
EDRLOG.log(u"EDR update available! {version} vs. {latest}"
.format(version=self.edr_version, latest=version_range["latest"]), "INFO")
self.mandatory_update = False
self.autoupdate_pending = version_range.get("autoupdatable", False)
self.__status_update_pending()
示例12: prefs_changed
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def prefs_changed(self):
set_language(config.get("language"))
if self.mandatory_update:
EDRLOG.log(u"Out-of-date client, aborting.", "ERROR")
self.__status_update_pending()
return
config.set("EDREmail", self.email)
config.set("EDRPassword", self.password)
config.set("EDRVisualFeedback", "True" if self.visual_feedback else "False")
config.set("EDRAudioFeedback", "True" if self.audio_feedback else "False")
config.set("EDRRedactMyInfo", self.anonymous_reports)
EDRLOG.log(u"Audio cues: {}, {}".format(config.get("EDRAudioFeedback"),
config.get("EDRAudioFeedbackVolume")), "DEBUG")
EDRLOG.log(u"Anonymous reports: {}".format(config.get("EDRRedactMyInfo")), "DEBUG")
self.login()
示例13: noteworthy_about_system
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def noteworthy_about_system(self, fsdjump_event):
if fsdjump_event["SystemSecurity"]:
self.player.location_security(fsdjump_event["SystemSecurity"])
self.edrsystems.system_id(fsdjump_event['StarSystem'], may_create=True, coords=fsdjump_event.get("StarPos", None))
facts = self.edrresourcefinder.assess_jump(fsdjump_event, self.player.inventory)
header = _('Rare materials in {} (USS-HGE/EE, Mission Rewards)'.format(fsdjump_event['StarSystem']))
if not facts:
facts = EDRBodiesOfInterest.bodies_of_interest(fsdjump_event['StarSystem'])
header = _('Noteworthy stellar bodies in {}').format(fsdjump_event['StarSystem'])
if not facts:
if self.player.in_bad_neighborhood():
header = _(u"Anarchy system")
facts = [_(u"Crimes will not be reported.")]
else:
return False
self.__notify(header, facts, clear_before = True)
return True
示例14: show_navigation
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def show_navigation(self):
current = self.player.piloted_vehicle.attitude
destination = self.player.planetary_destination
if not destination or not current:
return
if not current.valid() or not destination.valid():
return
bearing = destination.bearing(current)
body = self.edrsystems.body(self.player.star_system, self.player.place)
radius = body.get("radius", None) if body else None
distance = destination.distance(current, radius) if radius else None
if distance <= 1.0:
return
pitch = destination.pitch(current, distance) if distance and distance <= 700 else None
if self.visual_feedback:
self.IN_GAME_MSG.navigation(bearing, destination, distance, pitch)
self.status = _(u"> {:03} < for Lat:{:.4f} Lon:{:.4f}".format(bearing, destination.latitude, destination.longitude))
示例15: __staoi_found
# 需要导入模块: from config import config [as 别名]
# 或者: from config.config import get [as 别名]
def __staoi_found(self, reference, radius, sc, soi_checker, result):
self.searching = False
details = []
if result:
sc_distance = result['station']['distanceToArrival']
distance = result['distance']
pretty_dist = _(u"{dist:.3g}LY").format(dist=distance) if distance < 50.0 else _(u"{dist}LY").format(dist=int(distance))
pretty_sc_dist = _(u"{dist}LS").format(dist=int(sc_distance))
details.append(_(u"{system}, {dist}").format(system=result['name'], dist=pretty_dist))
details.append(_(u"{station} ({type}), {sc_dist}").format(station=result['station']['name'], type=result['station']['type'], sc_dist=pretty_sc_dist))
details.append(_(u"as of {date} {ci}").format(date=result['station']['updateTime']['information'],ci=result.get('comment', '')))
self.status = u"{item}: {system}, {dist} - {station} ({type}), {sc_dist}".format(item=soi_checker.name, system=result['name'], dist=pretty_dist, station=result['station']['name'], type=result['station']['type'], sc_dist=pretty_sc_dist)
copy(result["name"])
else:
self.status = _(u"{}: nothing within [{}LY, {}LS] of {}".format(soi_checker.name, int(radius), int(sc), reference))
checked = _("checked {} systems").format(soi_checker.systems_counter)
if soi_checker.stations_counter:
checked = _("checked {} systems and {} stations").format(soi_checker.systems_counter, soi_checker.stations_counter)
details.append(_(u"nothing found within [{}LY, {}LS], {}.").format(int(radius), int(sc), checked))
if soi_checker.hint:
details.append(soi_checker.hint)
self.__notify(_(u"{} near {}").format(soi_checker.name, reference), details, clear_before = True)