def populate(): populate_steps() populate_states() populate_users(get_default_users()) populate_articles() populate_organization_types( [u'corporation', u'direction', u'service', u'site']) csv_file = os.path.join('data', 'fixtures', 'organizations.csv') populate_organizations(resource_filename(csv_file)) csv_file = os.path.join('data', 'fixtures', 'domains.csv') import_domains_csv(resource_stream(csv_file)) csv_file = os.path.join('data', 'fixtures', 'improvement_domains.csv') import_improvement_domains_csv(resource_stream(csv_file)) csv_file = os.path.join('data', 'fixtures', 'article_topics.csv') import_article_topics_csv(resource_stream(csv_file))
def _perform_substitutions(template_filename, locale, substitutions): # gets the template path template_path = os.path.join('data', 'templates', locale, template_filename) template = resource_stream(template_path) # read unicode content from the template content = unicode(template.read(), encoding='utf-8') # perform substitutions for marker, value in substitutions.items(): content = content.replace('@%s@' % marker, value) return content
def content(self): with resource_stream(self.filepath) as content: return content.read()
def xml_file(self): language = i18n.get_locale().language return resource_stream(os.path.join('data', 'staticcontent', language, self.filename))