def test_remove_comments(): text = '''{ "mock": 42 // truth }''' expect = '{\n "mock": 42 \n}' ret = remove_comments(text) assert ret == expect # testing for multiline comments text = '''{ "mock": 42, // truth /* foo bar */ "fake": true}''' ret = remove_comments(text) expect = '{\n "mock": 42, \n \n "fake": true}' assert ret == expect
def _load_ignores(self): ''' load ignores from ``.couchappignore`` The ``.couchappignore`` file is a json file containing a list of regexps for things to skip :return: a list of file name or ``[]`` for empty ''' path = os.path.join(self.docdir, '.couchappignore') if not os.path.exists(path): return [] with open(path, 'r') as f: return util.json.loads(util.remove_comments(f.read()))
def __init__(self, doc, dbs, update_delay=DEFAULT_UPDATE_DELAY, noatomic=False): super(CouchappEventHandler, self).__init__() self.update_delay = update_delay self.doc = doc self.dbs = dbs self.noatomic = noatomic self.last_update = None ignorefile = os.path.join(doc.docdir, '.couchappignore') if os.path.exists(ignorefile): with open(ignorefile, 'r') as f: self.ignores = json.loads(remove_comments(f.read())) else: self.ignores = []
def __init__(self, path, create=False, docid=None, is_ddoc=True): self.docdir = path self.ignores = [] self.is_ddoc = is_ddoc ignorefile = os.path.join(path, ".couchappignore") if os.path.exists(ignorefile): # A .couchappignore file is a json file containing a # list of regexps for things to skip with open(ignorefile, "r") as f: self.ignores = util.json.loads(util.remove_comments(f.read())) if not docid: docid = self.get_id() self.docid = docid self._doc = {"_id": self.docid} if create: self.create()
def __init__(self, path, create=False, docid=None, is_ddoc=True): self.docdir = path self.ignores = [] self.is_ddoc = is_ddoc ignorefile = os.path.join(path, '.couchappignore') if os.path.exists(ignorefile): # A .couchappignore file is a json file containing a # list of regexps for things to skip with open(ignorefile, 'r') as f: self.ignores = util.json.loads(util.remove_comments(f.read())) if not docid: docid = self.get_id() self.docid = docid self._doc = {'_id': self.docid} if create: self.create()