def build_files(args: Dict[str, str]) -> Dict[str, str]: platform = int(args['platform']) # prevent path traversal vars = { 'id': args['name'].lower(), 'summary': args['summary'], 'description': args['description'], 'name': ' '.join(re.findall(r'[A-Z][^A-Z]*', args['name'])), 'namespace': args['name'], 'author_name': args['author_name'], 'author_mail': args['author_email'], 'author_homepage': args['author_homepage'], 'issue_tracker': args['issue_tracker'], 'categories': args['categories'], 'nextcloud_version': platform } vars.update(settings.APP_SCAFFOLDING_PROFILES.get(platform, {})) relative_base = 'app-templates/%i/app/' % platform base = resolve_file_relative_path(__file__, relative_base) context = Context({'app': vars}) result = {} if isdir(base): for root, dirs, files in walk(base): for file in files: file_path = join(root, file) rel_file_path = '%s/%s' % ( vars['id'], relpath(file_path, base) ) with open(file_path) as f: t = Template(f.read()) result[rel_file_path] = t.render(context) return result
def build_files(args: Dict[str, str]) -> Dict[str, str]: platform = int(args['platform']) # prevent path traversal vars = { 'id': args['name'].lower(), 'summary': args['summary'], 'description': args['description'], 'name': ' '.join(re.findall(r'[A-Z][^A-Z]*', args['name'])), 'namespace': args['name'], 'author_name': args['author_name'], 'author_mail': args['author_email'], 'author_homepage': args['author_homepage'], 'issue_tracker': args['issue_tracker'], 'categories': args['categories'], 'nextcloud_version': platform } vars.update(APP_SCAFFOLDING_PROFILES.get(platform, {})) relative_base = 'app-templates/%i/app/' % platform base = resolve_file_relative_path(__file__, relative_base) context = Context({'app': vars}) result = {} if isdir(base): for root, dirs, files in walk(base): for file in files: file_path = join(root, file) rel_file_path = '%s/%s' % ( vars['id'], relpath(file_path, base) ) with open(file_path) as f: t = Template(f.read()) result[rel_file_path] = t.render(context) return result
class FakeDownload: filename = resolve_file_relative_path(__file__, 'data/infoxmls/minimal.xml') def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): pass
def get_path(self, target): return resolve_file_relative_path(__file__, target)
def get_path(self, target): return resolve_file_relative_path(__file__, target)
def _read_bin_file(self, rel_path: str) -> bytes: target_path = resolve_file_relative_path(__file__, rel_path) with open(target_path, 'rb') as f: return f.read()
def cert_path(self, name: str) -> str: path = 'data/%s' % name return resolve_file_relative_path(__file__, path)
def get_versions(): tpls = listdir(resolve_file_relative_path(__file__, 'app-templates')) return sorted(((v, v) for v in tpls))
def get_versions(): tpls = listdir(resolve_file_relative_path(__file__, 'app-templates')) return sorted(((v, v) for v in tpls))
def _read_bin_file(self, rel_path: str) -> bytes: target_path = resolve_file_relative_path(__file__, rel_path) with open(target_path, 'rb') as f: return f.read()