From d424993e8c7c17f6c809d4843f1bc73a6bb9d841 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 10 Jun 2015 11:35:30 -0700 Subject: [PATCH] Safer file writing --- autoapi/domains/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/autoapi/domains/base.py b/autoapi/domains/base.py index 8842b4b..729fc9b 100644 --- a/autoapi/domains/base.py +++ b/autoapi/domains/base.py @@ -1,6 +1,4 @@ import os -import yaml -import json import fnmatch from jinja2 import Environment, FileSystemLoader, TemplateNotFound @@ -140,7 +138,7 @@ class AutoAPIDomain(object): len(files_to_read)): yield _path - def read_file(self, path, format='yaml'): + def read_file(self, path, **kwargs): '''Read file input into memory :param path: Path of file to read @@ -185,7 +183,12 @@ class AutoAPIDomain(object): if not rst: continue - detail_dir = os.path.join(root, *id.split('.')) + try: + filename = id.split('(')[0] + except IndexError: + filename = id + filename = filename.replace('#', '-') + detail_dir = os.path.join(root, *filename.split('.')) ensuredir(detail_dir) path = os.path.join(detail_dir, '%s%s' % ('index', source_suffix)) with open(path, 'w+') as detail_file: