コード例 #1
0
ファイル: test_util.py プロジェクト: weijia/couchapp
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
コード例 #2
0
ファイル: localdoc.py プロジェクト: weijia/couchapp
    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()))
コード例 #3
0
ファイル: localdoc.py プロジェクト: couchapp/couchapp
    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()))
コード例 #4
0
ファイル: handler.py プロジェクト: GunioRobot/couchapp
    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 = []
コード例 #5
0
ファイル: localdoc.py プロジェクト: couchapp/couchapp
    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()
コード例 #6
0
    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()
コード例 #7
0
    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 = []