本文整理汇总了Python中profile.Profile.export_profile方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.export_profile方法的具体用法?Python Profile.export_profile怎么用?Python Profile.export_profile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profile.Profile
的用法示例。
在下文中一共展示了Profile.export_profile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PaellaExporter
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import export_profile [as 别名]
class PaellaExporter(object):
def __init__(self, conn):
self.conn = conn
self.cursor = self.conn.cursor(statement=True)
self.suitecursor = SuiteCursor(self.conn)
self.init_db_element()
if len(self.cursor.tables()):
self.setup_cursors()
def setup_cursors(self):
self.profile = Profile(self.conn)
self.family = Family(self.conn)
self.machines = MachineHandler(self.conn)
self.diskconfig = DiskConfigHandler(self.conn)
def init_db_element(self):
self.dbelement = PaellaDatabaseElement()
def make_complete_db_element(self):
self.init_db_element()
self._append_apt_sources_to_db_element()
fields = ['suite']
for suite in self.suitecursor.get_suites():
self._append_suite_to_db_element(suite)
def _append_apt_sources_to_db_element(self):
rows = self.cursor.select(table='apt_sources', order=['apt_id'])
for row in rows:
self.dbelement.append_apt_source(row.apt_id, row.uri, row.dist,
row.sections, row.local_path)
def _append_suite_to_db_element(self, suite):
self.dbelement.append_suite(suite)
rows = self.cursor.select(table='suite_apt_sources', order=['ord'],
clause=Eq('suite', suite))
for row in rows:
self.dbelement.append_suite_apt_source(row.suite, row.apt_id,
str(row.ord))
rows = self.cursor.select(fields=['trait'], table='%s_traits' % suite,
order=['trait'])
traits = [row.trait for row in rows]
self.dbelement.append_suite_traits(suite, traits=traits)
def set_db_export_path(self, dirname):
self.db_export_path = path(dirname)
def export_db_element(self, dirname=None, filename='database.xml'):
if dirname is None:
dirname = self.db_export_path
filename = path(dirname) / filename
dbfile = filename.open('w')
self.dbelement.writexml(dbfile, indent='\t', newl='\n', addindent='\t')
dbfile.close()
def _make_suite_export_path(self, suite):
suitedir = self.db_export_path / suite
makepaths(suitedir)
return suitedir
def export_all_profiles(self, dirname=None):
if dirname is None:
dirname = self.db_export_path / 'profiles'
makepaths(dirname)
profiles = self.profile.get_profile_list()
self.report_total_profiles(len(profiles))
env = self.profile.make_environment_object()
for profile in profiles:
env.set_profile(profile)
self.profile.export_profile(dirname, profile=profile, env=env)
self.report_profile_exported(profile)
def export_all_diskconfigs(self, dirname=None):
if dirname is None:
dirname = self.db_export_path / 'diskconfig'
makepaths(dirname)
for row in self.diskconfig.cursor.select():
filename = row.name
diskconfig = dirname / filename
diskconfig.write_text(row.content)
def export_all_families(self, dirname=None):
if dirname is None:
dirname = self.db_export_path / 'families'
makepaths(dirname)
self.family.export_families(dirname)
def export_trait(self, trait, suite=None, dirname=None, traitdb=None):
if traitdb is None:
if suite is None:
RuntimeError , "you must pass a suite if you don't pass a Trait object"
print "make new traitdb"
traitdb = Trait(self.conn, suite)
traitdb.set_trait(trait)
if suite is None:
suite = traitdb.suite
if dirname is None:
dirname = self._make_suite_export_path(suite)
#.........这里部分代码省略.........